-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdigitalclock_esp8266.ino
More file actions
613 lines (536 loc) · 20.8 KB
/
digitalclock_esp8266.ino
File metadata and controls
613 lines (536 loc) · 20.8 KB
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
/**
* Digitalclock - Clock with 7-segment digitis based on NeoPixel with ESP8266 and NTP time update
*
* created by techniccontroller 29.03.2025
*
* components:
* - ESP8266 (Wemos D1 mini)
* - 47x NeoPixel WS2812B LED-strip 60/m
* - 46x NeoPixel WS2812B LED-strip 30/m
*
* Board settings:
* - Board: LOLIN(WEMOS) D1 mini (clone)
* - Flash Size: 4MB (FS:2MB OTA:~1019KB)
* - Upload Speed: 115200
*
* Libraries:
* - Adafruit NeoPixel
* - Adafruit GFX
* - ArduinoOTA
* - ESP8266WiFi
* - WiFiManager
*/
#include <LittleFS.h>
#include <Adafruit_NeoPixel.h> // NeoPixel library used to run the NeoPixel LEDs: https://github.com/adafruit/Adafruit_NeoPixel
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager WiFi Configuration Magic
#include <EEPROM.h> //from ESP8266 Arduino Core (automatically installed when ESP8266 was installed via Boardmanager)
// own libraries
#include "constants.h"
#include "udplogger.h"
#include "ntp_client_plus.h"
#include "ledstrip.h"
#include "segment_clock.h"
#include "Arduino.h"
#define DELAYVAL 100
// ports
const unsigned int HTTPPort = 80;
const unsigned int logMulticastPort = 8123;
// ip addresses for multicast logging
IPAddress logMulticastIP = IPAddress(230, 120, 10, 2);
// ip addresses for Access Point
IPAddress IPAdress_AccessPoint(192,168,10,2);
IPAddress Gateway_AccessPoint(192,168,10,0);
IPAddress Subnetmask_AccessPoint(255,255,255,0);
// SSID for Access Point
const char* AP_SSID = "digitalclockAP";
// hostname
const String hostname = "digitalclock";
int utcOffset = 60; // UTC offset in minutes
// ----------------------------------------------------------------------------------
// GLOBAL VARIABLES
// ----------------------------------------------------------------------------------
// Webserver
ESP8266WebServer server(HTTPPort);
// Wifi manager
WiFiManager wifiManager;
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel neopixel_leds(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// timestamp variables
long lastheartbeat = millis(); // time of last heartbeat sending
long lastStep = millis(); // time of last clock update
long lastLedStep = millis(); // time of last led update
long lastNTPUpdate = millis() - (PERIOD_NTP_UPDATE-5000); // time of last NTP update
long lastNightmodeCheck = millis(); // time of last nightmode check
long lastRandomBackground = millis(); // time of last random background change
// Create necessary global objects
UDPLogger logger;
WiFiUDP NTPUDP;
NTPClientPlus ntp = NTPClientPlus(NTPUDP, "pool.ntp.org", utcOffset, true);
LEDStrip ledstrip = LEDStrip(&neopixel_leds, &logger);
SegmentClock segmentClock = SegmentClock(&ledstrip, &logger);
// colors
uint32_t colorTime = LEDStrip::Color24bit(200, 200, 0); // color of the hours
uint32_t colorBackground = LEDStrip::Color24bit(0, 200, 200); // color of the minutes
bool nightMode = false; // stores state of nightmode
bool ledOff = false; // stores state of LED off
// nightmode settings
uint8_t nightModeStartHour = 22;
uint8_t nightModeStartMin = 0;
uint8_t nightModeEndHour = 7;
uint8_t nightModeEndMin = 0;
// Watchdog counter to trigger restart if NTP update was not possible 30 times in a row (5min)
int watchdogCounter = 30;
bool waitForTimeAfterReboot = false; // wait for time update after reboot
// ----------------------------------------------------------------------------------
// SETUP
// ----------------------------------------------------------------------------------
void setup() {
Serial.begin(115200);
delay(100);
Serial.println();
Serial.printf("\nSketchname: %s\nBuild: %s\n", (__FILE__), (__TIMESTAMP__));
Serial.println();
//Init EEPROM
EEPROM.begin(EEPROM_SIZE);
ledstrip.initializeStrip();
ledstrip.setCurrentLimit(CURRENT_LIMIT_LED);
/** Use WiFiMaanger for handling initial Wifi setup **/
// Local intialization. Once its business is done, there is no need to keep it around
// Uncomment and run it once, if you want to erase all the stored information
//wifiManager.resetSettings();
// set custom ip for portal
//wifiManager.setAPStaticIPConfig(IPAdress_AccessPoint, Gateway_AccessPoint, Subnetmask_AccessPoint);
// set a custom hostname
wifiManager.setHostname(hostname);
// fetches ssid and pass from eeprom and tries to connect
// if it does not connect it starts an access point with the specified name
// here "digitalclockAP"
// and goes into a blocking loop awaiting configuration
wifiManager.autoConnect(AP_SSID);
// if you get here you have connected to the WiFi
Serial.println("Connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// init ESP8266 File manager (LittleFS)
setupFS();
setupOTA(hostname);
server.on("/data", handleDataRequest); // process datarequests
server.on("/cmd", handleCommand); // process commands
server.begin();
// create UDP Logger to send logging messages via UDP multicast
logger = UDPLogger(WiFi.localIP(), logMulticastIP, logMulticastPort);
logger.setName("Digitalclock");
logger.logString("Start program\n");
logger.logString("Sketchname: "+ String(__FILE__));
logger.logString("Build: " + String(__TIMESTAMP__));
logger.logString("IP: " + WiFi.localIP().toString());
logger.logString("Reset Reason: " + ESP.getResetReason());
loadColorsFromEEPROM();
loadNightmodeSettingsFromEEPROM();
loadBrightnessSettingsFromEEPROM();
if(ESP.getResetReason().equals("Power On") || ESP.getResetReason().equals("External System")){
ledstrip.runLEDTest();
// display IP
uint8_t address = WiFi.localIP()[3];
uint8_t first_digit = address/100;
uint8_t second_digit = (address/10)%10;
uint8_t third_digit = address%10;
segmentClock.setTime(first_digit, second_digit * 10 + third_digit);
ledstrip.drawOnLEDsInstant();
delay(3000);
// clear matrix
ledstrip.flush();
ledstrip.drawOnLEDsInstant();
}
else {
waitForTimeAfterReboot = true;
}
delay(2000);
// setup NTP
updateUTCOffsetFromTimezoneAPI(logger, ntp);
ntp.setupNTPClient();
logger.logString("NTP running");
logger.logString("Time: " + ntp.getFormattedTime());
}
// ----------------------------------------------------------------------------------
// LOOP
// ----------------------------------------------------------------------------------
void loop() {
// handle OTA
handleOTA();
// handle Webserver
server.handleClient();
// send regularly heartbeat messages via UDP multicast
if(millis() - lastheartbeat > PERIOD_HEARTBEAT){
logger.logString("Heartbeat, FreeHeap: " + String(ESP.getFreeHeap())
+ ", HeapFrag: " + String(ESP.getHeapFragmentation())
+ ", MaxFreeBlock: " + String(ESP.getMaxFreeBlockSize()) + "\n");
lastheartbeat = millis();
}
if((millis() - lastStep > PERIOD_CLOCK_UPDATE) && !nightMode && !ledOff){
// update LEDs
updateClock();
lastStep = millis();
}
// Turn off LEDs if ledOff is true or nightmode is active
if((ledOff || nightMode) && !waitForTimeAfterReboot){
ledstrip.flush();
ledstrip.drawOnLEDsInstant();
}
// periodically write colors to leds
else if(millis() - lastLedStep > PERIOD_LED_UPDATE && !waitForTimeAfterReboot){
ledstrip.drawOnLEDsSmooth(0.2);
lastLedStep = millis();
}
if(!ledOff && !nightMode && millis() - lastRandomBackground > PERIOD_BACKGROUND_RANDOM){
segmentClock.randomizeBackground();
ledstrip.drawOnLEDsInstant();
lastRandomBackground = millis();
}
// NTP time update
if(millis() - lastNTPUpdate > PERIOD_NTP_UPDATE){
int res = ntp.updateNTP();
if(res == 0){
ntp.calcDate();
logger.logString("NTP-Update successful");
logger.logString("Time: " + ntp.getFormattedTime());
logger.logString("Date: " + ntp.getFormattedDate());
logger.logString("Day of Week (Mon=1, Sun=7): " + String(ntp.getDayOfWeek()));
logger.logString("Summertime: " + String(ntp.updateSWChange()));
lastNTPUpdate = millis();
watchdogCounter = 30;
checkNightmode();
if(waitForTimeAfterReboot && !nightMode){
updateClock();
ledstrip.drawOnLEDsInstant();
}
waitForTimeAfterReboot = false;
}
else if(res == -1){
logger.logString("NTP-Update not successful. Reason: Timeout");
lastNTPUpdate += 10000;
watchdogCounter--;
}
else if(res == 1){
logger.logString("NTP-Update not successful. Reason: Too large time difference");
logger.logString("Time: " + ntp.getFormattedTime());
logger.logString("Date: " + ntp.getFormattedDate());
logger.logString("Day of Week (Mon=1, Sun=7): " + ntp.getDayOfWeek());
logger.logString("Summertime: " + String(ntp.updateSWChange()));
lastNTPUpdate += 10000;
watchdogCounter--;
}
else {
logger.logString("NTP-Update not successful. Reason: NTP time not valid (<1970)");
lastNTPUpdate += 10000;
watchdogCounter--;
}
logger.logString("Watchdog Counter: " + String(watchdogCounter));
if(watchdogCounter <= 0){
logger.logString("Trigger restart due to watchdog...");
delay(100);
ESP.restart();
}
}
// check if nightmode need to be activated
if(millis() - lastNightmodeCheck > PERIOD_NIGHTMODE_CHECK && !waitForTimeAfterReboot){
checkNightmode();
lastNightmodeCheck = millis();
}
}
// ----------------------------------------------------------------------------------
// FUNCTIONS
// ----------------------------------------------------------------------------------
/**
* @brief Clock update
*/
void updateClock(){
int hours = ntp.getHours24();
int minutes = ntp.getMinutes();
segmentClock.setTimeColor(colorTime);
segmentClock.setBackgroundColor(colorBackground);
segmentClock.setTime(hours, minutes);
}
/**
* @brief Check if nightmode should be activated
*/
void checkNightmode(){
logger.logString("Check nightmode");
int hours = ntp.getHours24();
int minutes = ntp.getMinutes();
nightMode = false; // Initial assumption
// Convert all times to minutes for easier comparison
int currentTimeInMinutes = hours * 60 + minutes;
int startInMinutes = nightModeStartHour * 60 + nightModeStartMin;
int endInMinutes = nightModeEndHour * 60 + nightModeEndMin;
if (startInMinutes < endInMinutes) { // Same day scenario
if (startInMinutes < currentTimeInMinutes && currentTimeInMinutes < endInMinutes) {
nightMode = true;
logger.logString("Nightmode activated");
}
} else if (startInMinutes > endInMinutes) { // Overnight scenario
if (currentTimeInMinutes >= startInMinutes || currentTimeInMinutes < endInMinutes) {
nightMode = true;
logger.logString("Nightmode activated");
}
}
}
/**
* @brief Load the colors for hours, minutes and seconds from EEPROM
*/
void loadColorsFromEEPROM(){
colorTime = getRGBColorFromEEPROM(ADR_TI_RED, ADR_TI_GREEN, ADR_TI_BLUE);
colorBackground = getRGBColorFromEEPROM(ADR_BG_RED, ADR_BG_GREEN, ADR_BG_BLUE);
}
/**
* @brief Load a color from EEPROM
*
* @param adr_red address of red value in EEPROM
* @param adr_green address of green value in EEPROM
* @param adr_blue address of blue value in EEPROM
*
* @return color as 24bit integer
*/
uint32_t getRGBColorFromEEPROM(uint8_t adr_red, uint8_t adr_green, uint8_t adr_blue){
uint8_t red = EEPROM.read(adr_red);
uint8_t green = EEPROM.read(adr_green);
uint8_t blue = EEPROM.read(adr_blue);
if(int(red) + int(green) + int(blue) < 50){
return LEDStrip::Color24bit(200, 200, 0);
} else {
return LEDStrip::Color24bit(red, green, blue);
}
}
/**
* @brief Load the nightmode settings from EEPROM
*/
void loadNightmodeSettingsFromEEPROM()
{
nightModeStartHour = EEPROM.read(ADR_NM_START_H);
nightModeStartMin = EEPROM.read(ADR_NM_START_M);
nightModeEndHour = EEPROM.read(ADR_NM_END_H);
nightModeEndMin = EEPROM.read(ADR_NM_END_M);
if (nightModeStartHour > 23)
nightModeStartHour = 22; // set to 22 o'clock as default
if (nightModeStartMin > 59)
nightModeStartMin = 0;
if (nightModeEndHour > 23)
nightModeEndHour = 7; // set to 7 o'clock as default
if (nightModeEndMin > 59)
nightModeEndMin = 0;
logger.logString("Nightmode starts at: " + String(nightModeStartHour) + ":" + String(nightModeStartMin));
logger.logString("Nightmode ends at: " + String(nightModeEndHour) + ":" + String(nightModeEndMin));
}
/**
* @brief Load the brightness settings from EEPROM
*
* lower limit is 10 so that the LEDs are not completely off
*/
void loadBrightnessSettingsFromEEPROM()
{
uint8_t brightnessTime = EEPROM.read(ADR_BRIGHTNESS_TIME);
uint8_t brightnessBackground = EEPROM.read(ADR_BRIGHTNESS_BACKGROUND);
float speedBackground = EEPROM.read(ADR_SPEED_BACKGROUND) / 100.0; // read speed as percentage
if (brightnessTime < 10)
brightnessTime = 10;
if (brightnessBackground < 10)
brightnessBackground = 10;
if (speedBackground < 0.2)
speedBackground = 0.2; // set minimum speed to 0.2
segmentClock.setTimeBrightness(brightnessTime);
segmentClock.setBackgroundBrightness(brightnessBackground);
segmentClock.setBackgroundAnimationSpeed(speedBackground);
logger.logString("BrightnessTime: " + String(brightnessTime) + ", BrightnessBackround: " + String(brightnessBackground)
+ ", SpeedBackground: " + String(speedBackground));
}
/**
* @brief Set the color for hours
*
* @param red red value
* @param green green value
* @param blue blue value
*/
void setColorTime(uint8_t red, uint8_t green, uint8_t blue){
colorTime = LEDStrip::Color24bit(red, green, blue);
EEPROM.write(ADR_TI_RED, red);
EEPROM.write(ADR_TI_GREEN, green);
EEPROM.write(ADR_TI_BLUE, blue);
EEPROM.commit();
}
/**
* @brief Set the color for minutes
*
* @param red red value
* @param green green value
* @param blue blue value
*/
void setColorBackround(uint8_t red, uint8_t green, uint8_t blue){
colorBackground = LEDStrip::Color24bit(red, green, blue);
EEPROM.write(ADR_BG_RED, red);
EEPROM.write(ADR_BG_GREEN, green);
EEPROM.write(ADR_BG_BLUE, blue);
EEPROM.commit();
}
/**
* @brief Handler for handling commands sent to "/cmd" url
*
*/
void handleCommand() {
// receive command and handle accordingly
for (uint8_t i = 0; i < server.args(); i++) {
String log_str = "Command received: " + server.argName(i) + " " + server.arg(i);
logger.logString(log_str);
}
if (server.argName(0) == "col_time") // the parameter which was sent to this server is the color for time
{
String colorstr = server.arg(0) + "-";
String redstr = split(colorstr, '-', 0);
String greenstr= split(colorstr, '-', 1);
String bluestr = split(colorstr, '-', 2);
logger.logString(colorstr);
logger.logString("r: " + String(redstr.toInt()));
logger.logString("g: " + String(greenstr.toInt()));
logger.logString("b: " + String(bluestr.toInt()));
setColorTime(redstr.toInt(), greenstr.toInt(), bluestr.toInt());
}
else if (server.argName(0) == "col_background") // the parameter which was sent to this server is the color for background
{
String colorstr = server.arg(0) + "-";
String redstr = split(colorstr, '-', 0);
String greenstr= split(colorstr, '-', 1);
String bluestr = split(colorstr, '-', 2);
logger.logString(colorstr);
logger.logString("r: " + String(redstr.toInt()));
logger.logString("g: " + String(greenstr.toInt()));
logger.logString("b: " + String(bluestr.toInt()));
setColorBackround(redstr.toInt(), greenstr.toInt(), bluestr.toInt());
}
else if(server.argName(0) == "ledoff"){
String modestr = server.arg(0);
logger.logString("LED off change via Webserver to: " + modestr);
if(modestr == "1") ledOff = true;
else ledOff = false;
}
else if(server.argName(0) == "setting"){
String timestr = server.arg(0) + "-";
logger.logString("Nightmode setting change via Webserver to: " + timestr);
nightModeStartHour = split(timestr, '-', 0).toInt();
nightModeStartMin = split(timestr, '-', 1).toInt();
nightModeEndHour = split(timestr, '-', 2).toInt();
nightModeEndMin = split(timestr, '-', 3).toInt();
uint8_t brightnessTime = split(timestr, '-', 4).toInt();
uint8_t brightnessBackground = split(timestr, '-', 5).toInt();
float speedBackground = split(timestr, '-', 6).toFloat();
if(nightModeStartHour > 23) nightModeStartHour = 22; // set default
if(nightModeStartMin > 59) nightModeStartMin = 0;
if(nightModeEndHour > 23) nightModeEndHour = 7; // set default
if(nightModeEndMin > 59) nightModeEndMin = 0;
if(brightnessTime < 10) brightnessTime = 10;
if(brightnessBackground < 10) brightnessBackground = 10;
if(speedBackground < 0.2) speedBackground = 0.2; // set minimum speed
EEPROM.write(ADR_NM_START_H, nightModeStartHour);
EEPROM.write(ADR_NM_START_M, nightModeStartMin);
EEPROM.write(ADR_NM_END_H, nightModeEndHour);
EEPROM.write(ADR_NM_END_M, nightModeEndMin);
EEPROM.write(ADR_BRIGHTNESS_TIME, brightnessTime);
EEPROM.write(ADR_BRIGHTNESS_BACKGROUND, brightnessBackground);
EEPROM.write(ADR_SPEED_BACKGROUND, (uint8_t)(speedBackground * 100)); // store speed as percentage
EEPROM.commit();
logger.logString("Nightmode starts at: " + String(nightModeStartHour) + ":" + String(nightModeStartMin));
logger.logString("Nightmode ends at: " + String(nightModeEndHour) + ":" + String(nightModeEndMin));
logger.logString("BrightnessTime: " + String(brightnessTime) + ", BrightnessBackground: " + String(brightnessBackground));
logger.logString("SpeedBackground: " + String(speedBackground));
segmentClock.setTimeBrightness(brightnessTime);
segmentClock.setBackgroundBrightness(brightnessBackground);
segmentClock.setBackgroundAnimationSpeed(speedBackground);
lastNightmodeCheck = 0;
}
else if (server.argName(0) == "resetwifi"){
logger.logString("Reset Wifi via Webserver...");
wifiManager.resetSettings();
ledstrip.runLEDTest();
}
else if (server.argName(0) == "reboot"){
logger.logString("Reboot via Webserver...");
server.send(204, "text/plain", "No Content"); // this page doesn't send back content --> 204
delay(1000);
ESP.restart();
}
server.send(204, "text/plain", "No Content"); // this page doesn't send back content --> 204
}
/**
* @brief Splits a string at given character and return specified element
*
* @param s string to split
* @param parser separating character
* @param index index of the element to return
* @return String
*/
String split(String s, char parser, int index) {
String rs="";
int parserCnt=0;
int rFromIndex=0, rToIndex=-1;
while (index >= parserCnt) {
rFromIndex = rToIndex+1;
rToIndex = s.indexOf(parser,rFromIndex);
if (index == parserCnt) {
if (rToIndex == 0 || rToIndex == -1) return "";
return s.substring(rFromIndex,rToIndex);
} else parserCnt++;
}
return rs;
}
/**
* @brief Handler for GET requests
*
*/
void handleDataRequest() {
// receive data request and handle accordingly
for (uint8_t i = 0; i < server.args(); i++) {
String log_str = "Command received: " + server.argName(i) + " " + server.arg(i);
logger.logString(log_str);
}
if (server.argName(0) == "key") // the parameter which was sent to this server is led color
{
String message = "{";
String keystr = server.arg(0);
if(keystr == "mode"){
message += "\"ledoff\":\"" + String(ledOff) + "\"";
message += ",";
message += "\"nightMode\":\"" + String(nightMode) + "\"";
message += ",";
message += "\"nightModeStart\":\"" + leadingZero2Digit(nightModeStartHour) + "-" + leadingZero2Digit(nightModeStartMin) + "\"";
message += ",";
message += "\"nightModeEnd\":\"" + leadingZero2Digit(nightModeEndHour) + "-" + leadingZero2Digit(nightModeEndMin) + "\"";
message += ",";
message += "\"brightnessTime\":\"" + String(segmentClock.getBrightnessTime()) + "\"";
message += ",";
message += "\"brightnessBackground\":\"" + String(segmentClock.getBrightnessBackground()) + "\"";
message += ",";
message += "\"speedBackground\":\"" + String(segmentClock.getBackgroundAnimationSpeed()) + "\"";
}
message += "}";
logger.logString(message);
server.send(200, "application/json", message);
}
}
/**
* @brief Convert Integer to String with leading zero
*
* @param value
* @return String
*/
String leadingZero2Digit(int value){
String msg = "";
if(value < 10){
msg = "0";
}
msg += String(value);
return msg;
}