dashboard: fix battery widget update function
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#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.
|
// Update these if your Cargo ESP AP credentials are different.
|
||||||
static const char *CARGO_WIFI_SSID = "OverlandController";
|
static const char *CARGO_WIFI_SSID = "OverlandController";
|
||||||
|
|||||||
@@ -461,10 +461,11 @@ static void update_system_status_label()
|
|||||||
|
|
||||||
static void update_overview_widgets()
|
static void update_overview_widgets()
|
||||||
{
|
{
|
||||||
String current_text = "";
|
String current_text = "Idle";
|
||||||
String estimate_text = "";
|
String estimate_text = "";
|
||||||
|
|
||||||
if (status_model.current > 0.05 || status_model.current < -0.05) {
|
if (status_model.current > 0.05 || status_model.current < -0.05) {
|
||||||
|
current_text = "";
|
||||||
current_text += status_model.current > 0 ? "+" : "";
|
current_text += status_model.current > 0 ? "+" : "";
|
||||||
current_text += String(status_model.current, 2);
|
current_text += String(status_model.current, 2);
|
||||||
current_text += " A";
|
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) {
|
} 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));
|
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;
|
String soc_text;
|
||||||
soc_text += status_model.soc >= 0 ? String(status_model.soc) : "--";
|
soc_text += status_model.soc >= 0 ? String(status_model.soc) : "--";
|
||||||
|
|||||||
Reference in New Issue
Block a user