dashboard: improve charge glow and initial metadata poll
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
static const char *DASHBOARD_VERSION = "0.1.3-simple-battery-gauge";
|
||||
static const char *DASHBOARD_VERSION = "0.1.4-charge-glow-metadata";
|
||||
|
||||
// Update these if your Cargo ESP AP credentials are different.
|
||||
static const char *CARGO_WIFI_SSID = "OverlandController";
|
||||
|
||||
@@ -37,6 +37,8 @@ static unsigned long last_metadata_poll_ms = 0;
|
||||
|
||||
static bool api_request_in_progress = false;
|
||||
static bool fast_status_refresh_requested = false;
|
||||
static bool metadata_refresh_requested = true;
|
||||
static bool was_wifi_connected = false;
|
||||
|
||||
static bool relay_command_pending = false;
|
||||
static String pending_relay_id;
|
||||
@@ -290,6 +292,18 @@ static void connect_wifi_if_needed()
|
||||
|
||||
static void update_system_status_label()
|
||||
{
|
||||
bool wifi_connected = WiFi.status() == WL_CONNECTED;
|
||||
|
||||
if (wifi_connected && !was_wifi_connected) {
|
||||
was_wifi_connected = true;
|
||||
fast_status_refresh_requested = true;
|
||||
metadata_refresh_requested = true;
|
||||
last_status_poll_ms = 0;
|
||||
last_metadata_poll_ms = 0;
|
||||
} else if (!wifi_connected) {
|
||||
was_wifi_connected = false;
|
||||
}
|
||||
|
||||
if (millis() - last_wifi_label_update_ms < 5000) {
|
||||
return;
|
||||
}
|
||||
@@ -298,7 +312,7 @@ static void update_system_status_label()
|
||||
|
||||
String text;
|
||||
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
if (wifi_connected) {
|
||||
text += "Dashboard WiFi: connected";
|
||||
text += "\nIP: ";
|
||||
text += WiFi.localIP().toString();
|
||||
@@ -495,7 +509,8 @@ static void poll_status_api()
|
||||
fetch_status_fields(CARGO_API_FAST_STATUS_URL, "fast status");
|
||||
}
|
||||
|
||||
if (millis() - last_metadata_poll_ms >= 30000) {
|
||||
if (metadata_refresh_requested || millis() - last_metadata_poll_ms >= 30000) {
|
||||
metadata_refresh_requested = false;
|
||||
last_metadata_poll_ms = millis();
|
||||
fetch_status_fields(CARGO_API_SLOW_STATUS_URL, "slow status");
|
||||
}
|
||||
@@ -538,8 +553,8 @@ static void create_overland_overview_screen()
|
||||
lv_obj_t *system_card = create_card(screen, "System", 620, 175, LV_ALIGN_BOTTOM_LEFT, 32, -50);
|
||||
|
||||
battery_charge_pulse_arc = lv_arc_create(battery_card);
|
||||
lv_obj_set_size(battery_charge_pulse_arc, 180, 180);
|
||||
lv_obj_align(battery_charge_pulse_arc, LV_ALIGN_TOP_MID, 0, 34);
|
||||
lv_obj_set_size(battery_charge_pulse_arc, 190, 190);
|
||||
lv_obj_align(battery_charge_pulse_arc, LV_ALIGN_TOP_MID, 0, 29);
|
||||
lv_arc_set_range(battery_charge_pulse_arc, 0, 100);
|
||||
lv_arc_set_value(battery_charge_pulse_arc, 0);
|
||||
lv_arc_set_rotation(battery_charge_pulse_arc, 135);
|
||||
@@ -548,8 +563,8 @@ static void create_overland_overview_screen()
|
||||
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_color(battery_charge_pulse_arc, lv_color_hex(0x32D583), LV_PART_INDICATOR);
|
||||
lv_obj_set_style_arc_width(battery_charge_pulse_arc, 18, LV_PART_INDICATOR);
|
||||
lv_obj_set_style_arc_opa(battery_charge_pulse_arc, LV_OPA_30, LV_PART_INDICATOR);
|
||||
lv_obj_set_style_arc_width(battery_charge_pulse_arc, 24, LV_PART_INDICATOR);
|
||||
lv_obj_set_style_arc_opa(battery_charge_pulse_arc, LV_OPA_70, LV_PART_INDICATOR);
|
||||
lv_obj_add_flag(battery_charge_pulse_arc, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
battery_soc_arc = lv_arc_create(battery_card);
|
||||
|
||||
Reference in New Issue
Block a user