From 1327eb6781cdf6c7665b6db89de152fc6fbb885e Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 11 Feb 2024 12:00:34 +0200 Subject: [PATCH] Improve events view --- Software/src/devboard/utils/events.cpp | 12 ++--- Software/src/devboard/webserver/README.md | 4 -- .../src/devboard/webserver/events_html.cpp | 46 +++++++++++++++++-- .../src/devboard/webserver/index_html.cpp | 7 ++- 4 files changed, 53 insertions(+), 16 deletions(-) diff --git a/Software/src/devboard/utils/events.cpp b/Software/src/devboard/utils/events.cpp index 18f8da4a..3bf9035b 100644 --- a/Software/src/devboard/utils/events.cpp +++ b/Software/src/devboard/utils/events.cpp @@ -19,10 +19,10 @@ void init_events(void) { entries[i].timestamp = 0; entries[i].data = 0; entries[i].occurences = 0; - entries[i].led_color = RED; // Most events are RED + entries[i].led_color = RED; // Most events are RED, critical errors } - // YELLOW events below + // YELLOW warning events below entries[EVENT_12V_LOW].led_color = YELLOW; entries[EVENT_CAN_WARNING].led_color = YELLOW; entries[EVENT_CELL_DEVIATION_HIGH].led_color = YELLOW; @@ -59,13 +59,13 @@ static void update_led_color(EVENTS_ENUM_TYPE event) { const char* get_led_color_display_text(u_int8_t led_color) { switch (led_color) { case RED: - return "RED"; + return "Error"; case YELLOW: - return "YELLOW"; + return "Warning"; case GREEN: - return "GREEN"; + return "Info"; case BLUE: - return "BLUE"; + return "Debug"; default: return "UNKNOWN"; } diff --git a/Software/src/devboard/webserver/README.md b/Software/src/devboard/webserver/README.md index 4965a784..b3027538 100644 --- a/Software/src/devboard/webserver/README.md +++ b/Software/src/devboard/webserver/README.md @@ -24,10 +24,6 @@ This section lists a number of features that can be implemented as part of the w - TODO: list all available ssids: scan WiFi Networks https://randomnerdtutorials.com/esp32-useful-wi-fi-functions-arduino/ - TODO: add option to add/change ssid and password and save, connect to the new ssid (Option: save ssid and password using Preferences.h library https://randomnerdtutorials.com/esp32-save-data-permanently-preferences/) -- TODO: display WiFi connection strength (https://randomnerdtutorials.com/esp32-useful-wi-fi-functions-arduino/) -- TODO: display CAN state (indicate if there is a communication error) -- TODO: display battery errors in battery diagnosis tab -- TODO: display inverter errors in battery diagnosis tab - TODO: add functionality to turn WiFi AP off - TODO: fix IP address on home network (https://randomnerdtutorials.com/esp32-static-fixed-ip-address-arduino-ide/) - TODO: set hostname (https://randomnerdtutorials.com/esp32-set-custom-hostname-arduino/) diff --git a/Software/src/devboard/webserver/events_html.cpp b/Software/src/devboard/webserver/events_html.cpp index 0879dcc8..597245e0 100644 --- a/Software/src/devboard/webserver/events_html.cpp +++ b/Software/src/devboard/webserver/events_html.cpp @@ -9,21 +9,57 @@ const char EVENTS_HTML_START[] = R"=====( .event > div { flex: 1; min-width: 100px; max-width: 90%; word-break: break-word; }
-

Event log:

-
Event Type
LED Color
Last Event (seconds ago)
Count
Data
Message
+
Event Type
Severity
Last Event
Count
Data
Message
)====="; const char EVENTS_HTML_END[] = R"=====(
+ +)====="; + +/* The above -)====="; +*/ String events_processor(const String& var) { if (var == "PLACEHOLDER") { @@ -39,10 +75,12 @@ String events_processor(const String& var) { content.concat("
"); content.concat("
" + String(get_event_enum_string(static_cast(i))) + "
"); content.concat("
" + String(get_led_color_display_text(entries[i].led_color)) + "
"); - content.concat("
" + String((millis() / 1000) - entries[i].timestamp) + "
"); + content.concat("
" + String((millis() / 1000) - entries[i].timestamp) + + "
"); content.concat("
" + String(entries[i].occurences) + "
"); content.concat("
" + String(entries[i].data) + "
"); content.concat("
" + String(get_event_message(static_cast(i))) + "
"); + content.concat("
" + String(entries[i].timestamp) + "
"); content.concat("
"); // End of event row } } diff --git a/Software/src/devboard/webserver/index_html.cpp b/Software/src/devboard/webserver/index_html.cpp index 51bd5bd5..c7a11e90 100644 --- a/Software/src/devboard/webserver/index_html.cpp +++ b/Software/src/devboard/webserver/index_html.cpp @@ -1,9 +1,12 @@ const char index_html[] = R"rawliteral( +Battery Emulator

Battery Emulator

%PLACEHOLDER% +)rawliteral"; + +/* The above code is minified to increase performance. Here is the full HTML function: Battery Emulator -