firmware - fix bug when saving system settings resetting LED and FAN PWM

This commit is contained in:
DeltaLima 2024-12-05 05:07:06 +01:00
parent f9914343e7
commit 61c7af5eb5

View file

@ -852,6 +852,9 @@ void POSTgrowSettings() {
void POSTsystemSettings() { void POSTsystemSettings() {
unsigned short UseLEDrelais_old = UseLEDrelais;
unsigned short UseFANrelais_old = UseFANrelais;
NtpOffset = webserver.arg("NtpOffset").toInt(); NtpOffset = webserver.arg("NtpOffset").toInt();
MoistureSensor_Type = webserver.arg("MoistureSensor_Type").toInt(); MoistureSensor_Type = webserver.arg("MoistureSensor_Type").toInt();
SoilmoistureLow = webserver.arg("SoilmoistureLow").toInt(); SoilmoistureLow = webserver.arg("SoilmoistureLow").toInt();
@ -909,14 +912,14 @@ void POSTsystemSettings() {
// when user uses an relais for LED control, we force here PinLEDPWM to 255 // when user uses an relais for LED control, we force here PinLEDPWM to 255
// to ensure nothing bad happens and its turned on // to ensure nothing bad happens and its turned on
if(UseLEDrelais == false) { if( (UseLEDrelais == false) && (UseLEDrelais != UseLEDrelais_old) ) {
PinLEDPWM = 255; PinLEDPWM = 255;
EEPROM.put(213, PinLEDPWM); EEPROM.put(213, PinLEDPWM);
EEPROM.commit(); EEPROM.commit();
Serial.println("UseLEDrelais is 0, forcing PinLEDPWM to max to prevent relais damage and ensure its turned on"); Serial.println("UseLEDrelais is 0, forcing PinLEDPWM to max to prevent relais damage and ensure its turned on");
} }
if(UseFANrelais == false) { if( (UseFANrelais == false) && (UseFANrelais != UseFANrelais_old) ) {
PinFANPWM = 255; PinFANPWM = 255;
EEPROM.put(215, PinFANPWM); EEPROM.put(215, PinFANPWM);
EEPROM.commit(); EEPROM.commit();