Skip to content

Commit f339c74

Browse files
committed
* Add #ifdef, reuse variable
1 parent a38418e commit f339c74

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

examples/companion_radio/ui-new/UITask.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
#include <helpers/TxtDataHelpers.h>
33
#include "../MyMesh.h"
44
#include "target.h"
5-
#include <WiFi.h>
6-
5+
#ifdef WIFI_SSID
6+
#include <WiFi.h>
7+
#endif
78

89
#ifndef AUTO_OFF_MILLIS
910
#define AUTO_OFF_MILLIS 15000 // 15 seconds
@@ -132,8 +133,6 @@ class HomeScreen : public UIScreen {
132133
int sensors_scroll_offset = 0;
133134
int next_sensors_refresh = 0;
134135

135-
char ipStr[20];
136-
137136
void refresh_sensors() {
138137
if (millis() > next_sensors_refresh) {
139138
sensors_lpp.reset();
@@ -198,9 +197,9 @@ class HomeScreen : public UIScreen {
198197

199198
#ifdef WIFI_SSID
200199
IPAddress ip = WiFi.localIP();
201-
snprintf(ipStr, sizeof(ipStr), "IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
200+
snprintf(tmp, sizeof(tmp), "IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
202201
display.setTextSize(1);
203-
display.drawTextCentered(display.width() / 2, 54, ipStr);
202+
display.drawTextCentered(display.width() / 2, 54, tmp);
204203
#endif
205204
if (_task->hasConnection()) {
206205
display.setColor(DisplayDriver::GREEN);

0 commit comments

Comments
 (0)