dashboard: improve battery overview card
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#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.
|
// Update these if your Cargo ESP AP credentials are different.
|
||||||
static const char *CARGO_WIFI_SSID = "OverlandController";
|
static const char *CARGO_WIFI_SSID = "OverlandController";
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ using namespace esp_panel::board;
|
|||||||
static DashboardStatus status_model;
|
static DashboardStatus status_model;
|
||||||
|
|
||||||
static lv_obj_t *soc_value_label = nullptr;
|
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 *inside_temp_label = nullptr;
|
||||||
static lv_obj_t *outside_temp_label = nullptr;
|
static lv_obj_t *outside_temp_label = nullptr;
|
||||||
static lv_obj_t *system_status_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 bool pending_relay_previous_state = false;
|
||||||
|
|
||||||
static String last_soc_text;
|
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_inside_temp_text;
|
||||||
static String last_outside_temp_text;
|
static String last_outside_temp_text;
|
||||||
static String last_system_status_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 += status_model.soc >= 0 ? String(status_model.soc) : "--";
|
||||||
soc_text += "%";
|
soc_text += "%";
|
||||||
|
|
||||||
String battery_detail;
|
String voltage_text;
|
||||||
battery_detail += String(status_model.voltage, 2);
|
voltage_text += String(status_model.voltage, 2);
|
||||||
battery_detail += " V\n";
|
voltage_text += " V";
|
||||||
battery_detail += String(status_model.current, 2);
|
|
||||||
battery_detail += " A\n";
|
String current_text;
|
||||||
battery_detail += String(status_model.remaining_ah, 1);
|
current_text += String(status_model.current, 2);
|
||||||
battery_detail += " / ";
|
current_text += " A";
|
||||||
battery_detail += String(status_model.capacity_ah, 0);
|
|
||||||
battery_detail += " Ah\n";
|
String capacity_text;
|
||||||
battery_detail += String(status_model.battery_temp_f, 1);
|
capacity_text += String(status_model.remaining_ah, 1);
|
||||||
battery_detail += " F battery\nBMS ";
|
capacity_text += " / ";
|
||||||
battery_detail += status_model.bms_connected ? "online" : "offline";
|
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) {
|
if (status_model.cell_delta_mv >= 0) {
|
||||||
battery_detail += "\nCell delta ";
|
health_text += "\nCell delta ";
|
||||||
battery_detail += String(status_model.cell_delta_mv);
|
health_text += String(status_model.cell_delta_mv);
|
||||||
battery_detail += " mV";
|
health_text += " mV";
|
||||||
}
|
}
|
||||||
|
|
||||||
set_label_text_if_changed(soc_value_label, last_soc_text, soc_text);
|
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);
|
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_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_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_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_obj_t *soc_caption = lv_label_create(battery_card);
|
||||||
lv_label_set_text(battery_detail_label, "Waiting for battery data...");
|
lv_label_set_text(soc_caption, "STATE OF CHARGE");
|
||||||
lv_obj_set_style_text_color(battery_detail_label, lv_color_hex(0xDDE3EA), 0);
|
lv_obj_set_style_text_color(soc_caption, lv_color_hex(0x7D8996), 0);
|
||||||
lv_obj_set_width(battery_detail_label, 260);
|
lv_obj_align(soc_caption, LV_ALIGN_TOP_LEFT, 0, 82);
|
||||||
lv_label_set_long_mode(battery_detail_label, LV_LABEL_LONG_WRAP);
|
|
||||||
lv_obj_align(battery_detail_label, LV_ALIGN_TOP_LEFT, 0, 95);
|
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);
|
inside_temp_label = lv_label_create(temp_card);
|
||||||
lv_label_set_text(inside_temp_label, "Inside\n--");
|
lv_label_set_text(inside_temp_label, "Inside\n--");
|
||||||
|
|||||||
Reference in New Issue
Block a user