From d9a851f89cfbe20dd37adc5dc96617cc7d6f3e6b Mon Sep 17 00:00:00 2001 From: Kaj Schittecat Date: Thu, 15 Oct 2026 15:48:38 +0200 Subject: [PATCH] fix(repeater,room): build again with the one-palette display API The repeater and room-server envs with a display stopped compiling at the 1.17 merge: meshcomod's extended UIs still used DisplayDriver::LIGHT/GREEN/ RED/... after upstream replaced that enum with UIColor roles (b8504e55). - Port both UIs to the roles the companion OLED UI uses for the same pages: titles corp_blue, content primary_txt, problems warning_txt, the alert overlay popup_bkg/popup_txt, the OTA bar background window_bkg. - repeater_tcp: pass the board to UITask, whose constructor gained it upstream in 2efb3af6 (poweroff on long press). - esp32_base also compiles SdNvsPrefs.cpp. It compiled WifiRuntimeStore.cpp for every ESP32 env, but that store has used SdNvsPrefs since beta_17, so envs without helpers/esp32/*.cpp (repeater_tcp) failed to link. build_as_lib.py already drops it for wadamesh's vendored build. - Room server UITask::begin: drop the version-string block the 1.17 merge appended after ours. It redeclared `version` on boards without a user button and overwrote the multitransport version string elsewhere. Co-Authored-By: Claude Opus 5.5 --- examples/repeater_tcp/main.cpp | 2 +- examples/simple_repeater/UITask.cpp | 68 ++++++++++---------- examples/simple_room_server/UITask.cpp | 86 +++++++++++--------------- platformio.ini | 1 + 4 files changed, 73 insertions(+), 84 deletions(-) diff --git a/examples/repeater_tcp/main.cpp b/examples/repeater_tcp/main.cpp index ccff32bd9..346ab94d8 100644 --- a/examples/repeater_tcp/main.cpp +++ b/examples/repeater_tcp/main.cpp @@ -25,7 +25,7 @@ extern "C" void set_boot_phase(int phase) { #ifdef DISPLAY_CLASS #include "UITask.h" -static UITask ui_task(display); +static UITask ui_task(board, display); #endif #ifndef TCP_PORT diff --git a/examples/simple_repeater/UITask.cpp b/examples/simple_repeater/UITask.cpp index 6723651a1..72ddde0df 100644 --- a/examples/simple_repeater/UITask.cpp +++ b/examples/simple_repeater/UITask.cpp @@ -90,7 +90,7 @@ static void render_repeater_tcp_boot_splash(DisplayDriver &display) { char ver_info[12]; repeater_tcp_splash_version_buf(ver_info, FIRMWARE_VERSION); - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.setTextSize(2); display.drawTextCentered(display.width() / 2, 4, "meshcomod"); @@ -105,11 +105,11 @@ static void render_repeater_tcp_home(DisplayDriver &display, NodePrefs *prefs) { char tmp[80]; display.setCursor(0, 0); display.setTextSize(1); - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); display.print(prefs->node_name); display.setCursor(0, 20); - display.setColor(DisplayDriver::YELLOW); + display.setColor(UIColor::warning_txt); sprintf(tmp, "FREQ: %06.3f SF%d", prefs->freq, prefs->sf); display.print(tmp); @@ -120,17 +120,17 @@ static void render_repeater_tcp_home(DisplayDriver &display, NodePrefs *prefs) { static void render_repeater_tcp_network(DisplayDriver &display) { char tmp[80]; - display.setColor(DisplayDriver::BLUE); + display.setColor(UIColor::corp_blue); display.setTextSize(1); int y = 10; display.drawTextCentered(display.width() / 2, y, "Network"); y += 12; if (!repeater_transport_enabled) { - display.setColor(DisplayDriver::RED); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, y, "TCP/WS off"); y = 64 - 11; - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, y, "ON: long press"); return; } @@ -145,24 +145,24 @@ static void render_repeater_tcp_network(DisplayDriver &display) { if (WiFi.status() == WL_CONNECTED) { IPAddress ip = WiFi.localIP(); if (ip[0] != 0 || ip[1] != 0 || ip[2] != 0 || ip[3] != 0) { - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); snprintf(tmp, sizeof(tmp), "IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); display.drawTextCentered(display.width() / 2, y, tmp); y += 10; snprintf(tmp, sizeof(tmp), "TCP:%d WS:%d", (int)TCP_PORT, (int)WS_PORT); display.drawTextCentered(display.width() / 2, y, tmp); y += 10; - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); snprintf(tmp, sizeof(tmp), "%.32s", WiFi.SSID().c_str()); display.drawTextCentered(display.width() / 2, y, tmp); } else { - display.setColor(DisplayDriver::RED); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, y, "WiFi connecting..."); } } else { String ssid = WiFi.SSID(); wl_status_t ws = WiFi.status(); - display.setColor(DisplayDriver::RED); + display.setColor(UIColor::warning_txt); if (!have_runtime && !compile_cred) { display.drawTextCentered(display.width() / 2, y, "WiFi not configured"); } else if (ssid.length() == 0 || ws == WL_NO_SSID_AVAIL) { @@ -175,63 +175,63 @@ static void render_repeater_tcp_network(DisplayDriver &display) { } y = 64 - 11; - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, y, "off: long press"); } static void render_repeater_tcp_ws(DisplayDriver &display) { char tmp[80]; - display.setColor(DisplayDriver::BLUE); + display.setColor(UIColor::corp_blue); display.setTextSize(1); int y = 10; display.drawTextCentered(display.width() / 2, y, "WebSocket (WS)"); y += 12; if (!repeater_transport_enabled) { - display.setColor(DisplayDriver::RED); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, y, "Off with TCP"); y += 11; - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, y, "ON: Network page"); y = 64 - 11; display.drawTextCentered(display.width() / 2, y, "long press there"); return; } - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); snprintf(tmp, sizeof(tmp), "Port %d", (int)WS_PORT); display.drawTextCentered(display.width() / 2, y, tmp); y += 11; if (WiFi.status() != WL_CONNECTED) { - display.setColor(DisplayDriver::YELLOW); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, y, "Waiting WiFi"); y += 11; - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, y, "WS off until IP"); return; } IPAddress ip = WiFi.localIP(); if (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0) { - display.setColor(DisplayDriver::YELLOW); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, y, "Waiting IP..."); return; } - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); snprintf(tmp, sizeof(tmp), "ws://%d.%d.%d.%d:%d", ip[0], ip[1], ip[2], ip[3], (int)WS_PORT); display.drawTextCentered(display.width() / 2, y, tmp); y = 64 - 11; - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, y, "mirrors TCP on/off"); } static void render_repeater_tcp_advert(DisplayDriver &display) { - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); display.setTextSize(1); display.drawTextCentered(display.width() / 2, 20, "Flood advert"); - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, 34, "long press: send"); display.drawTextCentered(display.width() / 2, 48, "click: next page"); } @@ -239,7 +239,7 @@ static void render_repeater_tcp_advert(DisplayDriver &display) { // Keep this page byte-for-byte aligned with companion `ui-new` Resources tab. static void render_repeater_tcp_resources(DisplayDriver &display) { char tmp[80]; - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.setTextSize(1); int y = 20; snprintf(tmp, sizeof(tmp), "CPU %u MHz", (unsigned)ESP.getCpuFreqMHz()); @@ -298,26 +298,26 @@ static void draw_page_dots(DisplayDriver &display) { static void render_http_ota_screen(DisplayDriver &display) { display.setTextSize(1); - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, 6, "WiFi OTA"); - display.setColor(DisplayDriver::YELLOW); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, 20, g_meshcore_http_ota_display_line); int bw = display.width() - 8; int bx = 4; int by = 34; - display.setColor(DisplayDriver::DARK); + display.setColor(UIColor::window_bkg); display.fillRect(bx, by, bw, 10); - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawRect(bx, by, bw, 10); int pct = (int)(unsigned)g_meshcore_http_ota_display_pct; if (pct >= 0 && pct <= 100) { int fill = (bw - 2) * pct / 100; if (fill > 0) { - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); display.fillRect(bx + 1, by + 1, fill, 8); } } else { - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); int seg = (bw - 2) / 4; if (seg > 2) { uint32_t t = millis() / 400; @@ -325,7 +325,7 @@ static void render_http_ota_screen(DisplayDriver &display) { display.fillRect(bx + 1 + phase * seg, by + 2, seg - 2, 6); } } - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, 50, "do not power off"); } @@ -421,9 +421,9 @@ void UITask::renderCurrScreen() { int y = _display->height() / 3; int p = _display->height() / 32; _display->setTextSize(1); - _display->setColor(DisplayDriver::DARK); + _display->setColor(UIColor::popup_bkg); _display->fillRect(p, y, _display->width() - p * 2, y); - _display->setColor(DisplayDriver::LIGHT); + _display->setColor(UIColor::popup_txt); _display->drawRect(p, y, _display->width() - p * 2, y); _display->drawTextCentered(_display->width() / 2, y + p * 3, s_alert); } @@ -431,11 +431,11 @@ void UITask::renderCurrScreen() { #endif char tmp[80]; if (millis() < BOOT_SCREEN_MILLIS) { - _display->setColor(DisplayDriver::BLUE); + _display->setColor(UIColor::corp_blue); int logoWidth = 128; _display->drawXbm((_display->width() - logoWidth) / 2, 3, meshcore_logo, logoWidth, 13); - _display->setColor(DisplayDriver::LIGHT); + _display->setColor(UIColor::primary_txt); _display->setTextSize(1); uint16_t versionWidth = _display->getTextWidth(_version_info); _display->setCursor((_display->width() - versionWidth) / 2, 22); diff --git a/examples/simple_room_server/UITask.cpp b/examples/simple_room_server/UITask.cpp index 0591ac0fb..5613d493c 100644 --- a/examples/simple_room_server/UITask.cpp +++ b/examples/simple_room_server/UITask.cpp @@ -89,7 +89,7 @@ static void render_room_mt_boot_splash(DisplayDriver &display) { char ver_info[12]; room_mt_splash_version_buf(ver_info, FIRMWARE_VERSION); - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.setTextSize(2); display.drawTextCentered(display.width() / 2, 4, "meshcomod"); @@ -104,11 +104,11 @@ static void render_room_mt_radio(DisplayDriver &display, NodePrefs *prefs) { char tmp[80]; display.setCursor(0, 0); display.setTextSize(1); - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); display.print(prefs->node_name); display.setCursor(0, 20); - display.setColor(DisplayDriver::YELLOW); + display.setColor(UIColor::warning_txt); snprintf(tmp, sizeof(tmp), "FREQ: %06.3f SF%d", prefs->freq, prefs->sf); display.print(tmp); @@ -121,24 +121,24 @@ static void render_room_mt_network(DisplayDriver &display) { char tmp[80]; const int foot_y = display.height() - 11; - display.setColor(DisplayDriver::BLUE); + display.setColor(UIColor::corp_blue); display.setTextSize(1); int y = 10; display.drawTextCentered(display.width() / 2, y, "Network (TCP)"); y += 12; if (!wifiConfigGetRadioEnabled()) { - display.setColor(DisplayDriver::RED); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, y, "WiFi radio off"); - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, foot_y, "USB: set wifi.radio 1"); return; } if (!serial_interface.isTcpEnabled()) { - display.setColor(DisplayDriver::RED); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, y, "TCP/WS off"); - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, foot_y, "ON: long press"); return; } @@ -153,24 +153,24 @@ static void render_room_mt_network(DisplayDriver &display) { if (WiFi.status() == WL_CONNECTED) { IPAddress ip = WiFi.localIP(); if (ip[0] != 0 || ip[1] != 0 || ip[2] != 0 || ip[3] != 0) { - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); snprintf(tmp, sizeof(tmp), "IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); display.drawTextCentered(display.width() / 2, y, tmp); y += 10; snprintf(tmp, sizeof(tmp), "TCP:%d WS:%d", (int)TCP_PORT, (int)WS_PORT); display.drawTextCentered(display.width() / 2, y, tmp); y += 10; - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); snprintf(tmp, sizeof(tmp), "%.32s", WiFi.SSID().c_str()); display.drawTextCentered(display.width() / 2, y, tmp); } else { - display.setColor(DisplayDriver::RED); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, y, "WiFi connecting..."); } } else { String ssid = WiFi.SSID(); wl_status_t ws = WiFi.status(); - display.setColor(DisplayDriver::RED); + display.setColor(UIColor::warning_txt); if (!have_runtime && !compile_cred) { display.drawTextCentered(display.width() / 2, y, "WiFi not configured"); } else if (ssid.length() == 0 || ws == WL_NO_SSID_AVAIL) { @@ -182,7 +182,7 @@ static void render_room_mt_network(DisplayDriver &display) { display.drawTextCentered(display.width() / 2, y, "IP: 0.0.0.0"); } - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, foot_y, "off: long press"); } @@ -190,7 +190,7 @@ static void render_room_mt_ble(DisplayDriver &display) { char tmp[80]; const int foot_y = display.height() - 11; - display.setColor(DisplayDriver::BLUE); + display.setColor(UIColor::corp_blue); display.setTextSize(1); int y = 10; display.drawTextCentered(display.width() / 2, y, "Bluetooth (BLE)"); @@ -199,7 +199,7 @@ static void render_room_mt_ble(DisplayDriver &display) { #ifdef BLE_PIN_CODE if (serial_interface.hasBleCapability()) { if (serial_interface.isBleEnabled()) { - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); snprintf(tmp, sizeof(tmp), "Pin: %lu", (unsigned long)(uint32_t)BLE_PIN_CODE); display.drawTextCentered(display.width() / 2, y, tmp); y += 11; @@ -213,19 +213,19 @@ static void render_room_mt_ble(DisplayDriver &display) { display.drawTextCentered(display.width() / 2, y, "Waiting for device"); } } else { - display.setColor(DisplayDriver::RED); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, y, "BLE disabled"); } } else { - display.setColor(DisplayDriver::RED); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, y, "BLE n/a"); } #else - display.setColor(DisplayDriver::RED); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, y, "BLE n/a"); #endif - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); #ifdef BLE_PIN_CODE if (serial_interface.hasBleCapability()) { display.drawTextCentered(display.width() / 2, foot_y, @@ -238,30 +238,30 @@ static void render_room_mt_ws(DisplayDriver &display) { char tmp[80]; const int foot_y = display.height() - 11; - display.setColor(DisplayDriver::BLUE); + display.setColor(UIColor::corp_blue); display.setTextSize(1); int y = 10; display.drawTextCentered(display.width() / 2, y, "WebSocket (WS)"); y += 12; if (!serial_interface.isTcpEnabled()) { - display.setColor(DisplayDriver::RED); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, y, "Off with TCP"); - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, foot_y, "ON: Network page"); return; } - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); snprintf(tmp, sizeof(tmp), "Port %d", (int)WS_PORT); display.drawTextCentered(display.width() / 2, y, tmp); y += 11; if (WiFi.status() != WL_CONNECTED) { - display.setColor(DisplayDriver::YELLOW); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, y, "Waiting WiFi"); y += 11; - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, y, "WS off until IP"); display.drawTextCentered(display.width() / 2, foot_y, "mirrors TCP on/off"); return; @@ -269,15 +269,15 @@ static void render_room_mt_ws(DisplayDriver &display) { IPAddress ip = WiFi.localIP(); if (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0) { - display.setColor(DisplayDriver::YELLOW); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, y, "Waiting IP..."); return; } - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); snprintf(tmp, sizeof(tmp), "ws://%d.%d.%d.%d:%d", ip[0], ip[1], ip[2], ip[3], (int)WS_PORT); display.drawTextCentered(display.width() / 2, y, tmp); - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, foot_y, "mirrors TCP on/off"); } @@ -296,26 +296,26 @@ static void draw_room_page_dots(DisplayDriver &display) { static void render_room_http_ota_screen(DisplayDriver &display) { display.setTextSize(1); - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, 6, "WiFi OTA"); - display.setColor(DisplayDriver::YELLOW); + display.setColor(UIColor::warning_txt); display.drawTextCentered(display.width() / 2, 20, g_meshcore_http_ota_display_line); int bw = display.width() - 8; int bx = 4; int by = 34; - display.setColor(DisplayDriver::DARK); + display.setColor(UIColor::window_bkg); display.fillRect(bx, by, bw, 10); - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawRect(bx, by, bw, 10); int pct = (int)(unsigned)g_meshcore_http_ota_display_pct; if (pct >= 0 && pct <= 100) { int fill = (bw - 2) * pct / 100; if (fill > 0) { - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); display.fillRect(bx + 1, by + 1, fill, 8); } } else { - display.setColor(DisplayDriver::GREEN); + display.setColor(UIColor::primary_txt); int seg = (bw - 2) / 4; if (seg > 2) { uint32_t t = millis() / 400; @@ -323,7 +323,7 @@ static void render_room_http_ota_screen(DisplayDriver &display) { display.fillRect(bx + 1 + phase * seg, by + 2, seg - 2, 6); } } - display.setColor(DisplayDriver::LIGHT); + display.setColor(UIColor::primary_txt); display.drawTextCentered(display.width() / 2, 50, "do not power off"); } @@ -382,18 +382,6 @@ void UITask::begin(NodePrefs* node_prefs, const char* build_date, const char* fi _auto_off = millis() + AUTO_OFF_MILLIS; _node_prefs = node_prefs; _display->turnOn(); - - // strip off dash and commit hash by changing dash to null terminator - // e.g: v1.2.3-abcdef -> v1.2.3 - char *version = strdup(firmware_version); - char *dash = strchr(version, '-'); - if(dash){ - *dash = 0; - } - - // v1.2.3 (1 Jan 2025) - snprintf(_version_info, sizeof(_version_info), "%s (%s)", version, build_date); - free(version); } void UITask::renderCurrScreen() { @@ -423,9 +411,9 @@ void UITask::renderCurrScreen() { int p = _display->height() / 32; if (p < 2) p = 2; _display->setTextSize(1); - _display->setColor(DisplayDriver::DARK); + _display->setColor(UIColor::popup_bkg); _display->fillRect(p, y, _display->width() - p * 2, y); - _display->setColor(DisplayDriver::LIGHT); + _display->setColor(UIColor::popup_txt); _display->drawRect(p, y, _display->width() - p * 2, y); _display->drawTextCentered(_display->width() / 2, y + p * 3, s_room_alert); } diff --git a/platformio.ini b/platformio.ini index ab49561ef..5e5805bcd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -71,6 +71,7 @@ build_flags = ${arduino_base.build_flags} ; -D ESP32_CPU_FREQ=80 ; change it to your need build_src_filter = ${arduino_base.build_src_filter} + + + ; WifiRuntimeStore's backend (NVS, or SD under Launcher) [esp32_ota] lib_deps =