From 9196ef1076e332c821e34c44e0dbf717625aed4a Mon Sep 17 00:00:00 2001 From: Marcus Date: Wed, 8 May 2024 17:35:56 +0200 Subject: [PATCH] firmware wip - save MaintenanceDuration in EEPROM --- Arduino/CanGrow/CanGrow.ino | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index 2451fd5..2a181e1 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -121,7 +121,7 @@ bool UseLEDrelais; bool UseFANrelais; // Which temperature sensor to use? byte TemperatureSensor_Type; -unsigned short MaintenanceDuration = 60000; +unsigned short MaintenanceDuration = 60; // // Grow Stuff @@ -973,6 +973,8 @@ bool loadEEPROM() { * 216 PinFANPWM * 217 SunFade * 218 SunFadeDuration + * 219 MaintenanceDuration + * 221 .. * */ @@ -1032,6 +1034,8 @@ bool loadEEPROM() { EEPROM.get(214, TemperatureSensor_Type); // size is 1 byte EEPROM.get(215, UseFANrelais); + // size is 2 byte + EEPROM.get(219, MaintenanceDuration); } // TODO auth does not work atm // EEPROM.get(160, WebUiUsername); @@ -1092,6 +1096,8 @@ bool loadEEPROM() { Serial.println(PumpOnTime); Serial.print("MoistureSensor_Type: "); Serial.println(MoistureSensor_Type); + Serial.print("TemperatureSensor_Type: "); + Serial.println(TemperatureSensor_Type); Serial.print("SoilmoistureLow: "); Serial.println(SoilmoistureLow); Serial.print("NtpOffset: "); @@ -1100,6 +1106,8 @@ bool loadEEPROM() { Serial.println(UseLEDrelais); Serial.print("UseFANrelais: "); Serial.println(UseFANrelais); + Serial.print("MaintenanceDuration: "); + Serial.println(MaintenanceDuration); Serial.println("---- Grow values ----"); Serial.print("GrowName: "); @@ -1576,7 +1584,7 @@ void loop() { // when being in Maintenance Mode and UseRelaisLED not true, // dimm the light if(MaintenanceMode == true) { - if((currentRuntime - MaintenanceStarted <= MaintenanceDuration) && (UseLEDrelais == false)) { + if((currentRuntime - MaintenanceStarted <= MaintenanceDuration * 1000 ) && (UseLEDrelais == false)) { // in case of being in Maintenance Mode , dimm the grow light when not a relais is used setOutput(1, 20); } else { @@ -2205,6 +2213,10 @@ void WEBsystemSettings() { body += "NTP offset: Hours
\n"; + + body += "Maintenance Duration: Seconds
\n"; body += "\n"; body += "\n"; @@ -2393,6 +2405,7 @@ void POSTsystemSettings() { UseLEDrelais = webserver.arg("UseLEDrelais").toInt(); UseFANrelais = webserver.arg("UseFANrelais").toInt(); TemperatureSensor_Type = webserver.arg("TemperatureSensor_Type").toInt(); + MaintenanceDuration = webserver.arg("TemperatureSensor_Type").toInt(); configured = true; @@ -2416,6 +2429,7 @@ void POSTsystemSettings() { EEPROM.put(214, TemperatureSensor_Type); // size is 1 byte EEPROM.put(215, UseFANrelais); + EEPROM.put(219, MaintenanceDuration); // write data to EEPROM EEPROM.commit(); @@ -2464,6 +2478,8 @@ void POSTsystemSettings() { Serial.println(UseFANrelais); Serial.print("TemperatureSensor_Type: "); Serial.println(TemperatureSensor_Type); + Serial.print("MaintenanceDuration: "); + Serial.println(MaintenanceDuration); if(strlen(GrowName) < 1) { webserver.sendHeader("Location", String("/growSettings?success"), true);