Browse Source

small cleanup

master
Thorsten Riess 2 years ago
parent
commit
10666336b9
2 changed files with 57 additions and 55 deletions
  1. 2
    4
      steuerung/steuerung.ino
  2. 55
    51
      webinterface/webinterface.ino

+ 2
- 4
steuerung/steuerung.ino View File

@@ -65,9 +65,9 @@ void setup()
// head motor pins to output
pinMode(HEAD_MOTOR_PIN1, OUTPUT);
pinMode(HEAD_MOTOR_PIN2, OUTPUT);
attachInterrupt(INTERRUPT_PIN, interruptPositionUpdate, RISING);
Serial.begin(19200);
waitForInput=true;
attachInterrupt(INTERRUPT_PIN, interruptPositionUpdate, RISING);
}

void loop()
@@ -196,12 +196,10 @@ void serialEvent()
continue;
}
if (inChar != 'E' && spos < 11) {
readarr[spos] = inChar;
spos++;
readarr[spos++] = inChar;
}
else {
if (inChar == 'E') {
int posi = 0;
if ( waitForInput ) {
if(readarr[0] == '-') {
switches[6] = true;

+ 55
- 51
webinterface/webinterface.ino View File

@@ -17,18 +17,18 @@ ESP8266WebServer server(80); //creating the server at port 80
IPAddress apIP(192, 168, 4, 1);
IPAddress netMsk(255, 255, 255, 0);

volatile bool cts = true;

void setup() {
Serial.begin(19200);
// put your setup code here, to run once:

Serial.print("Configuring access point...");
//Serial.print("Configuring access point...");
/* You can remove the password parameter if you want the AP to be open. */
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(apIP, apIP, netMsk);
WiFi.softAP(ssid); /*, password*/
delay(500); // Without delay I've seen the IP address blank
//Serial.print("AP IP address: ");
//Serial.println(WiFi.softAPIP());

/* Setup the DNS server redirecting all the domains to the apIP */
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
@@ -46,56 +46,60 @@ void handleroot() {
}

void formdata() {
char op='+';
char sw1='0',sw2='0',sw3='0',sw4='0',sw5='0',sw6='0',sw7='0',sw8='0',sw9='0',sw10='0';
if(server.hasArg("op")) {
if(server.arg("op").equals("m")) {
op = '-';
if(cts) {
cts = false;
char op='+';
char sw1='0',sw2='0',sw3='0',sw4='0',sw5='0',sw6='0',sw7='0',sw8='0',sw9='0',sw10='0';
if(server.hasArg("op")) {
if(server.arg("op").equals("m")) {
op = '-';
}
}
if(server.hasArg("switch1")) {
sw1 = '1';
}
if(server.hasArg("switch2")) {
sw2 = '1';
}
if(server.hasArg("switch3")) {
sw3 = '1';
}
if(server.hasArg("switch4")) {
sw4 = '1';
}
if(server.hasArg("switch5")) {
sw5 = '1';
}
if(server.hasArg("switch6")) {
sw6 = '1';
}
if(server.hasArg("switch7")) {
sw7 = '1';
}
if(server.hasArg("switch8")) {
sw8 = '1';
}
if(server.hasArg("switch9")) {
sw9 = '1';
}
if(server.hasArg("switch10")) {
sw10 = '1';
}
Serial.print('A');
Serial.print(op);
Serial.print(sw1);
Serial.print(sw2);
Serial.print(sw3);
Serial.print(sw4);
Serial.print(sw5);
Serial.print(sw6);
Serial.print(sw7);
Serial.print(sw8);
Serial.print(sw9);
Serial.print(sw10);
Serial.print('E');
cts = true;
}
if(server.hasArg("switch1")) {
sw1 = '1';
}
if(server.hasArg("switch2")) {
sw2 = '1';
}
if(server.hasArg("switch3")) {
sw3 = '1';
}
if(server.hasArg("switch4")) {
sw4 = '1';
}
if(server.hasArg("switch5")) {
sw5 = '1';
}
if(server.hasArg("switch6")) {
sw6 = '1';
}
if(server.hasArg("switch7")) {
sw7 = '1';
}
if(server.hasArg("switch8")) {
sw8 = '1';
}
if(server.hasArg("switch9")) {
sw9 = '1';
}
if(server.hasArg("switch10")) {
sw10 = '1';
}
Serial.print('A');
Serial.print(op);
Serial.print(sw1);
Serial.print(sw2);
Serial.print(sw3);
Serial.print(sw4);
Serial.print(sw5);
Serial.print(sw6);
Serial.print(sw7);
Serial.print(sw8);
Serial.print(sw9);
Serial.print(sw10);
Serial.print('E');
server.sendHeader("Location", String("/"), true);
server.send ( 302, "text/plain", "");
}

Loading…
Cancel
Save