-
Notifications
You must be signed in to change notification settings - Fork 0
/
20x4_Menu_System.ino
1394 lines (1335 loc) · 36.3 KB
/
20x4_Menu_System.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
// ***********************************************
// MENU SYSTEM FOR A 20X4 CHARACTER DISPLAY
// ***********************************************
void CharMenuTitle()
{
menuTimeout = 0;
if (mLevel == 3) { // menu printing is not necessary if its the final level so it just calls the do function
CharMenuDo();
return;
}
lcd.clear(); // clear the menu in preparation for setting the new title
lcd.setCursor(0, 0); // set the lcd cursor back to 0,0
if (mLevel <= 0) { mLevel = 0; } // keeps the menu level from going negative
// switches necessary to print the title on the menu page and to set the max number of lines for the given menu
switch (mLevel)
{
case 0: // Prints the title on the Main Menu
lcd.setCursor(5, 0);
lcd.print("Main Menu");
miMax = 4;
break;
case 1: // Main Menu Printing ie. print all m0Items[]
switch (m1Sel)
{
case 0:
lcd.setCursor(5, 0);
lcd.print(m0Items[m1Sel + 1]); // User Setup
miMax = 8;
break;
case 1:
lcd.setCursor(3, 0);
lcd.print(m0Items[m1Sel + 1]); // Timer Setup
miMax = 7;
break;
case 2:
lcd.setCursor(1, 0);
lcd.print(m0Items[m1Sel + 1]); // Sensor Addr Setup
miMax = 3;
break;
case 3:
lcd.setCursor(4, 0);
lcd.print(m0Items[m1Sel + 1]); // Sensor Setup
miMax = 4;
break;
case 4:
lcd.setCursor(4, 0);
lcd.print(m0Items[m1Sel + 1]); // System Setup
miMax = 2;
break;
}
break;
case 2: // 2nd Level Menu Printing
switch (m1Sel)
{
case 0: // User Setup Menu Printing ie. prints all m1Items0[]
switch (m2Sel)
{
case 0:
lcd.setCursor(5, 0);
lcd.print(m1Items0[m2Sel + 1]); // Temp Type
miMax = 1;
break;
case 1:
lcd.setCursor(3, 0);
lcd.print(m1Items0[m2Sel + 1]); // Temp Precision
miMax = 1;
break;
case 2:
lcd.setCursor(2, 0);
lcd.print(m1Items0[m2Sel + 1]); // Temp Read Delay
miMax = 0;
break;
case 3:
lcd.setCursor(1, 0);
lcd.print(m1Items0[m2Sel + 1]); // B Light Brightness
miMax = 0;
break;
case 4:
lcd.setCursor(4, 0);
lcd.print(m1Items0[m2Sel + 1]); // Time Format
miMax = 1;
break;
case 5:
lcd.setCursor(2, 0);
lcd.print(m1Items0[m2Sel + 1]); // Display Seconds
miMax = 1;
break;
case 6:
lcd.setCursor(3, 0);
lcd.print(m1Items0[m2Sel + 1]); // Set Date/Time
miMax = 1;
break;
case 7:
lcd.setCursor(1, 0);
lcd.print(m1Items0[m2Sel + 1]); // Flow Sensor
miMax = 1;
break;
case 8:
lcd.print(m1Items0[m2Sel + 1]); // XXXXXX
miMax = 1;
break;
}
break;
case 1: // Timer Setup Menu Printing
// its going to call the same function no matter what case, so no switch is needed
AlarmSetDisplay(m2Sel);
break;
case 2: // Sensor Addr Setup ie. print all m1Items2[]
switch (m2Sel)
{
case 0:
lcd.setCursor(2, 0);
lcd.print(m1Items2[m2Sel + 1]); // Temp Sens 1 Addr
miMax = 1;
break;
case 1:
lcd.setCursor(2, 0);
lcd.print(m1Items2[m2Sel + 1]); // Temp Sens 2 Addr
miMax = 1;
break;
case 2:
lcd.setCursor(2, 0);
lcd.print(m1Items2[m2Sel + 1]); // Temp Sens 3 Addr
miMax = 1;
break;
case 3:
lcd.setCursor(2, 0);
lcd.print(m1Items2[m2Sel + 1]); // Temp Sens 4 Addr
miMax = 1;
break;
}
break;
case 3: // Sensor Setup ie. print all m1Items3[]
switch (m2Sel)
{
case 0:
lcd.setCursor(1, 0);
lcd.print(m1Items3[m2Sel + 1]); // Temp Sens 1
miMax = 1;
break;
case 1:
lcd.setCursor(1, 0);
lcd.print(m1Items3[m2Sel + 1]); // Temp Sens 2
miMax = 1;
break;
case 2:
lcd.setCursor(1, 0);
lcd.print(m1Items3[m2Sel + 1]); // Temp Sens 3
miMax = 1;
break;
case 3:
lcd.setCursor(1, 0);
lcd.print(m1Items3[m2Sel + 1]); // Temp Sens 4
miMax = 1;
break;
case 4:
lcd.setCursor(1, 0);
lcd.print(m1Items3[m2Sel + 1]); // Flow Sensor
miMax = 3;
break;
}
break;
case 4: // System Setup ie. print all m1Items4[]
switch (m2Sel)
{
case 0:
lcd.setCursor(2, 0);
lcd.print(m1Items4[m2Sel + 1]); // Serial Debugging
miMax = 8;
break;
case 1:
lcd.setCursor(4, 0);
lcd.print(m1Items4[m2Sel + 1]); // Erase EEPROM
miMax = 1;
break;
case 2:
lcd.setCursor(2, 0);
lcd.print(m1Items4[m2Sel + 1]); // Restore Defaults
miMax = 1;
break;
}
break;
}
break;
}
// sets the menu navigation pointers up for the line printing for statement
// this also will allow the menu to roll from top to bottom and visa versa once you reach the end
// when you are at the top of the menu and hit the up button you get 255 from the subtraction of 0 from the negative incrementation
switch (mLevel)
{
case 0:
if (m0Start == 255) { m0Start = miMax; } // roll the menu back to the last entry
if (m0Start > miMax) { m0Start = 0; } // roll the menu back to the first entry
mStart = m0Start;
break;
case 1:
if (m1Start == 255) { m1Start = miMax; } // roll the menu back to the last entry
if (m1Start > miMax) { m1Start = 0; } // roll the menu back to the first entry
mStart = m1Start;
break;
case 2:
if (m2Start == 255) { m2Start = miMax; } // roll the menu back to the last entry
if (m2Start > miMax) { m2Start = 0; } // roll the menu back to the first entry
mStart = m2Start;
break;
case 3:
if (m3Start == 255) { m3Start = miMax; } // roll the menu back to the last entry
if (m3Start > miMax) { m3Start = 0; } // roll the menu back to the first entry
mStart = m3Start;
break;
}
uint8_t mmax = 1; // sets mmax = 1 for use to only print 3 lines.
mPoint = mStart; // set the starting position of the pointer
mmax = mPoint + 3; // sets the ending position of the pointer to only print 3 lines
lcd.setCursor(0, 2); // moves the lcd cursor to line 3
lcd.write(byte(2)); // prints the right arrow to indicate the current menu selection
mCur = 1; // sets the lcd cursor to start on line 1
// this for loop actually prints the lines. it runs this loop 3 times to print each line
byte timerCount = 0; // this byte is needed to count up to 2 so that the Set Timers will only print the current time once
for (; mPoint < mmax; mPoint++)
{
lcd.setCursor(1, mCur); // move the lcd cursor to the lines location
// determines what menu array to use when printing each line.
switch (mLevel)
{
case 0:
lcd.print(m0Items[mPoint]); // prints 1st level Main Menu items
break;
case 1:
switch (m1Sel)
{
case 0: // prints 2nd level User Setup items
lcd.print(m1Items0[mPoint]);
break;
case 1: // prints 2nd level Timer Setup items
lcd.print(m1Items1[mPoint]);
// this prints the current times for the alarms only on the 3rd item it prints
if (timerCount == 2) {
timestr = TimeString(1, AlarmHourOn[mPoint - 2], AlarmMinOn[mPoint - 2], 0 ); // assemble the string for the on time
// prints the alarm on time to the display depending on the timeFormat
if (timeFormat == 1) { PrintTimeDisplay(timestr, 12, 1, 7); }
else { PrintTimeDisplay(timestr, 14, 1, 7); }
timestr = TimeString(1, AlarmHourOff[mPoint - 2], AlarmMinOff[mPoint - 2], 0); // assemble the string for the off time
// prints the alarm on time to the display depending on the timeFormat
if (timeFormat == 1) { PrintTimeDisplay(timestr, 12, 2, 7); }
else { PrintTimeDisplay(timestr, 14, 2, 7); }
}
timerCount++; // increase the timer count so that it will print the current alarm times on the 3rd run through
break;
case 2: // prints 2nd level Sensor Addr Config items
lcd.print(m1Items2[mPoint]);
break;
case 3: // prints 2nd level Calibration items
lcd.print(m1Items3[mPoint]);
break;
case 4: // prints 2nd level System Setup items
lcd.print(m1Items4[mPoint]);
break;
}
break;
case 2:
switch (m1Sel)
{
case 0: // prints 3rd level System Config Items
switch (m2Sel)
{
case 0: // prints Temp Type
lcd.print(m2Items00[mPoint]);
// Prints the current setting
if (tempType == 0) {
lcd.setCursor(13, 1);
lcd.print(m2Items00[1]); } // Print Celcius
else {
lcd.setCursor(10, 1);
lcd.print(m2Items00[2]); } // Print Fahrenheit
break;
case 1: // prints Temp Precision
lcd.print(m2Items01[mPoint]);
// Prints the current setting
if (tempPrecision == 0) {
lcd.setCursor(10, 1);
lcd.print(m2Items01[1]); } // No Decimal
else {
lcd.setCursor(11, 1);
lcd.print(m2Items01[2]); } // 1 Decimal
break;
case 2: // prints Temp Read Delay
lcd.print(m2Items02[mPoint]);
// Prints the current setting
lcd.setCursor(13, 1);
lcd.print(tempReadDelay);
lcd.print(" Sec");
break;
case 3: // prints Backlight Brightness
lcd.print(m2Items03[mPoint]);
// Prints the current setting
lcd.setCursor(17, 1);
lcd.print(backlightLevel);
break;
case 4: // prints Time Format
lcd.print(m2Items04[mPoint]);
// Prints the current setting
lcd.setCursor(13, 1);
if (timeFormat == 0) { lcd.print(m2Items04[1]); } // 24 Hour
else { lcd.print(m2Items04[2]); } // 12 Hour
break;
case 5: // prints Second Display
lcd.print(m2Items05[mPoint]);
// Prints the current setting
lcd.setCursor(17, 1);
if (secondsDisplay == 0) {
lcd.setCursor(18, 1);
lcd.print(m2Items05[1]); } // No
else {
lcd.setCursor(17, 1);
lcd.print(m2Items05[2]); } // Yes
break;
case 6: // prints Set Date and Time
lcd.print(m2Items06[mPoint]);
break;
case 7: // prints Flow Sensor On/Off
lcd.print(m2Items07[mPoint]);
// Prints the current setting
if (flowSensorEnable == 0) {
lcd.setCursor(12, 1);
lcd.print(m2Items07[1]); } // Disable
else {
lcd.setCursor(13, 1);
lcd.print(m2Items07[2]); } // Enable
lcd.print("d");
break;
case 8: // prints nothing atm
break;
}
break;
case 1: // prints 3rd level Timer Setup Items
// its going to print the same string no matter what case, so no switch is needed to set the timers
lcd.print(m2Items10[mPoint]);
break;
case 2: // prints 3rd level Sensor Addr Config Items
// its going to print the same string no matter what case, so no switch is needed to set the timers
lcd.print(m2Items20[mPoint]);
break;
case 3: // prints 3rd level Sensor Items
// 0,1,2,3 all print the same thing for the Sensor Calibration setups using an if instead of a switch
if (m2Sel == 4) { lcd.print(m2Items34[mPoint]); } // prints flow sensor calibration items
else { lcd.print(m2Items30[mPoint]); }
break;
case 4: // prints 3 level System Setup items
switch (m2Sel)
{
case 0: // prints Serial Debugging items
lcd.print(m2Items40[mPoint]);
lcd.setCursor(12, 1);
lcd.print(serialDebug, BIN);
break;
case 1: // prints Erase EEPROM items
lcd.print(m2Items41[mPoint]);
break;
case 2: // prints Restore Defaults items
lcd.print(m2Items42[mPoint]);
break;
}
break;
}
default:
break;
}
mCur++; // increase the cursor and return to the begining of the for loop
}
// after the for loop prints the 3 lines it sets the new starting position for the pointer
switch (mLevel)
{
case 0:
mPoint = m0Start;
break;
case 1:
mPoint = m1Start;
break;
case 2:
mPoint = m2Start;
break;
}
delay(150);
// If it just entered the menu system it will call the MenuLoop function and reset the interrupt in the MCP chip. Otherwise it will use the return to fall
// back to the MenuLoop. This prevents an endless loop with no return and keeps the stack from piling up. When the
// menu is called from the main loop it sets mRet to 0 to make sure it calls the MenuLoop the first time through.
if (mRet == 0) { // will only run the first time through
mRet = 1; // set to 1 to cause subsequent runs to not do the following 2 lines
mcpA.readByte(INTCAPA); // clear the interrupt in the mcpA
CharMenuLoop(); // start the MenuLoop
}
else { return; } // return to the MenuLoop
}
void CharMenuLoop()
{
Alarm.delay(200);
mcpA.readByte(GPIOA); // clear the interrupt from the MCP
while (menuMode == 1) // scans for a button press to do the appropriate action
{
uint8_t Down = mcpA.readBit(menubuttonbank, downButton);
uint8_t Up = mcpA.readBit(menubuttonbank, upButton);
uint8_t Right = mcpA.readBit(menubuttonbank, rightButton);
uint8_t Left = mcpA.readBit(menubuttonbank, leftButton);
if (Up == 1) { CharMenuUp(); }
if (Down == 1) { CharMenuDown(); }
if (Right == 1) { CharMenuSelect(); }
if (Left == 1) { CharMenuBack(); }
menuTimeout++;
if (menuTimeout == 10000) { menuMode = 0; } // this will exit the menu system after approx 20 seconds after a button has not been pushed
}
// reset all pointers to 0 in preparation for the next time the menu is run
mLevel = 0;
m0Start = 0;
m1Start = 0;
m2Start = 0;
mRet = 0;
lcd.clear(); // clear the screen
today = 0; // set today to 0 so that the date function gets called
Alarm.delay(200);
mcpA.readByte(GPIOA); // clear the interrupt from MCP
RelayStatusDisplay(0, 3);
ReadTempSensors(); // read the temp sensors so that the display has them
}
void CharMenuUp()
{
switch (mLevel) // switches to adjust the appropriate pointer
{
case 0:
m0Start--;
break;
case 1:
m1Start--;
break;
case 2:
m2Start--;
break;
}
CharMenuTitle();
}
void CharMenuDown()
{
switch (mLevel) // switches to adjust the appropriate pointer
{
case 0:
m0Start++;
break;
case 1:
m1Start++;
break;
case 2:
m2Start++;
break;
}
CharMenuTitle();
}
void CharMenuSelect()
{
mLevel++; // increments the menu level
switch (mLevel) // switches for selecting the appropriate title and menu lines
{
case 0:
m0Start = 0;
break;
case 1:
m1Sel = mStart; // sets the current position to the selected position
m1Start = 0;
break;
case 2:
m2Sel = mStart; // sets the current position to the selected position
m2Start = 0;
break;
case 3:
if (mLevel > 3) { mLevel = 3; } // keeps the MLevel from overflowing
m3Sel = mStart; // sets the current position to the selected position
m3Start = 0;
break;
}
CharMenuTitle();
}
void CharMenuBack() // function for going back 1 level in the menu system
{
if (mLevel > 0) { mLevel--; } // decrements the menu level back 1 level if the level isnt 0 already.
CharMenuTitle();
}
void CharMenuDo() // function for doing the currently selected menu item at the final level
{
if ((serialDebug & 2) == 2) {
Serial.printf("Doing Selection, %d, %d, %d\n", m1Sel, m2Sel, m3Sel);
}
lcd.clear();
lcd.setCursor(0, 1);
switch (m1Sel)
{
case 0: // User Setup menu items
switch (m2Sel)
{
case 0:
lcd.setCursor(2, 0);
lcd.print("Temperature Type");
lcd.setCursor(0, 2);
switch (m2Start)
{
case 0:
eeprom.write(20, 0);
tempType = eeprom.read(20);
lcd.setCursor(3, 1);
lcd.print("Set to Celsius");
break;
case 1:
eeprom.write(20, 1);
tempType = eeprom.read(20);
lcd.setCursor(1, 1);
lcd.print("Set to Fahrenheit");
break;
}
break;
case 1:
lcd.setCursor(3, 0);
lcd.print("Temp Precision");
lcd.setCursor(0, 2);
switch (m2Start)
{
case 0:
eeprom.write(21, 0);
tempPrecision = eeprom.read(21);
lcd.setCursor(1, 1);
lcd.print("Set to No Decimal");
break;
case 1:
eeprom.write(21, 1);
tempPrecision = eeprom.read(21);
lcd.setCursor(2, 1);
lcd.print("Set to 1 Decimal");
break;
}
break;
case 2:
lcd.setCursor(2, 0);
lcd.print("Temp Read Delay");
lcd.setCursor(0, 2);
switch (m2Start)
{
case 0:
tempReadDelay = eeprom.read(22);
to = CharMenuNumSel(0, 22, tempReadDelay, 1, 60, 1, 9, 2, 200);
if (to == 32767) { return; }
tempReadDelay = eeprom.read(22);
Alarm.write(tempReadID, tempReadDelay);
Alarm.disable(tempReadID);
Alarm.enable(tempReadID);
break;
}
break;
case 3:
lcd.print("Backlight Brightness");
lcd.setCursor(0, 2);
switch (m2Start)
{
case 0:
backlightLevel = eeprom.read(25);
to = CharMenuNumSel(0, 25, backlightLevel, 0, 255, 5, 9, 2, 250);
if (to == 32767) { return; }
backlightLevel = eeprom.read(25);
analogWrite(backlight, backlightLevel);
break;
}
break;
case 4:
lcd.setCursor(4, 0);
lcd.print("Time Format");
lcd.setCursor(0, 2);
switch (m2Start)
{
case 0:
eeprom.write(23, 0);
timeFormat = eeprom.read(23);
lcd.setCursor(3, 1);
lcd.print("Set to 24 Hour");
break;
case 1:
eeprom.write(23, 1);
timeFormat = eeprom.read(23);
lcd.setCursor(3, 1);
lcd.print("Set to 12 Hour");
break;
}
break;
case 5:
lcd.setCursor(0, 0);
lcd.setCursor(2, 0);
lcd.print("Seconds Display");
lcd.setCursor(0, 2);
switch (m2Start)
{
case 0:
eeprom.write(24, 0);
secondsDisplay = eeprom.read(24);
lcd.setCursor(1, 1);
lcd.print("Seconds Display Off");
break;
case 1:
eeprom.write(24, 1);
secondsDisplay = eeprom.read(24);
lcd.setCursor(1, 1);
lcd.print("Seconds Display On");
break;
}
break;
case 6:
lcd.setCursor(1, 0);
lcd.print("Set Date and Time");
lcd.setCursor(0, 2);
switch (m2Start)
{
case 0:
lcd.setCursor(6, 1);
lcd.print((String)strExiting);
break;
case 1:
CharMenuSetTime();
break;
}
break;
case 7:
lcd.setCursor(3, 0);
lcd.print(" Flow Sensor");
lcd.setCursor(0, 1);
switch (m2Start)
{
case 0:
eeprom.write(27, 0);
flowSensorEnable = eeprom.read(27);
Alarm.disable(flowReadID);
lcd.print("Flow Sensor Disabled");
break;
case 1:
eeprom.write(27, 1);
flowSensorEnable = eeprom.read(27);
Alarm.enable(flowReadID);
lcd.print("Flow Sensor Enabled");
break;
}
break;
case 8:
break;
}
break;
case 1: // timer setup menu items
switch (m2Sel)
{
case 0: // Timer 1 editing
switch (m2Start)
{
case 0:
AlarmSet(0);
break;
case 1:
lcd.setCursor(6, 1);
lcd.print((String)strExiting);
break;
}
break;
case 1: // Timer 2 editing
switch (m2Start)
{
case 0:
AlarmSet(1);
break;
case 1:
lcd.setCursor(6, 1);
lcd.print((String)strExiting);
break;
}
break;
case 2: // Timer 3 editing
switch (m2Start)
{
case 0:
AlarmSet(2);
break;
case 1:
lcd.setCursor(6, 1);
lcd.print((String)strExiting);
break;
}
break;
case 3: // Timer 4 editing
switch (m2Start)
{
case 0:
AlarmSet(3);
break;
case 1:
lcd.setCursor(6, 1);
lcd.print((String)strExiting);
break;
}
break;
case 4: // Timer 5 editing
switch (m2Start)
{
case 0:
AlarmSet(4);
break;
case 1:
lcd.setCursor(6, 1);
lcd.print((String)strExiting);
break;
}
break;
case 5: // Timer 6 editing
switch (m2Start)
{
case 0:
AlarmSet(5);
break;
case 1:
lcd.setCursor(6, 1);
lcd.print((String)strExiting);
break;
}
break;
case 6: // Timer 7 editing
switch (m2Start)
{
case 0:
AlarmSet(6);
break;
case 1:
lcd.setCursor(6, 1);
lcd.print((String)strExiting);
break;
}
break;
case 7: // Timer 8 editing
switch (m2Start)
{
case 0:
AlarmSet(7);
break;
case 1:
lcd.setCursor(6, 1);
lcd.print((String)strExiting);
break;
}
break;
}
break;
case 2: // sensor addressing menu items
break;
case 3: // calibration menu items
switch (m2Sel)
{
case 4:
switch (m2Start)
{
case 0:
uint8_t rd;
lcd.setCursor(0, 1);
lcd.print("Calibrate Flow Sens");
rd = CharMenuNumSel(66, 28, 0, 0, 1, 1, 8, 3, 250);
if (rd == 0) { break; }
Alarm.disable(tempReadID);
Alarm.disable(flowReadID);
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("Taking Readings");
lcd.setCursor(1, 2);
lcd.print("Sensor Reading #");
for (uint8_t i = 0; i <= 4; i++)
{
flowRateMax = 0; // using this variable to supress the LCD display for Flow Good/Alarm
FlowSensorRead();
lcd.setCursor(17, 2);
lcd.print(i + 1);
delay(1500);
}
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("Avg Flow = ");
lcd.print(flowPulseTotal / 5);
lcd.setCursor(0, 1);
lcd.print("Set As Normal Flow?");
rd = CharMenuNumSel(66, 28, 0, 0, 1, 1, 8, 2, 250);
if (rd == 0) {
lcd.clear();
lcd.setCursor(5, 1);
lcd.print("Not Saving");
}
else {
eeprom.write(28, (flowPulseTotal / 5));
flowRateMax = eeprom.read(28);
eeprom.write(27, 1);
flowSensorEnable = eeprom.read(27);
lcd.clear();
lcd.setCursor(2, 1);
lcd.print("Flow Rate Normal");
lcd.setCursor(7, 2);
lcd.print("Saved");
}
Alarm.enable(tempReadID);
Alarm.enable(flowReadID);
break;
case 1:
lcd.setCursor(2, 1);
lcd.print("Set Minimum Flow");
flowRateMin = eeprom.read(29);
lcd.setCursor(11, 2);
lcd.print("%");
to = CharMenuNumSel(0, 29, flowRateMin, 5, 100, 5, 8, 2, 250);
if (to == 32767) { return; }
flowRateMin = eeprom.read(29);
break;
case 2:
eeprom.write(27, 0);
flowSensorEnable = eeprom.read(27);
lcd.print("Flow Sensor Disabled");
break;
case 3:
lcd.print(" Exiting");
break;
}
break;
}
break;
case 4:
switch (m2Sel)
{
case 0:
lcd.setCursor(2, 0);
lcd.print("Serial Debugging");
lcd.setCursor(0, 2);
switch (m2Start)
{
byte readee;
case 0:
eeprom.write(5, 0);
serialDebug = eeprom.read(5);
lcd.setCursor(2, 2);
lcd.print("All Debugging OFF");
break;
case 1:
eeprom.write(5, 255);
serialDebug = eeprom.read(5);
lcd.setCursor(2, 2);
lcd.print("ALL Debugging ON");
break;
case 2:
readee = eeprom.read(5);
if ((readee & 1) == 1) { // see if the 1st bit flag is set.
readee = readee - 1; // if it is set, turn it off
lcd.print("Disabled Tmp Sns Dbg");
}
else {
readee = readee + 1; // if it is not set, turn it on
lcd.print("Enabled Tmp Sns Dbg");
}
eeprom.write(5, readee);
serialDebug = eeprom.read(5);
break;
case 3:
readee = eeprom.read(5);
if ((readee & 2) == 2) { // see if the 2nd bit flag is set.
readee = readee - 2; // if it is set, turn it off
lcd.print("Disabled Menu Dbg");
}
else {
readee = readee + 2; // if it is not set, turn it on
lcd.print("Enabled Menu Dbg");
}
eeprom.write(5, readee);
serialDebug = eeprom.read(5);
break;
case 4:
readee = eeprom.read(5);
if ((readee & 4) == 4) { // see if the 3rd bit flag is set.
readee = readee - 4; // if it is set, turn it off
lcd.print("Disabled Alarm Dbg");
}
else {
readee = readee + 4; // if it is not set, turn it on
lcd.print("Enabled Alarm Dbg");
}
eeprom.write(5, readee);
serialDebug = eeprom.read(5);
break;
case 5:
readee = eeprom.read(5);
if ((readee & 8) == 8) { // see if the 4th bit flag is set.
readee = readee - 8; // if it is set, turn it off
lcd.print("Disabled EEPROM Dbg");
}
else {
readee = readee + 8; // if it is not set, turn it on
lcd.print("Enabled EEPROM Dbg");
}
eeprom.write(5, readee);
serialDebug = eeprom.read(5);
break;
case 6:
readee = eeprom.read(5);
if ((readee & 16) == 16) { // see if the 4th bit flag is set.
readee = readee - 16; // if it is set, turn it off
lcd.print("Disabled Relay Dbg");
}
else {
readee = readee + 16; // if it is not set, turn it on
lcd.print("Enabled Relay Dbg");
}
eeprom.write(5, readee);
serialDebug = eeprom.read(5);
break;
case 7:
readee = eeprom.read(5);
if ((readee & 32) == 32) { // see if the 5th bit flag is set.
readee = readee - 32; // if it is set, turn it off
lcd.print("Disabled System Dbg");
}
else {
readee = readee + 32; // if it is not set, turn it on
lcd.print("Enabled System Dbg");
}
eeprom.write(5, readee);
serialDebug = eeprom.read(5);
break;
case 8:
readee = eeprom.read(5);
if ((readee & 64) == 64) { // see if the 4th bit flag is set.
readee = readee - 64; // if it is set, turn it off
lcd.print("Disabled Flow Dbg");
}
else {
readee = readee + 64; // if it is not set, turn it on
lcd.print("Enabled Flow Dbg");
}
eeprom.write(5, readee);
serialDebug = eeprom.read(5);
break;
}
break;
case 1:
lcd.setCursor(0, 0);
lcd.print(" Erase EEPROM");
lcd.setCursor(0, 2);
switch (m2Start)
{
case 0:
lcd.setCursor(6, 2);
lcd.print(strExiting);
break;
case 1:
lcd.setCursor(3, 2);
lcd.print("Erasing EEPROM");
eeprom.eraseAll();
lcd.clear();
lcd.setCursor(3, 2);
lcd.print("Erase Complete");
break;
}
break;
case 2:
lcd.setCursor(2, 0);
lcd.print("Restore Defaults");
switch (m2Start)
{
case 0:
lcd.setCursor(6, 2);
lcd.print("Exiting");
break;
case 1:
lcd.setCursor(1, 2);
lcd.print("Restoring Defaults");
serialDebug = (serialDebug | 8);
factoryDefaultset();
lcd.clear();
lcd.setCursor(1, 2);
lcd.print("Defaults Restored");
break;
}