firmware wip - save MaintenanceDuration in EEPROM

This commit is contained in:
Marcus 2024-05-08 17:35:56 +02:00
parent 12fdd869c4
commit 9196ef1076

View file

@ -121,7 +121,7 @@ bool UseLEDrelais;
bool UseFANrelais; bool UseFANrelais;
// Which temperature sensor to use? // Which temperature sensor to use?
byte TemperatureSensor_Type; byte TemperatureSensor_Type;
unsigned short MaintenanceDuration = 60000; unsigned short MaintenanceDuration = 60;
// //
// Grow Stuff // Grow Stuff
@ -973,6 +973,8 @@ bool loadEEPROM() {
* 216 PinFANPWM * 216 PinFANPWM
* 217 SunFade * 217 SunFade
* 218 SunFadeDuration * 218 SunFadeDuration
* 219 MaintenanceDuration
* 221 ..
* *
*/ */
@ -1032,6 +1034,8 @@ bool loadEEPROM() {
EEPROM.get(214, TemperatureSensor_Type); EEPROM.get(214, TemperatureSensor_Type);
// size is 1 byte // size is 1 byte
EEPROM.get(215, UseFANrelais); EEPROM.get(215, UseFANrelais);
// size is 2 byte
EEPROM.get(219, MaintenanceDuration);
} }
// TODO auth does not work atm // TODO auth does not work atm
// EEPROM.get(160, WebUiUsername); // EEPROM.get(160, WebUiUsername);
@ -1092,6 +1096,8 @@ bool loadEEPROM() {
Serial.println(PumpOnTime); Serial.println(PumpOnTime);
Serial.print("MoistureSensor_Type: "); Serial.print("MoistureSensor_Type: ");
Serial.println(MoistureSensor_Type); Serial.println(MoistureSensor_Type);
Serial.print("TemperatureSensor_Type: ");
Serial.println(TemperatureSensor_Type);
Serial.print("SoilmoistureLow: "); Serial.print("SoilmoistureLow: ");
Serial.println(SoilmoistureLow); Serial.println(SoilmoistureLow);
Serial.print("NtpOffset: "); Serial.print("NtpOffset: ");
@ -1100,6 +1106,8 @@ bool loadEEPROM() {
Serial.println(UseLEDrelais); Serial.println(UseLEDrelais);
Serial.print("UseFANrelais: "); Serial.print("UseFANrelais: ");
Serial.println(UseFANrelais); Serial.println(UseFANrelais);
Serial.print("MaintenanceDuration: ");
Serial.println(MaintenanceDuration);
Serial.println("---- Grow values ----"); Serial.println("---- Grow values ----");
Serial.print("GrowName: "); Serial.print("GrowName: ");
@ -1576,7 +1584,7 @@ void loop() {
// when being in Maintenance Mode and UseRelaisLED not true, // when being in Maintenance Mode and UseRelaisLED not true,
// dimm the light // dimm the light
if(MaintenanceMode == true) { 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 // in case of being in Maintenance Mode , dimm the grow light when not a relais is used
setOutput(1, 20); setOutput(1, 20);
} else { } else {
@ -2205,6 +2213,10 @@ void WEBsystemSettings() {
body += "NTP offset: <input class='inputShort' type='number' name='NtpOffset' min='-12' max='14' value='"; body += "NTP offset: <input class='inputShort' type='number' name='NtpOffset' min='-12' max='14' value='";
body += NtpOffset; body += NtpOffset;
body+= "' required> Hours<br>\n"; body+= "' required> Hours<br>\n";
body += "Maintenance Duration: <input class='inputShort' type='number' name='MaintenanceDuration' min='0' max='900' value='";
body += MaintenanceDuration;
body += "' required> Seconds<br>\n";
body += "<input type='submit' value='Save'>\n"; body += "<input type='submit' value='Save'>\n";
body += "</form>\n"; body += "</form>\n";
@ -2393,6 +2405,7 @@ void POSTsystemSettings() {
UseLEDrelais = webserver.arg("UseLEDrelais").toInt(); UseLEDrelais = webserver.arg("UseLEDrelais").toInt();
UseFANrelais = webserver.arg("UseFANrelais").toInt(); UseFANrelais = webserver.arg("UseFANrelais").toInt();
TemperatureSensor_Type = webserver.arg("TemperatureSensor_Type").toInt(); TemperatureSensor_Type = webserver.arg("TemperatureSensor_Type").toInt();
MaintenanceDuration = webserver.arg("TemperatureSensor_Type").toInt();
configured = true; configured = true;
@ -2416,6 +2429,7 @@ void POSTsystemSettings() {
EEPROM.put(214, TemperatureSensor_Type); EEPROM.put(214, TemperatureSensor_Type);
// size is 1 byte // size is 1 byte
EEPROM.put(215, UseFANrelais); EEPROM.put(215, UseFANrelais);
EEPROM.put(219, MaintenanceDuration);
// write data to EEPROM // write data to EEPROM
EEPROM.commit(); EEPROM.commit();
@ -2464,6 +2478,8 @@ void POSTsystemSettings() {
Serial.println(UseFANrelais); Serial.println(UseFANrelais);
Serial.print("TemperatureSensor_Type: "); Serial.print("TemperatureSensor_Type: ");
Serial.println(TemperatureSensor_Type); Serial.println(TemperatureSensor_Type);
Serial.print("MaintenanceDuration: ");
Serial.println(MaintenanceDuration);
if(strlen(GrowName) < 1) { if(strlen(GrowName) < 1) {
webserver.sendHeader("Location", String("/growSettings?success"), true); webserver.sendHeader("Location", String("/growSettings?success"), true);