From 8444855f24822dc5d1fcea0ece291a4638e307dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96ster?= Date: Sun, 17 Aug 2025 20:02:11 +0300 Subject: [PATCH] Add new box for contactor status --- Software/src/devboard/webserver/webserver.cpp | 166 ++++++++++-------- 1 file changed, 94 insertions(+), 72 deletions(-) diff --git a/Software/src/devboard/webserver/webserver.cpp b/Software/src/devboard/webserver/webserver.cpp index 174efc78..3d4b6975 100644 --- a/Software/src/devboard/webserver/webserver.cpp +++ b/Software/src/devboard/webserver/webserver.cpp @@ -824,6 +824,28 @@ String processor(const String& var) { content += "button:hover { background-color: #3A4A52; }"; content += "h2 { font-size: 1.2em; margin: 0.3em 0 0.5em 0; }"; content += "h4 { margin: 0.6em 0; line-height: 1.2; }"; + //content += ".tooltip { position: relative; display: inline-block; }"; + content += ".tooltip .tooltiptext {"; + content += " visibility: hidden;"; + content += " width: 200px;"; + content += " background-color: #3A4A52;"; // Matching your button hover color + content += " color: white;"; + content += " text-align: center;"; + content += " border-radius: 6px;"; + content += " padding: 8px;"; + content += " position: absolute;"; + content += " z-index: 1;"; + content += " bottom: 125%;"; + content += " left: 50%;"; + content += " margin-left: -100px;"; + content += " opacity: 0;"; + content += " transition: opacity 0.3s;"; + content += " font-size: 0.9em;"; + content += " font-weight: normal;"; + content += " line-height: 1.4;"; + content += "}"; + content += ".tooltip:hover .tooltiptext { visibility: visible; opacity: 1; }"; + content += ".tooltip-icon { color: #505E67; cursor: help; }"; // Matching your button color content += ""; // Compact header @@ -1103,58 +1125,6 @@ String processor(const String& var) { } } - content += "

Battery allows contactor closing: "; - if (datalayer.system.status.battery_allows_contactor_closing == true) { - content += ""; - } else { - content += ""; - } - - content += " Inverter allows contactor closing: "; - if (datalayer.system.status.inverter_allows_contactor_closing == true) { - content += "

"; - } else { - content += ""; - } - if (emulator_pause_status == NORMAL) - content += "

Power status: " + String(get_emulator_pause_status().c_str()) + "

"; - else - content += "

Power status: " + String(get_emulator_pause_status().c_str()) + "

"; - - if (contactor_control_enabled) { - content += "

Contactors controlled by emulator, state: "; - if (datalayer.system.status.contactors_engaged) { - content += "ON"; - } else { - content += "OFF"; - } - content += "

"; - if (contactor_control_enabled_double_battery) { - if (pwm_contactor_control) { - content += "

Cont. Neg.: "; - if (datalayer.system.status.contactors_battery2_engaged) { - content += "Economized"; - content += " Cont. Pos.: "; - content += "Economized"; - } else { - content += ""; - content += " Cont. Pos.: "; - content += ""; - } - } else if ( - esp32hal->SECOND_BATTERY_CONTACTORS_PIN() != - GPIO_NUM_NC) { // No PWM_CONTACTOR_CONTROL , we can read the pin and see feedback. Helpful if channel overloaded - content += "

Cont. Neg.: "; - if (digitalRead(esp32hal->SECOND_BATTERY_CONTACTORS_PIN()) == HIGH) { - content += ""; - } else { - content += ""; - } - } //no PWM_CONTACTOR_CONTROL - content += "

"; - } - } - // Close the block content += ""; @@ -1253,26 +1223,6 @@ String processor(const String& var) { content += "

Battery charging!

"; } - content += "

Automatic contactor closing allowed:

"; - content += "

Battery: "; - if (datalayer.system.status.battery2_allowed_contactor_closing == true) { - content += ""; - } else { - content += ""; - } - - content += " Inverter: "; - if (datalayer.system.status.inverter_allows_contactor_closing == true) { - content += "

"; - } else { - content += ""; - } - - if (emulator_pause_status == NORMAL) - content += "

Power status: " + String(get_emulator_pause_status().c_str()) + "

"; - else - content += "

Power status: " + String(get_emulator_pause_status().c_str()) + "

"; - if (contactor_control_enabled) { content += "

Contactors controlled by emulator, state: "; if (datalayer.system.status.contactors_battery2_engaged) { @@ -1317,6 +1267,78 @@ String processor(const String& var) { content += ""; } } + // Block for Contactor status and component request status + // Start a new block with gray background color + content += "
"; + + if (emulator_pause_status == NORMAL) { + content += "

Power status: " + String(get_emulator_pause_status().c_str()) + "

"; + } else { + content += "

Power status: " + String(get_emulator_pause_status().c_str()) + "

"; + } + + content += "

Battery allows contactor closing: "; + if (datalayer.battery.status.bms_status == FAULT) { + content += ""; + } else { + content += ""; + } + content += " Inverter allows contactor closing: "; + if (datalayer.system.status.inverter_allows_contactor_closing == true) { + content += "

"; + } else { + content += "

"; + } + content += "

Secondary battery allowed to join "; + if (datalayer.system.status.battery2_allowed_contactor_closing == true) { + content += ""; + } else { + content += "✕ (voltage mismatch)"; + } + + if (!contactor_control_enabled) { + content += "
"; + content += "

Contactors not fully controlled via emulator [?]

"; + content += + "This means you are either running CAN controlled contactors OR manually " + "powering the contactors. Battery-Emulator will have limited amount of control over the contactors!"; + content += "
"; + } else { //contactor_control_enabled TRUE + content += "

Contactors controlled by emulator, state: "; + if (datalayer.system.status.contactors_engaged) { + content += "ON"; + } else { + content += "OFF"; + } + content += "

"; + if (contactor_control_enabled_double_battery) { + if (pwm_contactor_control) { + content += "

Cont. Neg.: "; + if (datalayer.system.status.contactors_battery2_engaged) { + content += "Economized"; + content += " Cont. Pos.: "; + content += "Economized"; + } else { + content += ""; + content += " Cont. Pos.: "; + content += ""; + } + } else if ( + esp32hal->SECOND_BATTERY_CONTACTORS_PIN() != + GPIO_NUM_NC) { // No PWM_CONTACTOR_CONTROL , we can read the pin and see feedback. Helpful if channel overloaded + content += "

Cont. Neg.: "; + if (digitalRead(esp32hal->SECOND_BATTERY_CONTACTORS_PIN()) == HIGH) { + content += ""; + } else { + content += ""; + } + } //no PWM_CONTACTOR_CONTROL + content += "

"; + } + } + + // Close the block + content += ""; if (charger) { // Start a new block with orange background color