diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index 6a3ce9c..3382699 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -172,13 +172,16 @@ ESP8266WebServer webserver(80); */ // Template: const char HTMLexamplepage[] PROGMEM = R"EOF()EOF"; -const char HTMLheader[] PROGMEM = R"EOF( +const char HTMLheaderP1[] PROGMEM = R"EOF( - CanGrow + )EOF"; + // page title +const char HTMLheaderP2[] PROGMEM = R"EOF( + - - -
- -)EOF"; +
@@ -1286,79 +1271,72 @@ void WebHandler() { String returnHTMLheader(String MenuEntry = "") { String header; - header += FPSTR(HTMLheader); + String activeMenu = "class='activeMenu'"; + // add first part of the header + header += FPSTR(HTMLheaderP1); + // check if GrowName was set. if yes, its part of the page title. + if(strlen(GrowName) > 0) { + header += "Cangrow - "; + header += GrowName; + } else { + header += "Cangrow"; + } + header += FPSTR(HTMLheaderP2); + // first menu entry + header += "
  • 🌱 "; + if(strlen(GrowName) > 0) { + header += GrowName; + } else { + header += "CanGrow"; + } + header += "
  • \n"; + // second menu entry + header += "
  • 0){ - - - //~ footer += ""; - //~ } + // fourth menu entry + header += "
  • and start
    + header += "
    "; return header; } -// returns footer with javascript stuff -String returnHTMLfooter(String MenuEntry = "") { - String footer; - - // print actual time in header - - footer += ""; - - // show the GrowName in the menu if set - if(strlen(GrowName) > 0){ - - - footer += ""; - } - - footer += FPSTR(HTMLfooter); - - return footer; -} - - /* * returnSelected(bool) * returns char[] "selected" if bool is true @@ -1407,14 +1385,14 @@ String returnStrDateFromEpoch(unsigned long epochTime) { } void SysRestart() { - String body = FPSTR(HTMLheader); + String body = returnHTMLheader(); // TODO only debug and development solution, remove this later if( (webserver.hasArg("confirmed")) || (NeedRestart == true) ) { body += "

    Restarting

    "; body += "
    After restart CanGrow will be connected to WiFi SSID
    "; body += WIFIssid; body += "
    You get its IP-Address from the display or serial console.
    "; - body += returnHTMLfooter(); + body += FPSTR(HTMLfooter); webserver.send(200, "text/html", body); Serial.println("Restarting... see you soon space cowboy!"); delay(1000); @@ -1425,17 +1403,17 @@ void SysRestart() { body += "
    Please confirm."; body += "
    "; body += "
    "; - body += returnHTMLfooter(); + body += FPSTR(HTMLfooter); webserver.send(200, "text/html", body); } } void SysWipe() { - String body = FPSTR(HTMLheader); + String body = returnHTMLheader(); // TODO only debug and development solution, remove this later if(webserver.hasArg("confirmed")) { body += "

    !! Wiping CanGrow's EEPROM !!


    Device will restart in a few seconds.
    "; - body += returnHTMLfooter(); + body += FPSTR(HTMLfooter); webserver.send(200, "text/html", body); wipeEEPROM(); } else { @@ -1444,7 +1422,7 @@ void SysWipe() { body += "
    Please confirm wiping the EEPROM"; body += "
    "; body += "
    "; - body += returnHTMLfooter(); + body += FPSTR(HTMLfooter); webserver.send(200, "text/html", body); } } @@ -1488,14 +1466,14 @@ void SysWipe() { */ void WEB404() { - String body = FPSTR(HTMLheader); + String body = returnHTMLheader(); body += "

    404 - not found

    "; - body += returnHTMLfooter(); + body += FPSTR(HTMLfooter); webserver.send(404, "text/html", body); } void WEBlogout() { - String body = FPSTR(HTMLheader); + String body = returnHTMLheader(); body += "

    you are logged out.

    "; body += FPSTR(HTMLfooter); @@ -1504,9 +1482,9 @@ void WEBlogout() { } void WEBhelp() { - String body = FPSTR(HTMLheader); + String body = returnHTMLheader("help"); body += FPSTR(HTMLhelp); - body += returnHTMLfooter("help"); + body += FPSTR(HTMLfooter); webserver.send(200, "text/html", body); } @@ -1525,7 +1503,7 @@ void WEBroot() { webserver.sendHeader("Location", String("/growSettings"), true); webserver.send(302, "text/plain", "please configure growSettings first"); } else { - String body = FPSTR(HTMLheader); + String body = returnHTMLheader(); body += "

    🌱 "; body += GrowName; @@ -1586,7 +1564,7 @@ void WEBroot() { - body += returnHTMLfooter(); + body += FPSTR(HTMLfooter); webserver.send(200, "text/html", body); } @@ -1598,7 +1576,7 @@ void WEBroot() { void WEBwifiSettings() { byte ssidsAvail = WiFi.scanNetworks(); - String body = FPSTR(HTMLheader); + String body = returnHTMLheader("wifiSettings"); if(FirstRun == true) { body += "

    Welcome!

    "; body += "

    CanGrow is actually unconfigured. You need to Setup your WiFi first down below.
    "; @@ -1657,7 +1635,7 @@ void WEBwifiSettings() { body += "DNS:
    \n"; body += "\n"; body += "\n"; - body += returnHTMLfooter("wifiSettings"); + body += FPSTR(HTMLfooter); webserver.send(200, "text/html", body); } @@ -1669,7 +1647,7 @@ void WEBsystemSettings() { webserver.send(302, "text/plain", "please configure wifiSettings first"); } else { - String body = FPSTR(HTMLheader); + String body = returnHTMLheader("systemSettings"); if(configured == false) { body += "

    Step 2: System settings

    "; @@ -1752,7 +1730,7 @@ void WEBsystemSettings() { body += "\n"; body += "\n"; - body += returnHTMLfooter("systemSettings"); + body += FPSTR(HTMLfooter); webserver.send(200, "text/html", body); } @@ -1768,7 +1746,7 @@ void WEBgrowSettings() { webserver.send(302, "text/plain", "please configure systemSettings first"); } else { - String body = FPSTR(HTMLheader); + String body = returnHTMLheader("growSettings"); if(strlen(GrowName) < 1) { body += "

    Final step: Grow settings

    "; @@ -1852,7 +1830,7 @@ void WEBgrowSettings() { body += "\n"; body += "\n"; body += FPSTR(JSconvertDateToEpoch); - body += returnHTMLfooter("growSettings"); + body += FPSTR(HTMLfooter); webserver.send(200, "text/html", body); } @@ -2173,8 +2151,6 @@ void APIgetSensors() { * TODO LIST / NOTES * * - * - avoid using javascript to set the GrowName in the Menu and the time - * as well * - when PWM for fan is set, set fan speed to regulate humidity and * temperature * - re-organize EEPROM saved values.