dashboard: add battery card double tap navigation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
static const char *DASHBOARD_VERSION = "0.1.104-no-overview-rebuild-on-back";
|
||||
static const char *DASHBOARD_VERSION = "0.1.105-battery-card-doubletap";
|
||||
|
||||
// Update these if your Cargo ESP AP credentials are different.
|
||||
//static const char *CARGO_WIFI_SSID = "OverlandController";
|
||||
|
||||
@@ -764,6 +764,43 @@ static void show_dashboard_screen(DashboardScreen screen)
|
||||
}
|
||||
|
||||
|
||||
static void battery_card_doubletap_event_cb(lv_event_t *event)
|
||||
{
|
||||
if (lv_event_get_code(event) != LV_EVENT_SHORT_CLICKED) return;
|
||||
|
||||
static uint32_t last_tap_ms = 0;
|
||||
uint32_t now_ms = millis();
|
||||
|
||||
if (now_ms - last_tap_ms <= 550) {
|
||||
last_tap_ms = 0;
|
||||
Serial.println("NAV: Battery card double tap");
|
||||
queue_dashboard_page_switch(SCREEN_BATTERY_DETAIL);
|
||||
return;
|
||||
}
|
||||
|
||||
last_tap_ms = now_ms;
|
||||
}
|
||||
|
||||
static void add_battery_card_doubletap_hitbox(lv_obj_t *screen)
|
||||
{
|
||||
lv_obj_t *hitbox = lv_obj_create(screen);
|
||||
lv_obj_set_size(hitbox, 380, 310);
|
||||
lv_obj_align(hitbox, LV_ALIGN_TOP_LEFT, 32, 68);
|
||||
lv_obj_set_style_bg_opa(hitbox, LV_OPA_TRANSP, 0);
|
||||
lv_obj_set_style_border_opa(hitbox, LV_OPA_TRANSP, 0);
|
||||
lv_obj_set_style_pad_all(hitbox, 0, 0);
|
||||
lv_obj_clear_flag(hitbox, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_add_flag(hitbox, LV_OBJ_FLAG_CLICKABLE);
|
||||
|
||||
lv_obj_add_event_cb(hitbox, battery_card_doubletap_event_cb, LV_EVENT_SHORT_CLICKED, nullptr);
|
||||
|
||||
// Keep swipe navigation working even over the battery card.
|
||||
lv_obj_add_event_cb(hitbox, dashboard_root_event_cb, LV_EVENT_GESTURE, nullptr);
|
||||
|
||||
lv_obj_move_foreground(hitbox);
|
||||
}
|
||||
|
||||
|
||||
static void layout_relay_buttons()
|
||||
{
|
||||
int visible_count = relay_count;
|
||||
|
||||
Reference in New Issue
Block a user