-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jarduino_v2.ino
6447 lines (5971 loc) · 223 KB
/
Jarduino_v2.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
//************************************************************************************/
// Jarduino Aquarium Controller v.1.1 - release date: April 2012
// Written and Debugged by Jamie M. Jardin
// Copyright 2011, 2012 Jamie M. Jardin
// email: [email protected]
// http://www.ultimatereef.net/forums/member.php?u=44387
// http://www.reefcentral.co.uk/member.php/13262-TheDOdblG
//************************************************************************************/
//
// Previous Version - Jarduino Aquarium Controller v.1.0 (December 2011)
//
// Main code based on Stilo
// http://code.google.com/p/stilo/
//
// LED controlling algorithm is based on Krusduino by Hugh Dangerfield
// http://code.google.com/p/dangerduino/
//
// Moon Phase algorithm is based in part on a Moon Phase function by NightAtTheOpera
// http://www.nano-reef.com/forums/index.php?showtopic=217305&st=0&
//
// Special Thanks:
// Dave Rosser & Hugh Dangerfield - (aka Lewis & Clark?) - Krusduino's their baby
// http://www.ultimatereef.net/forums/showthread.php?t=363432
// Mark Chester aka "Koyaanisqatsi" - Knows everything there's to know about LEDs
// http://www.chestersgarage.com/
// Kev Tench aka "tangtastic" - DIY Reef Wizard!
// http://ukreefs.com/index.php?action=profile;u=1
// Ned Simpson aka "Surff" - Another DIY Reef Guy
// http://www.ultimatereef.net/forums/showthread.php?t=400993
// Neil Williams aka "neildotwilliams" - Yet another DIY Reefer
// http://www.ultimatereef.net/forums/member.php?u=37721
// Albert aka "selfonlypath" - Arduino genius
// http://arduino.cc/forum/index.php?action=profile;u=12410
//
//************************************************************************************/
//
// Known Bugs/Issues:
// - It may be possible to set a date that does not exist (ie. FEB 31, 2011)
// - Occasionally when returing from ScreenSaver, minor Time and Date Bar issues
// - The WaveMaker may cut the set amount of seconds by half
// - The level of automation may make you lazy
// - If you spot an error or bug, please let me know!
// -
// -
//************************************************************************************/
//
// LEGAL DISCLAIMER:
// Jarduino Aquarium Controller v.1.1, Copyright 2011, 2012 Jamie M. Jardin.
// I'm providing this program as free software with the sole intent on furthering
// DIY Aquarium Lighting, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You may modify and/or use
// it under the terms of the GNU General Public License as published by the Free
// Software Foundation version 3 of the License, or (at your option) any later
// version. However if you intend on using the program (either in its entirety or any
// part of it) in any way, shape, or form for PROFIT, you MUST contact me and obtain
// my EXPRESS WRITTEN CONSENT (contact information is provided above).
// VIOLATORS WILL BE PROSECUTED TO THE FULLEST EXTENT OF THE LAW.
//
//************************************************************************************/
//
// IF YOU WANT SOME HELP, PLEASE READ ME!
// Feel free to make changes to suit your needs. For you convenience, I’m listing the
// line numbers in the sketch most commonly changed. Some of these values will require
// a change while other values can simply be modified according to user preference.
// If you make changes to lines other than those listed below, know that it may render
// the program inoperable or cause unpredictable behavior.
//
// 86, 87, 92, 93, 104-110, 113-116, 119-122, 125, 129-131, 136, 137, 155, 176, 207,
// 209, 212, 234, 298-309, 313-324, 328-339, 343-354, 358-369, 373-384
//
//************************************************************************************/
//LIBRARIES
#include <ITDB02_Graph16.h>
#include <avr/pgmspace.h>
#include <ITDB02_Touch.h>
#include <Wire.h>
#include <EEPROM.h>
#include "writeAnything.h"
#include <DS1307.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <EasyTransfer.h>
//dimm execution
struct SEND_DATA_STRUCTURE {
//put your variable definitions here for the data you want to send
//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
uint8_t blau1;
uint8_t blau2;
uint8_t weiss1;
uint8_t weiss2;
uint8_t weiss3;
};
//create object
EasyTransfer ET;
//give a name to the group of data
SEND_DATA_STRUCTURE mydata;
//Default Controller Settings
boolean RECOM_RCD = true; //For Mean Well drivers change "true" to "false"
boolean CLOCK_SCREENSAVER = true; //For a Clock Screensaver "true" / Blank Screen "false"
//You can turn the Screensaver ON/OFF in the pogram
//TOUCH PANEL and ITDB02 MEGA SHIELD
//(Mega Shield utilizes pins 5V, 3V3, GND, 2-6, 20-41, & (50-53 for SD Card))
ITDB02 myGLCD ( 38, 39, 40, 41, ITDB32S ); //May need to add "ITDB32S" depending on LCD controller
ITDB02_Touch myTouch ( 6, 5, 4, 3, 2 );
//Declare which fonts to be utilized
extern uint8_t SmallFont [];
extern uint8_t BigFont [];
extern uint8_t SevenSegNumFont [];
#define LARGE true
#define SMALL false
#define BUTTONCOLOR_BLUE 0
#define BUTTONCOLOR_RED 1
#define BUTTONCOLOR_GREEN 2
//Free pins: 7-13,14,15,1,2,46,
//Define the PWM PINS for the LEDs
const int ledPinSump = 53; //PowerLed Shield pin 10
const int ledPinBlue = 53; //PowerLed Shield pin 5
const int ledPinWhite = 53; //PowerLed Shield pin 3
const int ledPinRoyBlue = 53; //PowerLed Shield pin 6
const int ledPinRed = 53; //PowerLed Shield pin 9
const int ledPinUV = 53; //PowerLed Shield pin 11
const int ledPinMoon = 53; //PowerLed Shield pin 13 (Modification to Shield & NOT controlled by an array)
// Pin 18 & 19 are used for Serial1 comm with Dimm Module
// Pin 16 & 17 are reserved for Bluetooth-communication (or use Serial?)
// Define the other DIGITAL and/or PWM PINS being used
const int tempHeatPin = 53; //Heater on/off (set thermostat on heater to highest desired level)
const int tempChillPin = 53; //Chiller on/off (set thermostat on chiller to lowest desired level)
const int WaveMakerTop = 44; //Hydor Koralia Evolution (Top Plug)
const int WaveMakerBottom = 45; //Hydor Koralia Evolution (Bottom Plug)
const int HoodFansPWM = 9; //PWM Hood Heatsink Fan (code added so frequency = 25kHz)
const int SumpFanPWM = 10; //PWM Sump Heatsink Fan (code added so frequency = 25kHz)
const int HoodFansTranzPin = 53; // falsch!! //Hood Heatsink Fan on/off
const int SumpFanTranzPin = 53; //falsch !!!Sump Heatsink Fan on/off
const int tempAlarmPin = 53; //Buzzer Alarm for Temperature offsets
const int autoFeeder = 53; //Automatic Fish Feeder
const int dosingPump1Pin = 42; //
const int dosingPump2Pin = 43; //
const int dosingPump3Pin = 47; //
const int dosingPump4Pin = 48; //
const int aquaTemp = 49;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++//
// Dosing pump values //
//++++++++++++++++++++++++++++++++++++++++++++++++++++++//
int mlPerTimePump1 = 10; // ML per second for pump 1. real value is this / 10 (so no float is needed)
int mlPerTimePump2 = 10; // ML per second for pump 2. real value is this / 10 (so no float is needed)
int mlPerTimePump3 = 10; // ML per second for pump 3. real value is this / 10 (so no float is needed)
int mlPerTimePump4 = 10; // ML per second for pump 4. real value is this / 10 (so no float is needed)
const int testtime = 10; // test for 10 seconds
int pump1On = 3;
int pump2On = 3;
int pump3On = 3;
int pump4On = 3; // values 0 = deactived=3; int 1 = one pump time=3; int 2 = two pump time=3; int ... till 3
int pump1_1h = 2;
int pump1_1m = 3;
int pump1_2h = 1;
int pump1_2m = 4;
int pump1_3h = 5;
int pump1_3m = 1; // time values for pump1
int pump2_1h = 1;
int pump2_1m = 10;
int pump2_2h = 10;
int pump2_2m = 2;
int pump2_3h = 3;
int pump2_3m = 1; // time values for pump2
int pump3_1h = 2;
int pump3_1m = 10;
int pump3_2h = 10;
int pump3_2m = 4;
int pump3_3h = 4;
int pump3_3m = 1; // time values for pump3
int pump4_1h = 2;
int pump4_1m = 10;
int pump4_2h = 2;
int pump4_2m = 1;
int pump4_3h = 1;
int pump4_3m = 1; // time values for pump4
int pump1_1ml = 10;
int pump1_2ml = 220;
int pump1_3ml = 111; // ml values for pump 1 at given times
int pump2_1ml = 330;
int pump2_2ml = 320;
int pump2_3ml = 22; // ml values for pump 1 at given times
int pump3_1ml = 33;
int pump3_2ml = 222;
int pump3_3ml = 300; // ml values for pump 1 at given times
int pump4_1ml = 134;
int pump4_2ml = 120;
int pump4_3ml = 1122; // ml values for pump 1 at given times
int *pumph [4] [3] = { { &pump1_1h, &pump1_2h, &pump1_3h }, { &pump2_1h, &pump2_2h, &pump2_3h }, { &pump3_1h, &pump3_2h, &pump3_3h }, { &pump4_1h, &pump4_2h,
&pump4_3h } };
int *pumpm [4] [3] = { { &pump1_1m, &pump1_2m, &pump1_3m }, { &pump2_1m, &pump2_2m, &pump2_3m }, { &pump3_1m, &pump3_2m, &pump3_3m }, { &pump4_1m, &pump4_2m,
&pump4_3m } };
int *pumpml [4] [3] = { { &pump1_1ml, &pump1_2ml, &pump1_3ml }, { &pump2_1ml, &pump2_2ml, &pump2_3ml }, { &pump3_1ml, &pump3_2ml, &pump3_3ml }, { &pump4_1ml,
&pump4_2ml, &pump4_3ml } };
int *pumpCalibrate [4] = { &mlPerTimePump1, &mlPerTimePump2, &mlPerTimePump3, &mlPerTimePump4 };
int *pumpOn [4] = { &pump1On, &pump2On, &pump3On, &pump4On };
bool pumpRunning [4] ={ false, false, false, false};
const int *pumpPins [4] = { &dosingPump1Pin, &dosingPump2Pin, &dosingPump3Pin, &dosingPump4Pin };
boolean dosingPumpCalibrationActive = false; // For calibrating dosing pump
boolean dosingPumpSettingsChanged = false;
long dosingPumpOffTimes [4] = { 0L, 0L, 0L, 0L }; // End times: when shoudl pumpes be deactivated?
//++++++++++++++++++++++++++++++++++++++++++++++++++++++//
// other values //
//++++++++++++++++++++++++++++++++++++++++++++++++++++++//
boolean checkTemp = true;
// DS18B20 Temperature sensors plugged into pin 51 (Water, Hood, & Sump)
OneWire OneWireBus ( 51 ); //Choose a digital pin
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors ( &OneWireBus );
// Assign the addresses of temperature sensors. Add/Change addresses as needed.
// dtaa: green. White for fanspeed / pwm
DeviceAddress waterThermometer = { 0x28, 0x5C, 0x56, 0x59, 0x03, 0x00, 0x00, 0xEB };
//10 C6 95 77 02 08 00 A4
DeviceAddress hoodThermometer2 = { 0x10, 0x79, 0xAA, 0x77, 0x02, 0x08, 0x00, 0x6C };
DeviceAddress hoodThermometer = { 0x10, 0xC6, 0x95, 0x77, 0x02, 0x08, 0x00, 0xA4 };
DeviceAddress sumpThermometer = { 0x10, 0x35, 0x90, 0x77, 0x02, 0x08, 0x00, 0x5D };
float tempW = 0; //Water temperature values
float tempH = 0; //Heatsink temperature
float tempS = 0; //Sump heatsink temperature
int TempToBeginHoodFanInDegC = 29; //Temperature to Turn on Hood Fans (in Degrees C)
int TempToBeginSumpFanInDegC = 29; //Temperature to Turn on Sump Fan (in Degrees C)
float FanOn = 0.2; //Starts Fan(s) at 20% Duty Cycle
int HoodTempInterval = 0; //Used for PWM Duty calculations
int SumpTempInterval = 0; //Used for PWM Duty calculations
float HoodFanSpeedIncrease = 0; //Used for PWM Duty calculations
float SumpFanSpeedIncrease = 0; //Used for PWM Duty calculations
float HoodPWM = 0; //Used for PWM Duty calculations
float SumpPWM = 0; //Used for PWM Duty calculations
float setTempC = 0.0; //Desired Water Temperature (User input in program)
float setTempF = 0.0;
float offTempC = 0.0; //Desired Water Temp. Offsets for Heater & Chiller (User input in program)
float offTempF = 0.0;
float alarmTempC = 0.0; //Temperature the Alarm will sound (User input in program)
float alarmTempF = 0.0;
boolean tempCoolflag = 0; //1 if cooling on
boolean tempHeatflag = 0; //1 if heating on
boolean tempAlarmflag = 0; //1 if alarm on
unsigned long intervalAlarm = 1000 * 30; //Interval to beep the Alarm (1000 * seconds)
float temp2beS; //Temporary Temperature Values
float temp2beO; //Temporary Temperature Values
float temp2beA; //Temporary Temperature Values
int setTempScale = 0; //Celsius=0 || Fahrenheit=1 (change in prog)
char degC_F [2]; //Used in the Conversion of Celsius to Fahrenheit
int setCalendarFormat = 0; //DD/MM/YYYY=0 || Month DD, YYYY=1 (change in prog)
int setTimeFormat = 0; //24HR=0 || 12HR=1 (change in prog)
int rtc [7], rtcSet [7]; //Clock arrays
int rtcSet2, AM_PM, yTime; //Setting clock stuff
int timeDispH, timeDispM, xTimeH, xTimeM10, xTimeM1, xTimeAMPM, xColon;
char otherData [19]; // other printed data
//char formattetTime12[9]; //07:48 PM
//char formattetTime24[6]; //19:48
//byte data [56];
char time [11], date [16], day [16];
float LC = 29.53059; //1 Lunar Cycle = 29.53059 days
char LP [16]; //LP = Lunar Phase - variable used to print out Moon Phase
double AG;
int MI, tMI; //Maximum Illumination of Moon (User Defined/Set in Prog. -- Default = 0)
int MoonLow = 43; //Highest Value (0-255) at which Led is Still OFF, or the Value
//you wish the New Moon to Shine (it will increase from here to MI)
unsigned int *MoonPic; //Pointer to the Lunar Phase Pics
extern unsigned int //Lunar Phase Pics
New_Moon [0xD24], Waxing_Crescent [0xD24], First_Quarter [0xD24], Waxing_Gibbous [0xD24], Full_Moon [0xD24], Waning_Gibbous [0xD24], Last_Quarter [0xD24],
Waning_Crescent [0xD24];
int dispScreen = 0; //0-Main Screen, 1-Menu, 2-Clock Setup, 3-Temp Control,
//4-LED Test Options, 5-Test LED Arrays, 6-Test Individual
//LED Colors, 7-Choose LED Color, 8-View Selected Color
//Values, 9-Change Selected Color Array Values
//10-Wavemaker, 11-Wavemaker Settings, 12-General
//Settings, 13-Automatic Feeder, 14-Set Feeder Timers,
//15-About, 16-Options menu 2
#define MAINSCREEN 0
#define MENUSCREEN_ONE 1
#define CLOCKSETUP 2
#define TEMPCONTROL 3
#define LED_TEST_OPTIONS 4
#define TEST_LED_ARRAYS 5
#define TEST_INDIVIDUAL_LED 6
#define CHOOSE_LED_COLOR_VALUES 7
#define VIEW_LED_COLOR_VALUES 8
#define CHANGE_LED_COLOR_VALUES 9
#define WAVEMAKER_MAIN 10
#define WAVEMAKER_SETTINGS 11
#define GENERAL_SETTINGS 12
#define AUTOMATIC_FEEDER 13
#define FEEDER_TIMER 14
#define ABOUT 15
#define MENUSCREEN_TWO 16
#define DOSINGPUMP_MENU 17
int x, y; //touch coordinates
unsigned long previousMillisLED = 0; //Used in the Test LED Array Function
unsigned long previousMillisWave = 0; //Used in the WaveMaker Function wave_output()
unsigned long previousMillisFive = 0; //Used in the Main Loop (Checks Time,Temp,LEDs,Screen)
unsigned long previousMillisAlarm = 0; //Used in the Alarm
int setScreensaver = 2; //ON=1 || OFF=2 (change in prog)
int screenSaverTimer = 0; //counter for Screen Saver
int setScreenSaverTimer = ( 20 ) * 12; //how long in (minutes) before Screensaver comes on
boolean SCREEN_RETURN = true; //Auto Return to mainScreen() after so long of inactivity
int returnTimer = 0; //counter for Screen Return
int setReturnTimer = setScreenSaverTimer * .75; //Will return to main screen after 75% of the amount of
//time it takes before the screensaver turns on
boolean waveMakerOff = false; //For Turning ON/OFF WaveMaker
boolean waveMakerTest = false; //For Testing Wave Settings
unsigned long wPump1, wPump2; //Total Alternating Times
unsigned long intervalAlt = wPump1; //Changing Interval for Alternating Mode
unsigned long wOnForT, wOffForT; //Total Synchronous-Pulse Times
unsigned long intervalSynch = wOnForT; //Changing Interval for Synch-Pulse Mode
int PumpTstate = LOW; //Used to set the Top Powerhead ON or OFF
int PumpBstate = LOW; //Used to set the Bottom Powerhead ON or OFF
int WAVE, Pump1m, Pump1s, Pump2m, //EEPROM vars
Pump2s, Synch, OnForTm, OnForTs, OffForTm, OffForTs;
int MODE = WAVE;
int MIN1 = 0, SEC1 = 0, MIN2 = 0, SEC2 = 0, //Used in the Wavemaker viewWaveTimes()
minY1, minY2;
int Min1 = 0, Sec1 = 0, Min2 = 0, Sec2 = 0; //Used in the Wavemaker viewWaveTimesPage() & wave+/-
int min1X = 91, sec1X = 237, //Used in the Wavemaker waveModePlusMinus()
min2X = 91, sec2X = 237, tTime1 = 0, tTime2 = 0;
int WaveCorrector = 2; //Fix for halving of wave seconds (Change to "1" if
//your wave seconds are doubled)
unsigned long previousMillisCt = 0; //stores the last update for the Countdown Timer
unsigned long intervalCt = 1000; //One Second Interval for Countdown Timer
int countDown = 5 * 60 + 0; //Countdown for 5 minutes and zero seconds
int MIN_O = 5; //Start the Time at 5 (for looks only)
int SEC_T = 0;
int SEC_O = 0;
int LedChangTime = 0; //LED change page, time and values
int min_cnt; //Used to determine the place in the color arrays
boolean LEDtestTick = false; //for testing leds and speed up clock
int whiteLed, blueLed, rblueLed, //previous LED output values
redLed, uvLed, sumpLed;
int bled_out, wled_out, rbled_out, //current LED output values
rled_out, uvled_out, sled_out, moonled_out, colorled_out;
int COLOR = 0, WHITE = 1, BLUE = 2, //Used to Determine View/Change Color LED Values
ROYAL = 3, RED = 4, ULTRA = 5, SUMP = 6, MOON = 7;
boolean colorLEDtest = false; //To test individual color LEDs
int Rgad = 0, Ggad = 0, Bgad = 0, //Used in the Test Ind. Color LEDs Gadget
Rfont = 0, Gfont = 0, Bfont = 0, Rback = 0, Gback = 0, Bback = 0, Rline = 0, Gline = 0, Bline = 0;
int CL_1 = 0, CL_10 = 0, CL_100 = 0, //Used in the Test Ind. Color LEDs Gadget
cl_1, cl_10, cl_100;
int bcol_out, wcol_out, rbcol_out, //Current LED output values for Test Ind. Color LEDs
rcol_out, uvcol_out, scol_out, mooncol_out;
int x1Bar = 0, x2Bar = 0, //Used in LED Output Chart on Test Ind. LEDs Screen
xValue = 0, yValue = 0, LEDlevel, yBar;
int feedTime;
int dosingPumpSelected;
int FEEDTime1, FEEDTime2, FEEDTime3, FEEDTime4;
int feedFish1H, feedFish1M, //Times to feed the fish
feedFish2H, feedFish2M, feedFish3H, feedFish3M, feedFish4H, feedFish4M;
int setAutoStop = 2; //ON=1 || OFF=2 (change in prog)
int fiveTillBackOn1, fiveTillBackOn2, fiveTillBackOn3, fiveTillBackOn4;
boolean FeedWaveCtrl_1 = false;
boolean FeedWaveCtrl_2 = false;
boolean FeedWaveCtrl_3 = false;
boolean FeedWaveCtrl_4 = false;
float getAverageOnTime ( const byte* led [] ) {
int result = 0;
for ( int i = 0; i < 96; i++ ) {
result += *led [i];
}
// multiply by 100 and divert by 96 to get two points
result = ( result * 100 ) / 96;
return result / 100;
}
//DIMMING VALUES can be changed below BUT the EEPROM must be cleared first.
//To CLEAR EEPROM, use arduino-0022\libraries\EEPROM\examples\eeprom_clear\eeprom_clear.pde
//and change the 512 to 4096 before Upload. After the LED comes on indicating the EEPROM
//has been cleared, it is now ok to change DIMMING VALUES below & Upload the sketch.
//SUMP Dimming Values 8pm to 8am
byte sled [96] = { 192, 200, 200, 200, 200, 200, 200, 200, //0 - 1
200, 200, 200, 200, 200, 200, 200, 200, //2 - 3
197, 195, 192, 190, 175, 175, 175, 175, //4 - 5
140, 140, 140, 140, 105, 95, 85, 75, //6 - 7
0, 0, 0, 0, 0, 0, 0, 0, //8 - 9
0, 0, 0, 0, 0, 0, 0, 0, //10 - 11
0, 0, 0, 0, 0, 0, 0, 0, //12 - 13
0, 0, 0, 0, 0, 0, 0, 0, //14 - 15
0, 0, 0, 0, 0, 0, 0, 0, //16 - 17
0, 0, 0, 0, 0, 0, 0, 0, //18 - 19
75, 85, 95, 105, 140, 140, 140, 140, //20 - 21
175, 175, 175, 175, 190, 192, 195, 197 //22 - 23
};
//REGULAR BLUE Dimming Values
byte bled [96] = { 0, 0, 0, 0, 0, 0, 0, 0, //0 - 1
0, 0, 0, 0, 0, 0, 0, 0, //2 - 3
0, 0, 0, 0, 0, 0, 0, 0, //4 - 5
0, 0, 0, 0, 0, 0, 0, 0, //6 - 7
5, 10, 30, 80, 80, 120, 120, 160, //8 - 9
160, 200, 255, 255, 255, 255, 255, 255, //10 - 11
255, 255, 255, 255, 255, 255, 255, 255, //12 - 13
255, 255, 255, 255, 255, 255, 255, 255, //14 - 15
255, 255, 255, 255, 255, 255, 255, 255, //16 - 17
255, 255, 255, 255, 255, 255, 255, 255, //18 - 19
255, 255, 255, 255, 200, 180, 140, 100, //20 - 21
30, 20, 10, 0, 0, 0, 0, 0 //22 - 23
};
//WHITE Dimming Values (White LED array in RAM)
byte wled [96] = { 0, 0, 0, 0, 0, 0, 0, 0, //0 - 1
0, 0, 0, 0, 0, 0, 0, 0, //2 - 3
0, 0, 0, 0, 0, 0, 0, 0, //4 - 5
0, 0, 0, 0, 0, 0, 0, 0, //6 - 7
0, 0, 0, 30, 80, 120, 120, 160, //8 - 9
160, 200, 255, 255, 255, 255, 255, 255, //10 - 11
255, 255, 255, 255, 255, 255, 255, 255, //12 - 13
255, 255, 255, 255, 255, 255, 255, 255, //14 - 15
255, 255, 255, 255, 255, 255, 255, 255, //16 - 17
255, 255, 255, 255, 255, 255, 255, 255, //18 - 19
255, 255, 255, 255, 200, 180, 140, 50, //20 - 21
0, 0, 0, 0, 0, 0, 0, 0 //22 - 23
};
//ROYAL BLUE Dimming Values
byte rbled [96] = { 0, 0, 0, 0, 0, 0, 0, 0, //0 - 1
0, 0, 0, 0, 0, 0, 0, 0, //2 - 3
0, 0, 0, 0, 0, 0, 0, 0, //4 - 5
0, 0, 0, 0, 0, 0, 35, 40, //6 - 7
40, 43, 47, 55, 65, 75, 80, 85, //8 - 9
90, 95, 95, 100, 110, 110, 115, 120, //10 - 11
125, 130, 135, 145, 145, 145, 150, 155, //12 - 13
160, 165, 170, 175, 180, 180, 180, 180, //14 - 15
180, 180, 180, 180, 175, 170, 165, 160, //16 - 17
155, 150, 145, 145, 145, 135, 130, 125, //18 - 19
120, 115, 110, 110, 100, 75, 65, 50, //20 - 21
40, 35, 33, 28, 0, 0, 0, 0 //22 - 23
};
//RED Dimming Values
byte rled [96] = { 0, 0, 0, 0, 0, 0, 0, 0, //0 - 1
0, 0, 0, 0, 0, 0, 0, 0, //2 - 3
0, 0, 0, 0, 0, 0, 0, 0, //4 - 5
0, 0, 0, 0, 0, 0, 0, 0, //6 - 7
0, 0, 0, 0, 0, 0, 0, 0, //8 - 9
0, 0, 0, 0, 0, 0, 0, 0, //10 - 11
30, 30, 40, 40, 50, 50, 60, 60, //12 - 13
60, 60, 50, 50, 40, 40, 30, 30, //14 - 15
0, 0, 0, 0, 0, 0, 0, 0, //16 - 17
0, 0, 0, 0, 0, 0, 0, 0, //18 - 19
0, 0, 0, 0, 0, 0, 0, 0, //20 - 21
0, 0, 0, 0, 0, 0, 0, 0 };
//ULTRA VIOLET (UV) Dimming Values
byte uvled [96] = { 0, 0, 0, 0, 0, 0, 0, 0, //0 - 1
0, 0, 0, 0, 0, 0, 0, 0, //2 - 3
0, 0, 0, 0, 0, 0, 0, 0, //4 - 5
0, 0, 0, 0, 0, 0, 0, 0, //6 - 7
0, 0, 0, 0, 0, 0, 0, 0, //8 - 9
0, 0, 0, 0, 20, 25, 30, 35, //10 - 11
40, 45, 50, 55, 60, 65, 70, 70, //12 - 13
65, 60, 55, 50, 45, 40, 35, 30, //14 - 15
25, 20, 0, 0, 0, 0, 0, 0, //16 - 17
0, 0, 0, 0, 0, 0, 0, 0, //18 - 19
0, 0, 0, 0, 0, 0, 0, 0, //20 - 21
0, 0, 0, 0, 0, 0, 0, 0 };
byte tled [96]; //Temporary Array to Hold changed LED Values
/**************************** CHOOSE OPTION MENU1 BUTTONS *****************************/
const int tanD [] = { 10, 29, 155, 59 }; //"TIME and DATE" settings
const int temC [] = { 10, 69, 155, 99 }; //"H2O TEMP CONTROL" settings
const int wave [] = { 10, 109, 155, 139 }; //"Wavemaker CONTROL" settings
const int gSet [] = { 10, 149, 155, 179 }; //"GENERAL SETTINGS" page
const int tesT [] = { 165, 29, 310, 59 }; //"LED TESTING OPTIONS" menu
const int ledChM [] = { 165, 69, 310, 99 }; //"CHANGE LED VALUES" menu
const int aFeed [] = { 165, 109, 310, 139 }; //"AUTOMATIC FEEDER" menu
const int about [] = { 165, 149, 310, 179 }; //"ABOUT" program information
/**************************** CHOOSE OPTION MENU2 BUTTONS *****************************/
const int dosingPumpButton [] = { 10, 29, 155, 59 }; //"Dosing Pump" settings
/**************************** Dosing Pump Main BUTTONS *****************************/
//const int about [] = { 165, 149, 310, 179 }; //"ABOUT" program information
// defined in function
/**************************** TIME AND DATE SCREEN BUTTONS ***************************/
const int houU [] = { 110, 22, 135, 47 }; //hour up
const int minU [] = { 180, 22, 205, 47 }; //min up
const int ampmU [] = { 265, 22, 290, 47 }; //AM/PM up
const int houD [] = { 110, 73, 135, 96 }; //hour down
const int minD [] = { 180, 73, 205, 96 }; //min down
const int ampmD [] = { 265, 73, 290, 96 }; //AM/PM down
const int dayU [] = { 110, 112, 135, 137 }; //day up
const int monU [] = { 180, 112, 205, 137 }; //month up
const int yeaU [] = { 265, 112, 290, 137 }; //year up
const int dayD [] = { 110, 162, 135, 187 }; //day down
const int monD [] = { 180, 162, 205, 187 }; //month down
const int yeaD [] = { 265, 162, 290, 187 }; //year down
/*************************** H2O TEMP CONTROL SCREEN BUTTONS *************************/
const int temM [] = { 90, 49, 115, 74 }; //temp. minus
const int temP [] = { 205, 49, 230, 74 }; //temp. plus
const int offM [] = { 90, 99, 115, 124 }; //offset minus
const int offP [] = { 205, 99, 230, 124 }; //offset plus
const int almM [] = { 90, 149, 115, 174 }; //alarm minus
const int almP [] = { 205, 149, 230, 174 }; //alarm plus
/**************************** LED TESTING MENU BUTTONS *******************************/
const int tstLA [] = { 40, 59, 280, 99 }; //"Test LED Array Output" settings
const int cntIL [] = { 40, 109, 280, 149 }; //"Control Individual Leds" settings
/********************** TEST LED ARRAY OUTPUT SCREEN BUTTONS *************************/
const int stsT [] = { 110, 105, 200, 175 }; //start/stop
const int tenM [] = { 20, 120, 90, 160 }; //-10s
const int tenP [] = { 220, 120, 290, 160 }; //+10s
/******************** TEST INDIVIDUAL LED VALUES SCREEN BUTTONS **********************/
//These Buttons are made within the function
/****************** CHANGE INDIVIDUAL LED VALUES SCREEN BUTTONS **********************/
//These Buttons are made within the function
/************************* CHANGE LED VALUES MENU BUTTONS ****************************/
const int btCIL [] = { 5, 188, 90, 220 }; //back to Change Individual LEDs Screen
const int ledChV [] = { 110, 200, 210, 220 }; //LED Change Values
const int eeprom [] = { 215, 200, 315, 220 }; //Save to EEPROM (Right Button)
const int miM [] = { 90, 115, 115, 140 }; //MI minus
const int miP [] = { 205, 115, 230, 140 }; //MI plus
/********************* WAVEMAKER SCREEN & STETTINGS BUTTONS **************************/
//Many Wavemaker Buttons are made within the function(s)
const int pump1Mm [] = { 21, 70, 46, 95 }; //Pump 1 minute minus
const int pump1Mp [] = { 120, 70, 145, 95 }; //Pump 1 minute plus
const int pump1Sm [] = { 175, 70, 200, 95 }; //Pump 1 second minus
const int pump1Sp [] = { 274, 70, 299, 95 }; //Pump 1 second plus
const int pump2Mm [] = { 21, 147, 46, 172 }; //Pump 2 minute minus
const int pump2Mp [] = { 120, 147, 145, 172 }; //Pump 2 minute plus
const int pump2Sm [] = { 175, 147, 200, 172 }; //Pump 2 second minus
const int pump2Sp [] = { 274, 147, 299, 172 }; //Pump 2 second plus
/************************* AUTOMATIC FISH FEEDER BUTTONS *****************************/
//These Buttons are made within the function
/******************* SET AUTOMATIC FISH FEEDING TIMES BUTTONS ************************/
const int houP [] = { 110, 38, 135, 63 }; //hour up
const int minP [] = { 180, 38, 205, 63 }; //min up
const int ampmP [] = { 265, 38, 290, 63 }; //AM/PM up
const int houM [] = { 110, 89, 135, 114 }; //hour down
const int minM [] = { 180, 89, 205, 114 }; //min down
const int ampmM [] = { 265, 89, 290, 114 }; //AM/PM down
/***************************** MISCELLANEOUS BUTTONS *********************************/
const int back [] = { 5, 200, 105, 220 }; //BACK
const int prSAVE [] = { 110, 200, 210, 220 }; //SAVE or NEXT
const int canC [] = { 215, 200, 315, 220 }; //CANCEL
/***************************** DOSING PUMP BUTTONS *********************************/
//const int
const int calibrateDosingPump [] = { 60, 20, 240, 40 }; //CANCEL
const int dosingHour1up [] = { 30, 45, 50, 67 }; //plus
const int dosingHour1down [] = { 30, 73, 50, 95 }; //plus
const int dosingHour2up [] = { 30, 98, 50, 118 }; //plus
const int dosingHour2down [] = { 30, 122, 50, 142 }; //plus
const int dosingHour3up [] = { 30, 144, 50, 164 }; //plus
const int dosingHour3down [] = { 30, 170, 50, 190 }; //plus
const int dosingMinute1up [] = { 110, 45, 130, 67 }; //plus
const int dosingMinute1down [] = { 110, 73, 130, 95 }; //plus
const int dosingMinute2up [] = { 110, 98, 130, 118 }; //plus
const int dosingMinute2down [] = { 110, 122, 130, 142 }; //plus
const int dosingMinute3up [] = { 110, 144, 130, 164 }; //plus
const int dosingMinute3down [] = { 110, 170, 130, 190 }; //plus
const int dosingML1up [] = { 135, 45, 157, 67 }; //plus
const int dosingML1down [] = { 135, 73, 157, 95 }; //plus
const int dosingML2up [] = { 135, 98, 157, 118 }; //plus
const int dosingML2down [] = { 135, 122, 157, 142 }; //plus
const int dosingML3up [] = { 135, 144, 157, 164 }; //plus
const int dosingML3down [] = { 135, 170, 157, 190 }; //plus
const int dosingSubML1up [] = { 225, 45, 247, 67 }; //plus
const int dosingSubML1down [] = { 225, 73, 247, 95 }; //plus
const int dosingSubML2up [] = { 225, 98, 247, 118 }; //plus
const int dosingSubML2down [] = { 225, 122, 247, 142 }; //plus
const int dosingSubML3up [] = { 225, 144, 247, 164 }; //plus
const int dosingSubML3down [] = { 225, 170, 247, 190 }; //plus
const int dosingPump1Off [] = { 265, 55, 315, 85 };
const int dosingPump2Off [] = { 265, 110, 315, 140 };
const int dosingPump3Off [] = { 265, 154, 315, 180 };
const int dosingCalibrationStart [] = { 60, 20, 240, 60 };
const int dosingCalibrationMLup [] = { 135, 144, 157, 164 }; //plus
const int dosingCalibrationMLdown [] = { 135, 170, 157, 190 }; //plus
const int dosingCalibrationSubMLup [] = { 225, 144, 247, 164 }; //plus
const int dosingCalibrationSubMLdown [] = { 225, 170, 247, 190 }; //plus
/**************************** END OF PRIMARY BUTTONS *********************************/
/********************************* EEPROM FUNCTIONS ***********************************/
struct config_t {
int tempset;
int tempFset;
int tempoff;
int tempFoff;
int tempalarm;
int tempFalarm;
} tempSettings; //640 - 660
struct config_m {
int MI_t;
} MIsettings; // 600 -620
struct config_w {
int waveMode;
int altPump1m;
int altPump1s;
int altPump2m;
int altPump2s;
int synchMode;
int synchPumpOnM;
int synchPumpOnS;
int synchPumpOffM;
int synchPumpOffS;
} WAVEsettings; // 620 - 640
struct config_g {
int calendarFormat;
int timeFormat;
int tempScale;
int SCREENsaver;
int autoStop;
} GENERALsettings; //660 - 680
struct config_f {
int feedFish1h;
int feedFish1m;
int feedFish2h;
int feedFish2m;
int feedFish3h;
int feedFish3m;
int feedFish4h;
int feedFish4m;
int feedTime1;
int feedTime2;
int feedTime3;
int feedTime4;
} FEEDERsettings; //680 - 700
struct config_d {
int mlPerTimePump1; // ML per testtime for pump 1. real value is this / 10 (so no float is needed)
int mlPerTimePump2; // ML per testtime for pump 2. real value is this / 10 (so no float is needed)
int mlPerTimePump3; // ML per testtime for pump 3. real value is this / 10 (so no float is needed)
int mlPerTimePump4; // ML per testtime for pump 4. real value is this / 10 (so no float is needed)
int pump1On;
int pump2On;
int pump3On;
int pump4On; // values 0 = deactived;int 1 = one pump time;int 2 = two pump time;int ... till 3
int pump1_1h;
int pump1_1m;
int pump1_2h;
int pump1_2m;
int pump1_3h;
int pump1_3m; // time values for pump1
int pump2_1h;
int pump2_1m;
int pump2_2h;
int pump2_2m;
int pump2_3h;
int pump2_3m; // time values for pump2
int pump3_1h;
int pump3_1m;
int pump3_2h;
int pump3_2m;
int pump3_3h;
int pump3_3m; // time values for pump3
int pump4_1h;
int pump4_1m;
int pump4_2h;
int pump4_2m;
int pump4_3h;
int pump4_3m; // time values for pump4
int pump1_1ml;
int pump1_2ml;
int pump1_3ml; // ml values for pump 1 at given times
int pump2_1ml;
int pump2_2ml;
int pump2_3ml; // ml values for pump 1 at given times
int pump3_1ml;
int pump3_2ml;
int pump3_3ml; // ml values for pump 1 at given times
int pump4_1ml;
int pump4_2ml;
int pump4_3ml;
} DOSINGSettings; // 24 ints -> 48 byte; 700 - 760
void SaveLEDToEEPROM () { // 0 - 600
EEPROM.write ( 0, 123 ); //to determine if data available in EEPROM
for ( int i = 1; i < 97; i++ ) {
EEPROM.write ( i + ( 96 * 0 ), wled [i] );
EEPROM.write ( i + ( 96 * 1 ), bled [i] );
EEPROM.write ( i + ( 96 * 2 ), rbled [i] );
EEPROM.write ( i + ( 96 * 3 ), rled [i] );
EEPROM.write ( i + ( 96 * 4 ), sled [i] );
EEPROM.write ( i + ( 96 * 5 ), uvled [i] );
}
}
void SaveMoonLEDToEEPROM () {
MIsettings.MI_t = int ( MI );
EEPROM_writeAnything ( 600, MIsettings );
}
void SaveWaveToEEPROM () {
WAVEsettings.waveMode = int ( WAVE );
WAVEsettings.altPump1m = int ( Pump1m );
WAVEsettings.altPump1s = int ( Pump1s );
WAVEsettings.altPump2m = int ( Pump2m );
WAVEsettings.altPump2s = int ( Pump2s );
WAVEsettings.synchMode = int ( Synch );
WAVEsettings.synchPumpOnM = int ( OnForTm );
WAVEsettings.synchPumpOnS = int ( OnForTs );
WAVEsettings.synchPumpOffM = int ( OffForTm );
WAVEsettings.synchPumpOffS = int ( OffForTs );
EEPROM_writeAnything ( 620, WAVEsettings );
}
void SaveTempToEEPROM () {
tempSettings.tempset = int ( setTempC * 10 );
tempSettings.tempFset = int ( setTempF * 10 );
tempSettings.tempoff = int ( offTempC * 10 );
tempSettings.tempFoff = int ( offTempF * 10 );
tempSettings.tempalarm = int ( alarmTempC * 10 );
tempSettings.tempFalarm = int ( alarmTempF * 10 );
EEPROM_writeAnything ( 640, tempSettings );
}
void SaveGenSetsToEEPROM () {
GENERALsettings.calendarFormat = int ( setCalendarFormat );
GENERALsettings.timeFormat = int ( setTimeFormat );
GENERALsettings.tempScale = int ( setTempScale );
GENERALsettings.SCREENsaver = int ( setScreensaver );
GENERALsettings.autoStop = int ( setAutoStop );
EEPROM_writeAnything ( 660, GENERALsettings );
}
void SaveFeedTimesToEEPROM () {
FEEDERsettings.feedFish1h = int ( feedFish1H );
FEEDERsettings.feedFish1m = int ( feedFish1M );
FEEDERsettings.feedFish2h = int ( feedFish2H );
FEEDERsettings.feedFish2m = int ( feedFish2M );
FEEDERsettings.feedFish3h = int ( feedFish3H );
FEEDERsettings.feedFish3m = int ( feedFish3M );
FEEDERsettings.feedFish4h = int ( feedFish4H );
FEEDERsettings.feedFish4m = int ( feedFish4M );
FEEDERsettings.feedTime1 = int ( FEEDTime1 );
FEEDERsettings.feedTime2 = int ( FEEDTime2 );
FEEDERsettings.feedTime3 = int ( FEEDTime3 );
FEEDERsettings.feedTime4 = int ( FEEDTime4 );
EEPROM_writeAnything ( 680, FEEDERsettings );
}
void SaveDosingPumpToEEPROM () {
DOSINGSettings.mlPerTimePump1 = mlPerTimePump1; // ML per testtime for pump 1. real value is this / 10 (so no float is needed)
DOSINGSettings.mlPerTimePump2 = mlPerTimePump2; // ML per testtime for pump 2. real value is this / 10 (so no float is needed)
DOSINGSettings.mlPerTimePump3 = mlPerTimePump3; // ML per testtime for pump 3. real value is this / 10 (so no float is needed)
DOSINGSettings.mlPerTimePump4 = mlPerTimePump4; // ML per testtime for pump 4. real value is this / 10 (so no float is needed)
DOSINGSettings.pump1On = pump1On;
DOSINGSettings.pump2On = pump2On;
DOSINGSettings.pump3On = pump3On;
DOSINGSettings.pump4On = pump4On; // values 0 = deactived;DOSINGSettings. 1 = one pump time;DOSINGSettings. 2 = two pump time;DOSINGSettings. ... till 3
DOSINGSettings.pump1_1h = pump1_1h;
DOSINGSettings.pump1_1m = pump1_1m;
DOSINGSettings.pump1_2h = pump1_2h;
DOSINGSettings.pump1_2m = pump1_2m;
DOSINGSettings.pump1_3h = pump1_3h;
DOSINGSettings.pump1_3m = pump1_3m; // time values for pump1
DOSINGSettings.pump2_1h = pump2_1h;
DOSINGSettings.pump2_1m = pump2_1m;
DOSINGSettings.pump2_2h = pump2_2h;
DOSINGSettings.pump2_2m = pump2_2m;
DOSINGSettings.pump2_3h = pump2_3h;
DOSINGSettings.pump2_3m = pump2_3m;
DOSINGSettings.pump3_1h = pump3_1h;
DOSINGSettings.pump3_1m = pump3_1m;
DOSINGSettings.pump3_2h = pump3_2h;
DOSINGSettings.pump3_2m = pump3_2m;
DOSINGSettings.pump3_3h = pump3_3h;
DOSINGSettings.pump3_3m = pump3_3m;
DOSINGSettings.pump4_1h = pump4_1h;
DOSINGSettings.pump4_1m = pump4_1m;
DOSINGSettings.pump4_2h = pump4_2h;
DOSINGSettings.pump4_2m = pump4_2m;
DOSINGSettings.pump4_3h = pump4_3h;
DOSINGSettings.pump4_3m = pump4_3m;
DOSINGSettings.pump1_1ml = pump1_1ml;
DOSINGSettings.pump1_2ml = pump1_2ml;
DOSINGSettings.pump1_3ml = pump1_3ml; // ml values for pump 1 at given times
DOSINGSettings.pump2_1ml = pump2_1ml;
DOSINGSettings.pump2_2ml = pump2_2ml;
DOSINGSettings.pump2_3ml = pump2_3ml; // ml values for pump 1 at given times
DOSINGSettings.pump3_1ml = pump3_1ml;
DOSINGSettings.pump3_2ml = pump3_2ml;
DOSINGSettings.pump3_3ml = pump3_3ml; // ml values for pump 1 at given times
DOSINGSettings.pump4_1ml = pump4_1ml;
DOSINGSettings.pump4_2ml = pump4_2ml;
DOSINGSettings.pump4_3ml = pump4_3ml;
EEPROM_writeAnything ( 700, DOSINGSettings );
}
void ReadFromEEPROM () {
int k = EEPROM.read ( 0 );
char tempString [3];
if ( k == 123 ) {
for ( int i = 1; i < 97; i++ ) {
wled [i] = EEPROM.read ( i + ( 96 * 0 ) );
bled [i] = EEPROM.read ( i + ( 96 * 1 ) );
rbled [i] = EEPROM.read ( i + ( 96 * 2 ) );
rled [i] = EEPROM.read ( i + ( 96 * 3 ) );
sled [i] = EEPROM.read ( i + ( 96 * 4 ) );
uvled [i] = EEPROM.read ( i + ( 96 * 5 ) );
}
}
EEPROM_readAnything ( 600, MIsettings );
MI = MIsettings.MI_t;
EEPROM_readAnything ( 620, WAVEsettings );
WAVE = WAVEsettings.waveMode;
Pump1m = WAVEsettings.altPump1m;
Pump1s = WAVEsettings.altPump1s;
Pump2m = WAVEsettings.altPump2m;
Pump2s = WAVEsettings.altPump2s;
Synch = WAVEsettings.synchMode;
OnForTm = WAVEsettings.synchPumpOnM;
OnForTs = WAVEsettings.synchPumpOnS;
OffForTm = WAVEsettings.synchPumpOffM;
OffForTs = WAVEsettings.synchPumpOffS;
EEPROM_readAnything ( 640, tempSettings );
setTempC = tempSettings.tempset;
setTempC /= 10;
setTempF = tempSettings.tempFset;
setTempF /= 10;
offTempC = tempSettings.tempoff;
offTempC /= 10;
offTempF = tempSettings.tempFoff;
offTempF /= 10;
alarmTempC = tempSettings.tempalarm;
alarmTempC /= 10;
alarmTempF = tempSettings.tempFalarm;
alarmTempF /= 10;
EEPROM_readAnything ( 660, GENERALsettings );
setCalendarFormat = GENERALsettings.calendarFormat;
setTimeFormat = GENERALsettings.timeFormat;
setTempScale = GENERALsettings.tempScale;
setScreensaver = GENERALsettings.SCREENsaver;
setAutoStop = GENERALsettings.autoStop;
EEPROM_readAnything ( 680, FEEDERsettings );
feedFish1H = FEEDERsettings.feedFish1h;
feedFish1M = FEEDERsettings.feedFish1m;
feedFish2H = FEEDERsettings.feedFish2h;
feedFish2M = FEEDERsettings.feedFish2m;
feedFish3H = FEEDERsettings.feedFish3h;
feedFish3M = FEEDERsettings.feedFish3m;
feedFish4H = FEEDERsettings.feedFish4h;
feedFish4M = FEEDERsettings.feedFish4m;
FEEDTime1 = FEEDERsettings.feedTime1;
FEEDTime2 = FEEDERsettings.feedTime2;
FEEDTime3 = FEEDERsettings.feedTime3;
FEEDTime4 = FEEDERsettings.feedTime4;
EEPROM_readAnything ( 700, DOSINGSettings );
mlPerTimePump1 = DOSINGSettings.mlPerTimePump1; // ML per testtime for pump 1. real value is this / 10 (so no float is needed)
mlPerTimePump2 = DOSINGSettings.mlPerTimePump2; // ML per testtime for pump 2. real value is this / 10 (so no float is needed)
mlPerTimePump3 = DOSINGSettings.mlPerTimePump3; // ML per testtime for pump 3. real value is this / 10 (so no float is needed)
mlPerTimePump4 = DOSINGSettings.mlPerTimePump4; // ML per testtime for pump 4. real value is this / 10 (so no float is needed)
pump1On = DOSINGSettings.pump1On;
pump2On = DOSINGSettings.pump2On;
pump3On = DOSINGSettings.pump3On;
pump4On = DOSINGSettings.pump4On; // values 0 =DOSINGSettings. deactived; 1 =DOSINGSettings. one pump time; 2 =DOSINGSettings. two pump time; ... till 3
pump1_1h = DOSINGSettings.pump1_1h;
pump1_1m = DOSINGSettings.pump1_1m;
pump1_2h = DOSINGSettings.pump1_2h;
pump1_2m = DOSINGSettings.pump1_2m;
pump1_3h = DOSINGSettings.pump1_3h;
// Serial.println ( " Dosing pump settings read" );
pump1_3m = DOSINGSettings.pump1_3m; // time values for pump1
pump2_1h = DOSINGSettings.pump2_1h;
pump2_1m = DOSINGSettings.pump2_1m;
pump2_2h = DOSINGSettings.pump2_2h;
pump2_2m = DOSINGSettings.pump2_2m;
pump2_3h = DOSINGSettings.pump2_3h;
pump2_3m = DOSINGSettings.pump2_3m;
pump3_1h = DOSINGSettings.pump3_1h;
pump3_1m = DOSINGSettings.pump3_1m;
pump3_2h = DOSINGSettings.pump3_2h;
pump3_2m = DOSINGSettings.pump3_2m;
pump3_3h = DOSINGSettings.pump3_3h;
pump3_3m = DOSINGSettings.pump3_3m;
pump4_1h = DOSINGSettings.pump4_1h;
pump4_1m = DOSINGSettings.pump4_1m;
pump4_2h = DOSINGSettings.pump4_2h;
pump4_2m = DOSINGSettings.pump4_2m;
pump4_3h = DOSINGSettings.pump4_3h;
pump4_3m = DOSINGSettings.pump4_3m;
pump1_1ml = DOSINGSettings.pump1_1ml;
pump1_2ml = DOSINGSettings.pump1_2ml;
pump1_3ml = DOSINGSettings.pump1_3ml; // ml values for pump 1 at given times
pump2_1ml = DOSINGSettings.pump2_1ml;
pump2_2ml = DOSINGSettings.pump2_2ml;
pump2_3ml = DOSINGSettings.pump2_3ml; // ml values for pump 1 at given times
pump3_1ml = DOSINGSettings.pump3_1ml;
pump3_2ml = DOSINGSettings.pump3_2ml;
pump3_3ml = DOSINGSettings.pump3_3ml; // ml values for pump 1 at given times
pump4_1ml = DOSINGSettings.pump4_1ml;
pump4_2ml = DOSINGSettings.pump4_2ml;
pump4_3ml = DOSINGSettings.pump4_3ml;
}
/***************************** END OF EEPROM FUNCTIONS ********************************/
/********************************** RTC FUNCTIONS *************************************/
void SaveRTC () {
int year = rtcSet [6] - 2000;
RTC.stop (); //RTC clock setup
RTC.set ( DS1307_SEC, 1 );
RTC.set ( DS1307_MIN, rtcSet [1] );
RTC.set ( DS1307_HR, rtcSet [2] );
//RTC.set(DS1307_DOW,1);
RTC.set ( DS1307_DATE, rtcSet [4] );
RTC.set ( DS1307_MTH, rtcSet [5] );
RTC.set ( DS1307_YR, year );
delay ( 10 );
RTC.start ();
delay ( 10 );
for ( int i = 0; i < 56; i++ ) {
RTC.set_sram_byte ( 65, i );
}
delay ( 50 );
}
/********************************* END OF RTC FUNCTIONS *******************************/
/********************************** TIME AND DATE BAR **********************************/
void TimeDateBar ( boolean refreshAll = false ) {
char oldVal [16], minute [3], stunde [3], ampm [6], month [5];
if ( ( rtc [1] >= 0 ) && ( rtc [1] <= 9 ) ) {
sprintf ( minute, "%i%i", 0, rtc [1] );
// rtc1= '0' + String(rtc[1]);
} //adds 0 to minutes
else {
sprintf ( minute, "%i", rtc [1] );
// rtc1= String(rtc[1]);
}
if ( setTimeFormat == 1 ) {
if ( rtc [2] == 0 ) {
sprintf ( stunde, "%i", 12 );
// rtc2=String( 12);
} //12 HR Format
else {
if ( rtc [2] > 12 ) {
sprintf ( stunde, "%i", rtc [2] - 12 );
// rtc2= String( rtc[2]-12);
}
else {
sprintf ( stunde, "%i", rtc [2] );
// rtc2= String(rtc[2]);
}
}
}
if ( rtc [2] < 12 ) {
sprintf ( ampm, " AM " );