Make webserver work with PWM

This commit is contained in:
Daniel Öster 2024-12-12 23:48:21 +02:00
parent 62778628e5
commit 3a4ea70666

View file

@ -685,7 +685,7 @@ String processor(const String& var) {
content += "<h4 style='color: red;'>Power status: " + String(get_emulator_pause_status().c_str()) + " </h4>"; content += "<h4 style='color: red;'>Power status: " + String(get_emulator_pause_status().c_str()) + " </h4>";
#ifdef CONTACTOR_CONTROL #ifdef CONTACTOR_CONTROL
content += "<h4>Contactors controlled by Battery-Emulator: "; content += "<h4>Contactors controlled by emulator, state: ";
if (datalayer.system.status.contactors_engaged) { if (datalayer.system.status.contactors_engaged) {
content += "<span style='color: green;'>ON</span>"; content += "<span style='color: green;'>ON</span>";
} else { } else {
@ -693,13 +693,21 @@ String processor(const String& var) {
} }
content += "</h4>"; content += "</h4>";
content += "<h4>Pre Charge: "; content += "<h4>Precharge: (";
if (digitalRead(PRECHARGE_PIN) == HIGH) { content += PRECHARGE_TIME_MS;
content += "<span style='color: green;'>&#10003;</span>"; content += " ms) Cont. Neg.: ";
#ifdef PWM_CONTACTOR_CONTROL
if (datalayer.system.status.contactors_engaged) {
content += "<span style='color: green;'>Economized</span>";
content += " Cont. Pos.: ";
content += "<span style='color: green;'>Economized</span>";
} else { } else {
content += "<span style='color: red;'>&#10005;</span>"; content += "<span style='color: red;'>&#10005;</span>";
content += " Cont. Pos.: ";
content += "<span style='color: red;'>&#10005;</span>";
} }
content += " Cont. Neg.: ";
#else // No PWM_CONTACTOR_CONTROL , we can read the pin and see feedback. Helpful if channel overloaded
if (digitalRead(NEGATIVE_CONTACTOR_PIN) == HIGH) { if (digitalRead(NEGATIVE_CONTACTOR_PIN) == HIGH) {
content += "<span style='color: green;'>&#10003;</span>"; content += "<span style='color: green;'>&#10003;</span>";
} else { } else {
@ -712,6 +720,7 @@ String processor(const String& var) {
} else { } else {
content += "<span style='color: red;'>&#10005;</span>"; content += "<span style='color: red;'>&#10005;</span>";
} }
#endif //no PWM_CONTACTOR_CONTROL
content += "</h4>"; content += "</h4>";
#endif #endif
@ -816,7 +825,7 @@ String processor(const String& var) {
content += "<h4 style='color: red;'>Power status: " + String(get_emulator_pause_status().c_str()) + " </h4>"; content += "<h4 style='color: red;'>Power status: " + String(get_emulator_pause_status().c_str()) + " </h4>";
#ifdef CONTACTOR_CONTROL #ifdef CONTACTOR_CONTROL
content += "<h4>Contactors controlled by Battery-Emulator: "; content += "<h4>Contactors controlled by emulator, state: ";
if (datalayer.system.status.contactors_battery2_engaged) { if (datalayer.system.status.contactors_battery2_engaged) {
content += "<span style='color: green;'>ON</span>"; content += "<span style='color: green;'>ON</span>";
} else { } else {
@ -824,13 +833,19 @@ String processor(const String& var) {
} }
content += "</h4>"; content += "</h4>";
#ifdef CONTACTOR_CONTROL_DOUBLE_BATTERY #ifdef CONTACTOR_CONTROL_DOUBLE_BATTERY
content += "<h4>Pre Charge: "; content += "<h4>Cont. Neg.: ";
if (digitalRead(SECOND_PRECHARGE_PIN) == HIGH) { #ifdef PWM_CONTACTOR_CONTROL
content += "<span style='color: green;'>&#10003;</span>"; if (datalayer.system.status.contactors_battery2_engaged) {
content += "<span style='color: green;'>Economized</span>";
content += " Cont. Pos.: ";
content += "<span style='color: green;'>Economized</span>";
} else { } else {
content += "<span style='color: red;'>&#10005;</span>"; content += "<span style='color: red;'>&#10005;</span>";
content += " Cont. Pos.: ";
content += "<span style='color: red;'>&#10005;</span>";
} }
content += " Cont. Neg.: ";
#else // No PWM_CONTACTOR_CONTROL , we can read the pin and see feedback. Helpful if channel overloaded
if (digitalRead(SECOND_NEGATIVE_CONTACTOR_PIN) == HIGH) { if (digitalRead(SECOND_NEGATIVE_CONTACTOR_PIN) == HIGH) {
content += "<span style='color: green;'>&#10003;</span>"; content += "<span style='color: green;'>&#10003;</span>";
} else { } else {
@ -843,6 +858,7 @@ String processor(const String& var) {
} else { } else {
content += "<span style='color: red;'>&#10005;</span>"; content += "<span style='color: red;'>&#10005;</span>";
} }
#endif //no PWM_CONTACTOR_CONTROL
content += "</h4>"; content += "</h4>";
#endif // CONTACTOR_CONTROL_DOUBLE_BATTERY #endif // CONTACTOR_CONTROL_DOUBLE_BATTERY
#endif // CONTACTOR_CONTROL #endif // CONTACTOR_CONTROL