From d34798f2ca3ce4979a32d152857144571fbc63f3 Mon Sep 17 00:00:00 2001 From: nick Date: Wed, 10 Jun 2026 01:28:48 -0600 Subject: [PATCH] dashboard: draw wifi signal bars --- .../esp32-s3-dashboard/dashboard_config.h | 2 +- .../esp32-s3-dashboard/esp32-s3-dashboard.ino | 44 ++++++++++++++----- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/firmware/esp32-s3-dashboard/dashboard_config.h b/firmware/esp32-s3-dashboard/dashboard_config.h index 4c83227..43d14f1 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.11-main-ui-pass"; +static const char *DASHBOARD_VERSION = "0.1.12-wifi-bars"; // 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 77f1931..cc97650 100644 --- a/firmware/esp32-s3-dashboard/esp32-s3-dashboard.ino +++ b/firmware/esp32-s3-dashboard/esp32-s3-dashboard.ino @@ -24,6 +24,7 @@ static lv_obj_t *inside_temp_label = nullptr; static lv_obj_t *outside_temp_label = nullptr; static lv_obj_t *system_status_label = nullptr; static lv_obj_t *wifi_icon_label = nullptr; +static lv_obj_t *wifi_bars_obj[4] = {nullptr}; static lv_obj_t *cargo_status_dot = nullptr; static lv_obj_t *relay_buttons[6] = {nullptr}; static lv_obj_t *relay_button_labels[6] = {nullptr}; @@ -89,27 +90,27 @@ static String format_hours(float hours) return text; } -static String wifi_bars() +static int wifi_bar_count() { if (WiFi.status() != WL_CONNECTED) { - return "□□□□"; + return 0; } int rssi = WiFi.RSSI(); if (rssi > -60) { - return "■■■■"; + return 4; } if (rssi > -70) { - return "■■■□"; + return 3; } if (rssi > -80) { - return "■■□□"; + return 2; } - return "■□□□"; + return 1; } static void update_status_icons() @@ -120,7 +121,19 @@ static void update_status_icons() lvgl_port_lock(-1); - lv_label_set_text(wifi_icon_label, wifi_bars().c_str()); + int bars = wifi_bar_count(); + + for (int i = 0; i < 4; i++) { + if (wifi_bars_obj[i] == nullptr) { + continue; + } + + lv_obj_set_style_bg_color( + wifi_bars_obj[i], + i < bars ? lv_color_hex(0xDDE3EA) : lv_color_hex(0x3A4652), + 0 + ); + } lv_obj_set_style_bg_color( cargo_status_dot, @@ -830,17 +843,24 @@ static void create_overland_overview_screen() } wifi_icon_label = lv_label_create(system_card); - lv_label_set_text(wifi_icon_label, "□□□□"); - lv_obj_set_style_text_color(wifi_icon_label, lv_color_hex(0xDDE3EA), 0); - lv_obj_set_style_text_font(wifi_icon_label, &lv_font_montserrat_30, 0); - lv_obj_align(wifi_icon_label, LV_ALIGN_LEFT_MID, 10, 0); + lv_label_set_text(wifi_icon_label, ""); + lv_obj_add_flag(wifi_icon_label, LV_OBJ_FLAG_HIDDEN); + + 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_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)); + } cargo_status_dot = lv_obj_create(system_card); lv_obj_set_size(cargo_status_dot, 22, 22); 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, 118, 0); + lv_obj_align(cargo_status_dot, LV_ALIGN_LEFT_MID, 100, 0); system_status_label = lv_label_create(system_card); lv_label_set_text(system_status_label, "");