diff --git a/firmware/esp32-s3-dashboard/dashboard_config.h b/firmware/esp32-s3-dashboard/dashboard_config.h index fccaa90..bcdb848 100644 --- a/firmware/esp32-s3-dashboard/dashboard_config.h +++ b/firmware/esp32-s3-dashboard/dashboard_config.h @@ -1,6 +1,6 @@ #pragma once -static const char *DASHBOARD_VERSION = "0.1.20-battery-idle-state"; +static const char *DASHBOARD_VERSION = "0.1.21-fix-battery-widget-update"; // Update these if your Cargo ESP AP credentials are different. static const char *CARGO_WIFI_SSID = "OverlandController"; diff --git a/firmware/esp32-s3-dashboard/esp32-s3-dashboard.ino b/firmware/esp32-s3-dashboard/esp32-s3-dashboard.ino index 3a3b659..b68cbd3 100644 --- a/firmware/esp32-s3-dashboard/esp32-s3-dashboard.ino +++ b/firmware/esp32-s3-dashboard/esp32-s3-dashboard.ino @@ -461,10 +461,11 @@ static void update_system_status_label() static void update_overview_widgets() { - String current_text = ""; + String current_text = "Idle"; String estimate_text = ""; if (status_model.current > 0.05 || status_model.current < -0.05) { + current_text = ""; current_text += status_model.current > 0 ? "+" : ""; current_text += String(status_model.current, 2); current_text += " A"; @@ -475,11 +476,30 @@ static void update_overview_widgets() } else if (status_model.current < -0.05 && status_model.remaining_ah > 0.0) { estimate_text = "Runtime " + format_hours(status_model.remaining_ah / abs(status_model.current)); } - } else { - current_text = "Idle"; - estimate_text = ""; } + + String soc_text; + soc_text += status_model.soc >= 0 ? String(status_model.soc) : "--"; + soc_text += "%"; + + update_battery_soc_gauge(); + set_label_text_if_changed(battery_soc_label, last_battery_soc_text, soc_text); + update_battery_current_label(current_text, status_model.current); + + if (battery_estimate_label != nullptr) { + set_label_text_if_changed(battery_estimate_label, last_battery_estimate_text, estimate_text); + + lvgl_port_lock(-1); + if (estimate_text.length() == 0) { + lv_obj_add_flag(battery_estimate_label, LV_OBJ_FLAG_HIDDEN); + } else { + lv_obj_clear_flag(battery_estimate_label, LV_OBJ_FLAG_HIDDEN); + } + lvgl_port_unlock(); } +} + + String soc_text; soc_text += status_model.soc >= 0 ? String(status_model.soc) : "--";