From 3f1c50889db48d3fdaf47f4edc1253c1cc50bc2c Mon Sep 17 00:00:00 2001 From: nick Date: Wed, 10 Jun 2026 01:35:33 -0600 Subject: [PATCH] dashboard: fit cards without scrollbars --- .../esp32-s3-dashboard/dashboard_config.h | 2 +- .../esp32-s3-dashboard/esp32-s3-dashboard.ino | 45 ++++++++++--------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/firmware/esp32-s3-dashboard/dashboard_config.h b/firmware/esp32-s3-dashboard/dashboard_config.h index 43d14f1..24bea27 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.12-wifi-bars"; +static const char *DASHBOARD_VERSION = "0.1.13-fit-cards"; // 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 cc97650..407f35c 100644 --- a/firmware/esp32-s3-dashboard/esp32-s3-dashboard.ino +++ b/firmware/esp32-s3-dashboard/esp32-s3-dashboard.ino @@ -35,7 +35,7 @@ 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_Y = 408; static const int RELAY_STRIP_W = 960; static const int RELAY_BUTTON_GAP = 10; @@ -277,8 +277,8 @@ static void layout_relay_buttons() } 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); + lv_obj_set_size(relay_buttons[i], button_width, 62); + lv_obj_align(relay_buttons[i], LV_ALIGN_TOP_LEFT, start_x + (i * (button_width + RELAY_BUTTON_GAP)), 34); } } } @@ -667,13 +667,18 @@ static lv_obj_t *create_card(lv_obj_t *parent, const char *title, int width, int lv_obj_set_style_bg_color(card, lv_color_hex(0x1F2933), 0); lv_obj_set_style_border_color(card, lv_color_hex(0x3A4652), 0); lv_obj_set_style_border_width(card, 2, 0); - lv_obj_set_style_pad_all(card, 14, 0); + lv_obj_set_style_pad_all(card, 6, 0); + lv_obj_set_scrollbar_mode(card, LV_SCROLLBAR_MODE_OFF); lv_obj_t *title_label = lv_label_create(card); lv_label_set_text(title_label, title); lv_obj_set_style_text_color(title_label, lv_color_hex(0xB8C0C8), 0); lv_obj_align(title_label, LV_ALIGN_TOP_LEFT, 0, 0); + if (title == nullptr || title[0] == '\0') { + lv_obj_add_flag(title_label, LV_OBJ_FLAG_HIDDEN); + } + return card; } @@ -717,14 +722,14 @@ 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 *system_card = create_card(screen, "", 960, 54, LV_ALIGN_TOP_MID, 0, 14); - lv_obj_t *battery_card = create_card(screen, "", 380, 340, LV_ALIGN_TOP_LEFT, 32, 84); - lv_obj_t *temp_card = create_card(screen, "", 260, 340, LV_ALIGN_TOP_LEFT, 426, 84); - lv_obj_t *vehicle_card = create_card(screen, "", 274, 340, LV_ALIGN_TOP_RIGHT, -32, 84); - lv_obj_t *relay_card = create_card(screen, "", RELAY_STRIP_W, 138, LV_ALIGN_TOP_LEFT, RELAY_STRIP_X, RELAY_STRIP_Y); + lv_obj_t *system_card = create_card(screen, "", 960, 48, LV_ALIGN_TOP_MID, 0, 12); + lv_obj_t *battery_card = create_card(screen, "", 380, 310, LV_ALIGN_TOP_LEFT, 32, 76); + lv_obj_t *temp_card = create_card(screen, "", 260, 310, LV_ALIGN_TOP_LEFT, 426, 76); + lv_obj_t *vehicle_card = create_card(screen, "", 274, 310, LV_ALIGN_TOP_RIGHT, -32, 76); + lv_obj_t *relay_card = create_card(screen, "", RELAY_STRIP_W, 126, LV_ALIGN_TOP_LEFT, RELAY_STRIP_X, 408); battery_charge_pulse_arc = lv_arc_create(battery_card); - lv_obj_set_size(battery_charge_pulse_arc, 292, 292); + lv_obj_set_size(battery_charge_pulse_arc, 252, 252); 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); @@ -740,7 +745,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, 266, 266); + lv_obj_set_size(battery_soc_arc, 230, 230); 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); @@ -802,7 +807,7 @@ static void create_overland_overview_screen() lv_obj_set_style_text_color(inside_temp_label, lv_color_hex(0xFFFFFF), 0); lv_obj_set_style_text_font(inside_temp_label, &lv_font_montserrat_40, 0); lv_obj_set_width(inside_temp_label, 260); - lv_obj_align(inside_temp_label, LV_ALIGN_TOP_LEFT, 0, 56); + lv_obj_align(inside_temp_label, LV_ALIGN_TOP_LEFT, 0, 42); outside_temp_label = lv_label_create(temp_card); lv_label_set_text(outside_temp_label, "Outside\n--"); @@ -815,19 +820,19 @@ static void create_overland_overview_screen() lv_obj_set_style_text_color(outside_temp_label, lv_color_hex(0xFFFFFF), 0); lv_obj_set_style_text_font(outside_temp_label, &lv_font_montserrat_40, 0); lv_obj_set_width(outside_temp_label, 260); - lv_obj_align(outside_temp_label, LV_ALIGN_TOP_LEFT, 0, 190); + lv_obj_align(outside_temp_label, LV_ALIGN_TOP_LEFT, 0, 172); lv_obj_t *vehicle_label = lv_label_create(vehicle_card); lv_label_set_text(vehicle_label, "Vehicle\n\nOffline\n\nFuture:\nCoolant\nTrans Temp\n4WD\nTilt/Roll"); lv_obj_set_style_text_color(vehicle_label, lv_color_hex(0xDDE3EA), 0); - lv_obj_set_width(vehicle_label, 230); + lv_obj_set_width(vehicle_label, 220); lv_label_set_long_mode(vehicle_label, LV_LABEL_LONG_WRAP); lv_obj_align(vehicle_label, LV_ALIGN_CENTER, 0, 0); for (int i = 0; i < 6; i++) { relay_buttons[i] = lv_btn_create(relay_card); - 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_set_size(relay_buttons[i], 140, 62); + lv_obj_align(relay_buttons[i], LV_ALIGN_TOP_LEFT, 14 + (i * 150), 34); lv_obj_add_event_cb( relay_buttons[i], relay_button_event_cb, @@ -848,19 +853,19 @@ static void create_overland_overview_screen() for (int i = 0; i < 4; i++) { wifi_bars_obj[i] = lv_obj_create(system_card); - lv_obj_set_size(wifi_bars_obj[i], 12, 14 + (i * 8)); + lv_obj_set_size(wifi_bars_obj[i], 10, 10 + (i * 7)); lv_obj_set_style_radius(wifi_bars_obj[i], 2, 0); lv_obj_set_style_border_width(wifi_bars_obj[i], 0, 0); lv_obj_set_style_bg_color(wifi_bars_obj[i], lv_color_hex(0x3A4652), 0); - lv_obj_align(wifi_bars_obj[i], LV_ALIGN_LEFT_MID, 12 + (i * 18), 12 - (i * 4)); + lv_obj_align(wifi_bars_obj[i], LV_ALIGN_LEFT_MID, 12 + (i * 16), 10 - (i * 4)); } cargo_status_dot = lv_obj_create(system_card); - lv_obj_set_size(cargo_status_dot, 22, 22); + lv_obj_set_size(cargo_status_dot, 18, 18); lv_obj_set_style_radius(cargo_status_dot, LV_RADIUS_CIRCLE, 0); lv_obj_set_style_bg_color(cargo_status_dot, lv_color_hex(0xF97066), 0); lv_obj_set_style_border_width(cargo_status_dot, 0, 0); - lv_obj_align(cargo_status_dot, LV_ALIGN_LEFT_MID, 100, 0); + lv_obj_align(cargo_status_dot, LV_ALIGN_LEFT_MID, 98, 0); system_status_label = lv_label_create(system_card); lv_label_set_text(system_status_label, "");