dashboard: center battery soc and show estimate

This commit is contained in:
2026-06-10 01:53:39 -06:00
parent 63cbd7c498
commit a1f9e782f9
2 changed files with 17 additions and 20 deletions
@@ -1,6 +1,6 @@
#pragma once #pragma once
static const char *DASHBOARD_VERSION = "0.1.14-large-battery-gauge"; static const char *DASHBOARD_VERSION = "0.1.15-battery-center-estimate";
// Update these if your Cargo ESP AP credentials are different. // Update these if your Cargo ESP AP credentials are different.
static const char *CARGO_WIFI_SSID = "OverlandController"; static const char *CARGO_WIFI_SSID = "OverlandController";
@@ -487,10 +487,12 @@ static void update_overview_widgets()
soc_text += "%"; soc_text += "%";
update_battery_soc_gauge(); update_battery_soc_gauge();
set_label_text_if_changed(battery_soc_label, last_battery_soc_text, soc_text);
set_label_text_if_changed(battery_voltage_label, last_battery_voltage_text, voltage_text); set_label_text_if_changed(battery_voltage_label, last_battery_voltage_text, voltage_text);
update_battery_current_label(current_text, status_model.current); update_battery_current_label(current_text, status_model.current);
set_label_text_if_changed(battery_estimate_label, last_battery_estimate_text, estimate_text);
if (battery_estimate_label != nullptr) { if (battery_estimate_label != nullptr) {
set_label_text_if_changed(battery_estimate_label, last_battery_estimate_text, estimate_text);
lvgl_port_lock(-1); lvgl_port_lock(-1);
if (estimate_text.length() == 0) { if (estimate_text.length() == 0) {
lv_obj_add_flag(battery_estimate_label, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(battery_estimate_label, LV_OBJ_FLAG_HIDDEN);
@@ -499,7 +501,6 @@ static void update_overview_widgets()
} }
lvgl_port_unlock(); lvgl_port_unlock();
} }
set_label_text_if_changed(battery_soc_label, last_battery_soc_text, soc_text);
set_label_text_if_changed(system_status_label, last_system_status_text, last_system_status_text); set_label_text_if_changed(system_status_label, last_system_status_text, last_system_status_text);
} }
@@ -759,38 +760,34 @@ static void create_overland_overview_screen()
lv_obj_set_style_arc_color(battery_soc_arc, lv_color_hex(0x84CAFF), LV_PART_INDICATOR); lv_obj_set_style_arc_color(battery_soc_arc, lv_color_hex(0x84CAFF), LV_PART_INDICATOR);
lv_obj_set_style_arc_width(battery_soc_arc, 14, LV_PART_INDICATOR); lv_obj_set_style_arc_width(battery_soc_arc, 14, LV_PART_INDICATOR);
battery_estimate_label = lv_label_create(battery_card);
lv_label_set_text(battery_estimate_label, "");
lv_obj_set_style_text_color(battery_estimate_label, lv_color_hex(0xB8C0C8), 0);
lv_obj_set_width(battery_estimate_label, 320);
lv_obj_set_style_text_align(battery_estimate_label, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_align(battery_estimate_label, LV_ALIGN_TOP_MID, 0, 232);
lv_obj_add_flag(battery_estimate_label, LV_OBJ_FLAG_HIDDEN);
battery_soc_label = lv_label_create(battery_card); battery_soc_label = lv_label_create(battery_card);
lv_label_set_text(battery_soc_label, "--%"); lv_label_set_text(battery_soc_label, "--%");
lv_obj_set_style_text_color(battery_soc_label, lv_color_hex(0xFFFFFF), 0); lv_obj_set_style_text_color(battery_soc_label, lv_color_hex(0xFFFFFF), 0);
lv_obj_set_style_text_font(battery_soc_label, &lv_font_montserrat_48, 0); lv_obj_set_style_text_font(battery_soc_label, &lv_font_montserrat_48, 0);
lv_obj_set_style_text_font( lv_obj_set_style_text_font(battery_soc_label, &lv_font_montserrat_48, 0);
battery_soc_label, lv_obj_set_width(battery_soc_label, 280);
&lv_font_montserrat_30,
0
);
lv_obj_set_width(battery_soc_label, 240);
lv_obj_set_style_text_align(battery_soc_label, LV_TEXT_ALIGN_CENTER, 0); lv_obj_set_style_text_align(battery_soc_label, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_align(battery_soc_label, LV_ALIGN_TOP_MID, 0, 90); lv_obj_align(battery_soc_label, LV_ALIGN_TOP_MID, 0, 90);
battery_voltage_label = lv_label_create(battery_card); battery_voltage_label = lv_label_create(battery_card);
lv_label_set_text(battery_voltage_label, "-- V"); lv_label_set_text(battery_voltage_label, "-- V");
lv_obj_set_style_text_color(battery_voltage_label, lv_color_hex(0xB8C0C8), 0); lv_obj_set_style_text_color(battery_voltage_label, lv_color_hex(0xB8C0C8), 0);
lv_obj_set_style_text_font( lv_obj_set_style_text_font(battery_voltage_label, &lv_font_montserrat_36, 0);
battery_voltage_label, lv_obj_set_width(battery_voltage_label, 280);
&lv_font_montserrat_30,
0
);
lv_obj_set_width(battery_voltage_label, 240);
lv_obj_set_style_text_align(battery_voltage_label, LV_TEXT_ALIGN_CENTER, 0); lv_obj_set_style_text_align(battery_voltage_label, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_align(battery_voltage_label, LV_ALIGN_TOP_MID, 0, 138); lv_obj_align(battery_voltage_label, LV_ALIGN_TOP_MID, 0, 138);
battery_current_label = lv_label_create(battery_card); battery_current_label = lv_label_create(battery_card);
lv_label_set_text(battery_current_label, ""); lv_label_set_text(battery_current_label, "");
lv_obj_set_style_text_font( lv_obj_set_style_text_font(battery_current_label, &lv_font_montserrat_30, 0);
battery_current_label,
&lv_font_montserrat_26,
0
);
lv_obj_set_width(battery_current_label, 260); lv_obj_set_width(battery_current_label, 260);
lv_obj_set_style_text_align(battery_current_label, LV_TEXT_ALIGN_CENTER, 0); lv_obj_set_style_text_align(battery_current_label, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_align(battery_current_label, LV_ALIGN_TOP_MID, 0, 166); lv_obj_align(battery_current_label, LV_ALIGN_TOP_MID, 0, 166);