diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index ba80e87..4d8212b 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -34,7 +34,8 @@ float valTemperature; // valTemperature - contains the value of getHumidity() float valHumidity; // valWaterlevel - contains the value of getWaterlevel() - +// do we need a restart? (e.g. after wifi settings change) +bool NeedRestart; @@ -212,19 +213,27 @@ a:active { color: #04AA6D; } -.infomsg { - background: #04AA6D; +.infomsg , .warnmsg { color: #fff; border-radius: 3px; padding: 4px; width: fit-content; min-width: 200px; max-width: 420px; margin: auto; + margin-bottom: 5px; font-weight: bold; text-align: center; text-decoration: none; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5); } +.infomsg { + background: #04AA6D; +} + +.warnmsg { + background: #aa4204; +} + /* from https://gist.github.com/iamhelenliu/5755179 - thank you! */ .nav { background: #333; @@ -268,6 +277,14 @@ a:active { +)EOF"; + +const char HTMLsuccess[] PROGMEM = R"EOF( +
Successfully saved!
+)EOF"; + +const char HTMLneedRestart[] PROGMEM = R"EOF( +
Restart is required to apply new WiFi settings!
)EOF"; const char HTMLhelp[] PROGMEM = R"EOF( @@ -1109,8 +1126,11 @@ void WEBwifiSettings() { body += "

"; } body += "

WiFi config

\n"; + if(NeedRestart == true) { + body += FPSTR(HTMLneedRestart); + } if(webserver.hasArg("success")) { - body += "
Successfully saved!
Please restart the device.
"; + body += FPSTR(HTMLsuccess); } body += "

Select your wifi network from the SSID list.
To use DHCP leave IP, Subnet, Gateway and DNS fields blank!

"; body += "
\n"; @@ -1126,9 +1146,9 @@ void WEBwifiSettings() { } body += "
\n"; if(strlen(WIFIssid) > 0) { - body += "Currently connected to: "; + body += "Currently connected to: "; body += WIFIssid; - body += "
\n"; + body += "

\n"; } body += "Password:
\n"; body += "IP:
\n"; @@ -1153,7 +1173,7 @@ void WEBsystemSettings() { body += "

System settings

"; if(webserver.hasArg("success")) { - body += "
Successfully saved!
Please restart the device.
"; + body += FPSTR(HTMLsuccess); } body += "

here you can set which features and sensors you use
"; body += "

"; @@ -1229,8 +1249,8 @@ void WEBgrowSettings() { body += "

Grow Settings

"; if(webserver.hasArg("success")) { - body += "
Successfully saved!
Please restart the device.
"; - } + body += FPSTR(HTMLsuccess); + } body += "

Here you can set everything grow related, like light hours, how much water, LED brightness
"; body += "

"; @@ -1371,6 +1391,7 @@ void POSTsystemSettings() { PumpOnTime = webserver.arg("PumpOnTime").toInt(); UseFan = webserver.arg("UseFan").toInt(); UseLEDrelais = webserver.arg("UseLEDrelais").toInt(); + configured = true; // size is 1 byte @@ -1438,7 +1459,8 @@ void POSTwifiSettings() { WIFIuseDHCP = true; } - + // restart is needed to load the new settings + NeedRestart = true; EEPROM.put(0, WIFIssid); EEPROM.put(32, WIFIpassword);