/
ESPixelStick.ino
662 lines (571 loc) · 22.3 KB
/
ESPixelStick.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
/*
* ESPixelStick.ino
*
* Project: ESPixelStick - An ESP8266 and E1.31 based pixel driver
* Copyright (c) 2016 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
* subject to the laws and regulations where you are using it. Due diligence
* is strongly suggested before using this code. Please give credit where due.
*
* The Author makes no warranty of any kind, express or implied, with regard
* to this program or the documentation contained in this document. The
* Author shall not be liable in any event for incidental or consequential
* damages in connection with, or arising out of, the furnishing, performance
* or use of these programs.
*
*/
/*****************************************/
/* BEGIN - Configuration */
/*****************************************/
/* Output Mode - There can be only one! (-Conor MacLeod) */
#define ESPS_MODE_PIXEL
//#define ESPS_MODE_SERIAL
/* Fallback configuration if config.json is empty or fails */
const char ssid[] = "ENTER_SSID_HERE";
const char passphrase[] = "ENTER_PASSPHRASE_HERE";
/*****************************************/
/* END - Configuration */
/*****************************************/
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncUDP.h>
#include <ESPAsyncWebServer.h>
//#include <WiFiUdp.h>
#include <ESP8266mDNS.h>
#include <ArduinoJson.h>
#include <Hash.h>
#include <SPI.h>
#include <E131Async.h>
#include "ESPixelStick.h"
#include "EFUpdate.h"
#include "wshandler.h"
extern "C" {
#include <user_interface.h>
}
uint8_t *seqTracker; /* Current sequence numbers for each Universe */
uint32_t lastUpdate; /* Update timeout tracker */
/* Forward Declarations */
void loadConfig();
int initWifi();
void initWeb();
void updateConfig();
RF_PRE_INIT() {
//wifi_set_phy_mode(PHY_MODE_11G); // Force 802.11g mode
system_phy_set_powerup_option(31); // Do full RF calibration on power-up
system_phy_set_max_tpw(82); // Set max TX power
}
void setup() {
/* Configure SDK params */
wifi_set_sleep_type(NONE_SLEEP_T);
/* Initial pin states */
pinMode(DATA_PIN, OUTPUT);
digitalWrite(DATA_PIN, LOW);
/* Setup serial log port */
LOG_PORT.begin(115200);
delay(10);
/* Enable SPIFFS */
SPIFFS.begin();
LOG_PORT.println("");
LOG_PORT.print(F("ESPixelStick v"));
for (uint8_t i = 0; i < strlen_P(VERSION); i++)
LOG_PORT.print((char)(pgm_read_byte(VERSION + i)));
LOG_PORT.println("");
/* Load configuration from SPIFFS and set Hostname */
loadConfig();
WiFi.hostname(config.hostname);
config.testmode = TestMode::DISABLED;
/* Fallback to default SSID and passphrase if we fail to connect */
int status = initWifi();
if (status != WL_CONNECTED) {
LOG_PORT.println(F("*** Timeout - Reverting to default SSID ***"));
config.ssid = ssid;
config.passphrase = passphrase;
status = initWifi();
}
/* If we fail again, go SoftAP or reboot */
if (status != WL_CONNECTED) {
if (config.ap_fallback) {
LOG_PORT.println(F("**** FAILED TO ASSOCIATE WITH AP, GOING SOFTAP ****"));
WiFi.mode(WIFI_AP);
String ssid = "ESPixelStick " + String(config.hostname);
WiFi.softAP(ssid.c_str());
} else {
LOG_PORT.println(F("**** FAILED TO ASSOCIATE WITH AP, REBOOTING ****"));
ESP.restart();
}
}
/* Configure and start the web server */
initWeb();
/* Setup mDNS / DNS-SD */
//TODO: Reboot or restart mdns when config.id is changed?
char chipId[7] = { 0 };
snprintf(chipId, sizeof(chipId), "%06x", ESP.getChipId());
MDNS.setInstanceName(config.id + " (" + String(chipId) + ")");
if (MDNS.begin(config.hostname.c_str())) {
MDNS.addService("http", "tcp", HTTP_PORT);
MDNS.addService("e131", "udp", E131_DEFAULT_PORT);
MDNS.addServiceTxt("e131", "udp", "TxtVers", String(RDMNET_DNSSD_TXTVERS));
MDNS.addServiceTxt("e131", "udp", "ConfScope", RDMNET_DEFAULT_SCOPE);
MDNS.addServiceTxt("e131", "udp", "E133Vers", String(RDMNET_DNSSD_E133VERS));
MDNS.addServiceTxt("e131", "udp", "CID", String(chipId));
MDNS.addServiceTxt("e131", "udp", "Model", "ESPixelStick");
MDNS.addServiceTxt("e131", "udp", "Manuf", "Forkineye");
} else {
LOG_PORT.println(F("*** Error setting up mDNS responder ***"));
}
/* Configure the outputs */
#if defined (ESPS_MODE_PIXEL)
pixels.setPin(DATA_PIN);
updateConfig();
pixels.show();
#else
updateConfig();
#endif
}
int initWifi() {
/* Switch to station mode and disconnect just in case */
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(secureRandom(100,500));
LOG_PORT.println("");
LOG_PORT.print(F("Connecting to "));
LOG_PORT.print(config.ssid);
LOG_PORT.print(F(" as "));
LOG_PORT.println(config.hostname);
WiFi.begin(config.ssid.c_str(), config.passphrase.c_str());
if (config.dhcp) {
LOG_PORT.print(F("Connecting with DHCP"));
} else {
/* We don't use DNS, so just set it to our gateway */
WiFi.config(IPAddress(config.ip[0], config.ip[1], config.ip[2], config.ip[3]),
IPAddress(config.gateway[0], config.gateway[1], config.gateway[2], config.gateway[3]),
IPAddress(config.netmask[0], config.netmask[1], config.netmask[2], config.netmask[3]),
IPAddress(config.gateway[0], config.gateway[1], config.gateway[2], config.gateway[3])
);
LOG_PORT.print(F("Connecting with Static IP"));
}
uint32_t timeout = millis();
while (WiFi.status() != WL_CONNECTED) {
delay(500);
LOG_PORT.print(".");
if (millis() - timeout > CONNECT_TIMEOUT) {
LOG_PORT.println("");
LOG_PORT.println(F("*** Failed to connect ***"));
break;
}
}
if (WiFi.status() == WL_CONNECTED) {
LOG_PORT.println("");
LOG_PORT.print(F("Connected with IP: "));
LOG_PORT.println(WiFi.localIP());
if (config.multicast)
e131.begin(E131_MULTICAST, config.universe,
uniLast - config.universe + 1);
else
e131.begin(E131_UNICAST);
}
return WiFi.status();
}
/* Configure and start the web server */
void initWeb() {
/* Handle OTA update from asynchronous callbacks */
Update.runAsync(true);
/* Setup WebSockets */
ws.onEvent(wsEvent);
web.addHandler(&ws);
/* Heap status handler */
web.on("/heap", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(200, "text/plain", String(ESP.getFreeHeap()));
});
/* JSON Config Handler */
web.on("/conf", HTTP_GET, [](AsyncWebServerRequest *request) {
String jsonString;
serializeConfig(jsonString);
request->send(200, "text/json", jsonString);
});
/* Firmware upload handler */
web.on("/updatefw", HTTP_POST, [](AsyncWebServerRequest *request) {
ws.textAll("X6");
}, handle_fw_upload);
/* Static Handler */
web.serveStatic("/", SPIFFS, "/www/").setDefaultFile("index.html");
web.onNotFound([](AsyncWebServerRequest *request) {
request->send(404, "text/plain", "Page not found");
});
web.begin();
LOG_PORT.print(F("- Web Server started on port "));
LOG_PORT.println(HTTP_PORT);
}
/* Configuration Validations */
void validateConfig() {
/* E1.31 Limits */
if (config.universe < 1)
config.universe = 1;
if (config.channel_start < 1)
config.channel_start = 1;
else if (config.channel_start > UNIVERSE_LIMIT)
config.channel_start = UNIVERSE_LIMIT;
#if defined(ESPS_MODE_PIXEL)
/* Set Mode */
config.devmode = DevMode::MPIXEL;
/* Generic channel limits for pixels */
if (config.channel_count % 3)
config.channel_count = (config.channel_count / 3) * 3;
if (config.channel_count > PIXEL_LIMIT * 3)
config.channel_count = PIXEL_LIMIT * 3;
else if (config.channel_count < 1)
config.channel_count = 1;
/* GECE Limits */
if (config.pixel_type == PixelType::GECE) {
config.pixel_color = PixelColor::RGB;
if (config.channel_count > 63 * 3)
config.channel_count = 63 * 3;
}
#elif defined(ESPS_MODE_SERIAL)
/* Set Mode */
config.devmode = DevMode::MSERIAL;
/* Generic serial channel limits */
if (config.channel_count > RENARD_LIMIT)
config.channel_count = RENARD_LIMIT;
else if (config.channel_count < 1)
config.channel_count = 1;
if (config.serial_type == SerialType::DMX512 && config.channel_count > UNIVERSE_LIMIT)
config.channel_count = UNIVERSE_LIMIT;
/* Baud rate check */
if (config.baudrate > BaudRate::BR_460800)
config.baudrate = BaudRate::BR_460800;
else if (config.baudrate < BaudRate::BR_38400)
config.baudrate = BaudRate::BR_57600;
#endif
}
void updateConfig() {
/* Validate first */
validateConfig();
/* Find the last universe we should listen for */
uint16_t span = config.channel_start + config.channel_count - 1;
if (span % UNIVERSE_LIMIT)
uniLast = config.universe + span / UNIVERSE_LIMIT;
else
uniLast = config.universe + span / UNIVERSE_LIMIT - 1;
/* Setup the sequence error tracker */
uint8_t uniTotal = (uniLast + 1) - config.universe;
if (seqTracker) free(seqTracker);
if (seqTracker = static_cast<uint8_t *>(malloc(uniTotal)))
memset(seqTracker, 0x00, uniTotal);
if (seqError) free(seqError);
if (seqError = static_cast<uint32_t *>(malloc(uniTotal * 4)))
memset(seqError, 0x00, uniTotal * 4);
/* Zero out packet stats */
e131.stats.num_packets = 0;
/* Initialize for our pixel type */
#if defined(ESPS_MODE_PIXEL)
pixels.begin(config.pixel_type, config.pixel_color, config.channel_count / 3);
pixels.setGamma(config.gamma);
#elif defined(ESPS_MODE_SERIAL)
serial.begin(&SEROUT_PORT, config.serial_type, config.channel_count, config.baudrate);
#endif
LOG_PORT.print(F("- Listening for "));
LOG_PORT.print(config.channel_count);
LOG_PORT.print(F(" channels, from Universe "));
LOG_PORT.print(config.universe);
LOG_PORT.print(F(" to "));
LOG_PORT.println(uniLast);
}
/* De-Serialize Network config */
void dsNetworkConfig(JsonObject &json) {
/* Fallback to embedded ssid and passphrase if null in config */
config.ssid = json["network"]["ssid"].as<String>();
if (!config.ssid.length())
config.ssid = ssid;
config.passphrase = json["network"]["passphrase"].as<String>();
if (!config.passphrase.length())
config.passphrase = passphrase;
/* Network */
for (int i = 0; i < 4; i++) {
config.ip[i] = json["network"]["ip"][i];
config.netmask[i] = json["network"]["netmask"][i];
config.gateway[i] = json["network"]["gateway"][i];
}
config.dhcp = json["network"]["dhcp"];
config.ap_fallback = json["network"]["ap_fallback"];
/* Generate default hostname if needed */
config.hostname = json["network"]["hostname"].as<String>();
if (!config.hostname.length()) {
char chipId[7] = { 0 };
snprintf(chipId, sizeof(chipId), "%06x", ESP.getChipId());
config.hostname = "esps-" + String(chipId);
}
}
void dsDeviceConfig(JsonObject &json) {
/* Device */
config.id = json["device"]["id"].as<String>();
/* E131 */
config.universe = json["e131"]["universe"];
config.channel_start = json["e131"]["channel_start"];
config.channel_count = json["e131"]["channel_count"];
config.multicast = json["e131"]["multicast"];
#if defined(ESPS_MODE_PIXEL)
/* Pixel */
config.pixel_type = PixelType(static_cast<uint8_t>(json["pixel"]["type"]));
config.pixel_color = PixelColor(static_cast<uint8_t>(json["pixel"]["color"]));
config.gamma = json["pixel"]["gamma"];
#elif defined(ESPS_MODE_SERIAL)
/* Serial */
config.serial_type = SerialType(static_cast<uint8_t>(json["serial"]["type"]));
config.baudrate = BaudRate(static_cast<uint32_t>(json["serial"]["baudrate"]));
#endif
}
/* Load configugration JSON file */
void loadConfig() {
/* Zeroize Config struct */
memset(&config, 0, sizeof(config));
/* Load CONFIG_FILE json. Create and init with defaults if not found */
File file = SPIFFS.open(CONFIG_FILE, "r");
if (!file) {
LOG_PORT.println(F("- No configuration file found."));
config.ssid = ssid;
config.passphrase = passphrase;
saveConfig();
} else {
/* Parse CONFIG_FILE json */
size_t size = file.size();
if (size > CONFIG_MAX_SIZE) {
LOG_PORT.println(F("*** Configuration File too large ***"));
return;
}
std::unique_ptr<char[]> buf(new char[size]);
file.readBytes(buf.get(), size);
DynamicJsonBuffer jsonBuffer;
JsonObject &json = jsonBuffer.parseObject(buf.get());
if (!json.success()) {
LOG_PORT.println(F("*** Configuration File Format Error ***"));
return;
}
dsNetworkConfig(json);
dsDeviceConfig(json);
LOG_PORT.println(F("- Configuration loaded."));
}
/* Validate it */
validateConfig();
}
/* Serialize the current config into a JSON string */
void serializeConfig(String &jsonString, bool pretty, bool creds) {
/* Create buffer and root object */
DynamicJsonBuffer jsonBuffer;
JsonObject &json = jsonBuffer.createObject();
/* Device */
JsonObject &device = json.createNestedObject("device");
device["id"] = config.id.c_str();
device["mode"] = static_cast<uint8_t>(config.devmode);
/* Network */
JsonObject &network = json.createNestedObject("network");
network["ssid"] = config.ssid.c_str();
if (creds)
network["passphrase"] = config.passphrase.c_str();
network["hostname"] = config.hostname.c_str();
JsonArray &ip = network.createNestedArray("ip");
JsonArray &netmask = network.createNestedArray("netmask");
JsonArray &gateway = network.createNestedArray("gateway");
for (int i = 0; i < 4; i++) {
ip.add(config.ip[i]);
netmask.add(config.netmask[i]);
gateway.add(config.gateway[i]);
}
network["dhcp"] = config.dhcp;
network["ap_fallback"] = config.ap_fallback;
/* E131 */
JsonObject &e131 = json.createNestedObject("e131");
e131["universe"] = config.universe;
e131["channel_start"] = config.channel_start;
e131["channel_count"] = config.channel_count;
e131["multicast"] = config.multicast;
#if defined(ESPS_MODE_PIXEL)
/* Pixel */
JsonObject &pixel = json.createNestedObject("pixel");
pixel["type"] = static_cast<uint8_t>(config.pixel_type);
pixel["color"] = static_cast<uint8_t>(config.pixel_color);
pixel["gamma"] = config.gamma;
#elif defined(ESPS_MODE_SERIAL)
/* Serial */
JsonObject &serial = json.createNestedObject("serial");
serial["type"] = static_cast<uint8_t>(config.serial_type);
serial["baudrate"] = static_cast<uint32_t>(config.baudrate);
#endif
if (pretty)
json.prettyPrintTo(jsonString);
else
json.printTo(jsonString);
}
/* Save configuration JSON file */
void saveConfig() {
/* Update Config */
updateConfig();
/* Serialize Config */
String jsonString;
serializeConfig(jsonString, true, true);
/* Save Config */
File file = SPIFFS.open(CONFIG_FILE, "w");
if (!file) {
LOG_PORT.println(F("*** Error creating configuration file ***"));
return;
} else {
file.println(jsonString);
LOG_PORT.println(F("* Configuration saved."));
}
}
/* Main Loop */
void loop() {
e131_packet_t packet;
// Reboot handler
if (reboot) {
delay(REBOOT_DELAY);
ESP.restart();
}
if (config.testmode == TestMode::DISABLED || config.testmode == TestMode::VIEW_STREAM) {
// Parse a packet and update pixels
if (!e131.pbuff->isEmpty(e131.pbuff)) {
e131.pbuff->pull(e131.pbuff, &packet);
uint16_t universe = htons(packet.universe);
uint8_t *data = packet.property_values + 1;
if ((universe >= config.universe) && (universe <= uniLast)) {
// Universe offset and sequence tracking
uint8_t uniOffset = (universe - config.universe);
if (packet.sequence_number != seqTracker[uniOffset]++) {
seqError[uniOffset]++;
seqTracker[uniOffset] = packet.sequence_number + 1;
}
// Offset the channels if required
uint16_t offset = 0;
offset = config.channel_start - 1;
// Find start of data based off the Universe
int16_t dataStart = uniOffset * UNIVERSE_LIMIT - offset;
// Calculate how much data we need for this buffer
uint16_t dataStop = config.channel_count;
if ((dataStart + UNIVERSE_LIMIT) < dataStop)
dataStop = dataStart + UNIVERSE_LIMIT;
// Set the data
uint16_t buffloc = 0;
// ignore data from start of first Universe before channel_start
if (dataStart < 0) {
dataStart = 0;
buffloc = config.channel_start-1;
}
for (int i = dataStart; i < dataStop; i++) {
#if defined(ESPS_MODE_PIXEL)
pixels.setValue(i, data[buffloc]);
#elif defined(ESPS_MODE_SERIAL)
serial.setValue(i, data[buffloc]);
#endif
buffloc++;
}
}
}
} else { // Other testmodes
switch (config.testmode) {
case TestMode::STATIC: {
// Continue to update color to whole string
uint16_t i = 0;
while (i <= config.channel_count - 3) {
#if defined(ESPS_MODE_PIXEL)
pixels.setValue(i++, testing.r);
pixels.setValue(i++, testing.g);
pixels.setValue(i++, testing.b);
#elif defined(ESPS_MODE_SERIAL)
serial.setValue(i++, testing.r);
serial.setValue(i++, testing.g);
serial.setValue(i++, testing.b);
#endif
}
break;
}
case TestMode::CHASE:
// Run chase routine
if (millis() - testing.last > 100) {
// Rime for new step
testing.last = millis();
#if defined(ESPS_MODE_PIXEL)
// Clear whole string
for (int y =0; y < config.channel_count; y++)
pixels.setValue(y, 0);
// Set pixel at step
int ch_offset = testing.step*3;
pixels.setValue(ch_offset++, testing.r);
pixels.setValue(ch_offset++, testing.g);
pixels.setValue(ch_offset, testing.b);
testing.step++;
if (testing.step >= (config.channel_count/3))
testing.step = 0;
#elif defined(ESPS_MODE_SERIAL)
for (int y =0; y < config.channel_count; y++)
serial.setValue(y, 0);
// Set pixel at step
serial.setValue(testing.step++, 0xFF);
if (testing.step >= config.channel_count)
testing.step = 0;
#endif
}
break;
case TestMode::RAINBOW:
// Run rainbow routine
if (millis() - testing.last > 50) {
testing.last = millis();
uint16_t i, WheelPos, num_pixels;
num_pixels = config.channel_count / 3;
if (testing.step < 255) {
for (i=0; i < (num_pixels); i++) {
int ch_offset = i*3;
WheelPos = 255 - (((i * 256 / num_pixels) + testing.step) & 255);
#if defined(ESPS_MODE_PIXEL)
if (WheelPos < 85) {
pixels.setValue(ch_offset++, 255 - WheelPos * 3);
pixels.setValue(ch_offset++, 0);
pixels.setValue(ch_offset, WheelPos * 3);
} else if (WheelPos < 170) {
WheelPos -= 85;
pixels.setValue(ch_offset++, 0);
pixels.setValue(ch_offset++, WheelPos * 3);
pixels.setValue(ch_offset, 255 - WheelPos * 3);
} else {
WheelPos -= 170;
pixels.setValue(ch_offset++, WheelPos * 3);
pixels.setValue(ch_offset++,255 - WheelPos * 3);
pixels.setValue(ch_offset, 0);
}
#elif defined(ESPS_MODE_SERIAL)
if (WheelPos < 85) {
serial.setValue(ch_offset++, 255 - WheelPos * 3);
serial.setValue(ch_offset++, 0);
serial.setValue(ch_offset, WheelPos * 3);
} else if (WheelPos < 170) {
WheelPos -= 85;
serial.setValue(ch_offset++, 0);
serial.setValue(ch_offset++, WheelPos * 3);
serial.setValue(ch_offset, 255 - WheelPos * 3);
} else {
WheelPos -= 170;
serial.setValue(ch_offset++, WheelPos * 3);
serial.setValue(ch_offset++,255 - WheelPos * 3);
serial.setValue(ch_offset, 0);
}
#endif
}
} else {
testing.step = 0;
}
testing.step++;
}
break;
}
}
/* Streaming refresh */
#if defined(ESPS_MODE_PIXEL)
if (pixels.canRefresh())
pixels.show();
#elif defined(ESPS_MODE_SERIAL)
if (serial.canRefresh())
serial.show();
#endif
}