From c4e362e0acf5715971f52cc3f2a641b5cd44ca36 Mon Sep 17 00:00:00 2001 From: Roman Terekhov Date: Thu, 15 Oct 2026 20:09:38 +0300 Subject: [PATCH] =?UTF-8?q?=D1=87=D0=B0=D1=81=D1=8B=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B2=D0=BE=D0=BC=20=D1=8D=D0=BA=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B5:=20=D0=B2=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D1=8B=20=D0=BD=D0=B0=20T096=20=D0=B8=20V4,=20=D1=80=D0=B0?= =?UTF-8?q?=D1=81=D0=BA=D0=BB=D0=B0=D0=B4=D0=BA=D0=B0=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=20128x64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/companion_radio/ui-new/UITask.cpp | 111 +++++++++++++-------- variants/heltec_t096/platformio.ini | 1 + variants/heltec_v4/platformio.ini | 1 + 3 files changed, 74 insertions(+), 39 deletions(-) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index f3d57ee7..61530587 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -543,52 +543,85 @@ public: if (_page == HomePage::FIRST) { display.setColor(UIColor::primary_txt); - #ifdef ENABLE_WIFI_INTERFACE - // smaller unread message ui for wifi variants - display.setTextSize(1); - sprintf(tmp, "Unread Msg: %d", _task->getMsgCount()); - display.drawTextCentered(display.width() / 2, 22, tmp); - #else - // larger unread message ui for non wifi variants - display.setTextSize(2); - sprintf(tmp, "MSG: %d", _task->getMsgCount()); - display.drawTextCentered(display.width() / 2, 22, tmp); - #endif + + // На узких экранах (128x64 — OLED и T096) раскладка оригинала не помещается: + // там счётчик и признак связи идут одной мелкой строкой, под ней часы и дата. + const bool compact = display.height() < 100; + + if (compact) { + display.setTextSize(1); + sprintf(tmp, "MSG: %d", _task->getMsgCount()); + display.setCursor(0, 19); + display.print(tmp); + if (_task->hasConnection()) { + display.setColor(UIColor::warning_txt); + display.drawTextRightAlign(display.width() - 1, 19, ""); + display.setColor(UIColor::primary_txt); + } else if (the_mesh.getBLEPin() != 0) { // BT pin + display.setColor(UIColor::warning_txt); + sprintf(tmp, "Pin:%d", the_mesh.getBLEPin()); + display.drawTextRightAlign(display.width() - 1, 19, tmp); + display.setColor(UIColor::primary_txt); + } + } else { + #ifdef ENABLE_WIFI_INTERFACE + // smaller unread message ui for wifi variants + display.setTextSize(1); + sprintf(tmp, "Unread Msg: %d", _task->getMsgCount()); + display.drawTextCentered(display.width() / 2, 22, tmp); + #else + // larger unread message ui for non wifi variants + display.setTextSize(2); + sprintf(tmp, "MSG: %d", _task->getMsgCount()); + display.drawTextCentered(display.width() / 2, 22, tmp); + #endif + } + #ifdef UI_SHOW_CLOCK - display.setTextSize(3); - uint32_t now = _rtc->getCurrentTime(); - now += (int32_t)_node_prefs->tz_offset * 3600; - DateTime dt (now); - sprintf(tmp, "%02d:%02d", dt.hour(), dt.minute()); - display.drawTextCentered(display.width() / 2, 60, tmp); - display.setTextSize(1); - sprintf(tmp, "%02d/%02d/%d", dt.day(), dt.month(), dt.year()); - display.drawTextCentered(display.width() / 2, 80, tmp); + { + uint32_t now = _rtc->getCurrentTime(); + now += (int32_t)_node_prefs->tz_offset * 3600; + DateTime dt (now); + display.setTextSize(compact ? 2 : 3); + sprintf(tmp, "%02d:%02d", dt.hour(), dt.minute()); + display.drawTextCentered(display.width() / 2, compact ? 30 : 60, tmp); + display.setTextSize(1); + display.setColor(UIColor::secondary_txt); + sprintf(tmp, "%02d/%02d/%d", dt.day(), dt.month(), dt.year()); + display.drawTextCentered(display.width() / 2, compact ? 46 : 80, tmp); + display.setColor(UIColor::primary_txt); + } #endif + #ifdef ENABLE_WIFI_INTERFACE IPAddress ip = WiFi.localIP(); snprintf(tmp, sizeof(tmp), "IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); display.setTextSize(1); - display.drawTextCentered(display.width() / 2, 32, tmp); + display.setColor(UIColor::secondary_txt); + display.drawTextCentered(display.width() / 2, compact ? 55 : 32, tmp); + display.setColor(UIColor::primary_txt); #endif - if (_task->hasConnection()) { - display.setColor(UIColor::warning_txt); - display.setTextSize(1); - #ifdef UI_SHOW_CLOCK - display.drawTextCentered(display.width() / 2, 110, "< Connected >"); - #else - display.drawTextCentered(display.width() / 2, 43, "< Connected >"); - #endif - } else if (the_mesh.getBLEPin() != 0) { // BT pin - display.setColor(UIColor::warning_txt); - sprintf(tmp, "Pin:%d", the_mesh.getBLEPin()); - #ifdef UI_SHOW_CLOCK - display.setTextSize(1); - display.drawTextCentered(display.width() / 2, 110, tmp); - #else - display.setTextSize(2); - display.drawTextCentered(display.width() / 2, 43, tmp); - #endif + + if (!compact) { + if (_task->hasConnection()) { + display.setColor(UIColor::warning_txt); + display.setTextSize(1); + #ifdef UI_SHOW_CLOCK + display.drawTextCentered(display.width() / 2, 110, "< Connected >"); + #else + display.drawTextCentered(display.width() / 2, 43, "< Connected >"); + #endif + } else if (the_mesh.getBLEPin() != 0) { // BT pin + display.setColor(UIColor::warning_txt); + sprintf(tmp, "Pin:%d", the_mesh.getBLEPin()); + #ifdef UI_SHOW_CLOCK + display.setTextSize(1); + display.drawTextCentered(display.width() / 2, 110, tmp); + #else + display.setTextSize(2); + display.drawTextCentered(display.width() / 2, 43, tmp); + #endif + } } } else if (_page == HomePage::RECENT) { the_mesh.getRecentlyHeard(recent, UI_RECENT_LIST_SIZE); diff --git a/variants/heltec_t096/platformio.ini b/variants/heltec_t096/platformio.ini index 82d691d3..968c59a4 100644 --- a/variants/heltec_t096/platformio.ini +++ b/variants/heltec_t096/platformio.ini @@ -10,6 +10,7 @@ build_flags = ${nrf52_base.build_flags} -I src/helpers/ui -D HELTEC_T096 -D OLED_RU=1 + -D UI_SHOW_CLOCK=1 -D P_LORA_DIO_1=21 -D P_LORA_NSS=5 -D P_LORA_RESET=16 diff --git a/variants/heltec_v4/platformio.ini b/variants/heltec_v4/platformio.ini index 2b20066a..9b12771b 100644 --- a/variants/heltec_v4/platformio.ini +++ b/variants/heltec_v4/platformio.ini @@ -7,6 +7,7 @@ build_flags = -I variants/heltec_v4 -D HELTEC_LORA_V4 -D OLED_RU=1 + -D UI_SHOW_CLOCK=1 -D USE_SX1262 -D ESP32_CPU_FREQ=80 -D RADIO_CLASS=CustomSX1262