-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimonel-MSS-ESP8266.ino
579 lines (560 loc) · 24.9 KB
/
Timonel-MSS-ESP8266.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
/*
Timonel bootloader I2C-master single slave application demo for ESP8266
............................................................................
File: Timonel-MSS-ESP8266.ino (Arduino sketch)
............................................................................
This demo implements an I2C serial commander to control interactively a
Tiny85 microcontroller running the Timonel bootloader from an ESP8266
master. It uses a serial console configured at 115200 N 8 1 for feedback.
............................................................................
Version: 1.5.0 / 2020-07-13 / [email protected]
............................................................................
*/
#include <NbMicro.h>
#include <TimonelTwiM.h>
#include <TwiBus.h>
#include "payload.h"
// This software
#define VER_MAJOR 1
#define VER_MINOR 5
#define VER_PATCH 0
// Serial display settings
#define USE_SERIAL Serial
#define SERIAL_BPS 115200
// I2C pins
#define SDA 2 // I2C SDA pin - ESP8266 2 - ESP32 21
#define SCL 0 // I2C SCL pin - ESP8266 0 - ESP32 22
// Upper EEPROM memory location
#define EEPROM_TOP 0x1FF
// Rotating bar delay
#define ROTATION_DLY 60
// Application mode switch delay
#define MODE_SWITCH_DLY 250
// Global variables
bool new_key = false;
bool new_word = false;
bool *p_app_mode = nullptr;
char key = '\0';
uint16_t flash_page_addr = 0x0000;
uint16_t eeprom_addr = 0x0000;
Timonel *p_timonel = nullptr; // Pointer to a bootloader objetct
// If the user application only needs simple I2C commands, it is enough to create just a
// Timonel object. Since it inherits from NbMicro, so the "TwiCmdXmit" method is available.
void (*resetFunc)(void) = 0;
/* ___________________
| |
| Setup block |
|___________________|
*/
void setup() {
bool app_mode = false; // This holds the slave device running mode info: bootloader or application
p_app_mode = &app_mode; // This is to take different actions depending on whether the bootloader or the application is active
USE_SERIAL.begin(SERIAL_BPS); // Initialize the serial port for debugging
ClrScr();
PrintLogo();
uint8_t slave_address = 0;
#if (ARDUINO_ARCH_ESP8266 || ARDUINO_ESP32_DEV || ESP_PLATFORM)
USE_SERIAL.printf_P("\n\rWaiting until a TWI slave device is detected on the bus ");
#else // -----
USE_SERIAL.print("\n\rWaiting until a TWI slave device is detected on the bus ");
#endif // ARDUINO_ARCH_ESP8266 || ARDUINO_ESP32_DEV || ESP_PLATFORM
slave_address = DiscoverDevice(p_app_mode, SDA, SCL);
ShowHeader(*p_app_mode);
p_timonel = new Timonel(slave_address, SDA, SCL);
if (!(*p_app_mode)) {
// p_timonel = new Timonel(slave_address, SDA, SCL);
p_timonel->GetStatus();
PrintStatus(p_timonel);
} else {
//p_micro = new NbMicro(slave_address, SDA, SCL);
}
ShowMenu(*p_app_mode);
}
/* _________________
| |
| Main loop |
|_________________|
*/
void loop() {
if (new_key == true) {
new_key = false;
DiscoverDevice(p_app_mode, SDA, SCL);
USE_SERIAL.printf_P("\b\n\r");
if (*p_app_mode) {
// ....................
// . APPLICATION MODE .
// ....................
switch (key) {
// *********************************
// * Test app ||| STDPB1_1 Command *
// *********************************
case 'a':
case 'A': {
USE_SERIAL.printf_P("\n\rApplication Cmd >>> Starting blink");
byte ret = p_timonel->TwiCmdXmit(SETIO1_1, ACKIO1_1);
if (ret) {
USE_SERIAL.printf_P(" > Error: %d\n\n\r", ret);
} else {
USE_SERIAL.printf_P(" > OK!\n\n\r");
}
break;
}
// *********************************
// * Test app ||| STDPB1_0 Command *
// *********************************
case 's':
case 'S': {
USE_SERIAL.printf_P("\n\rApplication Cmd >>> Stopping blink");
byte ret = p_timonel->TwiCmdXmit(SETIO1_0, ACKIO1_0);
if (ret) {
USE_SERIAL.printf_P(" > Error: %d\n\n\r", ret);
} else {
USE_SERIAL.printf_P(" > OK!\n\n\r");
}
break;
}
// *********************************
// * Test app ||| RESETINY Command *
// *********************************
case 'z':
case 'Z': {
byte ret = p_timonel->TwiCmdXmit(RESETMCU, ACKRESET);
USE_SERIAL.printf_P("\n .\n\r . .\n\r. . .\n\n\r");
if (ret) {
USE_SERIAL.printf_P(" > Error: %d\n\n\r", ret);
} else {
USE_SERIAL.printf_P(" > OK Resetting ATtiny85 -> going back to bootloader!\n\r");
}
delay(MODE_SWITCH_DLY);
// ESP.restart();
delete p_timonel;
USE_SERIAL.printf_P("\n\rWaiting for device ");
uint8_t slave_address = DiscoverDevice(p_app_mode, SDA, SCL);
//USE_SERIAL.printf_P("\n\r");
p_timonel = new Timonel(slave_address, SDA, SCL);
ShowHeader(*p_app_mode);
USE_SERIAL.printf_P("\n\r");
break;
}
// ******************
// * ? Help command *
// ******************
case '?':
case 'h':
case 'H': {
USE_SERIAL.printf_P("\n\r Help: Available application commands:\n\r");
USE_SERIAL.printf_P(" =====================================\n\r");
USE_SERIAL.printf_P(" a) Start LED blinking on device PB1.\n\r");
USE_SERIAL.printf_P(" s) Stop LED blinking on device PB1.\n\r");
USE_SERIAL.printf_P(" z) Reset Tiny85 and jump back to bootloader.\n\n\r");
break;
}
}
} else {
// ...................
// . BOOTLOADER MODE .
// ...................
switch (key) {
// ******************
// * Restart master *
// ******************
case 'z':
case 'Z': {
USE_SERIAL.printf_P("\nResetting TWI Master ...\n\r\n.\n.\n.\n");
delay(MODE_SWITCH_DLY);
ESP.restart();
break;
}
// ********************************
// * Timonel ::: GETTMNLV command *
// ********************************
case 'v':
case 'V':
case 13: {
USE_SERIAL.printf_P("\nBootloader Cmd >>> Get bootloader version ...\r\n");
PrintStatus(p_timonel);
//p_timonel->GetStatus();
//Timonel::Status sts = p_timonel->GetStatus();
//Timonel::Status sts = PrintStatus(p_timonel);
// if ((sts.features_code >> F_CMD_SETPGADDR) & true) {
// p_timonel->InitMicro();
// }
TwiBus twi_bus(SDA, SCL);
twi_bus.ScanBus(p_app_mode);
break;
}
// ********************************
// * Timonel ::: EXITTMNL command *
// ********************************
case 'r':
case 'R': {
USE_SERIAL.printf_P("\nBootloader Cmd >>> Run application ...\r\n");
USE_SERIAL.printf_P("\n. . .\n\r . .\n\r .\n\n\r");
USE_SERIAL.printf_P("Please wait ...\n\n\r");
// The GetStatus command below is to ensure that the remote device is properly initialized
// before running this case's command (e.g. when running after a firmware deletion)
// p_timonel->GetStatus();
uint8_t cmd_errors = p_timonel->RunApplication();
if (cmd_errors == 0) {
USE_SERIAL.printf_P("Bootloader exit successful, running the user application (if there is one) ...\r\n");
} else {
USE_SERIAL.printf_P(" [ command error! %d ]", cmd_errors);
}
delay(MODE_SWITCH_DLY);
delete p_timonel;
USE_SERIAL.printf_P("\n\rWaiting for device ");
uint8_t slave_address = DiscoverDevice(p_app_mode, SDA, SCL);
p_timonel = new Timonel(slave_address, SDA, SCL);
ShowHeader(*p_app_mode);
USE_SERIAL.printf_P("\n\r");
break;
}
// ********************************
// * Timonel ::: DELFLASH command *
// ********************************
case 'e':
case 'E': {
USE_SERIAL.printf_P("\n\rBootloader Cmd >>> Delete app firmware from flash memory, \x1b[5mPLEASE WAIT\x1b[0m ...");
uint8_t cmd_errors = p_timonel->DeleteApplication();
USE_SERIAL.printf_P("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
if (cmd_errors == 0) {
USE_SERIAL.printf_P(" successful ");
} else {
USE_SERIAL.printf_P(" [ command error! %d ]", cmd_errors);
}
USE_SERIAL.printf_P("\n\r");
// USE_SERIAL.printf_P("\n\rDeleting firmware ");
DiscoverDevice(p_app_mode, SDA, SCL);
// USE_SERIAL.printf_P("\n\r");
break;
}
// ********************************
// * Timonel ::: STPGADDR command *
// ********************************
case 'b':
case 'B': {
Timonel::Status sts = p_timonel->GetStatus();
if (((sts.features_code >> F_CMD_SETPGADDR) & true) == false) {
USE_SERIAL.printf_P("\n\rSet address command not supported by current Timonel features ...\n\r");
break;
}
USE_SERIAL.printf_P("\n\rPlease enter the flash memory page base address: ");
while (new_word == false) {
flash_page_addr = ReadWord();
}
if (new_word == true) {
USE_SERIAL.printf_P("\n\rFlash memory page base address: %d\r\n", flash_page_addr);
USE_SERIAL.printf_P("Address high byte: %d (<< 8) + Address low byte: %d\n\r", (flash_page_addr & 0xFF00) >> 8,
flash_page_addr & 0xFF);
if (sts.bootloader_start > MCU_TOTAL_MEM) {
USE_SERIAL.printf_P("\n\n\rWarning: Timonel bootloader start address unknown, please run 'version' command to find it !\n\r");
break;
}
if ((flash_page_addr > (sts.bootloader_start - SPM_PAGESIZE)) | (flash_page_addr == 0xFFFF)) {
USE_SERIAL.printf_P("\n\rWarning: The highest flash page address available is %d (0x%X), please correct it !!!\n\n\r", sts.bootloader_start - SPM_PAGESIZE, sts.bootloader_start - SPM_PAGESIZE);
flash_page_addr = 0x0000;
break;
}
}
new_word = false;
break;
}
// ********************************
// * Timonel ::: WRITPAGE command *
// ********************************
case 'w':
case 'W': {
USE_SERIAL.printf_P("\n\rBootloader Cmd >>> Firmware upload to flash memory, \x1b[5mPLEASE WAIT\x1b[0m ...");
// The GetStatus command below is to ensure that the remote device is properly initialized
// before running this case's command (e.g. when running after a firmware deletion)
// p_timonel->GetStatus();
uint8_t cmd_errors = p_timonel->UploadApplication(payload, sizeof(payload), flash_page_addr);
USE_SERIAL.printf_P("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
if (cmd_errors == 0) {
USE_SERIAL.printf_P(" successful, press 'r' to run the user app");
} else {
USE_SERIAL.printf_P(" [ command error! %d ]", cmd_errors);
}
USE_SERIAL.printf_P("\n\n\r");
break;
}
#if ((defined FEATURES_CODE) && ((FEATURES_CODE >> F_CMD_READFLASH) & true))
// ********************************
// * Timonel ::: READFLSH command *
// ********************************
case 'm':
case 'M': {
// (uint16_t) flash_size: MCU flash memory size
// (uint8_t) slave_data_size: slave-to-master Xmit packet size
// (uint8_t) values_per_line: MCU memory values shown per line
p_timonel->DumpMemory(MCU_TOTAL_MEM, SLV_PACKET_SIZE, 32);
break;
}
#if ((defined EXT_FEATURES) && ((EXT_FEATURES >> E_EEPROM_ACCESS) & true))
// ********************************
// * Timonel ::: WRITEEPR command *
// ********************************
case 'p':
case 'P': {
new_word = false;
uint8_t eeprom_data = 0;
USE_SERIAL.printf_P("\n\rPlease enter the EEPROM memory address: ");
while (new_word == false) {
eeprom_addr = ReadWord();
}
if (eeprom_addr > EEPROM_TOP) {
USE_SERIAL.printf_P("\n\rWarning: The highest EEPROM address available is %d (0x%X), please correct it !!!", EEPROM_TOP, EEPROM_TOP);
new_word = false;
break;
}
USE_SERIAL.printf_P("\n\rPlease enter EEPROM data: ");
//new_key = false;
new_word = false;
while (new_word == false) {
eeprom_data = ReadWord();
}
if (new_word == true) {
USE_SERIAL.printf_P("\n\r");
new_key = false;
}
USE_SERIAL.printf_P("\n\rWriting %d to EEPROM address 0x%04X\n\n\r", eeprom_data, eeprom_addr);
p_timonel->WriteEeprom(eeprom_addr, eeprom_data);
break;
}
// ********************************
// * Timonel ::: READEEPR command *
// ********************************
case 'o':
case 'O': {
USE_SERIAL.printf_P("\n\r");
for (uint16_t ee_addr = 0; ee_addr <= EEPROM_TOP; ee_addr++) {
USE_SERIAL.printf_P("%03d=%02d ", ee_addr, p_timonel->ReadEeprom(ee_addr));
}
USE_SERIAL.printf_P("\n\n\r");
break;
}
#endif // EXT_FEATURES >> E_EEPROM_ACCESS
#endif /* CMD_READFLASH) */
// *******************
// * Unknown command *
// *******************
default: {
USE_SERIAL.printf_P("Command '%d' unknown ...\n\r", key);
break;
}
USE_SERIAL.printf_P("\n\r");
}
}
ShowMenu(*p_app_mode);
}
ReadChar();
}
// Function ReadChar
void ReadChar(void) {
if (USE_SERIAL.available() > 0) {
key = USE_SERIAL.read();
new_key = true;
}
}
// Function ReadWord
uint16_t ReadWord(void) {
const uint8_t data_length = 16;
char serial_data[data_length]; // an array to store the received data
static uint8_t ix = 0;
char rc, endMarker = 0xD; //standard is: char endMarker = '\n'
while (USE_SERIAL.available() > 0 && new_word == false) {
rc = USE_SERIAL.read();
if (rc != endMarker) {
serial_data[ix] = rc;
USE_SERIAL.printf_P("%c", serial_data[ix]);
ix++;
if (ix >= data_length) {
ix = data_length - 1;
}
} else {
serial_data[ix] = '\0'; // terminate the string
ix = 0;
new_word = true;
}
}
return ((uint16_t)atoi(serial_data));
}
// Function DiscoverDevice
uint8_t DiscoverDevice(bool *p_app_mode, const uint8_t sda, const uint8_t scl) {
uint8_t slave_address = 0;
unsigned long start_time = 0;
unsigned long now = millis();
uint8_t rotary_state = 1;
uint8_t *p_rotary = &rotary_state;
TwiBus twi_bus(sda, scl);
while (slave_address == 0) {
slave_address = twi_bus.ScanBus(p_app_mode);
now = millis();
if ((now - start_time) >= ROTATION_DLY) {
RotatingBar(p_rotary);
start_time = now;
}
}
USE_SERIAL.printf_P("\b\b>>> device active at address [%d]", slave_address);
USE_SERIAL.printf_P("\n\r");
return slave_address;
}
// Function print Timonel instance status
Timonel::Status PrintStatus(Timonel *timonel) {
Timonel::Status tml_status = timonel->GetStatus(); /* Get the instance id parameters received from the ATTiny85 */
uint8_t twi_address = timonel->GetTwiAddress();
uint8_t version_major = tml_status.version_major;
uint8_t version_minor = tml_status.version_minor;
uint16_t app_start = tml_status.application_start;
uint8_t app_start_msb = ((tml_status.application_start >> 8) & 0xFF);
uint8_t app_start_lsb = (tml_status.application_start & 0xFF);
uint16_t trampoline = ((~(((app_start_lsb << 8) | app_start_msb) & 0xFFF)) + 1);
trampoline = ((((tml_status.bootloader_start >> 1) - trampoline) & 0xFFF) << 1);
if ((tml_status.signature == T_SIGNATURE) && ((version_major != 0) || (version_minor != 0))) {
String version_mj_nick = "";
switch (version_major) {
case 0: {
version_mj_nick = "\"Pre-release\"";
break;
}
case 1: {
version_mj_nick = "\"Sandra\"";
break;
}
default: {
version_mj_nick = "\"Unknown\"";
break;
}
}
USE_SERIAL.printf_P("\n\r Timonel v%d.%d %s ", version_major, version_minor, version_mj_nick.c_str());
USE_SERIAL.printf_P("(TWI: %02d)\n\r", twi_address);
USE_SERIAL.printf_P(" ====================================\n\r");
USE_SERIAL.printf_P(" Bootloader address: 0x%X\n\r", tml_status.bootloader_start);
if (app_start != 0xFFFF) {
USE_SERIAL.printf_P(" Application start: 0x%04X (0x%X)\n\r", app_start, trampoline);
} else {
USE_SERIAL.printf_P(" Application start: 0x%04X (Not Set)\n\r", app_start);
}
USE_SERIAL.printf_P(" Features code: %d | %d ", tml_status.features_code, tml_status.ext_features_code);
if ((tml_status.ext_features_code >> E_AUTO_CLK_TWEAK) & true) {
USE_SERIAL.printf_P("(Auto)");
} else {
USE_SERIAL.printf_P("(Fixed)");
}
USE_SERIAL.printf_P("\n\r");
USE_SERIAL.printf_P(" Low fuse: 0x%02X\n\r", tml_status.low_fuse_setting);
USE_SERIAL.printf_P(" RC osc: 0x%02X", tml_status.oscillator_cal);
#if ((defined EXT_FEATURES) && ((EXT_FEATURES >> E_CMD_READDEVS) & true))
if ((tml_status.ext_features_code >> E_CMD_READDEVS) & true) {
Timonel::DevSettings dev_settings = timonel->GetDevSettings();
USE_SERIAL.printf_P("\n\r ....................................\n\r");
USE_SERIAL.printf_P(" Fuse settings: L=0x%02X H=0x%02X E=0x%02X\n\r", dev_settings.low_fuse_bits, dev_settings.high_fuse_bits, dev_settings.extended_fuse_bits);
USE_SERIAL.printf_P(" Lock bits: 0x%02X\n\r", dev_settings.lock_bits);
USE_SERIAL.printf_P(" Signature: 0x%02X 0x%02X 0x%02X\n\r", dev_settings.signature_byte_0, dev_settings.signature_byte_1, dev_settings.signature_byte_2);
USE_SERIAL.printf_P(" Oscillator: 8.0Mhz=0x%02X, 6.4Mhz=0x%02X", dev_settings.calibration_0, dev_settings.calibration_1);
}
#endif // E_CMD_READDEVS
USE_SERIAL.printf_P("\n\n\r");
} else {
USE_SERIAL.printf_P("\n\r *************************************************\n\r");
USE_SERIAL.printf_P(" * User application running on TWI device %02d ... *\n\r", twi_address);
USE_SERIAL.printf_P(" *************************************************\n\n\r");
}
return tml_status;
}
// Function ShowHeader
void ShowHeader(const bool app_mode) {
delay(125);
USE_SERIAL.printf_P("\n\r............................................................\n\r");
USE_SERIAL.printf_P(". Timonel I2C Bootloader and Application Test (v%d.%d.%d MSS) .\n\r", VER_MAJOR, VER_MINOR, VER_PATCH);
USE_SERIAL.printf_P("............................................................\n\r");
USE_SERIAL.printf_P(". Running mode: ");
if (app_mode) {
USE_SERIAL.printf_P("[ USER APPLICATION ] ");
} else {
USE_SERIAL.printf_P("[ TIMONEL BOOTLOADER ]");
}
USE_SERIAL.printf_P(" .\n\r");
USE_SERIAL.printf_P("............................................................\n\r");
}
// Function ShowMenu
void ShowMenu(const bool app_mode) {
if (app_mode) {
USE_SERIAL.printf_P("Application command ('z' reset tiny, 'a' blink, 's' stop, '?' help): \x1b[5m_\x1b[0m");
} else {
Timonel::Status sts = p_timonel->GetStatus();
USE_SERIAL.printf_P("Timonel bootloader ('z' reset master, 'v' version, 'r' run app, 'e' erase flash, 'w' write flash");
#if ((defined FEATURES_CODE) && ((FEATURES_CODE >> F_CMD_SETPGADDR) & true))
if ((sts.features_code >> F_CMD_SETPGADDR) & true) {
USE_SERIAL.printf_P(", 'b' set addr");
}
#endif // F_CMD_SETPGADDR
#if ((defined FEATURES_CODE) && ((FEATURES_CODE >> F_CMD_READFLASH) & true))
if ((sts.features_code >> F_CMD_READFLASH) & true) {
USE_SERIAL.printf_P(", 'm' mem dump");
}
#endif // F_CMD_READFLASH
#if ((defined EXT_FEATURES) && ((EXT_FEATURES >> E_EEPROM_ACCESS) & true))
if ((sts.ext_features_code >> E_EEPROM_ACCESS) & true) {
USE_SERIAL.printf_P(", 'o/p' read/write eeprom");
}
#endif // EXT_FEATURES >> E_EEPROM_ACCESS
USE_SERIAL.printf_P("): ");
USE_SERIAL.printf_P("\x1b[5m_\x1b[0m");
}
}
// Function clear screen
void ClrScr() {
USE_SERIAL.write(27); // ESC command
USE_SERIAL.print("[2J"); // clear screen command
USE_SERIAL.write(27); // ESC command
USE_SERIAL.print("[H"); // cursor to home command
}
// Function PrintLogo
void PrintLogo(void) {
USE_SERIAL.printf_P(" _ _\n\r");
USE_SERIAL.printf_P(" _ (_) | |\n\r");
USE_SERIAL.printf_P(" _| |_ _ ____ ___ ____ _____| |\n\r");
USE_SERIAL.printf_P(" (_ _) | \\ / _ \\| _ \\| ___ | |\n\r");
USE_SERIAL.printf_P(" | |_| | | | | |_| | | | | ____| |\n\r");
USE_SERIAL.printf_P(" \\__)_|_|_|_|\\___/|_| |_|_____)\\_)\n\r");
}
// Function RotaryDelay
void RotaryDelay(void) {
USE_SERIAL.printf_P("\b\b| ");
delay(ROTATION_DLY);
USE_SERIAL.printf_P("\b\b/ ");
delay(ROTATION_DLY);
USE_SERIAL.printf_P("\b\b- ");
delay(ROTATION_DLY);
USE_SERIAL.printf_P("\b\b\\ ");
delay(ROTATION_DLY);
}
// Function RotatingBar
void RotatingBar(uint8_t *rotary_state) {
switch (*rotary_state) {
case 1: {
USE_SERIAL.printf_P("\b\b| ");
*rotary_state += 1;
break;
}
case 2: {
USE_SERIAL.printf_P("\b\b/ ");
*rotary_state += 1;
break;
}
case 3: {
USE_SERIAL.printf_P("\b\b- ");
*rotary_state += 1;
break;
}
case 4: {
USE_SERIAL.printf_P("\b\b\\ ");
*rotary_state = 1;
break;
}
default: {
break;
}
}
}