From 819f3f375098dfcecd9ad05523af5e55908a4687 Mon Sep 17 00:00:00 2001 From: Marcus Date: Tue, 16 Apr 2024 02:33:06 +0200 Subject: [PATCH] firmware wip - web ui stuff --- Arduino/CanGrow/CanGrow.ino | 50 ++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index 725ffcf..83ecde2 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -156,7 +156,7 @@ const char HTMLheader[] PROGMEM = R"EOF(
  • Grow settings
  • System settings
  • WiFi settings
  • -
  • Help
  • +
  • Help
  • @@ -176,7 +176,7 @@ body { } .center { - width: 60%; min-width: 200px; + width: 60%; min-width: 420px; margin: auto; } @@ -213,7 +213,7 @@ a:active { /* from https://gist.github.com/iamhelenliu/5755179 - thank you! */ .nav { background: #333; - width: 60%; min-width: 200px; + width: 60%; min-width: 420px; margin: auto; margin-bottom: 10px; padding: 0; @@ -253,10 +253,6 @@ a:active { -)EOF"; - -const char HTMLjsNoWifi[] PROGMEM = R"EOF( - )EOF"; const char HTMLhelp[] PROGMEM = R"EOF( @@ -817,7 +813,8 @@ void WebHandler() { webserver.on("/wifiSettings/save", HTTP_POST, POSTwifiSettings); webserver.on("/style.css", HTTP_GET, WEBstyleCSS); - + // help + webserver.on("/help", HTTP_GET, WEBhelp); // does not work atm TODO webserver.on("/logout", [](){ webserver.send(401, "text/html", "logged out!"); }); @@ -828,21 +825,29 @@ void WebHandler() { webserver.onNotFound(WEB404); + // when wifi is unconfigured (WIFIssid <1) then root are Wifi settings if(strlen(WIFIssid) < 1) { webserver.on("/", HTTP_GET, WEBwifiSettings); - } + webserver.on("/systemSettings", HTTP_GET, WEBwifiSettings); + webserver.on("/growSettings", HTTP_GET, WEBwifiSettings); + } else { - if(configured == false) { - webserver.on("/", HTTP_GET, WEBsystemSettings); - webserver.on("/growSettings", HTTP_GET, WEBsystemSettings); + // when system settings are unconfigured , then system settings are root + if(configured == false) { + webserver.on("/", HTTP_GET, WEBsystemSettings); + webserver.on("/systemSettings", HTTP_GET, WEBsystemSettings); + webserver.on("/growSettings", HTTP_GET, WEBsystemSettings); + } else { + webserver.on("/systemSettings", HTTP_GET, WEBsystemSettings); + } + + // when grow is unconfigured (GrowStart <1) then Grow settings are root + if(GrowStart < 1) { + webserver.on("/", HTTP_GET, WEBgrowSettings); + } else { + webserver.on("/growSettings", HTTP_GET, WEBgrowSettings); + } } - - webserver.on("/systemSettings", HTTP_GET, WEBsystemSettings); - - if(GrowStart < 1) { - webserver.on("/", HTTP_GET, WEBgrowSettings); - } - webserver.on("/growSettings", HTTP_GET, WEBgrowSettings); } @@ -933,9 +938,9 @@ void WEBwifiSettings() { byte ssidsAvail = WiFi.scanNetworks(); String body = FPSTR(HTMLheader); if(strlen(WIFIssid) == 0) { - body += "

    CanGrow

    "; - body += "

    CanGrow is actually unconfigured. You need to Setup your WiFi below first.
    "; - body += "
    After you configured the WiFi connection successfully, you can start your grow 🥦"; + body += "

    Welcome!

    "; + body += "

    CanGrow is actually unconfigured. You need to Setup your WiFi first down below.
    "; + body += "
    After you entered your WiFi connection details, you need to restart and are step closer to your grow 🥦"; body += "
    "; body += "

    "; } @@ -966,7 +971,6 @@ void WEBwifiSettings() { body += "DNS:
    \n"; body += "\n"; body += "\n"; - body += FPSTR(HTMLjsNoWifi); body += FPSTR(HTMLfooter); webserver.send(200, "text/html", body);