From a38418e09a450d9564db82b614285406c45c83eb Mon Sep 17 00:00:00 2001 From: Matthias Wientapper Date: Wed, 22 Oct 2025 20:01:15 +0200 Subject: [PATCH 1/2] * Add display of IP address to companion screen --- examples/companion_radio/ui-new/UITask.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 7c75a0892..38c09781e 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -2,6 +2,8 @@ #include #include "../MyMesh.h" #include "target.h" +#include + #ifndef AUTO_OFF_MILLIS #define AUTO_OFF_MILLIS 15000 // 15 seconds @@ -129,6 +131,8 @@ class HomeScreen : public UIScreen { bool sensors_scroll = false; int sensors_scroll_offset = 0; int next_sensors_refresh = 0; + + char ipStr[20]; void refresh_sensors() { if (millis() > next_sensors_refresh) { @@ -192,10 +196,17 @@ class HomeScreen : public UIScreen { sprintf(tmp, "MSG: %d", _task->getMsgCount()); display.drawTextCentered(display.width() / 2, 20, tmp); + #ifdef WIFI_SSID + IPAddress ip = WiFi.localIP(); + snprintf(ipStr, sizeof(ipStr), "IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); + display.setTextSize(1); + display.drawTextCentered(display.width() / 2, 54, ipStr); + #endif if (_task->hasConnection()) { display.setColor(DisplayDriver::GREEN); display.setTextSize(1); display.drawTextCentered(display.width() / 2, 43, "< Connected >"); + } else if (the_mesh.getBLEPin() != 0) { // BT pin display.setColor(DisplayDriver::RED); display.setTextSize(2); From f339c74bb489e2394583f427642c21dbae3b5625 Mon Sep 17 00:00:00 2001 From: Matthias Wientapper Date: Mon, 27 Oct 2025 17:58:29 +0100 Subject: [PATCH 2/2] * Add #ifdef, reuse variable --- examples/companion_radio/ui-new/UITask.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 38c09781e..35218ac2a 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -2,8 +2,9 @@ #include #include "../MyMesh.h" #include "target.h" -#include - +#ifdef WIFI_SSID + #include +#endif #ifndef AUTO_OFF_MILLIS #define AUTO_OFF_MILLIS 15000 // 15 seconds @@ -132,8 +133,6 @@ class HomeScreen : public UIScreen { int sensors_scroll_offset = 0; int next_sensors_refresh = 0; - char ipStr[20]; - void refresh_sensors() { if (millis() > next_sensors_refresh) { sensors_lpp.reset(); @@ -198,9 +197,9 @@ class HomeScreen : public UIScreen { #ifdef WIFI_SSID IPAddress ip = WiFi.localIP(); - snprintf(ipStr, sizeof(ipStr), "IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); + 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, 54, ipStr); + display.drawTextCentered(display.width() / 2, 54, tmp); #endif if (_task->hasConnection()) { display.setColor(DisplayDriver::GREEN);