forked from NineteenFire/MrAqua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Screens.ino
3709 lines (3251 loc) · 114 KB
/
Screens.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
void screenHome() // draw main home screen showing overview info
{
touchWaitTime = LONG_WAIT;
if(dispScreen != 1)
{
myGLCD.clrScr(); // clear if not home
}else
{
//myGLCD.setColor(0,0,0);
//myGLCD.fillRect(0,32,239,254); // clear the screen between the header and the dock
}
dispScreen=1; // set screen so we can know what screen was touched later
updateTimeDate(true);
// draw dock, home icon, and header
myFiles.load(0, 254, 240, 66, "dock.raw",4);
myFiles.load(2, 2, 30, 30, "1home.raw",4);
myGLCD.setFont(arial_bold);
myGLCD.setColor(34, 81, 255);
myGLCD.print(F("HOME"), 36, 12);
// draw lines to divide screen
myGLCD.setColor(175, 175, 175);
myGLCD.drawLine(40, 31, 239, 31); // under header
myGLCD.drawLine(0, 110, 239, 110); // across screen below temp
myGLCD.drawLine(56, 110, 56, 237); // 1st cutting into 4ths
myGLCD.drawLine(105, 110, 105, 237); // 2nd cutting into 4ths
myGLCD.drawLine(168, 110, 168, 237); // 3rd cutting into 4ths
myGLCD.drawLine(120, 31, 120, 110); // cutting top section in half for ATO
myGLCD.drawLine(0, 237, 239, 237); // across above dock
// draw temperature to screen
drawTemp();
// display feeding info
drawFeeding();
myFiles.load(5, 172, 46, 46, "1feed.raw",4);
// display lighting info
checkLighting();
// get remainding doses
checkDosing();
// display ATO status
drawATO();
// draw power status of outputs
myFiles.load(178, 121, 24, 24, pwrLightIconS[globalPower.pwrLight1],4);
myFiles.load(206, 121, 24, 24, pwrLightIconS[globalPower.pwrLight2],4);
myFiles.load(178, 149, 24, 24, pwrFilterIconS[globalPower.pwrFilter],4);
myFiles.load(206, 149, 24, 24, pwrCircIconS[globalPower.pwrCirc],4);
//swap locations of heater/co2 since my dc adaptor for co2 won't fit
//myFiles.load(178, 177, 24, 24, pwrHeatIconS[globalPower.pwrHeat],4);//normal
//myFiles.load(206, 177, 24, 24, pwrCO2IconS[globalPower.pwrCO2],4); //normal
myFiles.load(178, 177, 24, 24, pwrCO2IconS[globalPower.pwrCO2],4);//swapped
myFiles.load(206, 177, 24, 24, pwrHeatIconS[globalPower.pwrHeat],4);//swapped
myFiles.load(178, 205, 24, 24, pwrAux1IconS[globalPower.pwrAux1],4);
myFiles.load(206, 205, 24, 24, pwrAux2IconS[globalPower.pwrAux2],4);
}
void screenFeeding() // start the feeding cycle and draw the feeding screen
{
dispScreen=2;
touchWaitTime = LONG_WAIT;
myGLCD.clrScr();
updateTimeDate(true);
// draw header and footer
myGLCD.setColor(130, 130, 130);
myGLCD.drawLine(40, 31, 239, 31); // under header
myGLCD.drawLine(0, 307, 239, 307); // at footer
myFiles.load(2, 2, 30, 30, "2feed.raw",2);
myGLCD.setFont(arial_bold);
myGLCD.setColor(0, 184, 19);
myGLCD.print(F("FEEDING"), 36, 12);
myFiles.load(107, 294, 26, 26, "foothome.raw",2);
myGLCD.setFont(arial_bold);
myGLCD.setColor(0, 184, 19);
myGLCD.print(F("TIME REMAINING"), CENTER, 60);
myGLCD.setColor(240, 240, 255);
// buttons to stop and restart feeding
myFiles.load(67, 223, 48, 48, "2stop.raw",2);
myFiles.load(124, 223, 48, 48, "2restart.raw",2);
// picture of fish eating
myFiles.load(74, 110, 92, 92, "2feeding.raw",2);
// start feeding cycle if not already active
if (feedingActive==false)
{
// capture current power status so we can return to it
preFeedPower.pwrLight1 = globalPower.pwrLight1;
preFeedPower.pwrLight2 = globalPower.pwrLight2;
preFeedPower.pwrFilter = globalPower.pwrFilter;
preFeedPower.pwrCirc = globalPower.pwrCirc;
preFeedPower.pwrHeat = globalPower.pwrHeat;
preFeedPower.pwrCO2 = globalPower.pwrCO2;
preFeedPower.pwrAux1 = globalPower.pwrAux1;
preFeedPower.pwrAux2 = globalPower.pwrAux2;
// fire power relays as configured
if(feedSetting.pwrHeat)
{
if (feedPower.pwrHeat==1) AlarmPwrHeat_On();
else if (feedPower.pwrHeat==0) AlarmPwrHeat_Off();
}
if(feedSetting.pwrCO2)
{
if (feedPower.pwrCO2==1) AlarmPwrCO2_On();
else if (feedPower.pwrCO2==0) AlarmPwrCO2_Off();
}
if(feedSetting.pwrFilter)
{
if (feedPower.pwrFilter==1) AlarmPwrFilter_On();
else if (feedPower.pwrFilter==0) AlarmPwrFilter_Off();
}
if(feedSetting.pwrCirc)
{
if (feedPower.pwrCirc==1) AlarmPwrCirc_On();
else if (feedPower.pwrCirc==0) AlarmPwrCirc_Off();
}
if(feedSetting.pwrAux1)
{
if (feedPower.pwrAux1==1) AlarmPwrAux1_On();
else if (feedPower.pwrAux1==0) AlarmPwrAux1_Off();
}
if(feedSetting.pwrAux2)
{
if (feedPower.pwrAux2==1) AlarmPwrAux2_On();
else if (feedPower.pwrAux2==0) AlarmPwrAux2_Off();
}
feedingActive=true;
startFeedingTime = now(); // mark when feeding started
Serial.print(F("Feeding Started.\n"));
}
checkFeeding();
}
void screenPower() // draw the screen to turn power outputs on/off
{
dispScreen=3;
touchWaitTime = LONG_WAIT;
myGLCD.clrScr();
updateTimeDate(true);
// draw footer
myGLCD.setColor(130, 130, 130);
myGLCD.drawLine(40, 31, 239, 31); // under header
myGLCD.drawLine(0, 307, 104, 307); // left footer
myGLCD.drawLine(136, 307, 239, 307); // right footer
myFiles.load(107, 294, 26, 26, "foothome.raw",2);
// draw header
myFiles.load(2, 2, 30, 30, "3power.raw",2);
myGLCD.setFont(arial_bold);
myGLCD.setColor(222, 8, 51);
myGLCD.print(F("POWER"), 36, 12);
myGLCD.setColor(255, 255, 255);
myGLCD.print(F("MASTER"), CENTER, 52);
// all on and all off buttons
myFiles.load(73, 77, 40, 40, "3allon.raw",2);
myFiles.load(128, 77, 40, 40, "3alloff.raw",2);
// load all power icons and power dots
myFiles.load(15, 139, 48, 48, pwrLightIcon[globalPower.pwrLight1],4);
myFiles.load(34, 192, 10, 11, pwrDot[globalPower.pwrLight1],4);
myFiles.load(69, 139, 48, 48, pwrLightIcon[globalPower.pwrLight2],4);
myFiles.load(88, 192, 10, 11, pwrDot[globalPower.pwrLight2],4);
myFiles.load(124, 139, 48, 48, pwrFilterIcon[globalPower.pwrFilter],4);
myFiles.load(143, 192, 10, 11, pwrDot[globalPower.pwrFilter],4);
myFiles.load(178, 139, 48, 48, pwrCircIcon[globalPower.pwrCirc],4);
myFiles.load(197, 192, 10, 11, pwrDot[globalPower.pwrCirc],4);
myFiles.load(15, 212, 48, 48, pwrHeatIcon[globalPower.pwrHeat],4);
myFiles.load(34, 264, 10, 11, pwrDot[globalPower.pwrHeat],4);
myFiles.load(69, 212, 48, 48, pwrCO2Icon[globalPower.pwrCO2],4);
myFiles.load(88, 264, 10, 11, pwrDot[globalPower.pwrCO2],4);
myFiles.load(124, 212, 48, 48, pwrAux1Icon[globalPower.pwrAux1],4);
myFiles.load(143, 264, 10, 11, pwrDot[globalPower.pwrAux1],4);
myFiles.load(178, 212, 48, 48, pwrAux2Icon[globalPower.pwrAux2],4);
myFiles.load(197, 264, 10, 11, pwrDot[globalPower.pwrAux2],4);
}
void screenSettings() // draw the screen that has all of the extra settings apps
{
dispScreen=4;
touchWaitTime = LONG_WAIT;
myGLCD.clrScr();
updateTimeDate(true);
// draw header
myFiles.load(2, 2, 30, 30, "4extras.raw",2);
myGLCD.setFont(arial_bold);
myGLCD.setColor(255, 77, 0);
myGLCD.print(F("SETTINGS "), 36, 12);
myGLCD.setColor(130, 130, 130);
myGLCD.drawLine(40, 31, 239, 31); // under header
myGLCD.drawLine(0, 307, 104, 307); // left footer
myGLCD.drawLine(136, 307, 239, 307); // right footer
myFiles.load(107, 294, 26, 26, "foothome.raw",4); // footer home button
if ((globalPower.pwrLight1==1)||(lightCSP==false))
{
myFiles.load(10, 50, 48, 63, "4lights.raw",4);
}
else
{
myFiles.load(10, 50, 48, 63, "4lightsF.raw",4);
}
myFiles.load(67, 50, 48, 63, "4clock.raw",4);
myFiles.load(124, 50, 48, 63, "4feeding.raw",4);
myFiles.load(181, 50, 48, 63, "4sched.raw",4);
myFiles.load(10, 118, 48, 63, "4sensors.raw",4);
myFiles.load(67, 118, 48, 63, "4dosing.raw",4);
myFiles.load(124, 118, 48, 63, "4screen.raw",4);
myFiles.load(181, 118, 48, 63, "4ato.raw",4);
myFiles.load(10, 186, 48, 63, "4lunar.raw",4);
if (lightCSP==true) myFiles.load(67, 186, 48, 63, "4colorF.raw",4);//gray out icon for IR lights
if (lightCSP==false)myFiles.load(67, 186, 48, 63, "4color.raw",4);
myFiles.load(124, 186, 48, 63, "4graph.raw",4);
}
void screenLights() // draw the screen for configuring the lights
{
dispScreen=5;
touchWaitTime = LONG_WAIT;
myGLCD.clrScr();
updateTimeDate(true);
// draw header
myFiles.load(2, 2, 30, 30, "5lights.raw",2);
myGLCD.setFont(arial_bold);
myGLCD.setColor(185, 55, 255);
myGLCD.print(F("LIGHT MODES"), 36, 12);
myGLCD.setColor(130, 130, 130);
myGLCD.drawLine(40, 31, 239, 31); // under header
myGLCD.drawLine(0, 307, 104, 307); // left footer
myGLCD.drawLine(136, 307, 239, 307); // right footer
myGLCD.drawLine(0, 94, 239, 94); // vertical center line
myGLCD.drawLine(0, 168, 239, 168); // vertical center line
myFiles.load(107, 294, 26, 26, "footextr.raw",2); // footer button
// draw buttons based on current mode (either selected or not selected)
if (currentLightMode==0)// high sun
{
myFiles.load(10, 39, 48, 48, lightModeS[0],2);
myFiles.load(10, 39, 48, 48, lightMode[0],2);
myFiles.load(67, 39, 48, 48, lightMode[1],2);
myFiles.load(124, 39, 48, 48, lightMode[2],2);
myFiles.load(181, 39, 48, 48, lightMode[3],2);
myFiles.load(10, 101, 48, 63, lightEdit[1],2);
myFiles.load(181, 101, 48, 63, lightResync[1],2);
// get RGBW for high sun
currentColor.chan1=EEPROM.read(400);
currentColor.chan2=EEPROM.read(401);
currentColor.chan3=EEPROM.read(402);
currentColor.chan4=EEPROM.read(403);
currentColor.chan5=EEPROM.read(404);
currentColor.chan6=EEPROM.read(405);
// draw bargraphs
drawLEDBarGraph(1, currentColor.chan1);
drawLEDBarGraph(2, currentColor.chan2);
drawLEDBarGraph(3, currentColor.chan3);
drawLEDBarGraph(4, currentColor.chan4);
drawLEDBarGraph(5, currentColor.chan5);
drawLEDBarGraph(6, currentColor.chan6);
if(lightCSP == false)
{
if(PCA9685Installed == true) //if using PCA9685 scale values to 12-bit
{
currentColor.chan1 = map(currentColor.chan1,0,100,0,4095);
currentColor.chan2 = map(currentColor.chan2,0,100,0,4095);
currentColor.chan3 = map(currentColor.chan3,0,100,0,4095);
currentColor.chan4 = map(currentColor.chan4,0,100,0,4095);
currentColor.chan5 = map(currentColor.chan5,0,100,0,4095);
currentColor.chan6 = map(currentColor.chan6,0,100,0,4095);
} else //otherwise scale to 8-bit
{
currentColor.chan1 = map(currentColor.chan1,0,100,0,255);
currentColor.chan2 = map(currentColor.chan2,0,100,0,255);
currentColor.chan3 = map(currentColor.chan3,0,100,0,255);
currentColor.chan4 = map(currentColor.chan4,0,100,0,255);
currentColor.chan5 = map(currentColor.chan5,0,100,0,255);
currentColor.chan6 = map(currentColor.chan6,0,100,0,255);
}
}
}
else if (currentLightMode==1) // mid sun
{
myFiles.load(10, 39, 48, 48, lightMode[0],2);
myFiles.load(67, 39, 48, 48, lightModeS[1],2);
myFiles.load(124, 39, 48, 48, lightMode[2],2);
myFiles.load(181, 39, 48, 48, lightMode[3],2);
myFiles.load(10, 101, 48, 63, lightEdit[1],2);
myFiles.load(181, 101, 48, 63, lightResync[1],2);
// get RGBW for mid sun
currentColor.chan1=EEPROM.read(410);
currentColor.chan2=EEPROM.read(411);
currentColor.chan3=EEPROM.read(412);
currentColor.chan4=EEPROM.read(413);
currentColor.chan5=EEPROM.read(414);
currentColor.chan6=EEPROM.read(415);
// draw bargraphs
drawLEDBarGraph(1, currentColor.chan1);
drawLEDBarGraph(2, currentColor.chan2);
drawLEDBarGraph(3, currentColor.chan3);
drawLEDBarGraph(4, currentColor.chan4);
drawLEDBarGraph(5, currentColor.chan5);
drawLEDBarGraph(6, currentColor.chan6);
if(lightCSP == false)
{
if(PCA9685Installed == true) //if using PCA9685 scale values to 12-bit
{
currentColor.chan1 = map(currentColor.chan1,0,100,0,4095);
currentColor.chan2 = map(currentColor.chan2,0,100,0,4095);
currentColor.chan3 = map(currentColor.chan3,0,100,0,4095);
currentColor.chan4 = map(currentColor.chan4,0,100,0,4095);
currentColor.chan5 = map(currentColor.chan5,0,100,0,4095);
currentColor.chan6 = map(currentColor.chan6,0,100,0,4095);
} else //otherwise scale to 8-bit
{
currentColor.chan1 = map(currentColor.chan1,0,100,0,255);
currentColor.chan2 = map(currentColor.chan2,0,100,0,255);
currentColor.chan3 = map(currentColor.chan3,0,100,0,255);
currentColor.chan4 = map(currentColor.chan4,0,100,0,255);
currentColor.chan5 = map(currentColor.chan5,0,100,0,255);
currentColor.chan6 = map(currentColor.chan6,0,100,0,255);
}
}
}
else if (currentLightMode==2) // low sun
{
myFiles.load(10, 39, 48, 48, lightMode[0],2);
myFiles.load(67, 39, 48, 48, lightMode[1],2);
myFiles.load(124, 39, 48, 48, lightModeS[2],2);
myFiles.load(181, 39, 48, 48, lightMode[3],2);
myFiles.load(10, 101, 48, 63, lightEdit[1],2);
myFiles.load(181, 101, 48, 63, lightResync[1],2);
// get RGBW for low sun
currentColor.chan1=EEPROM.read(420);
currentColor.chan2=EEPROM.read(421);
currentColor.chan3=EEPROM.read(422);
currentColor.chan4=EEPROM.read(423);
currentColor.chan5=EEPROM.read(424);
currentColor.chan6=EEPROM.read(425);
// draw bargraphs
drawLEDBarGraph(1, currentColor.chan1);
drawLEDBarGraph(2, currentColor.chan2);
drawLEDBarGraph(3, currentColor.chan3);
drawLEDBarGraph(4, currentColor.chan4);
drawLEDBarGraph(5, currentColor.chan5);
drawLEDBarGraph(6, currentColor.chan6);
if(lightCSP == false)
{
if(PCA9685Installed == true) //if using PCA9685 scale values to 12-bit
{
currentColor.chan1 = map(currentColor.chan1,0,100,0,4095);
currentColor.chan2 = map(currentColor.chan2,0,100,0,4095);
currentColor.chan3 = map(currentColor.chan3,0,100,0,4095);
currentColor.chan4 = map(currentColor.chan4,0,100,0,4095);
currentColor.chan5 = map(currentColor.chan5,0,100,0,4095);
currentColor.chan6 = map(currentColor.chan6,0,100,0,4095);
} else //otherwise scale to 8-bit
{
currentColor.chan1 = map(currentColor.chan1,0,100,0,255);
currentColor.chan2 = map(currentColor.chan2,0,100,0,255);
currentColor.chan3 = map(currentColor.chan3,0,100,0,255);
currentColor.chan4 = map(currentColor.chan4,0,100,0,255);
currentColor.chan5 = map(currentColor.chan5,0,100,0,255);
currentColor.chan6 = map(currentColor.chan6,0,100,0,255);
}
}
}
else if (currentLightMode==3) // moon
{
myFiles.load(10, 39, 48, 48, lightMode[0],2);
myFiles.load(67, 39, 48, 48, lightMode[1],2);
myFiles.load(124, 39, 48, 48, lightMode[2],2);
myFiles.load(181, 39, 48, 48, lightModeS[3],2);
myFiles.load(10, 101, 48, 63, lightEdit[1],2);
myFiles.load(181, 101, 48, 63, lightResync[1],2);
// get RGBW for moon
currentColor.chan1=EEPROM.read(430);
currentColor.chan2=EEPROM.read(431);
currentColor.chan3=EEPROM.read(432);
currentColor.chan4=EEPROM.read(433);
currentColor.chan5=EEPROM.read(434);
currentColor.chan6=EEPROM.read(435);
// draw bargraphs
drawLEDBarGraph(1, currentColor.chan1);
drawLEDBarGraph(2, currentColor.chan2);
drawLEDBarGraph(3, currentColor.chan3);
drawLEDBarGraph(4, currentColor.chan4);
drawLEDBarGraph(5, currentColor.chan5);
drawLEDBarGraph(6, currentColor.chan6);
if(lightCSP == false)
{
if(PCA9685Installed == true) //if using PCA9685 scale values to 12-bit
{
currentColor.chan1 = map(currentColor.chan1,0,100,0,4095);
currentColor.chan2 = map(currentColor.chan2,0,100,0,4095);
currentColor.chan3 = map(currentColor.chan3,0,100,0,4095);
currentColor.chan4 = map(currentColor.chan4,0,100,0,4095);
currentColor.chan5 = map(currentColor.chan5,0,100,0,4095);
currentColor.chan6 = map(currentColor.chan6,0,100,0,4095);
} else //otherwise scale to 8-bit
{
currentColor.chan1 = map(currentColor.chan1,0,100,0,255);
currentColor.chan2 = map(currentColor.chan2,0,100,0,255);
currentColor.chan3 = map(currentColor.chan3,0,100,0,255);
currentColor.chan4 = map(currentColor.chan4,0,100,0,255);
currentColor.chan5 = map(currentColor.chan5,0,100,0,255);
currentColor.chan6 = map(currentColor.chan6,0,100,0,255);
}
}
}
else if ((currentLightMode==4)||(currentLightMode==5)) // lights in transition or unknown
{
myFiles.load(10, 39, 48, 48, lightMode[0],2);
myFiles.load(67, 39, 48, 48, lightMode[1],2);
myFiles.load(124, 39, 48, 48, lightMode[2],2);
myFiles.load(181, 39, 48, 48, lightMode[3],2);
myFiles.load(10, 101, 48, 63, lightEdit[0],2);
myFiles.load(181, 101, 48, 63, lightResync[1],2);
if(lightCSP == true)
{
// draw bargraphs
drawLEDBarGraph(1, currentColor.chan1);
drawLEDBarGraph(2, currentColor.chan2);
drawLEDBarGraph(3, currentColor.chan3);
drawLEDBarGraph(4, currentColor.chan4);
drawLEDBarGraph(5, 0);
drawLEDBarGraph(6, 0);
}else
{
byte temp1,temp2,temp3,temp4,temp5,temp6;
if(PCA9685Installed == true) //if using PCA9685 scale values to 12-bit
{
temp1 = map(currentColor.chan1,0,4095,0,100);
temp2 = map(currentColor.chan2,0,4095,0,100);
temp3 = map(currentColor.chan3,0,4095,0,100);
temp4 = map(currentColor.chan4,0,4095,0,100);
temp5 = map(currentColor.chan5,0,4095,0,100);
temp6 = map(currentColor.chan6,0,4095,0,100);
}else
{
temp1 = map(currentColor.chan1,0,255,0,100);
temp2 = map(currentColor.chan2,0,255,0,100);
temp3 = map(currentColor.chan3,0,255,0,100);
temp4 = map(currentColor.chan4,0,255,0,100);
temp5 = map(currentColor.chan5,0,255,0,100);
temp6 = map(currentColor.chan6,0,255,0,100);
}
// draw bargraphs
drawLEDBarGraph(1, temp1);
drawLEDBarGraph(2, temp2);
drawLEDBarGraph(3, temp3);
drawLEDBarGraph(4, temp4);
drawLEDBarGraph(5, temp5);
drawLEDBarGraph(6, temp6);
}
}
// draw the rest of the buttons disabled until the edit button is pressed
myFiles.load(67, 101, 48, 63, lightSave[0],2);
myFiles.load(124, 101, 48, 63, lightCancel[0],2);
tempColor = currentColor;
myGLCD.setFont(Sinclair_S);
myGLCD.setColor(255, 255, 255);
}
void screenLightsIR() // draw the screen for configuring the lights
{
dispScreen=24;
touchWaitTime = LONG_WAIT;
char char3[3]; // used for converting numbers to char
char char3t[3];
myGLCD.clrScr();
updateTimeDate(true);
// draw header
myFiles.load(2, 2, 30, 30, "5lights.raw",2);
myGLCD.setFont(arial_bold);
myGLCD.setColor(185, 55, 255);
myGLCD.print(F("LIGHT MODES"), 36, 12);
myGLCD.setColor(130, 130, 130);
myGLCD.drawLine(40, 31, 239, 31); // under header
myGLCD.drawLine(0, 307, 104, 307); // left footer
myGLCD.drawLine(136, 307, 239, 307); // right footer
myGLCD.drawLine(0, 94, 239, 94); // vertical center line
myGLCD.drawLine(0, 168, 239, 168); // vertical center line
myFiles.load(107, 294, 26, 26, "footextr.raw",2); // footer button
// draw buttons based on current mode (either selected or not selected)
if (currentLightMode==0)// high sun
{
Serial.print(F("Light mode = 0\n"));
myFiles.load(10, 39, 48, 48, lightModeS[0],2);
myFiles.load(67, 39, 48, 48, lightMode[1],2);
myFiles.load(124, 39, 48, 48, lightMode[2],2);
myFiles.load(181, 39, 48, 48, lightMode[3],2);
myFiles.load(10, 101, 48, 63, lightEdit[1],2);
myFiles.load(181, 101, 48, 63, lightResync[1],2);
// get RGBW for high sun
currentColor.chan1=EEPROM.read(400);
currentColor.chan2=EEPROM.read(401);
currentColor.chan3=EEPROM.read(402);
currentColor.chan4=EEPROM.read(403);
currentColor.chan5=EEPROM.read(404);
currentColor.chan6=EEPROM.read(405);
}
else if (currentLightMode==1) // mid sun
{
Serial.print(F("Light mode = 1\n"));
myFiles.load(10, 39, 48, 48, lightMode[0],2);
myFiles.load(67, 39, 48, 48, lightModeS[1],2);
myFiles.load(124, 39, 48, 48, lightMode[2],2);
myFiles.load(181, 39, 48, 48, lightMode[3],2);
myFiles.load(10, 101, 48, 63, lightEdit[1],2);
myFiles.load(181, 101, 48, 63, lightResync[1],2);
// get RGBW for mid sun
currentColor.chan1=EEPROM.read(410);
currentColor.chan2=EEPROM.read(411);
currentColor.chan3=EEPROM.read(412);
currentColor.chan4=EEPROM.read(413);
currentColor.chan5=EEPROM.read(414);
currentColor.chan6=EEPROM.read(415);
}
else if (currentLightMode==2) // low sun
{
Serial.print(F("Light mode = 2\n"));
myFiles.load(10, 39, 48, 48, lightMode[0],2);
myFiles.load(67, 39, 48, 48, lightMode[1],2);
myFiles.load(124, 39, 48, 48, lightModeS[2],2);
myFiles.load(181, 39, 48, 48, lightMode[3],2);
myFiles.load(10, 101, 48, 63, lightEdit[1],2);
myFiles.load(181, 101, 48, 63, lightResync[1],2);
// get RGBW for low sun
currentColor.chan1=EEPROM.read(420);
currentColor.chan2=EEPROM.read(421);
currentColor.chan3=EEPROM.read(422);
currentColor.chan4=EEPROM.read(423);
currentColor.chan5=EEPROM.read(424);
currentColor.chan6=EEPROM.read(425);
}
else if (currentLightMode==3) // moon
{
Serial.print(F("Light mode = 3\n"));
myFiles.load(10, 39, 48, 48, lightMode[0],2);
myFiles.load(67, 39, 48, 48, lightMode[1],2);
myFiles.load(124, 39, 48, 48, lightMode[2],2);
myFiles.load(181, 39, 48, 48, lightModeS[3],2);
myFiles.load(10, 101, 48, 63, lightEdit[1],2);
myFiles.load(181, 101, 48, 63, lightResync[1],2);
// get RGBW for moon
currentColor.chan1=EEPROM.read(430);
currentColor.chan2=EEPROM.read(431);
currentColor.chan3=EEPROM.read(432);
currentColor.chan4=EEPROM.read(433);
currentColor.chan5=EEPROM.read(434);
currentColor.chan6=EEPROM.read(435);
}
else if ((currentLightMode==4)||(currentLightMode==5)) // lights in transition or unknown
{
myFiles.load(10, 39, 48, 48, lightMode[0],2);
myFiles.load(67, 39, 48, 48, lightMode[1],2);
myFiles.load(124, 39, 48, 48, lightMode[2],2);
myFiles.load(181, 39, 48, 48, lightMode[3],2);
myFiles.load(10, 101, 48, 63, lightEdit[0],2);
myFiles.load(181, 101, 48, 63, lightResync[1],2);
}
//Draw greyed out up/down arrows
myFiles.load(10, 175, 48, 48, lightGray[0]);
myFiles.load(67, 175, 48, 48, lightGray[0]);
myFiles.load(124, 175, 48, 48, lightGray[0]);
myFiles.load(181, 175, 48, 48, lightGray[0]);
myFiles.load(10, 241, 48, 48, lightGray[1]);
myFiles.load(67, 241, 48, 48, lightGray[1]);
myFiles.load(124, 241, 48, 48, lightGray[1]);
myFiles.load(181, 241, 48, 48, lightGray[1]);
// draw the RGBW values to the screen
myGLCD.setFont(Sinclair_S);
myGLCD.setColor(255, 255, 255);
byte dx = 25;
if(currentColor.chan1 < 9) dx += 4;
if(currentColor.chan1 < 99) dx += 4;
itoa(currentColor.chan1, char3, 10);
myGLCD.print(char3, dx, 228);
dx = 80;
if(currentColor.chan2 < 9) dx += 4;
if(currentColor.chan2 < 99) dx += 4;
itoa(currentColor.chan2, char3, 10);
myGLCD.print(char3, dx, 228);
dx = 138;
if(currentColor.chan3 < 9) dx += 4;
if(currentColor.chan3 < 99) dx += 4;
itoa(currentColor.chan3, char3, 10);
myGLCD.print(char3, dx, 228);
dx = 195;
if(currentColor.chan4 < 9) dx += 4;
if(currentColor.chan4 < 99) dx += 4;
itoa(currentColor.chan4, char3, 10);
myGLCD.print(char3, dx, 228);
// draw the rest of the buttons disabled until the edit button is pressed
myFiles.load(67, 101, 48, 63, lightSave[0],2);
myFiles.load(124, 101, 48, 63, lightCancel[0],2);
myGLCD.setFont(Sinclair_S);
myGLCD.setColor(255, 255, 255);
}
void screenSensors()
{
dispScreen = 18;
touchWaitTime = LONG_WAIT;
myGLCD.clrScr();
updateTimeDate(true);
// draw header
myFiles.load(2, 2, 30, 30, "18sense.raw",2);
myGLCD.setFont(arial_bold);
myGLCD.setColor(238, 0, 145);
myGLCD.print(F("Sensors"), 36, 12);
myGLCD.setColor(130, 130, 130);
myGLCD.drawLine(40, 31, 239, 31); // under header
myGLCD.drawLine(0, 307, 104, 307); // left footer
myGLCD.drawLine(136, 307, 239, 307); // right footer
myFiles.load(107, 294, 26, 26, "foothome.raw",2);
// Sensor 1-3 names
myGLCD.setFont(arial_bold);
myGLCD.setColor(255, 255, 255);
myGLCD.print(F("Sensor 1"), 2, 55);
myGLCD.print(F("Sensor 2"), 2, 108);
myGLCD.print(F("Sensor 3"), 2, 161);
myGLCD.print(F("Display units"), 2, 214);
// Sensor descriptions
//myGLCD.setFont(Sinclair_S);
myGLCD.setColor(255, 0, 77);
myGLCD.print(F("Water"), 15, 75);
myGLCD.print(F("Heatsink"), 15, 128);
myGLCD.print(F("Internal"), 15, 181);
sensor1Enabled = EEPROM.read(50);
sensor2Enabled = EEPROM.read(51);
sensor3Enabled = EEPROM.read(52);
displayInC = EEPROM.read(57);
// Enable/disable buttons
myFiles.load(170, 55, 30, 30, schedActiveB[sensor1Enabled],2);
myFiles.load(170, 108, 30, 30, schedActiveB[sensor2Enabled],2);
myFiles.load(170, 161, 30, 30, schedActiveB[sensor3Enabled],2);
//display units
myFiles.load(100, 259, 14, 12, "c.raw",2);
myFiles.load(180, 259, 14, 12, "f.raw",2);
myFiles.load(60, 250, 30, 30, schedActiveB[displayInC],2);
myFiles.load(140, 250, 30, 30, schedActiveB[!displayInC],2);
//settings buttons
if(sensor1Enabled) myFiles.load(210, 58, 26, 26, "footextr.raw",2);
if(sensor2Enabled) myFiles.load(210, 111, 26, 26, "footextr.raw",2);
if(sensor3Enabled) myFiles.load(210, 164, 26, 26, "footextr.raw",2);
}
void screenHeatsink()
{
dispScreen = 19;
myGLCD.clrScr();
updateTimeDate(true);
char char6[6];
// draw header
myFiles.load(2, 2, 30, 30, "18sense.raw",2);
myGLCD.setFont(arial_bold);
myGLCD.setColor(238, 0, 145);
myGLCD.print(F("Heatsink"), 36, 12);
myGLCD.setColor(130, 130, 130);
myGLCD.drawLine(40, 31, 239, 31); // under header
myGLCD.drawLine(0, 307, 104, 307); // left footer
myGLCD.drawLine(136, 307, 239, 307); // right footer
myFiles.load(107, 294, 26, 26, "footextr.raw",2);
// lines to divide screen
myGLCD.drawLine(0, 97, 239, 97);
myGLCD.drawLine(0, 163, 239, 163);
myGLCD.drawLine(0, 229, 239, 229);
// buttons for adjusting off temp
myFiles.load(162, 37, 24, 24, arrowButton[0],2);
myFiles.load(162, 67, 24, 24, arrowButton[1],2);
// buttons for adjusting the on temp
myFiles.load(162, 103, 24, 24, arrowButton[0],2);
myFiles.load(162, 133, 24, 24, arrowButton[1],2);
// buttons for adjusting calibration
myFiles.load(136, 169, 24, 24, arrowButton[0],2);
myFiles.load(136, 199, 24, 24, arrowButton[1],2);
// off icon
myFiles.load(10, 40, 96, 48, "19fanoff.raw",2);
//myGLCD.setColor(0, 51, 222);
myGLCD.setColor(222, 8, 51); // Add Thiago
//myGLCD.print(F("FAN"), 105, 42);
//myGLCD.print(F("OFF"), 106, 69);
myGLCD.print(F("OFF"), 106, 58);
//display fan off temp
heatsinkFanOffTemp=EEPROM.read(54);
itoa(heatsinkFanOffTemp, char6, 10);
myGLCD.setColor(255, 77, 0);
myGLCD.print(char6, 194, 56);
if(displayInC == true) myFiles.load(226, 58, 14, 12, "c.raw",2);
if(displayInC == false)myFiles.load(226, 58, 14, 12, "f.raw",2);
// draw the on icon
myFiles.load(10, 106, 96, 48, "19fanon.raw",2);
//myGLCD.setColor(222, 8, 51);
myGLCD.setColor(0, 184, 19); // Add Thiago
//myGLCD.print(F("FAN"), 110, 108);
//myGLCD.print(F("ON"), 120, 122);
myGLCD.print(F("ON"), 120, 122);
//display fan on temp
heatsinkFanOnTemp=EEPROM.read(53);
itoa(heatsinkFanOnTemp, char6, 10);
myGLCD.setColor(255, 77, 0);
myGLCD.print(char6, 194, 122);
if(displayInC == true) myFiles.load(226, 124, 14, 12, "c.raw",2);
if(displayInC == false)myFiles.load(226, 124, 14, 12, "f.raw",2);
// calibration offset
myGLCD.setColor(VGA_WHITE);
myGLCD.print(F("Sensor"),10,174);
myGLCD.print(F("Offset"),10,201);
// display value to screen
byte storedVal = EEPROM.read(59);
byte dx = 176;
if(storedVal < 128)dx = 160;
sensor2Calibration = ((float)storedVal - 128) / 10;
dtostrf(sensor2Calibration, 3, 1, char6); //convert to string
myGLCD.setColor(255, 77, 0);
myGLCD.print(char6, dx, 188);
// display units on screen
if(displayInC == false)myFiles.load(226, 190, 14, 12, "f.raw",2);
if(displayInC == true) myFiles.load(226, 190, 14, 12, "c.raw",2);
// enable/disable display of sensor
myGLCD.setColor(VGA_WHITE);
myGLCD.print(F("Display?"),10,254);
//myFiles.load(170, 247, 30, 30, schedActiveB[displaySensor2],2);
myFiles.load(162, 251, 46, 22, schedOnOff[displaySensor2],2);
}
void screenInternalTemp()
{
dispScreen = 20;
myGLCD.clrScr();
updateTimeDate(true);
char char6[6];
// draw header
myFiles.load(2, 2, 30, 30, "18sense.raw",2);
myGLCD.setFont(arial_bold);
myGLCD.setColor(238, 0, 145);
myGLCD.print(F("Internal"), 36, 12);
myGLCD.setColor(130, 130, 130);
myGLCD.drawLine(40, 31, 239, 31); // under header
myGLCD.drawLine(0, 307, 104, 307); // left footer
myGLCD.drawLine(136, 307, 239, 307); // right footer
myFiles.load(107, 294, 26, 26, "footextr.raw",2);
// lines to divide screen
myGLCD.drawLine(0, 97, 239, 97);
myGLCD.drawLine(0, 163, 239, 163);
myGLCD.drawLine(0, 229, 239, 229);
// buttons for adjusting off temp
myFiles.load(162, 37, 24, 24, arrowButton[0],2);
myFiles.load(162, 67, 24, 24, arrowButton[1],2);
// buttons for adjusting the on temp
myFiles.load(162, 103, 24, 24, arrowButton[0],2);
myFiles.load(162, 133, 24, 24, arrowButton[1],2);
// buttons for adjusting calibration
myFiles.load(136, 169, 24, 24, arrowButton[0],2);
myFiles.load(136, 199, 24, 24, arrowButton[1],2);
// off icon
myFiles.load(10, 40, 96, 48, "19fanoff.raw",2);
//myGLCD.setColor(0, 51, 222);
myGLCD.setColor(222, 8, 51); // Add Thiago
//myGLCD.print(F("FAN"), 105, 42);
//myGLCD.print(F("OFF"), 106, 69);
myGLCD.print(F("OFF"), 106, 58);
// draw the on icon
myFiles.load(10, 106, 96, 48, "19fanon.raw",2);
//myGLCD.setColor(222, 8, 51);
myGLCD.setColor(0, 184, 19); // Add Thiago
//myGLCD.print(F("FAN"), 110, 108);
//myGLCD.print(F("ON"), 120, 122);
myGLCD.print(F("ON"), 120, 122);
//display fan off temp
internalFanOffTemp = EEPROM.read(56);
itoa(internalFanOffTemp, char6, 10);
myGLCD.setColor(255, 77, 0);
myGLCD.print(char6, 194, 56);
if(displayInC == true) myFiles.load(226, 58, 14, 12, "c.raw",2);
if(displayInC == false)myFiles.load(226, 58, 14, 12, "f.raw",2);
//display fan on temp
internalFanOnTemp = EEPROM.read(55);
itoa(internalFanOnTemp, char6, 10);
myGLCD.setColor(255, 77, 0);
myGLCD.print(char6, 194, 122);
if(displayInC == true) myFiles.load(226, 124, 14, 12, "c.raw",2);
if(displayInC == false)myFiles.load(226, 124, 14, 12, "f.raw",2);
// calibration offset
myGLCD.setColor(VGA_WHITE);
myGLCD.print(F("Sensor"),10,174);
myGLCD.print(F("Offset"),10,201);
// display value to screen
byte storedVal = EEPROM.read(60);
byte dx = 176;
if(storedVal < 128)dx = 160;
sensor3Calibration = ((float)storedVal - 128) / 10;
dtostrf(sensor3Calibration, 3, 1, char6); //convert to string
myGLCD.setColor(255, 77, 0);
myGLCD.print(char6, dx, 188);
// display units on screen
if(displayInC == false)myFiles.load(226, 190, 14, 12, "f.raw",2);
if(displayInC == true) myFiles.load(226, 190, 14, 12, "c.raw",2);
// enable/disable display of sensor
myGLCD.setColor(VGA_WHITE);
myGLCD.print(F("Display?"),10,254);
//myFiles.load(170, 247, 30, 30, schedActiveB[displaySensor3],2);
myFiles.load(162, 251, 46, 22, schedOnOff[displaySensor3],2);
}
void screenClock() // draw the screen for setting the date/time
{
dispScreen=6;
myGLCD.clrScr();
updateTimeDate(true);
// draw header
myFiles.load(2, 2, 30, 30, "6clock.raw",2);
myGLCD.setFont(arial_bold);
myGLCD.setColor(47, 168, 208);
myGLCD.print(F("CLOCK"), 36, 12);
myGLCD.print(F("TIME"), CENTER, 46);
myGLCD.print(F("DATE"), CENTER, 167);
myGLCD.setColor(130, 130, 130);
myGLCD.drawLine(40, 31, 239, 31); // under header
myGLCD.drawLine(0, 155, 239, 155); // center line
myGLCD.setFont(Sinclair_S);
myGLCD.setColor(255, 255, 255);
// draw clock buttons and text
myGLCD.print("24H", 12, 72);
myFiles.load(12, 89, 24, 24, arrowButton[0],2);
myFiles.load(12, 119, 24, 24, arrowButton[1],2);
myGLCD.print("M", 91, 72);
myFiles.load(83, 89, 24, 24, arrowButton[0],2);
myFiles.load(83, 119, 24, 24, arrowButton[1],2);
myGLCD.print("S", 172, 72);
myFiles.load(164, 89, 24, 24, arrowButton[0],2);
myFiles.load(164, 119, 24, 24, arrowButton[1],2);
// draw date buttons and text
myGLCD.print("M", 20, 194);
myFiles.load(12, 211, 24, 24, arrowButton[0],2);
myFiles.load(12, 241, 24, 24, arrowButton[1],2);
myGLCD.print("D", 91, 194);
myFiles.load(83, 211, 24, 24, arrowButton[0],2);
myFiles.load(83, 241, 24, 24, arrowButton[1],2);
myGLCD.print("Y", 172, 194);
myFiles.load(164, 211, 24, 24, arrowButton[0],2);
myFiles.load(164, 241, 24, 24, arrowButton[1],2);
myGLCD.setFont(arial_bold);
myGLCD.setColor(255, 77, 0);
saveRTC.Hour = hour();
saveRTC.Minute = minute();
saveRTC.Second = 0; // always have 0 seconds
saveRTC.Day = day();
saveRTC.Month = month();
saveRTC.Year = (year()-1970);
char char3[3];
char char3t[3];
// draw the date and time to the screen
itoa(saveRTC.Hour, char3, 10);
if (saveRTC.Hour>=0 && saveRTC.Hour<=9) // add a zero
{
itoa(0, char3t, 10); //make char3t 0
strcat(char3t, char3);
strcpy (char3,char3t);
}
myGLCD.print(char3, 45, 108);
itoa(saveRTC.Minute, char3, 10);
if (saveRTC.Minute>=0 && saveRTC.Minute<=9) // add a zero
{
itoa(0, char3t, 10); //make char3t 0
strcat(char3t, char3);
strcpy (char3,char3t);
}
myGLCD.print(char3, 123, 108);
myGLCD.print("00", 201, 108);
itoa(saveRTC.Month, char3, 10);
if (saveRTC.Month>=0 && saveRTC.Month<=9) // add a zero
{
itoa(0, char3t, 10); //make char3t 0
strcat(char3t, char3);
strcpy (char3,char3t);
}
myGLCD.print(char3, 45, 230);
itoa(saveRTC.Day, char3, 10);
if (saveRTC.Day>=0 && saveRTC.Day<=9) // add a zero
{
itoa(0, char3t, 10); //make char3t 0
strcat(char3t, char3);
strcpy (char3,char3t);