diff --git a/D1 mini/On_Air/On_Air.ino b/D1 mini/On_Air/On_Air.ino index baeecd6..e301010 100644 --- a/D1 mini/On_Air/On_Air.ino +++ b/D1 mini/On_Air/On_Air.ino @@ -2,8 +2,7 @@ #include -const int optocoupler = D7; -const int togglePin = D3; +const int optocoupler = D2; const char* ssid = "LeWe"; const char* password = "5275274365464843"; @@ -11,7 +10,6 @@ const char* password = "5275274365464843"; ESP8266WebServer server(80); int lightStatus = 0; // 0 off, 1 on, 2 pulse -int toggleStatus = 0; void setup() { @@ -23,9 +21,6 @@ void setup() { pinMode(optocoupler, OUTPUT); digitalWrite(optocoupler, LOW); - pinMode(togglePin, OUTPUT); - digitalWrite(togglePin, LOW); - // Connect WiFi Serial.println(); Serial.println(); @@ -45,7 +40,6 @@ void setup() { server.on("/click", handle_click); server.on("/light", handle_light); server.onNotFound(handle_NotFound); - server.on("/toggle", handle_toggle); server.begin(); Serial.println("HTTP server started"); @@ -94,6 +88,13 @@ void handle_click() { server.send(200, "text/plain", response); } +String getButtonStatus(int button) { + if (lightStatus == button) { + return "button_on"; + } + return "button_off"; +} + void handle_light(){ if (server.hasArg("status")) { @@ -111,14 +112,14 @@ void handle_light(){ String response = ""; response += ""; response += ""; - response += ""; response += "

On Air

"; - response += "

"; - response += "

"; - response += "

"; - response += "

" + String(lightStatus) + "

"; + response += "

"; + response += "

"; + response += "

"; response += ""; server.send(200, "text/html", response); @@ -127,16 +128,3 @@ void handle_light(){ void handle_NotFound(){ server.send(404, "text/plain", "Not found"); } - -void handle_toggle() { - if (toggleStatus == 0) { - toggleStatus = 1; - digitalWrite(togglePin, HIGH); - } - else { - toggleStatus = 0; - digitalWrite(togglePin, LOW); - } - - server.send(200, "text/html", "D3 is set to " + String(toggleStatus)); -}