From 324502c0e5db131211dcf04997d1a06ab1f4f6a9 Mon Sep 17 00:00:00 2001 From: nick Date: Wed, 10 Jun 2026 01:01:20 -0600 Subject: [PATCH] dashboard: relayout overview with output strip --- .../esp32-s3-dashboard/dashboard_config.h | 2 +- .../esp32-s3-dashboard/esp32-s3-dashboard.ino | 100 ++++++++++++------ 2 files changed, 70 insertions(+), 32 deletions(-) diff --git a/firmware/esp32-s3-dashboard/dashboard_config.h b/firmware/esp32-s3-dashboard/dashboard_config.h index 7d58b6b..d5da551 100644 --- a/firmware/esp32-s3-dashboard/dashboard_config.h +++ b/firmware/esp32-s3-dashboard/dashboard_config.h @@ -1,6 +1,6 @@ #pragma once -static const char *DASHBOARD_VERSION = "0.1.7-main-layout"; +static const char *DASHBOARD_VERSION = "0.1.8-output-strip-layout"; // Update these if your Cargo ESP AP credentials are different. static const char *CARGO_WIFI_SSID = "OverlandController"; diff --git a/firmware/esp32-s3-dashboard/esp32-s3-dashboard.ino b/firmware/esp32-s3-dashboard/esp32-s3-dashboard.ino index 0bcd056..8bd1d80 100644 --- a/firmware/esp32-s3-dashboard/esp32-s3-dashboard.ino +++ b/firmware/esp32-s3-dashboard/esp32-s3-dashboard.ino @@ -30,6 +30,11 @@ static String relay_names[6]; static bool relay_states[6] = {false}; static int relay_count = 0; +static const int RELAY_STRIP_X = 32; +static const int RELAY_STRIP_Y = 438; +static const int RELAY_STRIP_W = 960; +static const int RELAY_BUTTON_GAP = 10; + static unsigned long last_wifi_attempt_ms = 0; static unsigned long last_wifi_label_update_ms = 0; static unsigned long last_status_poll_ms = 0; @@ -161,10 +166,49 @@ static void request_fast_status_refresh() static void create_overland_overview_screen(); static void show_boot_screen(); +static void layout_relay_buttons() +{ + int visible_count = relay_count; + if (visible_count < 1) { + visible_count = 1; + } + + if (visible_count > 6) { + visible_count = 6; + } + + int available_width = RELAY_STRIP_W - 28; + int button_width = (available_width - ((visible_count - 1) * RELAY_BUTTON_GAP)) / visible_count; + + if (button_width < 110) { + button_width = 110; + } + + if (button_width > 210) { + button_width = 210; + } + + int total_width = (button_width * visible_count) + (RELAY_BUTTON_GAP * (visible_count - 1)); + int start_x = (available_width - total_width) / 2; + + for (int i = 0; i < 6; i++) { + if (relay_buttons[i] == nullptr) { + continue; + } + + if (i < relay_count) { + lv_obj_set_size(relay_buttons[i], button_width, 70); + lv_obj_align(relay_buttons[i], LV_ALIGN_TOP_LEFT, start_x + (i * (button_width + RELAY_BUTTON_GAP)), 42); + } + } +} + static void update_relay_buttons() { lvgl_port_lock(-1); + layout_relay_buttons(); + for (int i = 0; i < 6; i++) { if (relay_buttons[i] == nullptr || relay_button_labels[i] == nullptr) { continue; @@ -335,30 +379,25 @@ static void update_system_status_label() String text; if (wifi_connected) { - text += "Dashboard WiFi: connected"; - text += "\nIP: "; + text += "WiFi "; text += WiFi.localIP().toString(); - text += " RSSI: "; + text += " | RSSI "; text += String(WiFi.RSSI()); text += " dBm"; } else { - text += "Dashboard WiFi: connecting"; - text += "\nSSID: "; - text += CARGO_WIFI_SSID; + text += "WiFi connecting"; } - text += "\nCargo: "; + text += " | Cargo "; text += status_model.api_ok ? "online" : "waiting"; - - text += "\nProfile: "; - text += status_model.hardware_profile; - - text += "\nFirmware: "; + text += " | FW "; text += status_model.firmware_version; set_label_text_if_changed(system_status_label, last_system_status_text, text); } + + static void update_overview_widgets() { String voltage_text; @@ -597,14 +636,13 @@ static void create_overland_overview_screen() lv_obj_clean(screen); lv_obj_set_style_bg_color(screen, lv_color_hex(0x101418), 0); - lv_obj_t *battery_card = create_card(screen, "Greta Battery", 300, 350, LV_ALIGN_TOP_LEFT, 32, 24); - lv_obj_t *temp_card = create_card(screen, "Temperatures", 300, 350, LV_ALIGN_TOP_MID, 0, 24); - lv_obj_t *relay_card = create_card(screen, "Outputs", 300, 350, LV_ALIGN_TOP_RIGHT, -32, 24); - lv_obj_t *system_card = create_card(screen, "Status", 620, 145, LV_ALIGN_BOTTOM_LEFT, 32, -38); - lv_obj_t *nav_card = create_card(screen, "Pages", 300, 145, LV_ALIGN_BOTTOM_RIGHT, -32, -38); + lv_obj_t *system_card = create_card(screen, "Status", 960, 72, LV_ALIGN_TOP_MID, 0, 16); + lv_obj_t *battery_card = create_card(screen, "Greta Battery", 300, 330, LV_ALIGN_TOP_LEFT, 32, 104); + lv_obj_t *temp_card = create_card(screen, "Temperatures", 300, 330, LV_ALIGN_TOP_MID, 0, 104); + lv_obj_t *relay_card = create_card(screen, "Outputs", RELAY_STRIP_W, 138, LV_ALIGN_TOP_LEFT, RELAY_STRIP_X, RELAY_STRIP_Y); battery_charge_pulse_arc = lv_arc_create(battery_card); - lv_obj_set_size(battery_charge_pulse_arc, 190, 190); + lv_obj_set_size(battery_charge_pulse_arc, 236, 236); lv_obj_align(battery_charge_pulse_arc, LV_ALIGN_TOP_MID, 0, 42); lv_arc_set_range(battery_charge_pulse_arc, 0, 100); lv_arc_set_value(battery_charge_pulse_arc, 0); @@ -620,7 +658,7 @@ static void create_overland_overview_screen() lv_obj_add_flag(battery_charge_pulse_arc, LV_OBJ_FLAG_HIDDEN); battery_soc_arc = lv_arc_create(battery_card); - lv_obj_set_size(battery_soc_arc, 166, 166); + lv_obj_set_size(battery_soc_arc, 214, 214); lv_obj_align(battery_soc_arc, LV_ALIGN_TOP_MID, 0, 49); lv_arc_set_range(battery_soc_arc, 0, 100); lv_arc_set_value(battery_soc_arc, 0); @@ -638,14 +676,14 @@ static void create_overland_overview_screen() lv_label_set_text(battery_soc_label, "--%"); lv_obj_set_style_text_color(battery_soc_label, lv_color_hex(0xFFFFFF), 0); lv_obj_set_style_text_font(battery_soc_label, &lv_font_montserrat_30, 0); - lv_obj_set_width(battery_soc_label, 190); + lv_obj_set_width(battery_soc_label, 220); lv_obj_set_style_text_align(battery_soc_label, LV_TEXT_ALIGN_CENTER, 0); lv_obj_align(battery_soc_label, LV_ALIGN_TOP_MID, 0, 90); 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(0xB8C0C8), 0); - lv_obj_set_width(battery_voltage_label, 190); + lv_obj_set_width(battery_voltage_label, 220); lv_obj_set_style_text_align(battery_voltage_label, LV_TEXT_ALIGN_CENTER, 0); lv_obj_align(battery_voltage_label, LV_ALIGN_TOP_MID, 0, 138); @@ -672,8 +710,8 @@ static void create_overland_overview_screen() for (int i = 0; i < 6; i++) { relay_buttons[i] = lv_btn_create(relay_card); - lv_obj_set_size(relay_buttons[i], 125, 60); - lv_obj_align(relay_buttons[i], LV_ALIGN_TOP_LEFT, (i % 2) * 140, 40 + ((i / 2) * 68)); + lv_obj_set_size(relay_buttons[i], 140, 70); + lv_obj_align(relay_buttons[i], LV_ALIGN_TOP_LEFT, 14 + (i * 150), 42); lv_obj_add_event_cb( relay_buttons[i], relay_button_event_cb, @@ -691,16 +729,16 @@ static void create_overland_overview_screen() system_status_label = lv_label_create(system_card); lv_label_set_text(system_status_label, "Connecting to Cargo ESP..."); lv_obj_set_style_text_color(system_status_label, lv_color_hex(0xDDE3EA), 0); - lv_obj_set_width(system_status_label, 580); + lv_obj_set_width(system_status_label, 830); lv_label_set_long_mode(system_status_label, LV_LABEL_LONG_WRAP); - lv_obj_align(system_status_label, LV_ALIGN_TOP_LEFT, 0, 35); + lv_obj_align(system_status_label, LV_ALIGN_TOP_LEFT, 0, 32); - lv_obj_t *nav_label = lv_label_create(nav_card); - lv_label_set_text(nav_label, "Overview\nBattery\nTemps\nOutputs\nVehicle"); - lv_obj_set_style_text_color(nav_label, lv_color_hex(0xDDE3EA), 0); - lv_obj_set_width(nav_label, 260); - lv_label_set_long_mode(nav_label, LV_LABEL_LONG_WRAP); - lv_obj_align(nav_label, LV_ALIGN_TOP_LEFT, 0, 35); + lv_obj_t *page_dots = lv_label_create(system_card); + lv_label_set_text(page_dots, "● ○ ○ ○"); + lv_obj_set_style_text_color(page_dots, lv_color_hex(0xB8C0C8), 0); + lv_obj_set_width(page_dots, 110); + lv_obj_set_style_text_align(page_dots, LV_TEXT_ALIGN_RIGHT, 0); + lv_obj_align(page_dots, LV_ALIGN_TOP_RIGHT, 0, 32); } void setup()