dashboard: process swipe page switches from loop
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
static const char *DASHBOARD_VERSION = "0.1.91-battery-page-debug";
|
static const char *DASHBOARD_VERSION = "0.1.92-loop-page-switch";
|
||||||
|
|
||||||
// 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";
|
||||||
|
|||||||
@@ -559,28 +559,27 @@ static String signed_float_text(float value, int decimals, const char *suffix)
|
|||||||
|
|
||||||
|
|
||||||
static bool dashboard_page_switch_queued = false;
|
static bool dashboard_page_switch_queued = false;
|
||||||
|
static DashboardScreen dashboard_page_switch_target = SCREEN_OVERVIEW;
|
||||||
static void dashboard_page_switch_async_cb(void *user_data)
|
|
||||||
{
|
|
||||||
DashboardScreen target = (DashboardScreen)(intptr_t)user_data;
|
|
||||||
dashboard_page_switch_queued = false;
|
|
||||||
|
|
||||||
if (target == SCREEN_BATTERY_DETAIL) {
|
|
||||||
Serial.println("DEBUG PAGE: Switching to Battery Detail");
|
|
||||||
} else {
|
|
||||||
Serial.println("DEBUG PAGE: Switching to Overview");
|
|
||||||
}
|
|
||||||
|
|
||||||
show_dashboard_screen(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void queue_dashboard_page_switch(DashboardScreen target)
|
static void queue_dashboard_page_switch(DashboardScreen target)
|
||||||
{
|
{
|
||||||
if (dashboard_page_switch_queued) return;
|
if (dashboard_page_switch_queued) return;
|
||||||
if (target == current_dashboard_screen) return;
|
if (target == current_dashboard_screen) return;
|
||||||
|
|
||||||
|
dashboard_page_switch_target = target;
|
||||||
dashboard_page_switch_queued = true;
|
dashboard_page_switch_queued = true;
|
||||||
lv_async_call(dashboard_page_switch_async_cb, (void *)(intptr_t)target);
|
}
|
||||||
|
|
||||||
|
static void process_dashboard_page_switch()
|
||||||
|
{
|
||||||
|
if (!dashboard_page_switch_queued) return;
|
||||||
|
|
||||||
|
DashboardScreen target = dashboard_page_switch_target;
|
||||||
|
dashboard_page_switch_queued = false;
|
||||||
|
|
||||||
|
lvgl_port_lock(-1);
|
||||||
|
show_dashboard_screen(target);
|
||||||
|
lvgl_port_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dashboard_root_event_cb(lv_event_t *event)
|
static void dashboard_root_event_cb(lv_event_t *event)
|
||||||
@@ -654,7 +653,6 @@ static void update_battery_detail_widgets()
|
|||||||
|
|
||||||
static void create_battery_detail_screen()
|
static void create_battery_detail_screen()
|
||||||
{
|
{
|
||||||
Serial.println("DEBUG PAGE: Entering Battery Detail constructor");
|
|
||||||
lv_obj_t *screen = lv_scr_act();
|
lv_obj_t *screen = lv_scr_act();
|
||||||
lv_obj_clean(screen);
|
lv_obj_clean(screen);
|
||||||
current_dashboard_screen = SCREEN_BATTERY_DETAIL;
|
current_dashboard_screen = SCREEN_BATTERY_DETAIL;
|
||||||
@@ -692,7 +690,6 @@ static void create_battery_detail_screen()
|
|||||||
battery_detail_value_label(screen, "Cell Delta", &battery_detail_delta_label, 356, 504);
|
battery_detail_value_label(screen, "Cell Delta", &battery_detail_delta_label, 356, 504);
|
||||||
|
|
||||||
update_battery_detail_widgets();
|
update_battery_detail_widgets();
|
||||||
Serial.println("DEBUG PAGE: Leaving Battery Detail constructor");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_dashboard_screen(DashboardScreen screen)
|
static void show_dashboard_screen(DashboardScreen screen)
|
||||||
@@ -1830,6 +1827,7 @@ void loop()
|
|||||||
update_system_status_label();
|
update_system_status_label();
|
||||||
process_pending_relay_command();
|
process_pending_relay_command();
|
||||||
poll_status_api();
|
poll_status_api();
|
||||||
|
process_dashboard_page_switch();
|
||||||
|
|
||||||
delay(50);
|
delay(50);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user