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;
// 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 {
@ -2206,6 +2214,10 @@ void WEBsystemSettings() {
body += NtpOffset;
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 += "</form>\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);