diff --git a/Software/Software.ino b/Software/Software.ino index 0a139cba..bea32ea4 100644 --- a/Software/Software.ino +++ b/Software/Software.ino @@ -490,6 +490,7 @@ void handle_LED_state() { // BMS in fault state overrides everything if (bms_status == FAULT) { + LEDcolor = RED; pixels.setPixelColor(0, pixels.Color(255, 0, 0)); // Red LED full brightness } diff --git a/Software/src/devboard/webserver/webserver.cpp b/Software/src/devboard/webserver/webserver.cpp index dcc79da6..be806778 100644 --- a/Software/src/devboard/webserver/webserver.cpp +++ b/Software/src/devboard/webserver/webserver.cpp @@ -159,7 +159,7 @@ String processor(const String& var) { content += ""; // Start a new block with a specific background color - content += "
"; + content += "
"; // Display which components are used content += "

Inverter protocol: "; @@ -215,8 +215,27 @@ String processor(const String& var) { // Close the block content += "

"; - // Start a new block with a specific background color - content += "
"; + // Start a new block with a specific background color. Color changes depending on BMS status + switch (LEDcolor) { + case GREEN: + content += "
"; + break; + case YELLOW: + content += "
"; + break; + case BLUE: + content += "
"; + break; + case RED: + content += "
"; + break; + case TEST_ALL_COLORS: //Blue in test mode + content += "
"; + break; + default: //Some new color, make background green + content += "
"; + break; + } // Display battery statistics within this block float socFloat = static_cast(SOC) / 100.0; // Convert to float and divide by 100 @@ -228,7 +247,12 @@ String processor(const String& var) { } else { currentFloat = static_cast(battery_current) / 10.0; // Convert to float and divide by 10 } - + float powerFloat = 0; + if (stat_batt_power > 32767) { //Handle negative values on this unsigned value + powerFloat = static_cast(-(65535 - stat_batt_power)); + } else { + powerFloat = static_cast(stat_batt_power); + } float tempMaxFloat = 0; float tempMinFloat = 0; if (temperature_max > 32767) { //Handle negative values on this unsigned value @@ -241,35 +265,19 @@ String processor(const String& var) { } else { tempMinFloat = static_cast(temperature_min) / 10.0; // Convert to float and divide by 10 } - - char socString[10]; - char sohString[10]; - char currentString[10]; - char voltageString[10]; - char tempMaxString[10]; - char tempMinString[10]; - - // Format decimals - dtostrf(socFloat, 6, 2, socString); - dtostrf(sohFloat, 6, 2, sohString); - dtostrf(voltageFloat, 6, 1, voltageString); - dtostrf(currentFloat, 6, 1, currentString); - dtostrf(tempMaxFloat, 6, 1, tempMaxString); - dtostrf(tempMinFloat, 6, 1, tempMinString); - - content += "

SOC: " + String(socString) + "

"; - content += "

SOH: " + String(sohString) + "

"; - content += "

Voltage: " + String(voltageString) + " V

"; - content += "

Current: " + String(currentString) + " A

"; - content += "

Power: " + String(stat_batt_power) + " W

"; + content += "

SOC: " + String(socFloat, 2) + "

"; + content += "

SOH: " + String(sohFloat, 2) + "

"; + content += "

Voltage: " + String(voltageFloat, 1) + " V

"; + content += "

Current: " + String(currentFloat, 1) + " A

"; + content += "

Power: " + String(powerFloat, 0) + " W

"; content += "

Total capacity: " + String(capacity_Wh) + " Wh

"; content += "

Remaining capacity: " + String(remaining_capacity_Wh) + " Wh

"; content += "

Max discharge power: " + String(max_target_discharge_power) + " W

"; content += "

Max charge power: " + String(max_target_charge_power) + " W

"; content += "

Cell max: " + String(cell_max_voltage) + " mV

"; content += "

Cell min: " + String(cell_min_voltage) + " mV

"; - content += "

Temperature max: " + String(tempMaxString) + " C

"; - content += "

Temperature min: " + String(tempMinString) + " C

"; + content += "

Temperature max: " + String(tempMaxFloat, 1) + " C

"; + content += "

Temperature min: " + String(tempMinFloat, 1) + " C

"; if (bms_status == 3) { content += "

BMS Status: OK

"; } else { diff --git a/Software/src/devboard/webserver/webserver.h b/Software/src/devboard/webserver/webserver.h index e5e485b1..e5e736d4 100644 --- a/Software/src/devboard/webserver/webserver.h +++ b/Software/src/devboard/webserver/webserver.h @@ -25,7 +25,8 @@ extern uint16_t temperature_max; //C+1, Goes thru convert2unsignedint16 funct extern uint16_t cell_max_voltage; //mV, 0-4350 extern uint16_t cell_min_voltage; //mV, 0-4350 extern uint8_t LEDcolor; //Enum, 0-10 -extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false +extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false +extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false extern const char* ssid; extern const char* password;