diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index ef0b311..ba80e87 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -77,17 +77,17 @@ bool UsePump; // UseFan - is the fan used? bool byte PumpOnTime; bool UseFan; - // In case the user uses no 12V LED on the LED output and an relais instead // we have to disable PWM. So we ask here for what kind of light user is going bool UseLEDrelais; + + + // // Grow Stuff // -unsigned int NtpOffset; - // GrowName - contains the name of the grow/plant. Up to 32 byte char GrowName[32]; // GrowStart - contains unix timestamp from date where grow starts (00:00) @@ -108,7 +108,8 @@ byte SunriseHour; // SunriseHour - contains to which minute of SunriseHour the growlight turns on byte SunriseMinute; // PINled_PWM - contains the PWM value for dimming the grow light -byte PINled_PWM; +// default is 255 to ensure it is just on for the case UseLEDrelais is true +byte PINled_PWM = 255; @@ -645,6 +646,8 @@ bool loadEEPROM() { EEPROM.get(166, SoilmoistureLow); // size is 2 byte EEPROM.get(167, ntpOffset); + // size is 1 byte + EEPROM.get(169, UseLEDrelais); // TODO auth does not work atm // EEPROM.get(160, WebUiUsername); @@ -654,11 +657,36 @@ bool loadEEPROM() { * Grow settings */ - //TBD + // size is 32 byte + EEPROM.get(170, GrowName); + // size is 4 byte + EEPROM.get(202, GrowStart); + // size is 1 byte + EEPROM.get(206, DaysVeg); + // size is 1 byte + EEPROM.get(207, DaysBloom); + // size is 1 byte + EEPROM.get(208, LighthoursVeg); + // size is 1 byte + EEPROM.get(209, LighthoursBloom); + // size is 1 byte + EEPROM.get(210, SunriseHour); + // size is 1 byte + EEPROM.get(211, SunriseMinute); + + // to ensure PINled_PWM always set to 255 when UseLEDrelais is true + // we set it here again, does not matter whats stored. + // size is 1 byte + if(UseLEDrelais == true) { + PINled_PWM = 255; + } else { + EEPROM.get(212, PINled_PWM); + } // print values to Serial output + Serial.println("---- WiFi values ----"); Serial.print("WIFIssid: "); Serial.println(WIFIssid); Serial.print("WIFIpassword: "); @@ -666,6 +694,9 @@ bool loadEEPROM() { Serial.print("Use DHCP: "); Serial.println(WIFIuseDHCP); + Serial.println("---- System values ----"); + Serial.print("configured: "); + Serial.println(configured); Serial.print("UseFan: "); Serial.println(UseFan); Serial.print("UsePump: "); @@ -677,11 +708,31 @@ bool loadEEPROM() { Serial.print("SoilmoistureLow: "); Serial.println(SoilmoistureLow); Serial.print("ntpOffset: "); - Serial.println(ntpOffset); + Serial.println(ntpOffset); + Serial.print("UseLEDrelais: "); + Serial.println(UseLEDrelais); + + Serial.println("---- Grow values ----"); + Serial.print("GrowName: "); + Serial.println(GrowName); + Serial.print("GrowStart: "); + Serial.println(GrowStart); + Serial.print("DaysVeg: "); + Serial.println(DaysVeg); + Serial.print("DaysBloom: "); + Serial.println(DaysBloom); + Serial.print("LighthoursVeg: "); + Serial.println(LighthoursVeg); + Serial.print("LighthoursBloom: "); + Serial.println(LighthoursBloom); + Serial.print("SunriseHour: "); + Serial.println(SunriseHour); + Serial.print("SunriseMinute: "); + Serial.println(SunriseMinute); + Serial.print("PINled_PWM: "); + Serial.println(PINled_PWM); - Serial.print("configured: "); - Serial.println(configured); } else { Serial.println("EEPROM value WIFIssid is empty"); } @@ -959,6 +1010,22 @@ void WebAuthApi() { } } +// returns footer with javascript stuff +String returnHTMLfooter() { + String footer; + // show the GrowName in the menu if set + if(strlen(GrowName) > 0){ + // add a seedling to the growname :) + String divGrowName = "🌱 "; + divGrowName += GrowName; + // replace content of html ID GrowName + footer += JSreplaceStr("GrowName", divGrowName); + } + + footer += FPSTR(HTMLfooter); + + return footer; +} /* * returnSelected(bool) @@ -992,7 +1059,7 @@ void WEBstyleCSS() { void WEB404() { String body = FPSTR(HTMLheader); body += "
"; body += timeClient.getFormattedTime(); body += "
"; - body += FPSTR(HTMLfooter); + body += returnHTMLfooter(); webserver.send(200, "text/html", body); } @@ -1059,6 +1125,11 @@ void WEBwifiSettings() { body += wifiName + "\n"; } body += "here you can set which features and sensors you use
";
body += "