From 72af4cbe80d5f477b9eeac4d5cca682c419124f8 Mon Sep 17 00:00:00 2001 From: nick Date: Tue, 9 Jun 2026 23:38:09 -0600 Subject: [PATCH] dashboard: improve battery overview card --- .../esp32-s3-dashboard/dashboard_config.h | 2 +- .../esp32-s3-dashboard/esp32-s3-dashboard.ino | 88 +++++++++++++------ 2 files changed, 64 insertions(+), 26 deletions(-) diff --git a/firmware/esp32-s3-dashboard/dashboard_config.h b/firmware/esp32-s3-dashboard/dashboard_config.h index fb9a8d0..77399b1 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.0-overview-ui"; +static const char *DASHBOARD_VERSION = "0.1.1-battery-card"; // 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 f223d78..48a1c4f 100644 --- a/firmware/esp32-s3-dashboard/esp32-s3-dashboard.ino +++ b/firmware/esp32-s3-dashboard/esp32-s3-dashboard.ino @@ -15,7 +15,10 @@ using namespace esp_panel::board; static DashboardStatus status_model; static lv_obj_t *soc_value_label = nullptr; -static lv_obj_t *battery_detail_label = nullptr; +static lv_obj_t *battery_voltage_label = nullptr; +static lv_obj_t *battery_current_label = nullptr; +static lv_obj_t *battery_capacity_label = nullptr; +static lv_obj_t *battery_health_label = nullptr; static lv_obj_t *inside_temp_label = nullptr; static lv_obj_t *outside_temp_label = nullptr; static lv_obj_t *system_status_label = nullptr; @@ -42,7 +45,10 @@ static int pending_relay_index = -1; static bool pending_relay_previous_state = false; static String last_soc_text; -static String last_battery_detail_text; +static String last_battery_voltage_text; +static String last_battery_current_text; +static String last_battery_capacity_text; +static String last_battery_health_text; static String last_inside_temp_text; static String last_outside_temp_text; static String last_system_status_text; @@ -255,26 +261,37 @@ static void update_overview_widgets() soc_text += status_model.soc >= 0 ? String(status_model.soc) : "--"; soc_text += "%"; - String battery_detail; - battery_detail += String(status_model.voltage, 2); - battery_detail += " V\n"; - battery_detail += String(status_model.current, 2); - battery_detail += " A\n"; - battery_detail += String(status_model.remaining_ah, 1); - battery_detail += " / "; - battery_detail += String(status_model.capacity_ah, 0); - battery_detail += " Ah\n"; - battery_detail += String(status_model.battery_temp_f, 1); - battery_detail += " F battery\nBMS "; - battery_detail += status_model.bms_connected ? "online" : "offline"; + String voltage_text; + voltage_text += String(status_model.voltage, 2); + voltage_text += " V"; + + String current_text; + current_text += String(status_model.current, 2); + current_text += " A"; + + String capacity_text; + capacity_text += String(status_model.remaining_ah, 1); + capacity_text += " / "; + capacity_text += String(status_model.capacity_ah, 0); + capacity_text += " Ah"; + + String health_text; + health_text += "BMS "; + health_text += status_model.bms_connected ? "online" : "offline"; + health_text += " | "; + health_text += String(status_model.battery_temp_f, 1); + health_text += " F"; if (status_model.cell_delta_mv >= 0) { - battery_detail += "\nCell delta "; - battery_detail += String(status_model.cell_delta_mv); - battery_detail += " mV"; + health_text += "\nCell delta "; + health_text += String(status_model.cell_delta_mv); + health_text += " mV"; } set_label_text_if_changed(soc_value_label, last_soc_text, soc_text); - set_label_text_if_changed(battery_detail_label, last_battery_detail_text, battery_detail); + set_label_text_if_changed(battery_voltage_label, last_battery_voltage_text, voltage_text); + set_label_text_if_changed(battery_current_label, last_battery_current_text, current_text); + set_label_text_if_changed(battery_capacity_label, last_battery_capacity_text, capacity_text); + set_label_text_if_changed(battery_health_label, last_battery_health_text, health_text); set_label_text_if_changed(system_status_label, last_system_status_text, last_system_status_text); } @@ -472,14 +489,35 @@ static void create_overland_overview_screen() lv_label_set_text(soc_value_label, "--%"); lv_obj_set_style_text_color(soc_value_label, lv_color_hex(0xFFFFFF), 0); lv_obj_set_style_text_font(soc_value_label, &lv_font_montserrat_30, 0); - lv_obj_align(soc_value_label, LV_ALIGN_TOP_LEFT, 0, 40); + lv_obj_align(soc_value_label, LV_ALIGN_TOP_LEFT, 0, 34); - battery_detail_label = lv_label_create(battery_card); - lv_label_set_text(battery_detail_label, "Waiting for battery data..."); - lv_obj_set_style_text_color(battery_detail_label, lv_color_hex(0xDDE3EA), 0); - lv_obj_set_width(battery_detail_label, 260); - lv_label_set_long_mode(battery_detail_label, LV_LABEL_LONG_WRAP); - lv_obj_align(battery_detail_label, LV_ALIGN_TOP_LEFT, 0, 95); + lv_obj_t *soc_caption = lv_label_create(battery_card); + lv_label_set_text(soc_caption, "STATE OF CHARGE"); + lv_obj_set_style_text_color(soc_caption, lv_color_hex(0x7D8996), 0); + lv_obj_align(soc_caption, LV_ALIGN_TOP_LEFT, 0, 82); + + battery_voltage_label = lv_label_create(battery_card); + lv_label_set_text(battery_voltage_label, "-- V"); + lv_obj_set_style_text_color(battery_voltage_label, lv_color_hex(0xFFFFFF), 0); + lv_obj_align(battery_voltage_label, LV_ALIGN_TOP_LEFT, 0, 112); + + battery_current_label = lv_label_create(battery_card); + lv_label_set_text(battery_current_label, "-- A"); + lv_obj_set_style_text_color(battery_current_label, lv_color_hex(0xFFFFFF), 0); + lv_obj_align(battery_current_label, LV_ALIGN_TOP_LEFT, 135, 112); + + battery_capacity_label = lv_label_create(battery_card); + lv_label_set_text(battery_capacity_label, "-- / -- Ah"); + lv_obj_set_style_text_color(battery_capacity_label, lv_color_hex(0xDDE3EA), 0); + lv_obj_set_width(battery_capacity_label, 260); + lv_obj_align(battery_capacity_label, LV_ALIGN_TOP_LEFT, 0, 148); + + battery_health_label = lv_label_create(battery_card); + lv_label_set_text(battery_health_label, "Waiting for BMS..."); + lv_obj_set_style_text_color(battery_health_label, lv_color_hex(0xB8C0C8), 0); + lv_obj_set_width(battery_health_label, 260); + lv_label_set_long_mode(battery_health_label, LV_LABEL_LONG_WRAP); + lv_obj_align(battery_health_label, LV_ALIGN_TOP_LEFT, 0, 182); inside_temp_label = lv_label_create(temp_card); lv_label_set_text(inside_temp_label, "Inside\n--");