forked from thehookup/Holiday_LEDs_2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Holiday_LED_2.0_6_Zones.ino
2606 lines (2321 loc) · 99.8 KB
/
Holiday_LED_2.0_6_Zones.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
/***************** NEEDED TO MAKE NODEMCU WORK ***************************/
#define FASTLED_INTERRUPT_RETRY_COUNT 0
#define FASTLED_ESP8266_RAW_PIN_ORDER
/****************** LIBRARY SECTION *************************************/
#include <FastLED.h> //https://github.com/FastLED/FastLED
#include <SimpleTimer.h> //https://github.com/thehookup/Simple-Timer-Library
#include <PubSubClient.h> //https://github.com/knolleary/pubsubclient
#include <ESP8266WiFi.h> //if you get an error here you need to install the ESP8266 board manager
#include <ESP8266mDNS.h> //if you get an error here you need to install the ESP8266 board manager
#include <ArduinoOTA.h> //ArduinoOTA is now included with the ArduinoIDE
/***************** START USER CONFIG SECTION *********************************/
#define USER_SSID "YOUR_WIRELESS_SSID"
#define USER_PASSWORD "YOUR_WIRELESS_PW"
#define USER_MQTT_SERVER "YOUR_MQTT_SERVER_ADDRESS"
#define USER_MQTT_PORT 1883
#define USER_MQTT_USERNAME "YOUR_MQTT_USERNAME"
#define USER_MQTT_PASSWORD "YOUR_MQTT_PASSWORD"
#define USER_MQTT_CLIENT_NAME "LightMCU" // Used to define MQTT topics, MQTT Client ID, and ArduinoOTA
#define ZONEONE 1 //ZONEONE is pin D1, 1 = zone used 0 = zone unused
#define FIRSTZONE_SECTIONS 1 //Number of roof sections setup below
#define FIRSTZONE_LEDS 300 //Number of LEDS in this zone
#define FIRSTZONE_COLOR_ORDER GRB //Color orders, can be RGB, RBG, GRB, GBR, BRG, BGR
#define ZONETWO 1 //ZONETWO is pin D2, 1 = zone used 0 = zone unused
#define SECONDZONE_SECTIONS 3 //Number of roof sections setup below
#define SECONDZONE_LEDS 389 //Number of LEDS in this zone
#define SECONDZONE_COLOR_ORDER GRB //Color orders, can be RGB, RBG, GRB, GBR, BRG, BGR
#define ZONETHREE 1 //ZONETHREE is pin D3, 1 = zone used 0 = zone unused
#define THIRDZONE_SECTIONS 1 //Number of roof sections setup below
#define THIRDZONE_LEDS 300 //Number of LEDS in this zone
#define THIRDZONE_COLOR_ORDER GRB //Color orders, can be RGB, RBG, GRB, GBR, BRG, BGR
#define ZONEFOUR 1 //ZONEFOUR is pin D5, 1 = zone used 0 = zone unused
#define FOURTHZONE_SECTIONS 1 //Number of roof sections setup below
#define FOURTHZONE_LEDS 300 //Number of LEDS in this zone
#define FOURTHZONE_COLOR_ORDER GRB //Color orders, can be RGB, RBG, GRB, GBR, BRG, BGR
#define ZONEFIVE 1 //ZONEFIVE is pin D6, 1 = zone used 0 = zone unused
#define FIFTHZONE_SECTIONS 1 //Number of roof sections setup below
#define FIFTHZONE_LEDS 300 //Number of LEDS in this zone
#define FIFTHZONE_COLOR_ORDER GRB //Color orders, can be RGB, RBG, GRB, GBR, BRG, BGR
#define ZONESIX 1 //ZONESIX is pin D7, 1 = zone used 0 = zone unused
#define SIXTHZONE_SECTIONS 1 //Number of roof sections setup below
#define SIXTHZONE_LEDS 300 //Number of LEDS in this zone
#define SIXTHZONE_COLOR_ORDER GRB //Color orders, can be RGB, RBG, GRB, GBR, BRG, BGR
/***************************** ZONEONE ROOF SETUP *************************************/
/***************************** ZONEONE ROOF SETUP *************************************/
#if FIRSTZONE_SECTIONS >= 1
#define ZONEONE_SECTION1_START 0 //starting LED for this zone
#define ZONEONE_SECTION1_END 100 //ending LED for this zone
#define ZONEONE_SECTION1_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEONE_SECTION1_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIRSTZONE_SECTIONS >= 2
#define ZONEONE_SECTION2_START 0 //starting LED for this zone
#define ZONEONE_SECTION2_END 100 //ending LED for this zone
#define ZONEONE_SECTION2_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEONE_SECTION2_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIRSTZONE_SECTIONS >= 3
#define ZONEONE_SECTION3_START 0 //starting LED for this zone
#define ZONEONE_SECTION3_END 100 //ending LED for this zone
#define ZONEONE_SECTION3_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEONE_SECTION3_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIRSTZONE_SECTIONS >= 4
#define ZONEONE_SECTION4_START 0 //starting LED for this zone
#define ZONEONE_SECTION4_END 100 //ending LED for this zone
#define ZONEONE_SECTION4_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEONE_SECTION4_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIRSTZONE_SECTIONS >= 5
#define ZONEONE_SECTION5_START 0 //starting LED for this zone
#define ZONEONE_SECTION5_END 100 //ending LED for this zone
#define ZONEONE_SECTION5_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEONE_SECTION5_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIRSTZONE_SECTIONS >= 6
#define ZONEONE_SECTION6_START 0 //starting LED for this zone
#define ZONEONE_SECTION6_END 100 //ending LED for this zone
#define ZONEONE_SECTION6_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEONE_SECTION6_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIRSTZONE_SECTIONS >= 7
#define ZONEONE_SECTION7_START 0 //starting LED for this zone
#define ZONEONE_SECTION7_END 100 //ending LED for this zone
#define ZONEONE_SECTION7_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEONE_SECTION7_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIRSTZONE_SECTIONS >= 8
#define ZONEONE_SECTION8_START 0 //starting LED for this zone
#define ZONEONE_SECTION8_END 100 //ending LED for this zone
#define ZONEONE_SECTION8_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEONE_SECTION8_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIRSTZONE_SECTIONS >= 9
#define ZONEONE_SECTION9_START 0 //starting LED for this zone
#define ZONEONE_SECTION9_END 100 //ending LED for this zone
#define ZONEONE_SECTION9_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEONE_SECTION9_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
/***************************** ZONETWO ROOF SETUP *************************************/
/***************************** ZONETWO ROOF SETUP *************************************/
#if SECONDZONE_SECTIONS >= 1
#define ZONETWO_SECTION1_START 0 //starting LED for this zone
#define ZONETWO_SECTION1_END 44 //ending LED for this zone
#define ZONETWO_SECTION1_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETWO_SECTION1_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SECONDZONE_SECTIONS >= 2
#define ZONETWO_SECTION2_START 44 //starting LED for this zone
#define ZONETWO_SECTION2_END 87 //ending LED for this zone
#define ZONETWO_SECTION2_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETWO_SECTION2_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SECONDZONE_SECTIONS >= 3
#define ZONETWO_SECTION3_START 88 //starting LED for this zone
#define ZONETWO_SECTION3_END 94 //ending LED for this zone
#define ZONETWO_SECTION3_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETWO_SECTION3_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SECONDZONE_SECTIONS >= 4
#define ZONETWO_SECTION4_START 95 //starting LED for this zone
#define ZONETWO_SECTION4_END 182 //ending LED for this zone
#define ZONETWO_SECTION4_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETWO_SECTION4_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SECONDZONE_SECTIONS >= 5
#define ZONETWO_SECTION5_START 183 //starting LED for this zone
#define ZONETWO_SECTION5_END 189 //ending LED for this zone
#define ZONETWO_SECTION5_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETWO_SECTION5_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SECONDZONE_SECTIONS >= 6
#define ZONETWO_SECTION6_START 190 //starting LED for this zone
#define ZONETWO_SECTION6_END 286 //ending LED for this zone
#define ZONETWO_SECTION6_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETWO_SECTION6_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SECONDZONE_SECTIONS >= 7
#define ZONETWO_SECTION7_START 287 //starting LED for this zone
#define ZONETWO_SECTION7_END 382 //ending LED for this zone
#define ZONETWO_SECTION7_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETWO_SECTION7_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SECONDZONE_SECTIONS >= 8
#define ZONETWO_SECTION8_START 0 //starting LED for this zone
#define ZONETWO_SECTION8_END 100 //ending LED for this zone
#define ZONETWO_SECTION8_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETWO_SECTION8_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SECONDZONE_SECTIONS >= 9
#define ZONETWO_SECTION9_START 0 //starting LED for this zone
#define ZONETWO_SECTION9_END 100 //ending LED for this zone
#define ZONETWO_SECTION9_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETWO_SECTION9_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
/***************************** ZONETHREE ROOF SETUP *************************************/
/***************************** ZONETHREE ROOF SETUP *************************************/
#if THIRDZONE_SECTIONS >= 1
#define ZONETHREE_SECTION1_START 0 //starting LED for this zone
#define ZONETHREE_SECTION1_END 100 //ending LED for this zone
#define ZONETHREE_SECTION1_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETHREE_SECTION1_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if THIRDZONE_SECTIONS >= 2
#define ZONETHREE_SECTION2_START 0 //starting LED for this zone
#define ZONETHREE_SECTION2_END 100 //ending LED for this zone
#define ZONETHREE_SECTION2_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETHREE_SECTION2_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if THIRDZONE_SECTIONS >= 3
#define ZONETHREE_SECTION3_START 0 //starting LED for this zone
#define ZONETHREE_SECTION3_END 100 //ending LED for this zone
#define ZONETHREE_SECTION3_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETHREE_SECTION3_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if THIRDZONE_SECTIONS >= 4
#define ZONETHREE_SECTION4_START 0 //starting LED for this zone
#define ZONETHREE_SECTION4_END 100 //ending LED for this zone
#define ZONETHREE_SECTION4_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETHREE_SECTION4_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if THIRDZONE_SECTIONS >= 5
#define ZONETHREE_SECTION5_START 0 //starting LED for this zone
#define ZONETHREE_SECTION5_END 100 //ending LED for this zone
#define ZONETHREE_SECTION5_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETHREE_SECTION5_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if THIRDZONE_SECTIONS >= 6
#define ZONETHREE_SECTION6_START 0 //starting LED for this zone
#define ZONETHREE_SECTION6_END 100 //ending LED for this zone
#define ZONETHREE_SECTION6_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETHREE_SECTION6_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if THIRDZONE_SECTIONS >= 7
#define ZONETHREE_SECTION7_START 0 //starting LED for this zone
#define ZONETHREE_SECTION7_END 100 //ending LED for this zone
#define ZONETHREE_SECTION7_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETHREE_SECTION7_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if THIRDZONE_SECTIONS >= 8
#define ZONETHREE_SECTION8_START 0 //starting LED for this zone
#define ZONETHREE_SECTION8_END 100 //ending LED for this zone
#define ZONETHREE_SECTION8_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETHREE_SECTION8_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if THIRDZONE_SECTIONS >= 9
#define ZONETHREE_SECTION9_START 0 //starting LED for this zone
#define ZONETHREE_SECTION9_END 100 //ending LED for this zone
#define ZONETHREE_SECTION9_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONETHREE_SECTION9_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
/***************************** ZONEFOUR ROOF SETUP *************************************/
/***************************** ZONEFOUR ROOF SETUP *************************************/
#if FOURTHZONE_SECTIONS >= 1
#define ZONEFOUR_SECTION1_START 0 //starting LED for this zone
#define ZONEFOUR_SECTION1_END 100 //ending LED for this zone
#define ZONEFOUR_SECTION1_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFOUR_SECTION1_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FOURTHZONE_SECTIONS >= 2
#define ZONEFOUR_SECTION2_START 0 //starting LED for this zone
#define ZONEFOUR_SECTION2_END 100 //ending LED for this zone
#define ZONEFOUR_SECTION2_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFOUR_SECTION2_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FOURTHZONE_SECTIONS >= 3
#define ZONEFOUR_SECTION3_START 0 //starting LED for this zone
#define ZONEFOUR_SECTION3_END 100 //ending LED for this zone
#define ZONEFOUR_SECTION3_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFOUR_SECTION3_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FOURTHZONE_SECTIONS >= 4
#define ZONEFOUR_SECTION4_START 0 //starting LED for this zone
#define ZONEFOUR_SECTION4_END 100 //ending LED for this zone
#define ZONEFOUR_SECTION4_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFOUR_SECTION4_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FOURTHZONE_SECTIONS >= 5
#define ZONEFOUR_SECTION5_START 0 //starting LED for this zone
#define ZONEFOUR_SECTION5_END 100 //ending LED for this zone
#define ZONEFOUR_SECTION5_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFOUR_SECTION5_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FOURTHZONE_SECTIONS >= 6
#define ZONEFOUR_SECTION6_START 0 //starting LED for this zone
#define ZONEFOUR_SECTION6_END 100 //ending LED for this zone
#define ZONEFOUR_SECTION6_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFOUR_SECTION6_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FOURTHZONE_SECTIONS >= 7
#define ZONEFOUR_SECTION7_START 0 //starting LED for this zone
#define ZONEFOUR_SECTION7_END 100 //ending LED for this zone
#define ZONEFOUR_SECTION7_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFOUR_SECTION7_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FOURTHZONE_SECTIONS >= 8
#define ZONEFOUR_SECTION8_START 0 //starting LED for this zone
#define ZONEFOUR_SECTION8_END 100 //ending LED for this zone
#define ZONEFOUR_SECTION8_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFOUR_SECTION8_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FOURTHZONE_SECTIONS >= 9
#define ZONEFOUR_SECTION9_START 0 //starting LED for this zone
#define ZONEFOUR_SECTION9_END 100 //ending LED for this zone
#define ZONEFOUR_SECTION9_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFOUR_SECTION9_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
/***************************** ZONEFIVE ROOF SETUP *************************************/
/***************************** ZONEFIVE ROOF SETUP *************************************/
#if FIFTHZONE_SECTIONS >= 1
#define ZONEFIVE_SECTION1_START 0 //starting LED for this zone
#define ZONEFIVE_SECTION1_END 100 //ending LED for this zone
#define ZONEFIVE_SECTION1_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFIVE_SECTION1_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIFTHZONE_SECTIONS >= 2
#define ZONEFIVE_SECTION2_START 0 //starting LED for this zone
#define ZONEFIVE_SECTION2_END 100 //ending LED for this zone
#define ZONEFIVE_SECTION2_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFIVE_SECTION2_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIFTHZONE_SECTIONS >= 3
#define ZONEFIVE_SECTION3_START 0 //starting LED for this zone
#define ZONEFIVE_SECTION3_END 100 //ending LED for this zone
#define ZONEFIVE_SECTION3_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFIVE_SECTION3_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIFTHZONE_SECTIONS >= 4
#define ZONEFIVE_SECTION4_START 0 //starting LED for this zone
#define ZONEFIVE_SECTION4_END 100 //ending LED for this zone
#define ZONEFIVE_SECTION4_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFIVE_SECTION4_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIFTHZONE_SECTIONS >= 5
#define ZONEFIVE_SECTION5_START 0 //starting LED for this zone
#define ZONEFIVE_SECTION5_END 100 //ending LED for this zone
#define ZONEFIVE_SECTION5_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFIVE_SECTION5_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIFTHZONE_SECTIONS >= 6
#define ZONEFIVE_SECTION6_START 0 //starting LED for this zone
#define ZONEFIVE_SECTION6_END 100 //ending LED for this zone
#define ZONEFIVE_SECTION6_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFIVE_SECTION6_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIFTHZONE_SECTIONS >= 7
#define ZONEFIVE_SECTION7_START 0 //starting LED for this zone
#define ZONEFIVE_SECTION7_END 100 //ending LED for this zone
#define ZONEFIVE_SECTION7_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFIVE_SECTION7_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIFTHZONE_SECTIONS >= 8
#define ZONEFIVE_SECTION8_START 0 //starting LED for this zone
#define ZONEFIVE_SECTION8_END 100 //ending LED for this zone
#define ZONEFIVE_SECTION8_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFIVE_SECTION8_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if FIFTHZONE_SECTIONS >= 9
#define ZONEFIVE_SECTION9_START 0 //starting LED for this zone
#define ZONEFIVE_SECTION9_END 100 //ending LED for this zone
#define ZONEFIVE_SECTION9_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONEFIVE_SECTION9_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
/***************************** ZONESIX ROOF SETUP *************************************/
/***************************** ZONESIX ROOF SETUP *************************************/
#if SIXTHZONE_SECTIONS >= 1
#define ZONESIX_SECTION1_START 0 //starting LED for this zone
#define ZONESIX_SECTION1_END 100 //ending LED for this zone
#define ZONESIX_SECTION1_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONESIX_SECTION1_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SIXTHZONE_SECTIONS >= 2
#define ZONESIX_SECTION2_START 0 //starting LED for this zone
#define ZONESIX_SECTION2_END 100 //ending LED for this zone
#define ZONESIX_SECTION2_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONESIX_SECTION2_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SIXTHZONE_SECTIONS >= 3
#define ZONESIX_SECTION3_START 0 //starting LED for this zone
#define ZONESIX_SECTION3_END 100 //ending LED for this zone
#define ZONESIX_SECTION3_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONESIX_SECTION3_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SIXTHZONE_SECTIONS >= 4
#define ZONESIX_SECTION4_START 0 //starting LED for this zone
#define ZONESIX_SECTION4_END 100 //ending LED for this zone
#define ZONESIX_SECTION4_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONESIX_SECTION4_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SIXTHZONE_SECTIONS >= 5
#define ZONESIX_SECTION5_START 0 //starting LED for this zone
#define ZONESIX_SECTION5_END 100 //ending LED for this zone
#define ZONESIX_SECTION5_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONESIX_SECTION5_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SIXTHZONE_SECTIONS >= 6
#define ZONESIX_SECTION6_START 0 //starting LED for this zone
#define ZONESIX_SECTION6_END 100 //ending LED for this zone
#define ZONESIX_SECTION6_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONESIX_SECTION6_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SIXTHZONE_SECTIONS >= 7
#define ZONESIX_SECTION7_START 0 //starting LED for this zone
#define ZONESIX_SECTION7_END 100 //ending LED for this zone
#define ZONESIX_SECTION7_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONESIX_SECTION7_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SIXTHZONE_SECTIONS >= 8
#define ZONESIX_SECTION8_START 0 //starting LED for this zone
#define ZONESIX_SECTION8_END 100 //ending LED for this zone
#define ZONESIX_SECTION8_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONESIX_SECTION8_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
#if SIXTHZONE_SECTIONS >= 9
#define ZONESIX_SECTION9_START 0 //starting LED for this zone
#define ZONESIX_SECTION9_END 100 //ending LED for this zone
#define ZONESIX_SECTION9_START_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#define ZONESIX_SECTION9_END_FIRE 1 //would you like fire to begin from this point? 0 = no 1 = yes
#endif
/***************** END USER CONFIG SECTION *********************************/
/*********************** WIFI AND MQTT SETUP *****************************/
/*********************** DON'T CHANGE THIS INFO *****************************/
const char* ssid = USER_SSID ;
const char* password = USER_PASSWORD ;
const char* mqtt_server = USER_MQTT_SERVER ;
const int mqtt_port = USER_MQTT_PORT ;
const char *mqtt_user = USER_MQTT_USERNAME ;
const char *mqtt_pass = USER_MQTT_PASSWORD ;
const char *mqtt_client_name = USER_MQTT_CLIENT_NAME ;
/***************** DECLARATIONS ****************************************/
WiFiClient espClient;
PubSubClient client(espClient);
SimpleTimer timer;
struct Ball {
float position;
float velocity;
bool loaded;
bool reverse;
CRGB color;
int exploding;
float particlePosition;
};
#if ZONEONE == 1
CRGB firstZone[FIRSTZONE_LEDS];
const int Pin_firstZone = 5; //marked as D1 on the board
int center_firstZone = 25;
int step_firstZone = -1;
int previousLED_firstZone = 0;
const int fireworkCount_firstZone = 1;
#endif
#if ZONETWO == 1
CRGB secondZone[SECONDZONE_LEDS];
const int Pin_secondZone = 4; //marked as D2 on the board
int center_secondZone = 0;
int step_secondZone = -1;
int previousLED_secondZone = 0;
const int fireworkCount_secondZone = 3;
#endif
#if ZONETHREE == 1
CRGB thirdZone[THIRDZONE_LEDS];
const int Pin_thirdZone = 0; //marked as D3 on the board
int center_thirdZone = 0;
int step_thirdZone = -1;
int previousLED_thirdZone = 0;
const int fireworkCount_thirdZone = 1;
#endif
#if ZONEFOUR == 1
CRGB fourthZone[FOURTHZONE_LEDS];
const int Pin_fourthZone = 14; //marked as D5 on the board
int center_fourthZone = 0;
int step_fourthZone = -1;
int previousLED_fourthZone = 0;
const int fireworkCount_fourthZone = 1;
#endif
#if ZONEFIVE == 1
CRGB fifthZone[FIFTHZONE_LEDS];
const int Pin_fifthZone = 12; //marked as D6 on the board
int center_fifthZone = 0;
int step_fifthZone = -1;
int previousLED_fifthZone = 0;
const int fireworkCount_fifthZone = 1;
#endif
#if ZONESIX == 1
CRGB sixthZone[SIXTHZONE_LEDS];
const int Pin_sixthZone = 13; //marked as D7 on the board
int center_sixthZone = 0;
int step_sixthZone = -1;
int previousLED_sixthZone = 0;
const int fireworkCount_sixthZone = 1;
#endif
/***************** GENERAL VARIABLES *************************************/
CRGBPalette16 gPal;
int glitterFrequency = 100;
int lightningChance = 65280;
int SPARKING = 85;
int COOLING = 120;
bool gReverseDirection = false;
uint8_t mark = 0;
uint8_t gHue = 0;
int lastPosition = 1;
int lightning = 1;
bool boot = true;
bool showGlitter = false;
bool showLightning = false;
bool audioEffects = false;
byte red1 = 255;
byte green1 = 0;
byte blue1 = 0;
byte red2 = 0;
byte green2 = 255;
byte blue2 = 0;
byte red3 = 0;
byte green3 = 0;
byte blue3 = 255;
byte redG = 255;
byte greenG = 255;
byte blueG = 255;
char charPayload[50];
int maxLEDs = 500;
int locatorLED = 0;
char MQTT_locatorLED[50];
int locatorDelay = 1000;
String zoneEffects[6] = {"None","None","None","None","None","None"};
int zoneModifer[6] = { 100, 100, 100, 100, 100, 100 };
byte zoneBrightness[6] = {255,255,255,255,255,255};
uint8_t zoneStartPosition[6] = { 0, 0, 0, 0, 0, 0 };
bool showZoneLights[6] = { false, false, false, false, false, false };
const int colorsCount = 5;
String colorStates[colorsCount+1] = { "broken", "ON", "ON", "ON", "OFF", "OFF" };
byte rgbArray[colorsCount][3] = {{255,0,0},{255,0,0},{255,0,0},{255,0,0},{255,0,0}};
uint8_t colorsEnabled = 3;
CRGB availableColors[5] = {};
/***************** SYSTEM FUNCTIONS *************************************/
/***************** SYSTEM FUNCTIONS *************************************/
/***************** SYSTEM FUNCTIONS *************************************/
/***************** SYSTEM FUNCTIONS *************************************/
/***************** SYSTEM FUNCTIONS *************************************/
void setup_wifi()
{
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.hostname(USER_MQTT_CLIENT_NAME);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void reconnect()
{
// Loop until we're reconnected
int retries = 0;
while (!client.connected()) {
if(retries < 150)
{
Serial.print("Attempting MQTT connection...");
// Attempt to connect
if (client.connect(mqtt_client_name, mqtt_user, mqtt_pass))
{
Serial.println("connected");
// Once connected, publish an announcement...
if(boot == true)
{
client.publish(USER_MQTT_CLIENT_NAME"/checkIn","Rebooted");
boot = false;
}
if(boot == false)
{
client.publish(USER_MQTT_CLIENT_NAME"/checkIn","Reconnected");
}
publishStates();
// ... and resubscribe
client.subscribe(USER_MQTT_CLIENT_NAME"/configure");
client.subscribe(USER_MQTT_CLIENT_NAME"/modifier");
client.subscribe(USER_MQTT_CLIENT_NAME"/modifier/+");
client.subscribe(USER_MQTT_CLIENT_NAME"/effect");
client.subscribe(USER_MQTT_CLIENT_NAME"/effect/+");
client.subscribe(USER_MQTT_CLIENT_NAME"/state");
client.subscribe(USER_MQTT_CLIENT_NAME"/ColorSelector/+/Toggle");
client.subscribe(USER_MQTT_CLIENT_NAME"/color1");
client.subscribe(USER_MQTT_CLIENT_NAME"/color2");
client.subscribe(USER_MQTT_CLIENT_NAME"/color3");
client.subscribe(USER_MQTT_CLIENT_NAME"/color4");
client.subscribe(USER_MQTT_CLIENT_NAME"/color5");
client.subscribe(USER_MQTT_CLIENT_NAME"/power");
client.subscribe(USER_MQTT_CLIENT_NAME"/power/+");
client.subscribe(USER_MQTT_CLIENT_NAME"/brightness");
client.subscribe(USER_MQTT_CLIENT_NAME"/brightness/+");
client.subscribe(USER_MQTT_CLIENT_NAME"/addEffects");
client.subscribe(USER_MQTT_CLIENT_NAME"/lightningChance");
client.subscribe(USER_MQTT_CLIENT_NAME"/glitterChance");
client.subscribe(USER_MQTT_CLIENT_NAME"/glitterColor");
}
else
{
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
retries++;
// Wait 5 seconds before retrying
delay(5000);
}
}
if(retries > 1500)
{
ESP.restart();
}
}
}
void calculateMax()
{
#if ZONEONE == 1
maxLEDs = FIRSTZONE_LEDS;
#endif
#if ZONETWO == 1
maxLEDs = max(FIRSTZONE_LEDS, SECONDZONE_LEDS);
#endif
#if ZONETHREE == 1
maxLEDs = max(maxLEDs, THIRDZONE_LEDS);
#endif
#if ZONEFOUR == 1
maxLEDs = max(maxLEDs, FOURTHZONE_LEDS);
#endif
#if ZONEFIVE == 1
maxLEDs = max(maxLEDs, FIFTHZONE_LEDS);
#endif
#if ZONESIX == 1
maxLEDs = max(maxLEDs, SIXTHZONE_LEDS);
#endif
}
String boolToOnOff(bool setting)
{
String state = "OFF";
if(setting == true)
{
state = ("ON");
}
return state;
}
void publishStates()
{
char buff[50];
client.publish(USER_MQTT_CLIENT_NAME"/modifierState", itoa(zoneModifer[0], buff, 10));
client.publish(USER_MQTT_CLIENT_NAME"/audio/state", boolToOnOff(audioEffects).c_str());
client.publish(USER_MQTT_CLIENT_NAME"/glitter/state", boolToOnOff(showGlitter).c_str());
client.publish(USER_MQTT_CLIENT_NAME"/lightning/state", boolToOnOff(showLightning).c_str());
client.publish(USER_MQTT_CLIENT_NAME"/effectState", zoneEffects[0].c_str());
client.publish(USER_MQTT_CLIENT_NAME "/color1State", String(String(red1) + "," + String(green1) + "," + String(blue1)).c_str());
client.publish(USER_MQTT_CLIENT_NAME "/color2State", String(String(red2) + "," + String(green2) + "," + String(blue2)).c_str());
client.publish(USER_MQTT_CLIENT_NAME "/color3State", String(String(red3) + "," + String(green3) + "," + String(blue3)).c_str());
client.publish(USER_MQTT_CLIENT_NAME "/glitterColorState", String(String(redG) + "," + String(greenG) + "," + String(blueG)).c_str());
client.publish(USER_MQTT_CLIENT_NAME "/glitterChanceState", itoa(glitterFrequency, buff, 10));
client.publish(USER_MQTT_CLIENT_NAME "/lightningChanceState", itoa(65535-lightningChance, buff, 10));
client.publish(USER_MQTT_CLIENT_NAME "/brightnessState", itoa(zoneBrightness[0], buff, 10));
client.publish(USER_MQTT_CLIENT_NAME "/powerState", boolToOnOff(showZoneLights[0]).c_str());
#if ZONEONE == 1
client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone1", itoa(zoneModifer[0], buff, 10));
client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone1", boolToOnOff(showZoneLights[0]).c_str());
client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone1", zoneEffects[0].c_str());
client.publish(USER_MQTT_CLIENT_NAME "/brightnessStateZone1", itoa(zoneBrightness[0], buff, 10));
#endif
#if ZONETWO == 1
client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone2", itoa(zoneModifer[1], buff, 10));
client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone2", boolToOnOff(showZoneLights[1]).c_str());
client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone2", zoneEffects[1].c_str());
client.publish(USER_MQTT_CLIENT_NAME "/brightnessStateZone2", itoa(zoneBrightness[1], buff, 10));
#endif
#if ZONETHREE == 1
client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone3", itoa(zoneModifer[2], buff, 10));
client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone3", boolToOnOff(showZoneLights[2]).c_str());
client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone3", zoneEffects[2].c_str());
client.publish(USER_MQTT_CLIENT_NAME "/brightnessStateZone3", itoa(zoneBrightness[2], buff, 10));
#endif
#if ZONEFOUR == 1
client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone4", itoa(zoneModifer[3], buff, 10));
client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone4", boolToOnOff(showZoneLights[3]).c_str());
client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone4", zoneEffects[3].c_str());
client.publish(USER_MQTT_CLIENT_NAME "/brightnessStateZone4", itoa(zoneBrightness[3], buff, 10));
#endif
#if ZONEFIVE == 1
client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone5", itoa(zoneModifer[4], buff, 10));
client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone5", boolToOnOff(showZoneLights[4]).c_str());
client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone5", zoneEffects[4].c_str());
client.publish(USER_MQTT_CLIENT_NAME "/brightnessStateZone5", itoa(zoneBrightness[4], buff, 10));
#endif
#if ZONESIX == 1
client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone6", itoa(zoneModifer[5], buff, 10));
client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone6", boolToOnOff(showZoneLights[5]).c_str());
client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone6", zoneEffects[5].c_str());
client.publish(USER_MQTT_CLIENT_NAME "/brightnessStateZone6", itoa(zoneBrightness[5], buff, 10));
#endif
}
/************************** MQTT CALLBACK ***********************/
void callback(char* topic, byte* payload, unsigned int length)
{
Serial.print("Message arrived [");
String newTopic = topic;
Serial.print(topic);
Serial.print("] ");
payload[length] = '\0';
String newPayload = String((char *)payload);
int intPayload = newPayload.toInt();
Serial.println(newPayload);
Serial.println();
newPayload.toCharArray(charPayload, newPayload.length() + 1);
if (newTopic == USER_MQTT_CLIENT_NAME"/modifier")
{
for (byte i = 0; i < 6; i = i + 1) {
zoneModifer[i] = intPayload;
}
client.publish(USER_MQTT_CLIENT_NAME"/modifierState", charPayload);
locatorDelay = map(intPayload, 0, 500, 500, 5000);
}
#if ZONEONE == 1
if (newTopic == USER_MQTT_CLIENT_NAME"/modifier/Zone1")
{
zoneModifer[0] = intPayload;
client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone1", charPayload);
}
#endif
#if ZONETWO == 1
if (newTopic == USER_MQTT_CLIENT_NAME"/modifier/Zone2")
{
zoneModifer[1] = intPayload;
client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone2", charPayload);
}
#endif
#if ZONETHREE == 1
if (newTopic == USER_MQTT_CLIENT_NAME"/modifier/Zone3")
{
zoneModifer[2] = intPayload;
client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone3", charPayload);
}
#endif
#if ZONEFOUR == 1
if (newTopic == USER_MQTT_CLIENT_NAME"/modifier/Zone4")
{
zoneModifer[3] = intPayload;
client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone4", charPayload);
}
#endif
#if ZONEFIVE == 1
if (newTopic == USER_MQTT_CLIENT_NAME"/modifier/Zone5")
{
zoneModifer[4] = intPayload;
client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone5", charPayload);
}
#endif
#if ZONESIX == 1
if (newTopic == USER_MQTT_CLIENT_NAME"/modifier/Zone6")
{
zoneModifer[5] = intPayload;
client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone6", charPayload);
}
#endif
if (newTopic == USER_MQTT_CLIENT_NAME"/addEffects")
{
if(newPayload == "Audio On")
{
audioEffects = true;
client.publish(USER_MQTT_CLIENT_NAME"/audio/state", charPayload);
}
if(newPayload == "Audio Off")
{
audioEffects = false;
client.publish(USER_MQTT_CLIENT_NAME"/audio/state", charPayload);
}
if(newPayload == "Glitter On")
{
showGlitter = true;
client.publish(USER_MQTT_CLIENT_NAME"/glitter/state", charPayload);
}
if(newPayload == "Glitter Off")
{
showGlitter = false;
client.publish(USER_MQTT_CLIENT_NAME"/glitter/state", charPayload);
}
if(newPayload == "Lightning On")
{
showLightning = true;
client.publish(USER_MQTT_CLIENT_NAME"/lightning/state","Lightning On");
}
if(newPayload == "Lightning Off")
{
showLightning = false;
client.publish(USER_MQTT_CLIENT_NAME"/lightning/state","Lightning Off");
}
}
if (newTopic == USER_MQTT_CLIENT_NAME"/effect")
{
zoneEffects[0] = newPayload;
client.publish(USER_MQTT_CLIENT_NAME"/effectState", charPayload);
if(newPayload == "LED_Locator")
{
locator_Move();
}
}
#if ZONEONE == 1
if (newTopic == USER_MQTT_CLIENT_NAME"/effect/Zone1" || newTopic == USER_MQTT_CLIENT_NAME"/effect")
{
zoneEffects[0] = newPayload;
fill_solid(firstZone, FIRSTZONE_LEDS, CRGB::Black);
client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone1", charPayload);
}
#endif
#if ZONETWO == 1
if (newTopic == USER_MQTT_CLIENT_NAME"/effect/Zone2" || newTopic == USER_MQTT_CLIENT_NAME"/effect")
{
zoneEffects[1] = newPayload;
fill_solid(secondZone, SECONDZONE_LEDS, CRGB::Black);
client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone2", charPayload);
}
#endif
#if ZONETHREE == 1
if (newTopic == USER_MQTT_CLIENT_NAME"/effect/Zone3" || newTopic == USER_MQTT_CLIENT_NAME"/effect")
{
zoneEffects[2] = newPayload;
fill_solid(thirdZone, THIRDZONE_LEDS, CRGB::Black);
client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone3", charPayload);
}
#endif
#if ZONEFOUR == 1
if (newTopic == USER_MQTT_CLIENT_NAME"/effect/Zone4" || newTopic == USER_MQTT_CLIENT_NAME"/effect")
{
zoneEffects[3] = newPayload;
fill_solid(fourthZone, FOURTHZONE_LEDS, CRGB::Black);
client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone4", charPayload);
}
#endif
#if ZONEFIVE == 1
if (newTopic == USER_MQTT_CLIENT_NAME"/effect/Zone5" || newTopic == USER_MQTT_CLIENT_NAME"/effect")
{
zoneEffects[4] = newPayload;
fill_solid(fifthZone, FIFTHZONE_LEDS, CRGB::Black);
client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone5", charPayload);
}
#endif
#if ZONESIX == 1
if (newTopic == USER_MQTT_CLIENT_NAME"/effect/Zone6" || newTopic == USER_MQTT_CLIENT_NAME"/effect")
{
zoneEffects[5] = newPayload;
fill_solid(sixthZone, SIXTHZONE_LEDS, CRGB::Black);
client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone6", charPayload);
}
#endif
if (newTopic == USER_MQTT_CLIENT_NAME "/ColorSelector/1/Toggle")
{
colorStates[1] = newPayload;
client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/1/ToggleState", colorStates[1].c_str());
}
if (newTopic == USER_MQTT_CLIENT_NAME "/ColorSelector/2/Toggle")
{
colorStates[2] = newPayload;
client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/2/ToggleState", colorStates[2].c_str());
}
if (newTopic == USER_MQTT_CLIENT_NAME "/ColorSelector/3/Toggle")
{
colorStates[3] = newPayload;
client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/3/ToggleState", colorStates[3].c_str());
}
if (newTopic == USER_MQTT_CLIENT_NAME "/ColorSelector/4/Toggle")
{
colorStates[4] = newPayload;
client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/4/ToggleState", colorStates[4].c_str());
}
if (newTopic == USER_MQTT_CLIENT_NAME "/ColorSelector/5/Toggle")
{
colorStates[5] = newPayload;
client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/5/ToggleState", colorStates[5].c_str());
}
if (newTopic == USER_MQTT_CLIENT_NAME "/color1")
{
client.publish(USER_MQTT_CLIENT_NAME "/color1State", charPayload);
// get the position of the first and second commas
uint8_t firstIndex = newPayload.indexOf(',');
uint8_t lastIndex = newPayload.lastIndexOf(',');
uint8_t rgb_red = newPayload.substring(0, firstIndex).toInt();
if (rgb_red < 0 || rgb_red > 255) {
return;
} else {
red1 = rgb_red;
rgbArray[0][0] = rgb_red;
}
uint8_t rgb_green = newPayload.substring(firstIndex + 1, lastIndex).toInt();
if (rgb_green < 0 || rgb_green > 255) {
return;
} else {
green1 = rgb_green;
rgbArray[0][1] = rgb_green;
}
uint8_t rgb_blue = newPayload.substring(lastIndex + 1).toInt();
if (rgb_blue < 0 || rgb_blue > 255) {
return;
} else {
blue1 = rgb_blue;
rgbArray[0][2] = rgb_blue;
}
}
if (newTopic == USER_MQTT_CLIENT_NAME "/color2")
{
client.publish(USER_MQTT_CLIENT_NAME "/color2State", charPayload);
// get the position of the first and second commas
uint8_t firstIndex = newPayload.indexOf(',');
uint8_t lastIndex = newPayload.lastIndexOf(',');
uint8_t rgb_red = newPayload.substring(0, firstIndex).toInt();
if (rgb_red < 0 || rgb_red > 255) {