dashboard: make battery arc reflect soc value

This commit is contained in:
2026-06-10 00:22:01 -06:00
parent e99fee91d9
commit fb2f29ec56
2 changed files with 14 additions and 1 deletions
@@ -1,6 +1,6 @@
#pragma once #pragma once
static const char *DASHBOARD_VERSION = "0.1.4-charge-glow-metadata"; static const char *DASHBOARD_VERSION = "0.1.5-soc-arc-value";
// 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";
@@ -108,10 +108,15 @@ static void update_battery_soc_gauge()
int soc = clamp_int(status_model.soc, 0, 100); int soc = clamp_int(status_model.soc, 0, 100);
bool charging = status_model.current > 0.05; bool charging = status_model.current > 0.05;
int end_angle = (soc * 270) / 100;
lvgl_port_lock(-1); lvgl_port_lock(-1);
lv_arc_set_value(battery_soc_arc, soc); lv_arc_set_value(battery_soc_arc, soc);
lv_arc_set_angles(battery_soc_arc, 0, end_angle);
lv_arc_set_value(battery_charge_pulse_arc, soc); lv_arc_set_value(battery_charge_pulse_arc, soc);
lv_arc_set_angles(battery_charge_pulse_arc, 0, end_angle);
if (charging) { if (charging) {
lv_obj_clear_flag(battery_charge_pulse_arc, LV_OBJ_FLAG_HIDDEN); lv_obj_clear_flag(battery_charge_pulse_arc, LV_OBJ_FLAG_HIDDEN);
@@ -120,6 +125,12 @@ static void update_battery_soc_gauge()
} }
lvgl_port_unlock(); lvgl_port_unlock();
Serial.print("Battery SOC arc: ");
Serial.print(soc);
Serial.print("% -> ");
Serial.print(end_angle);
Serial.println(" degrees");
} }
static void update_battery_charge_animation() static void update_battery_charge_animation()
@@ -559,6 +570,7 @@ static void create_overland_overview_screen()
lv_arc_set_value(battery_charge_pulse_arc, 0); lv_arc_set_value(battery_charge_pulse_arc, 0);
lv_arc_set_rotation(battery_charge_pulse_arc, 135); lv_arc_set_rotation(battery_charge_pulse_arc, 135);
lv_arc_set_bg_angles(battery_charge_pulse_arc, 0, 270); lv_arc_set_bg_angles(battery_charge_pulse_arc, 0, 270);
lv_arc_set_angles(battery_charge_pulse_arc, 0, 0);
lv_obj_remove_style(battery_charge_pulse_arc, NULL, LV_PART_KNOB); lv_obj_remove_style(battery_charge_pulse_arc, NULL, LV_PART_KNOB);
lv_obj_clear_flag(battery_charge_pulse_arc, LV_OBJ_FLAG_CLICKABLE); lv_obj_clear_flag(battery_charge_pulse_arc, LV_OBJ_FLAG_CLICKABLE);
lv_obj_set_style_arc_opa(battery_charge_pulse_arc, LV_OPA_TRANSP, LV_PART_MAIN); lv_obj_set_style_arc_opa(battery_charge_pulse_arc, LV_OPA_TRANSP, LV_PART_MAIN);
@@ -574,6 +586,7 @@ static void create_overland_overview_screen()
lv_arc_set_value(battery_soc_arc, 0); lv_arc_set_value(battery_soc_arc, 0);
lv_arc_set_rotation(battery_soc_arc, 135); lv_arc_set_rotation(battery_soc_arc, 135);
lv_arc_set_bg_angles(battery_soc_arc, 0, 270); lv_arc_set_bg_angles(battery_soc_arc, 0, 270);
lv_arc_set_angles(battery_soc_arc, 0, 0);
lv_obj_remove_style(battery_soc_arc, NULL, LV_PART_KNOB); lv_obj_remove_style(battery_soc_arc, NULL, LV_PART_KNOB);
lv_obj_clear_flag(battery_soc_arc, LV_OBJ_FLAG_CLICKABLE); lv_obj_clear_flag(battery_soc_arc, LV_OBJ_FLAG_CLICKABLE);
lv_obj_set_style_arc_color(battery_soc_arc, lv_color_hex(0x3A4652), LV_PART_MAIN); lv_obj_set_style_arc_color(battery_soc_arc, lv_color_hex(0x3A4652), LV_PART_MAIN);