-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.ino
1526 lines (1359 loc) · 42.7 KB
/
main.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
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Word clock, made by Jordy Moors (@moors7). With some great help from
Garrett Bartley (@wgbartley) and Paul Kourany (@Peekay123).
I'd appreciate it if you left this in here should you modify this code :)
Thanks!
*/
SYSTEM_MODE(SEMI_AUTOMATIC);
// This #include statement was automatically added by the Particle IDE.
#include "SparkIntervalTimer/SparkIntervalTimer.h"
// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_mfGFX/Adafruit_mfGFX.h"
// This #include statement was automatically added by the Particle IDE.
#include "RGBmatrixPanel/RGBmatrixPanel.h"
#include <math.h>
// This #include statement was automatically added by the Particle IDE.
#include "snake.h"
// =========================== Snake code =========================
void play_snake();
int length = 3;
bool update = true;
int Delay = 0;
unsigned long speed = game_speed;
unsigned long previousMillis = 0;
unsigned long currentMillis = 0;
// ========================== Snake code ==========================
// ========================== MATRIX ==============================
byte matrixBuffer [3] [16] [16]; // A 3 layer display buffer for the creation of various graphical effects
boolean intro = true; // Indicates if mode has just been entered after mode change.
unsigned long FrameTime = 0; // Keeps track of timeing between animation frames.
unsigned int FrameRate = 0; // Animation frame rate.
unsigned int frameCount = 0; // Keeps counts of the number of frames since the begining of current transition.
byte field = 1; // Divides frames into fields to allow traces to move at different speeds
typedef struct // Traces are sprite like graphical elements that can be
{ // manipulated in a variety of ways.
boolean active; // Active or inactive.
int regen; // Frame when the trace will regenerate.
byte xPos; // X position
byte yPos; // Y position
byte speed; // Speed
byte length; // Length
byte terminate; // Termination point, Should be at least 8 + Length
} trace;
trace streamerTrace[16]; // 16 traces in struct array for streamer animations
// ===========================/MATRIX=================================
int colorRandom[6][3] = {{255,0,0},{0,255,0},{0,0,255},{255,255,0},{0,255,255},{255,0,255}};
// Mode 0 = "Its MM minute(s) past/to HH"
// mode 1 = "Its HH oh 0M"
int timeMode = 0;
// displayMode
// 0 = clock
// 1 = Snake
// 2 = Matrix animation
// 3 = Digital
int displayMode = 0;
int specialModeNumber = -1;
int r = 255;
int g = 0;
int b = 0;
char pubstring[64];
char topLine[64] = {};
int8_t timeZone = -7;
unsigned long previousDisplayMillis = 0;
unsigned long delayTime = 5000;
// // allow us to use itoa() in this scope
extern char* itoa(int a, char* buffer, unsigned char radix);
void doWord(const uint8_t *w);
void blackOut();
void displayHour();
void doTime();
void displayMinute();
void mayTheForce();
void useTheForce();
void doOrDoNot();
int setMode(String command);
void lightLetter(int X, int Y, int red, int green, int blue);
/** Define RGB matrix panel GPIO pins **/
#if defined (STM32F10X_MD) //Core
#define CLK D6
#define OE D7
#define LAT A4
#define A A0
#define B A1
#define C A2
#define D A3
#endif
/** Define RGB matrix panel GPIO pins **/
#define CLK D6
#define OE D7
#define LAT TX
#define A A0
#define B A1
#define C A2
#define D RX
/****************************************/
/****************************************/
//#define X_MAX 31 // Matrix X max LED coordinate (for 2 displays placed next to each other)
//#define Y_MAX 31
/***** Create RGBmatrix Panel instance *****
Last parameter = 'true' enables double-buffering, for flicker-free,
buttery smooth animation. Note that NOTHING WILL SHOW ON THE DISPLAY
until the first call to swapBuffers(). This is normal. */
//RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, true);
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, true);
/*******************************************/
// ======================== Snake code ========================
mysnake* temp;
mysnake snake[(ledmatrix_length * ledmatrix_width) - (ledmatrix_length * 2) - (ledmatrix_width * 2) + 4]; //create snake matrix
mysnake* snakehead; //pointer to head of the snake
food apple;
food* applepointer;
Serpent Snake(&matrix);
// ======================= /Snake code ========================
// All the word positions/lengths
//x, y, length, height
static const uint8_t wordIts[8] = {0, 0, 3, 1};
static const uint8_t wordHalf[8] = {4, 0, 4, 1};
static const uint8_t wordTwenty[8] = {10, 0, 6, 1};
static const uint8_t wordFive[8] = {1, 1, 4, 1};
static const uint8_t wordTwo[8] = {5, 1, 3, 1};
static const uint8_t wordEight[8] = {8, 1, 5, 1};
static const uint8_t wordEighteen[8] = {8, 1, 8, 1};
static const uint8_t wordOne[8] = {0, 2, 3, 1};
static const uint8_t wordThirteen[8] = {4, 2, 8, 1};
static const uint8_t wordTen[8] = {12, 2, 3, 1};
static const uint8_t wordEleven[8] = {1, 3, 6, 1};
static const uint8_t wordThree[8] = {10, 3, 5, 1};
static const uint8_t wordA[8] = {0, 4, 1, 1};
static const uint8_t wordQuarter[8] = {2, 4, 7, 1};
static const uint8_t wordTwelve[8] = {10, 4, 6, 1};
static const uint8_t wordSix[8] = {1, 5, 3, 1};
static const uint8_t wordSixteen[8] = {1, 5, 7, 1};
static const uint8_t wordFour[8] = {8, 5, 4, 1};
static const uint8_t wordFourteen[8] = {8, 5, 8, 1};
static const uint8_t wordSeven[8] = {0, 6, 5, 1};
static const uint8_t wordSeventeen[8] = {0, 6, 9, 1};
static const uint8_t wordNine[8] = {8, 6, 4, 1};
static const uint8_t wordNineteen[8] = {8, 6, 8, 1};
static const uint8_t wordMinute[8] = {1, 7, 6, 1};
static const uint8_t wordMinutes[8] = {1, 7, 7, 1};
static const uint8_t wordPast[8] = {9, 7, 4, 1};
static const uint8_t wordTo[8] = {12, 7, 2, 1};
static const uint8_t wordO[8] = {13, 7, 1, 1};
static const uint8_t wordOh[8] = {13, 7, 2, 1};
static const uint8_t wordFifty2[8] = {2, 8, 5, 1};
static const uint8_t wordTwenty2[8] = {9, 8, 6, 1};
static const uint8_t wordTwelve2[8] = {2, 9, 6, 1};
static const uint8_t wordTen2[8] = {8, 9, 3, 1};
static const uint8_t wordForty2[8] = {11, 9, 5, 1};
static const uint8_t wordThirty2[8] = {1, 10, 6, 1};
static const uint8_t wordThirteen2[8] = {7, 10, 8, 1};
static const uint8_t wordFifteen2[8] = {0, 11, 7, 1};
static const uint8_t wordThree2[8] = {10, 11, 5, 1};
static const uint8_t wordEight2[8] = {0, 12, 5, 1};
static const uint8_t wordEighteen2[8] = {0, 12, 8, 1};
static const uint8_t wordSix2[8] = {8, 12, 3, 1};
static const uint8_t wordSixteen2[8] = {8, 12, 12, 1};
static const uint8_t wordFive2[8] = {0, 13, 4, 1};
static const uint8_t wordTwo2[8] = {4, 13, 3, 1};
static const uint8_t wordOne2[8] = {6, 13, 3, 1};
static const uint8_t wordEleven2[8] = {8, 13, 6, 1};
static const uint8_t wordFour2[8] = {0, 14, 4, 1};
static const uint8_t wordFourteen2[8] = {0, 14, 8, 1};
static const uint8_t wordNine2[8] = {7, 14, 4, 1};
static const uint8_t wordNineteen2[8] = {7, 14, 8, 1};
static const uint8_t wordSeven2[8] = {0, 15, 5, 1};
static const uint8_t wordSeventeen2[8] = {0, 15, 9, 1};
static const uint8_t wordOclock[8] = {9, 15, 6, 1};
/* === May/Use the Force be with you === */
static const uint8_t wordUse[8] = {1, 4, 1, 3};
static const uint8_t wordMay[8] = {0, 3, 1, 3};
static const uint8_t wordThe[8] = {5, 1, 1, 3};
static const uint8_t wordForce[8] = {7, 0, 1, 5};
static const uint8_t wordBe[8] = {1, 8, 1, 2};
static const uint8_t wordWith[8] = {3, 9, 1, 4};
static const uint8_t wordYou[8] = {15, 13, 1, 3};
/* ===================================== */
/* === Do or do not, there is no try === */
static const uint8_t wordDo[8] = {0, 1, 1, 2};
static const uint8_t wordOr[8] = {7, 1, 1, 2};
static const uint8_t wordDo2[8] = {9, 4, 1, 2};
static const uint8_t wordNot[8] = {15, 1, 1, 3};
static const uint8_t wordThere[8] = {3, 11, 1, 5};
static const uint8_t wordIs[8] = {9, 10, 1, 2};
static const uint8_t wordNo[8] = {12, 8, 1, 2};
static const uint8_t wordTry[8] = {15, 7, 1, 3};
/* =================================== */
/* === Sith / Jedi / Yoda ============ */
static const uint8_t wordJedi[8] = {0, 7, 1, 4};
static const uint8_t wordSith[8] = {8, 7, 1, 4};
static const uint8_t wordYoda[8] = {15, 9, 1, 4};
/* =================================== */
void change_modes()
{
int pickedColor = random(5);
r = colorRandom[pickedColor][0];
g = colorRandom[pickedColor][1];
b = colorRandom[pickedColor][2];
switch (displayMode){
case 0:
displayMode = 2;
break;
case 2:
displayMode = 3;
break;
case 3:
displayMode = 0;
break;
default:
displayMode = 0;
break;
}
}
Timer timer(15000, change_modes);
void setup() {
Particle.connect();
// wait for the cloud connection to be connected or timeout after 10 seconds
if (!waitFor(Particle.connected, 10000)) {
Time.setTime(1463662528);
//doTime();
}
// Initialize the panel
matrix.begin();
Particle.function("text", text); // scroll a text over the matrix
Particle.function("handleparams",handleParams); // handles all parameters.
// ===== Snake =====
snakehead = &snake[(ledmatrix_length * ledmatrix_width) - (ledmatrix_length * 2) - (ledmatrix_width * 2) + 3];
apple.row = 5;
apple.column = 5;
applepointer = &apple;
Snake.snake_intialization(snake); //initialize snake location and direction
// ===== Snake =====
Time.zone(timeZone); // Set time zone
doTime();
//uncomment this for demo mode
timer.start();
}
void loop() {
currentMillis = millis();
if (specialModeNumber >= 0) {
delayTime = 5000;
blackOut();
switch (specialModeNumber) {
case 0:
useTheForce(); //display "use the force"
delayTime = 2500;
break;
case 1:
mayTheForce(); // display "may the force be with you"
delayTime = 2500;
break;
case 2:
doOrDoNot(); // display "Do ot do not, there is no try"
delayTime = 2500;
break;
case 3:
//lightLetter(14, 1, 0, 255, 0); // light up the Ion cannon pixel
shootCannon();
delayTime = 18000;
break;
case 4:
doWord(wordJedi); // display "Jedi"
delayTime = 2500;
break;
case 5:
doWord(wordSith); // display "Sith"
delayTime = 2500;
break;
case 6:
doWord(wordYoda); // display "Yoda"
delayTime = 2500;
break;
}
matrix.swapBuffers(true);
//delay(delayTime);
specialModeNumber = -1;
}
if (currentMillis - previousDisplayMillis > delayTime){
previousDisplayMillis = currentMillis;
switch (displayMode) {
case 0: // display the 'normal' wordclock
doTime();
break;
case 1: // play Snake
if (currentMillis - previousMillis > speed) {
// save the last time you blinked the LED
previousMillis = currentMillis;
update ? snake_alive() : snake_dead();
}
break;
case 2: // display matrix animation
if ( currentMillis >= FrameTime + FrameRate) { // Runs animation function every frame time
FrameTime = currentMillis;
streamerAnimation(); // Just streamer traces animation, no time.
}
matrix.swapBuffers(true);
break;
case 3: // Show time in digital fashion
printTimeBig();
break;
default: // default to normal wordclock
doTime();
break;
}
delayTime = 0;
}
}
void scrollBigMessage(char *m, int timeDelay = 50) {
matrix.setTextSize(2);
matrix.setTextWrap(false);
matrix.setTextColor(matrix.Color333(r,g,b));
int l = (strlen(m) * -12) - 32;
for (int i = 32; i > l; i -= 2) {
matrix.fillScreen(0);
matrix.swapBuffers(true);
matrix.setCursor(i, 8);
matrix.print(m);
matrix.swapBuffers(false);
delay(timeDelay);
Particle.process();
}
}
int text(String command) {
command.toCharArray(topLine, 64);
scrollBigMessage(topLine);
return 0;
}
// this function automagically gets called upon a matching POST request
int handleParams(String command)
{
//look for the matching argument <-- max of 64 characters long
int p = 0;
while (p<(int)command.length()) {
int i = command.indexOf(',',p);
if (i<0) i = command.length();
int j = command.indexOf('=',p);
if (j<0) break;
String key = command.substring(p,j).toUpperCase();
String value = command.substring(j+1,i);
int val = value.toInt();
// Modes
if (key=="SETTIMEMODE") // 0 - 1
timeMode = val;
else if (key=="SPECIALS") // 0 - 6
specialModeNumber = val;
else if (key=="DISPLAYMODE") // 0 - 3
displayMode = val;
// text color
else if (key=="R") // 0 - 255
r = val;
else if (key=="G")
g = val;
else if (key=="B")
b = val;
// Snake
else if (key=="DIRECTION")
Snake.set_new_direction(val); // 0 - 3
else if (key=="SNAKESPEED") // 50 - 250
speed = val;
else if (key=="SYSRESET") // instant
System.reset();
else if (key=="MATRIXSPEED")
FrameRate = val;
p = i+1;
}
return 1;
}
void shootCannon(){
// X - X - X - - - -
// - - - -> X - X -> - X -
// X - X - X - - - -
Particle.publish("shoot");
for (int i = 0; i < 38; i++){
blackOut();
lightLetter(13, 0, 0, 255, 0); // light up the top left
lightLetter(15, 0, 0, 255, 0); // top right
lightLetter(13, 2, 0, 255, 0);
lightLetter(15, 2, 0, 255, 0);
matrix.swapBuffers(true);
delay(100);
blackOut();
lightLetter(14, 0, 0, 255, 0);
lightLetter(14, 2, 0, 255, 0);
lightLetter(13, 1, 0, 255, 0);
lightLetter(15, 1, 0, 255, 0);
matrix.swapBuffers(true);
delay(100);
}
blackOut();
lightLetter(14, 1, 0, 255, 0);
matrix.swapBuffers(true);
delay(100);
blackOut();
lightLetter(14, 1, 0, 255, 0);
matrix.swapBuffers(true);
delay(100);
blackOut();
for (int i = 0; i < 15; i++){
blackOut();
lightLetter(13, 0, 0, 255, 0); // light up the top left
lightLetter(15, 0, 0, 255, 0); // top right
lightLetter(13, 2, 0, 255, 0);
lightLetter(15, 2, 0, 255, 0);
matrix.swapBuffers(true);
delay(50);
blackOut();
lightLetter(14, 0, 0, 255, 0);
lightLetter(14, 2, 0, 255, 0);
lightLetter(13, 1, 0, 255, 0);
lightLetter(15, 1, 0, 255, 0);
matrix.swapBuffers(true);
delay(50);
}
blackOut();
lightLetter(14, 1, 0, 255, 0);
matrix.swapBuffers(true);
delay(500);
blackOut();
matrix.swapBuffers(true);
delay(100);
lightLetter(14, 1, 0, 255, 0);
matrix.swapBuffers(true);
delay(500);
blackOut();
matrix.swapBuffers(true);
delay(100);
lightLetter(14, 1, 0, 255, 0);
matrix.swapBuffers(true);
delay(3000);
blackOut();
delay(500);
}
void doTime() {
blackOut();
doWord(wordIts);
displayHour();
displayMinute();
matrix.swapBuffers(true);
delay(1000);
}
void printTimeBig() {
blackOut();
matrix.setTextSize(2);
matrix.setCursor(2 * 3, 0);
matrix.setTextColor(matrix.Color333(0, 7, 0));
switch (Time.hour()) {
case 0:
matrix.print("00");
break;
case 1:
matrix.print("01");
break;
case 2:
matrix.print("02");
break;
case 3:
matrix.print("03");
break;
case 4:
matrix.print("04");
break;
case 5:
matrix.print("05");
break;
case 6:
matrix.print("06");
break;
case 7:
matrix.print("07");
break;
case 8:
matrix.print("08");
break;
case 9:
matrix.print("09");
break;
default:
matrix.print(Time.hour());
}
matrix.setCursor(2 * 3, 2 * 8);
matrix.setTextColor(matrix.Color333(0, 7, 7));
switch (Time.minute()) {
case 0:
matrix.print("00");
break;
case 1:
matrix.print("01");
break;
case 2:
matrix.print("02");
break;
case 3:
matrix.print("03");
break;
case 4:
matrix.print("04");
break;
case 5:
matrix.print("05");
break;
case 6:
matrix.print("06");
break;
case 7:
matrix.print("07");
break;
case 8:
matrix.print("08");
break;
case 9:
matrix.print("09");
break;
default:
matrix.print(Time.minute());
}
matrix.swapBuffers(true);
delay(1000);
}
//Display functions
void blackOut() {
matrix.fillScreen(matrix.Color444(0, 0, 0));
}
void useTheForce() {
doWord(wordUse);
doWord(wordThe);
doWord(wordForce);
}
void mayTheForce() {
doWord(wordMay);
doWord(wordThe);
doWord(wordForce);
doWord(wordBe);
doWord(wordWith);
doWord(wordYou);
}
void doOrDoNot() {
doWord(wordDo);
doWord(wordOr);
doWord(wordDo2);
doWord(wordNot);
doWord(wordThere);
doWord(wordIs);
doWord(wordNo);
doWord(wordTry);
}
void lightLetter(int X, int Y, int red = r, int green = g, int blue = b) {
X *= 2;
Y *= 2;
matrix.drawPixel(X , Y , matrix.Color333(red, green, blue));
matrix.drawPixel(X + 1 , Y , matrix.Color333(red, green, blue));
matrix.drawPixel(X , Y + 1 , matrix.Color333(red, green, blue));
matrix.drawPixel(X + 1 , Y + 1 , matrix.Color333(red, green, blue));
}
//(un)set Words
void doWord(const uint8_t *w) {
int X = 0;
int Y = 0;
//finish loop per vertical row
for (int i = 0; i < w[3]; i++) {
//finish loops horizontally
for (int j = 0; j < w[2]; j++) {
X = (w[0] + j);
Y = (w[1] + i);
lightLetter(X, Y);
}
}
}
//set hours/minutes
void displayHour() {
int h = Time.hourFormat12();
int m = Time.minute();
if (timeMode == 0) {
if (m != 0 && m <= 30) {
doWord(wordPast);
}
else if (m > 30) {
h++;
if (h == 13) {
h = 1;
}
doWord(wordTo);
}
// hour
switch (h) {
case 1:
(m != 0) ? doWord(wordOne2) : doWord(wordOne);
break;
case 2:
(m != 0) ? doWord(wordTwo2) : doWord(wordTwo);
break;
case 3:
(m != 0) ? doWord(wordThree2) : doWord(wordThree);
break;
case 4:
(m != 0) ? doWord(wordFour2) : doWord(wordFour);
break;
case 5:
(m != 0) ? doWord(wordFive2) : doWord(wordFive);
break;
case 6:
(m != 0) ? doWord(wordSix2) : doWord(wordSix);
break;
case 7:
(m != 0) ? doWord(wordSeven2) : doWord(wordSeven);
break;
case 8:
(m != 0) ? doWord(wordEight2) : doWord(wordEight);
break;
case 9:
(m != 0) ? doWord(wordNine2) : doWord(wordNine);
break;
case 10:
(m != 0) ? doWord(wordTen2) : doWord(wordTen);
break;
case 11:
(m != 0) ? doWord(wordEleven2) : doWord(wordEleven);
break;
case 12:
(m != 0) ? doWord(wordTwelve2) : doWord(wordTwelve);
break;
}
}
else if (timeMode == 1) {
switch (h) {
case 1:
doWord(wordOne);
break;
case 2:
doWord(wordTwo);
break;
case 3:
doWord(wordThree);
break;
case 4:
doWord(wordFour);
break;
case 5:
doWord(wordFive);
break;
case 6:
doWord(wordSix);
break;
case 7:
doWord(wordSeven);
break;
case 8:
doWord(wordEight);
break;
case 9:
doWord(wordNine);
break;
case 10:
doWord(wordTen);
break;
case 11:
doWord(wordEleven);
break;
case 12:
doWord(wordTwelve);
break;
}
}
}
void displayMinute() {
int m = Time.minute();
if (timeMode == 0) {
switch (m) {
case 0:
doWord(wordOclock);
break;
case 1:
doWord(wordOne);
doWord(wordMinute);
break;
case 2:
doWord(wordTwo);
break;
case 3:
doWord(wordThree);
break;
case 4:
doWord(wordFour);
break;
case 5:
doWord(wordFive);
break;
case 6:
doWord(wordSix);
break;
case 7:
doWord(wordSeven);
break;
case 8:
doWord(wordEight);
break;
case 9:
doWord(wordNine);
break;
case 10:
doWord(wordTen);
break;
case 11:
doWord(wordEleven);
break;
case 12:
doWord(wordTwelve);
break;
case 13:
doWord(wordThirteen);
break;
case 14:
doWord(wordFourteen);
break;
case 15:
doWord(wordA);
doWord(wordQuarter);
break;
case 16:
doWord(wordSixteen);
break;
case 17:
doWord(wordSeventeen);
break;
case 18:
doWord(wordEighteen);
break;
case 19:
doWord(wordNineteen);
break;
case 20:
doWord(wordTwenty);
break;
case 21:
doWord(wordTwenty);
doWord(wordOne);
break;
case 22:
doWord(wordTwenty);
doWord(wordTwo);
break;
case 23:
doWord(wordTwenty);
doWord(wordThree);
break;
case 24:
doWord(wordTwenty);
doWord(wordFour);
break;
case 25:
doWord(wordTwenty);
doWord(wordFive);
break;
case 26:
doWord(wordTwenty);
doWord(wordSix);
break;
case 27:
doWord(wordTwenty);
doWord(wordEight);
break;
case 28:
doWord(wordTwenty);
doWord(wordEight);
break;
case 29:
doWord(wordTwenty);
doWord(wordNine);
break;
case 30:
doWord(wordHalf);
break;
case 31:
doWord(wordTwenty);
doWord(wordNine);
break;
case 32:
doWord(wordTwenty);
doWord(wordEight);
break;
case 33:
doWord(wordTwenty);
doWord(wordSeven);
break;
case 34:
doWord(wordTwenty);
doWord(wordSix);
break;
case 35:
doWord(wordTwenty);
doWord(wordFive);
break;
case 36:
doWord(wordTwenty);
doWord(wordFour);
break;
case 37:
doWord(wordTwenty);
doWord(wordThree);
break;
case 38:
doWord(wordTwenty);
doWord(wordTwo);
break;
case 39:
doWord(wordTwenty);
doWord(wordOne);
break;
case 40:
doWord(wordTwenty);
break;
case 41:
doWord(wordNineteen);
break;
case 42:
doWord(wordEighteen);
break;
case 43:
doWord(wordSeventeen);
break;
case 44:
doWord(wordSixteen);
break;
case 45:
doWord(wordA);
doWord(wordQuarter);
break;
case 46:
doWord(wordFourteen);
break;
case 47:
doWord(wordThirteen);
break;
case 48:
doWord(wordTwelve);
break;
case 49:
doWord(wordEleven);
break;
case 50:
doWord(wordTen);
break;
case 51:
doWord(wordNine);
break;
case 52:
doWord(wordEight);
break;
case 53:
doWord(wordSeven);
break;
case 54:
doWord(wordSix);
break;
case 55:
doWord(wordFive);
break;
case 56:
doWord(wordFour);
break;
case 57:
doWord(wordThree);
break;
case 58:
doWord(wordTwo);
break;
case 59:
doWord(wordOne);
doWord(wordMinute);
break;
}
if (m != 0 && m != 1 && m != 15 && m != 30 && m != 45 && m != 59) {
doWord(wordMinutes);
}
}
else if (timeMode == 1) {
switch (m) {
case 0:
doWord(wordOclock);
break;
case 1:
doWord(wordO);
doWord(wordOne2);
break;
case 2:
doWord(wordO);
doWord(wordTwo2);
break;