diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index 7100a3e..9b4fea6 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -64,15 +64,15 @@ char WebUiPassword[32] = "cangrow"; // System // // configured - if true, run setup assistant -bool configured; +bool configured = false; // NTP Offset -int ntpOffset; +int ntpOffset = 0; // MoistureSensor_Type - contains which moisture sensor to use // 1: analog capacitive sensor // 2: I2C chirp sensor from catnip electronics byte MoistureSensor_Type; // SoilmoistureLow - contains the value , when soil moisture is assumed to be low, -byte SoilmoistureLow; +byte SoilmoistureLow = 20; // UsePump - is the pump used? bool bool UsePump; // UseFan - is the fan used? bool @@ -97,17 +97,17 @@ unsigned long GrowStart; // DayOfGrow contains on which day the grow is byte DayOfGrow; // DaysVeg - contains how many days to be in vegetation phase -byte DaysVeg; +byte DaysVeg = 35; // DaysBloom - contains how many days to be in bloom phase -byte DaysBloom; +byte DaysBloom = 49; // LighthoursVeg - contains how many hours the Growlight is on in Veg -byte LighthoursVeg; +byte LighthoursVeg = 16; // LighthoursBloom - contains how many hours the Growlight is on in Bloom -byte LighthoursBloom; +byte LighthoursBloom = 12; // SunriseHour - contains to which hour of day the growlight turns on -byte SunriseHour; +byte SunriseHour = 7; // SunriseHour - contains to which minute of SunriseHour the growlight turns on -byte SunriseMinute; +byte SunriseMinute = 0; // PINled_PWM - contains the PWM value for dimming the grow light // default is 255 to ensure it is just on for the case UseLEDrelais is true byte PINled_PWM = 255; @@ -284,7 +284,11 @@ const char HTMLsuccess[] PROGMEM = R"EOF( )EOF"; const char HTMLneedRestart[] PROGMEM = R"EOF( -
Restart is required to apply new WiFi settings!
+
Restart is required to apply new WiFi settings! +
+ +
+
)EOF"; const char HTMLhelp[] PROGMEM = R"EOF( @@ -966,6 +970,9 @@ void WebHandler() { webserver.on("/growSettings/save", HTTP_POST, POSTgrowSettings); // help webserver.on("/help", HTTP_GET, WEBhelp); + + // restart when NeedRestart is true + webserver.on("/restart", HTTP_GET, WebRestart); // does not work atm TODO //webserver.on("/logout", [](){ webserver.send(401, "text/html", "logged out!"); }); @@ -977,6 +984,21 @@ void WebHandler() { } +void WebRestart() { + if(NeedRestart == true) { + String body = FPSTR(HTMLheader); + body += "

Restarting

"; + body += "
After restart you will be connected to Wifi
"; + body += WIFIssid; + body += "
You get CanGrow's IP-Address from the display or serial console.
"; + body += returnHTMLfooter(); + webserver.send(200, "text/html", body); + Serial.println("Restarting... see you soon space cowboy!"); + delay(1000); + ESP.restart(); + } +} + void WebAuth() { /* @@ -1081,7 +1103,7 @@ void WEBhelp() { */ void WEBroot() { - if(FirstRun == true < 1) { + if(FirstRun == true) { webserver.sendHeader("Location", String("/wifiSettings"), true); webserver.send(302, "text/plain", "please configure wifiSettings first"); } else if(configured == false){ @@ -1247,7 +1269,7 @@ void WEBgrowSettings() { String body = FPSTR(HTMLheader); if(strlen(GrowName) < 1) { - body += "

Step 3: Grow settings

"; + body += "

Final step: Grow settings

"; body += "

Please configure all settings
"; body += "

"; } @@ -1436,7 +1458,12 @@ void POSTsystemSettings() { Serial.print("ntpOffset: "); Serial.println(ntpOffset); - webserver.sendHeader("Location", String("/systemSettings?success"), true); + if(strlen(GrowName) < 1) { + webserver.sendHeader("Location", String("/growSettings?success"), true); + } else { + webserver.sendHeader("Location", String("/systemSettings?success"), true); + } + webserver.send(302, "text/plain", "systemSettings/save: success!"); }