Очень простой контролер аквариумного освещения
- Войдите на сайт для отправки комментариев
Здравствуйте, товарищи! Веду поиск безвозмездной помощи. Есть исходники, нужно чуток подредактировать. Вобщем, нужно сделать контроллер аквариумного освещения. 3 ШИМ канала, т.е. должны управлять диммируемыми драйверами. Принцип работы.
Канал 1. Старт освещения в 7:30, плавное нарастание мощности до предела к 8:30. С 18:30 до 19:30 плавное выключение до нуля.
Канал 2. Старт освещения в 8:10, плавное нарастание мощности до максимума в течение часа. В 17:50 - 18:50 плавное выключение до нуля. Т.е. иммитация рассветов и закатов.
Канал 3. Иммитация фаз луны. Алгоритм имеется. Работать должна после выключения 1 канала и до его включени.
Теперь исходник. Есть код для Ардуино мега 2560 с сенсорным экраном, но он дороговат, и там слишком много функций. Весь код прокомментирован, так что, думаю (человек предполагает, а Бог располагает) знающий человек может разобраться. Конечная прошивка нужна для Ардуино Леонардо (ATmega32U4, точнее для китайского клона, но пишут, что там полная совместимость).
Заранее большое спасибо за внимание. Буду ждать ответа, надежда умирает последней.
00001
//************************************************************************************/
00002
// Jarduino Aquarium Controller v.1.2(beta) - release date: May 2012
00003
// Written and Debugged by Jamie M. Jardin aka "TheDOdblG"
00004
// Copyright 2011, 2012 Jamie M. Jardin
00005
// email: <a href="mailto:jjardi56@msn.com">jjardi56@msn.com</a>
00006
//
00007
// Aquarium and Controller Build Details
00008
// <a data-cke-saved-href="<a href="http://ukreefs.com/index.php?topic=117.0" rel="nofollow">http://ukreefs.com/index.php?topic=117.0</a>" href="<a href="http://ukreefs.com/index.php?topic=117.0" rel="nofollow">http://ukreefs.com/index.php?topic=117.0</a>" rel="nofollow"><a href="http://ukreefs.com/index.php?topic=117.0" rel="nofollow">http://ukreefs.com/index.php?topic=117.0</a></a>
00009
// <a data-cke-saved-href="<a href="http://www.reefcentral.co.uk/showthread.php/26598-44-Gallon-Pentagon-Corner-Tank-LED-Hood-DIY-Build-EXTRAS!-" rel="nofollow">http://www.reefcentral.co.uk/showthread.php/26598-44-Gallon-Pentagon-Corner-Tank-LED-Hood-DIY-Build-EXTRAS!-</a>" href="<a href="http://www.reefcentral.co.uk/showthread.php/26598-44-Gallon-Pentagon-Corner-Tank-LED-Hood-DIY-Build-EXTRAS!-" rel="nofollow">http://www.reefcentral.co.uk/showthread.php/26598-44-Gallon-Pentagon-Corner-Tank-LED-Hood-DIY-Build-EXTRAS!-</a>" rel="nofollow"><a href="http://www.reefcentral.co.uk/showthread.php/26598-44-Gallon-Pentagon-Corner-Tank-LED-Hood-DIY-Build-EXTRAS!-" rel="nofollow">http://www.reefcentral.co.uk/showthread.php/26598-44-Gallon-Pentagon-Corner-Tank-LED-Hood-DIY-Build-EXTRAS!-</a></a>(Sump-amp-Wave-Maker-etc)
00010
//
00011
// Jarduino Code Download Page
00012
// <a data-cke-saved-href="<a href="http://code.google.com/p/jarduino-aquarium-controller/" rel="nofollow">http://code.google.com/p/jarduino-aquarium-controller/</a>" href="<a href="http://code.google.com/p/jarduino-aquarium-controller/" rel="nofollow">http://code.google.com/p/jarduino-aquarium-controller/</a>" rel="nofollow"><a href="http://code.google.com/p/jarduino-aquarium-controller/" rel="nofollow">http://code.google.com/p/jarduino-aquarium-controller/</a></a>
00013
//
00014
// Jarduino Aquarium Controller v.1.2 Updates Demonstration Video
00015
// Coming soon to a YouTube near you!
00016
//
00017
// Jarduino Aquarium Controller v.1.1 Demonstration Video
00018
// <a data-cke-saved-href="<a href="http://www.youtube.com/watch?v=gN4XQHNijxw" rel="nofollow">http://www.youtube.com/watch?v=gN4XQHNijxw</a>" href="<a href="http://www.youtube.com/watch?v=gN4XQHNijxw" rel="nofollow">http://www.youtube.com/watch?v=gN4XQHNijxw</a>" rel="nofollow"><a href="http://www.youtube.com/watch?v=gN4XQHNijxw" rel="nofollow">http://www.youtube.com/watch?v=gN4XQHNijxw</a></a>
00019
//
00020
//************************************************************************************/
00021
//
00022
// Previous Versions
00023
// Jarduino Aquarium Controller v.1.0 (December 2011)
00024
// Jarduino Aquarium Controller v.1.1 (April 2012)
00025
//
00026
// Updates to Current Version (Jarduino Aquarium Controller v.1.2)
00027
// • Added support for Arduino 1.0 IDE (Must use patched version)
00028
// • Replaced the ITDB02_Graph16.h Library with UTFT.h Library by Henning Karlsen
00029
// • Replaced Matt Joyce's DS1307 Library with Henning Karlsen's DS1307 Library
00030
// - modified formatting in Karlsen's DS1307 Library
00031
// - rewrote all RTC coding in sketch, based on Karlsen's "ITDB02_Analog_Clock"
00032
// - added "Day of the Week" to the "Date & Time Bar."
00033
// - fixed setting a date that does not exist possibility (ie. FEB 31, 2011)
00034
// • Added 24 Hour Time formatting to the "Test LED Array Output Settings" screen
00035
// • Modified "View/Change Moon LED Max Output"
00036
// - Added pictures and the ability to set/save the Minimum Illumination
00037
// • Replaced LED Output Testing "Widget" with "Slider Bars"
00038
// • Upgraded "Change LED Output Values" page with "Slider Bars"
00039
// • Included more Built-In Protections and Redundancies
00040
// • Added an additional page of user settings including:
00041
// - choice of showing the Day of the Week
00042
// - setting the Fan(s) startup temperature
00043
// - choosing to Dim the LEDs at user defined temperature & How much to Dim them
00044
// - added four user-defined options to the Screensaver
00045
// • Changed the look of some buttons as well as some other visual tweaks
00046
//
00047
// Coming soon to Jarduino v.1.3
00048
// • WiFi and possibly Android/iPhone App
00049
//
00050
// Other Possible Future Developments
00051
// • Improved User Interfaces (Main Screen Panels & Shortcuts)
00052
// • Replace the ITDB02_Touch.h Library with the latest release (when available)
00053
// • Random Weather (Clouds, Storms, etc. along with Increased Wave Action)
00054
// • Real Weather (Mirror the real weather conditions from user-selected locations)
00055
// • Modification of Wave Maker to include Tidal Forces with Lunar Cycle
00056
// • Automatic Water Changer & Top Off
00057
// • Inclusion of Other Sensors:
00058
// 1. pH
00059
// 2. Salinity
00060
// 3. Calcium
00061
// 4. Orp
00062
// • Automatic Dosing
00063
//
00064
//************************************************************************************/
00065
//
00066
// Main code based on Stilo
00067
// <a data-cke-saved-href="<a href="http://code.google.com/p/stilo/" rel="nofollow">http://code.google.com/p/stilo/</a>" href="<a href="http://code.google.com/p/stilo/" rel="nofollow">http://code.google.com/p/stilo/</a>" rel="nofollow"><a href="http://code.google.com/p/stilo/" rel="nofollow">http://code.google.com/p/stilo/</a></a>
00068
//
00069
// LED controlling algorithm is based on Krusduino by Hugh Dangerfield
00070
// <a data-cke-saved-href="<a href="http://code.google.com/p/dangerduino/" rel="nofollow">http://code.google.com/p/dangerduino/</a>" href="<a href="http://code.google.com/p/dangerduino/" rel="nofollow">http://code.google.com/p/dangerduino/</a>" rel="nofollow"><a href="http://code.google.com/p/dangerduino/" rel="nofollow">http://code.google.com/p/dangerduino/</a></a>
00071
//
00072
// A number of functions and some button designs based on the work of Henning Karlsen
00073
// <a data-cke-saved-href="<a href="http://www.henningkarlsen.com/electronics/" rel="nofollow">http://www.henningkarlsen.com/electronics/</a>" href="<a href="http://www.henningkarlsen.com/electronics/" rel="nofollow">http://www.henningkarlsen.com/electronics/</a>" rel="nofollow"><a href="http://www.henningkarlsen.com/electronics/" rel="nofollow">http://www.henningkarlsen.com/electronics/</a></a>
00074
//
00075
// Moon Phase algorithm is based in part on a Moon Phase function by NightAtTheOpera
00076
// <a data-cke-saved-href="<a href="http://www.nano-reef.com/forums/index.php?showtopic=217305&st=0&" rel="nofollow">http://www.nano-reef.com/forums/index.php?showtopic=217305&st=0&</a>" href="<a href="http://www.nano-reef.com/forums/index.php?showtopic=217305&st=0&" rel="nofollow">http://www.nano-reef.com/forums/index.php?showtopic=217305&st=0&</a>" rel="nofollow"><a href="http://www.nano-reef.com/forums/index.php?showtopic=217305&st=0&" rel="nofollow">http://www.nano-reef.com/forums/index.php?showtopic=217305&st=0&</a></a>
00077
//
00078
// Special Thanks:
00079
// Dave Rosser & Hugh Dangerfield - (aka Lewis & Clark?) - Reef Controller Pioneers
00080
// <a data-cke-saved-href="<a href="http://www.ultimatereef.net/forums/showthread.php?t=363432" rel="nofollow">http://www.ultimatereef.net/forums/showthread.php?t=363432</a>" href="<a href="http://www.ultimatereef.net/forums/showthread.php?t=363432" rel="nofollow">http://www.ultimatereef.net/forums/showthread.php?t=363432</a>" rel="nofollow"><a href="http://www.ultimatereef.net/forums/showthread.php?t=363432" rel="nofollow">http://www.ultimatereef.net/forums/showthread.php?t=363432</a></a>
00081
// Mark Chester aka "Koyaanisqatsi" - Knows everything there's to know about LEDs
00082
// <a data-cke-saved-href="<a href="http://www.chestersgarage.com/" rel="nofollow">http://www.chestersgarage.com/</a>" href="<a href="http://www.chestersgarage.com/" rel="nofollow">http://www.chestersgarage.com/</a>" rel="nofollow"><a href="http://www.chestersgarage.com/" rel="nofollow">http://www.chestersgarage.com/</a></a>
00083
// Henning Karlsen
00084
// <a data-cke-saved-href="<a href="http://www.henningkarlsen.com/electronics/" rel="nofollow">http://www.henningkarlsen.com/electronics/</a>" href="<a href="http://www.henningkarlsen.com/electronics/" rel="nofollow">http://www.henningkarlsen.com/electronics/</a>" rel="nofollow"><a href="http://www.henningkarlsen.com/electronics/" rel="nofollow">http://www.henningkarlsen.com/electronics/</a></a>
00085
// Kev Tench aka "tangtastic" - DIY Reef Wizard!
00086
// <a data-cke-saved-href="<a href="http://ukreefs.com/index.php?action=profile;u=1" rel="nofollow">http://ukreefs.com/index.php?action=profile;u=1</a>" href="<a href="http://ukreefs.com/index.php?action=profile;u=1" rel="nofollow">http://ukreefs.com/index.php?action=profile;u=1</a>" rel="nofollow"><a href="http://ukreefs.com/index.php?action=profile;u=1" rel="nofollow">http://ukreefs.com/index.php?action=profile;u=1</a></a>
00087
// Ned Simpson aka "Surff" - Another DIY Reef Guy
00088
// <a data-cke-saved-href="<a href="http://www.ultimatereef.net/forums/showthread.php?t=400993" rel="nofollow">http://www.ultimatereef.net/forums/showthread.php?t=400993</a>" href="<a href="http://www.ultimatereef.net/forums/showthread.php?t=400993" rel="nofollow">http://www.ultimatereef.net/forums/showthread.php?t=400993</a>" rel="nofollow"><a href="http://www.ultimatereef.net/forums/showthread.php?t=400993" rel="nofollow">http://www.ultimatereef.net/forums/showthread.php?t=400993</a></a>
00089
// Neil Williams aka "neildotwilliams" - Yet another DIY Reefer
00090
// <a data-cke-saved-href="<a href="http://www.ultimatereef.net/forums/member.php?u=37721" rel="nofollow">http://www.ultimatereef.net/forums/member.php?u=37721</a>" href="<a href="http://www.ultimatereef.net/forums/member.php?u=37721" rel="nofollow">http://www.ultimatereef.net/forums/member.php?u=37721</a>" rel="nofollow"><a href="http://www.ultimatereef.net/forums/member.php?u=37721" rel="nofollow">http://www.ultimatereef.net/forums/member.php?u=37721</a></a>
00091
// Albert aka "selfonlypath" - Arduino genius
00092
// <a data-cke-saved-href="<a href="http://arduino.cc/forum/index.php?action=profile;u=12410" rel="nofollow">http://arduino.cc/forum/index.php?action=profile;u=12410</a>" href="<a href="http://arduino.cc/forum/index.php?action=profile;u=12410" rel="nofollow">http://arduino.cc/forum/index.php?action=profile;u=12410</a>" rel="nofollow"><a href="http://arduino.cc/forum/index.php?action=profile;u=12410" rel="nofollow">http://arduino.cc/forum/index.php?action=profile;u=12410</a></a>
00093
//
00094
// An Especially Big Thank You to all who Donated, helping to further development.
00095
//
00096
//************************************************************************************/
00097
//
00098
// Known Bugs/Issues:
00099
// • The level of automation may make you lazy
00100
// • If you spot an error or bug in this sketch, please let me know!
00101
// •
00102
//
00103
//************************************************************************************/
00104
//
00105
// LEGAL DISCLAIMER:
00106
// Jarduino Aquarium Controller v.1.1 and v.1.2, Copyright 2011, 2012 Jamie M. Jardin.
00107
// I'm providing this program as free software with the sole intent on furthering
00108
// DIY Aquarium Lighting, but WITHOUT ANY WARRANTY; without even the implied warranty
00109
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You may modify and/or use
00110
// it under the terms of the GNU General Public License as published by the Free
00111
// Software Foundation version 3 of the License, or (at your option) any later
00112
// version. However if you intend on using the program (either in its entirety or any
00113
// part of it) in any way, shape, or form for PROFIT, you MUST contact me and obtain
00114
// my EXPRESS WRITTEN CONSENT (contact information is provided above).
00115
// VIOLATORS WILL BE PROSECUTED TO THE FULLEST EXTENT OF THE LAW.
00116
//
00117
//************************************************************************************/
00118
//
00119
// IF YOU WANT SOME HELP, PLEASE READ ME!
00120
// Feel free to make changes to suit your needs. For you convenience, I’v listed the
00121
// line numbers in the sketch most commonly changed. Some of these values will require
00122
// a change while other values can simply be modified according to user preference.
00123
// If you make changes to lines other than those listed below, know that it may render
00124
// the program inoperable or cause unpredictable behavior.
00125
//
00126
// 144, 147/148, 191-197, 200-203, 206-209, 212, 216-218, 230 (0.2 or higher), 379-467
00127
//
00128
//************************************************************************************/
00129
//LIBRARIES
00130
#include <avr/pgmspace.h>
00131
#include <ITDB02_Touch.h>
00132
#include <Wire.h>
00133
#include <EEPROM.h>
00134
#include "writeAnything.h"
00135
#include <DS1307.h>
00136
#include <OneWire.h>
00137
#include <DallasTemperature.h>
00138
#include <SdFat.h>
00139
#include <SdFatUtil.h>
00140
00141
#include <UTFT.h>
00142
//#include <ITDB02_Graph16.h>
00143
00144
00145
00146
//**********************Define Graph library type (for TFT flat cable) ****************************
00147
//#define Graph16_lib
00148
00149
//**********************Define Shield TYPE ********************************************************
00150
//#define Standard_shield // Uncomment this line if you use the standard Shield for mega 2560,
00151
// standard Shield is support two modes, 6 channel only (UV and Yellow disconn.)
00152
// mode 1 - 8bit PWM for all color
00153
// mode 2 - 8bit PWM for Red, TV, Moon, and 11bit for RoyalBlue, Blue, White, Cyan
00154
00155
//#define Aqua_shield_v2 // Uncomment this line if you use the Aqua Shield V2 by Oleg
00156
// Aqua Shield V2 is support two modes, 8 channel
00157
// mode 1 - 8bit PWM for all color
00158
// mode 2 - 8bit PWM for UV, RoyalBlue, TV, and 11bit for Blue, White, Cyan, Moon, Yellow, DeepRed
00159
00160
#define Aqua_shield_v3 // Uncomment this line if you use the Aqua Shield V3...V3.5 by Oleg
00161
// Aqua Shield V3...V3.2 is support two modes, 8 channel
00162
// mode 1 - 8bit PWM for all color
00163
// mode 2 - 11bit PWM for all color, exept Moon (1khz freq)
00164
// Aqua Shield V3.5 by added TFT Britness dimming support
00165
00166
//************************************************************************************************
00167
//*********************** Change Touch Coordinate ************************************************
00168
//#define Mirror_X
00169
//#define Mirror_Y
00170
00171
//*********************** Define PWM Resolution **************************************************
00172
//#define Timers_8bit // 0-255 value for all version shield, and all colour
00173
//#define Timers_8_11bit // 0-1985 value exept RoyalBlue(0-255), UV(0-255), TV(0-255) colors, for standart & Aqua_shield_v2
00174
#define Timers_11bit // 0-1985 value for standart Shield or Aqua_shield_v3, 11bit PWM for all colour
00175
//************************************************************************************************
00176
00177
//***********************LED Driver Settings******************************************************
00178
boolean RECOM_RCD =
true
;
//Positive PWM output signal (true), for LDD, MW etc.
00179
// Negative - false
00180
00181
//***********************PWM Frequency Setting ***************************************************
00182
#ifdef Timers_8bit
00183
byte
PWM_FRQ_Value = 3;
// PWM_FRQ_Value=2 8bit PWM Frequency = 3906 Hz for colours White, Yellow, Blue, Cyan, Moon, Red
00184
// PWM_FRQ_Value=3 8bit PWM Frequency = 488 Hz
00185
// PWM_FRQ_Value=4 8bit PWM Frequency = 122 Hz
00186
// 8bit PWM Frequency = 976 Hz for RoyalBlue, UV - fixed, DO NOT CHANGE
00187
00188
byte
PWM_FRQ_ValueT2 = 4;
// PWM_FRQ_ValueT2=2 8bit PWM Frequency = 3906 Hz for colours True Violet (420nm)
00189
// PWM_FRQ_ValueT2=3 8bit PWM Frequency = 976 Hz
00190
// PWM_FRQ_ValueT2=4 8bit PWM Frequency = 488 Hz
00191
// PWM_FRQ_ValueT2=5 8bit PWM Frequency = 244 Hz
00192
// PWM_FRQ_ValueT2=6 8bit PWM Frequency = 122 Hz
00193
#endif
00194
00195
#ifdef Timers_8_11bit
00196
byte
PWM_FRQ_Value = 3;
// PWM_FRQ_Value=2 11bit PWM Frequency = 1khz for colours Cyan, White, Blue, DeepRed, Yellow, Moon
00197
// PWM_FRQ_Value=3 11bit PWM Frequency = 125hz
00198
00199
byte
PWM_FRQ_ValueT2 = 6;
// PWM_FRQ_ValueT2=2 8bit PWM Frequency = 3906 Hz for colours True Violet, UV, RoyalBlue
00200
// PWM_FRQ_ValueT2=3 8bit PWM Frequency = 976 Hz
00201
// PWM_FRQ_ValueT2=4 8bit PWM Frequency = 488 Hz
00202
// PWM_FRQ_ValueT2=5 8bit PWM Frequency = 244 Hz
00203
// PWM_FRQ_ValueT2=6 8bit PWM Frequency = 122 Hz
00204
#endif
00205
00206
#ifdef Timers_11bit
00207
byte
PWM_FRQ_Value = 3;
// PWM_FRQ_Value=2 11bit PWM Frequency = 1khz for all colours exept Moon
00208
// PWM_FRQ_Value=3 11bit PWM Frequency = 125hz
00209
#endif
00210
00211
00212
byte
PWM_FRQ_Value_Fan = 5;
// PWM_FRQ_Value_Fan=5 PWM Frequency = 30 Hz for Fans
00213
// PWM_FRQ_Value_Fan=4 PWM Frequency = 122 Hz
00214
//************************************************************************************************
00215
00216
//**********************Define LED PWM channel Colour ********************************************
00217
const
byte
rgbCh0[] = {0, 255, 255};
// PWM 0 Cyan |
00218
const
byte
rgbCh1[] = {224, 102, 255};
// PWM 1 UV |
00219
const
byte
rgbCh2[] = {255, 255, 255};
// PWM 2 Cool White |
00220
const
byte
rgbCh3[] = {43, 96, 222};
// PWM 3 Royal Blue |
00221
const
byte
rgbCh4[] = {0, 0, 200};
// PWM 4 Blue |
00222
const
byte
rgbCh5[] = {255, 0, 0};
// PWM 5 Deep Red |
00223
const
byte
rgbCh6[] = {142, 53, 239};
// PWM 6 TV |
00224
const
byte
rgbCh7[] = {255, 255, 0};
// PWM 7 Yellow |
00225
const
byte
rgbCh8[] = {236, 214, 114};
// PWM 8 Moon |
00226
//************************************************************************************************
00227
00228
00229
//**********************Define LED channel Name **************************************************
00230
char
* ChName[] PROGMEM = {
//resolution define 8 8/11 11 mega2560 pin
00231
"CY"
,
// ChName[0] PWM 0 Cyan | 8bit | 11bit | 11bit
00232
"UV"
,
// ChName[1] PWM 1 UV | 8bit | 8bit | 11bit
00233
"CW"
,
// ChName[2] PWM 2 Cool White | 8bit | 11bit | 11bit
00234
"RB"
,
// ChName[3] PWM 3 Royal Blue | 8bit | 8bit | 11bit
00235
"Bl"
,
// ChName[4] PWM 4 Blue | 8bit | 11bit | 11bit
00236
"DR"
,
// ChName[5] PWM 5 Deep Red | 8bit | 11bit | 11bit
00237
"TV"
,
// ChName[6] PWM 6 TV (420nm) | 8bit | 8bit | 11bit
00238
"Ye"
,
// ChName[7] PWM 7 Yellow | 8bit | 11bit | 11bit
00239
"Moon"
,
// ChName[8] PWM 8 Moon | 8bit | 11bit | 11bit
00240
"%"
,
// ChName[9] % |
00241
"="
// ChName[10] = |
00242
};
00243
//**********************Define LED channel Button Name ********************************************
00244
char
* ChButName[] PROGMEM = {
00245
"Cyan"
,
// ChButName[0]
00246
"UltraViolet"
,
// ChButName[1]
00247
"White"
,
// ChButName[2]
00248
"Royal Blue"
,
// ChButName[3]
00249
"Blue"
,
// ChButName[4]
00250
"DeepRed"
,
// ChButName[5]
00251
"TrueViolet"
,
// ChButName[6]
00252
"Yellow"
,
// ChButName[7]
00253
"Lunar"
,
// ChButName[8]
00254
"Curves Colors"
// ChButName[9]
00255
};
00256
//************************************************************************************************
00257
00258
#ifdef Graph16_lib
00259
ITDB02 myGLCD(38,39,40,41,ITDB32S);
//Uncomment this line for the SSD1289 & mega 2560 for ITDB02_Graph16
00260
#else
00261
UTFT myGLCD(ITDB32S, 38,39,40,41);
//Uncomment this line for the SSD1289 & mega 2560 for UTFT lib
00262
#endif
00263
00264
#ifdef Standard_shield
00265
ITDB02_Touch myTouch (6,5,4,3,2);
// for standart shield
00266
#else
00267
ITDB02_Touch myTouch (42,49,47,48,43);
// for Aqua_shield v3 and v2
00268
#endif
00269
00270
//Initialize the DS1307
00271
DS1307 rtc(20, 21);
00272
00273
Time t, t_temp;
//Init Time-data structure
00274
int
rtcSetMin, rtcSetHr, rtcSetDy,
00275
rtcSetMon, rtcSetYr;
00276
00277
00278
int
clockCenterX=200;
00279
int
clockCenterY=120;
00280
00281
byte
setCalendarFormat = 0;
//DD/MM/YYYY=0 || Month DD, YYYY=1 (change in prog)
00282
byte
displayDOW = 0;
//Hide=0 || Show=1 (change in prog)
00283
byte
setTimeFormat = 0;
//24HR=0 || 12HR=1 (change in prog)
00284
int
AM_PM, yTime;
//Setting clock stuff
00285
int
timeDispH, timeDispM,
00286
xTimeH, xTimeM10, xTimeM1,
00287
xTimeAMPM, xColon;
00288
String time, day;
00289
00290
byte
setLockScreen = 0;
//Lock Screensaver is OFF=0 || Lock Screensaver is ON=1
00291
byte
setScreensaverOnOff = 0;
//OFF=0 || ON=1 Turns it ON/OFF (change in prog)
00292
byte
ClockType = 1;
//ClockType = 0/1/2/3/ -> Blanc/An.Clock/Dig.Clock/Temperature
00293
int
SS_DOW_x;
//Moves the DOW to correct position
00294
byte
setSSmintues;
//Time in (minutes) before Screensaver comes on (change in program)
00295
byte
TempSSminutes;
//Temporary SetSSminutes used in calcs and prints, etc.
00296
byte
setScreenSaverTimer;
//how long in (minutes) before Screensaver comes on (change in program)
00297
byte
screenSaverCounter = 0;
//counter for Screen Saver
00298
byte
returnTimer = 0;
//counter for Screen Return, auto return after 2min timeout
00299
byte
BrigthnessCount = 4;
// brightness button counter (0-OFF, 4 - MAX)
00300
00301
//Declare which fonts to be utilized
00302
extern
uint8_t SmallFont[];
00303
extern
uint8_t BigFont[];
00304
00305
#ifdef Graph16_lib
00306
extern
uint8_t SevenSegNumFontPlus[];
00307
#else
00308
extern
uint8_t SevenSegNumFont[];
00309
#endif
00310
00311
00312
00313
00314
//extern uint8_t RusFont1[]; // маленькая кириллица
00315
//extern uint8_t RusFont3[]; // средняя кириллица
00316
00317
//extern uint8_t Ubuntu[];
00318
//extern uint8_t OCR_A_Extended_M[];
00319
00320
//extern uint8_t SevenSegNumFontPlus[];
00321
//extern uint8_t SixteenSegment[];
00322
//extern uint8_t DotMatrix_M_Num[];
00323
//extern uint8_t DotMatrix_XL_Num[];
00324
00325
#define LARGE true
00326
#define SMALL false
00327
//#define BlUE_BAC false
00328
//#define GREEN_BAC true
00329
00330
const
int
BlUE_BAC = 0;
00331
const
int
GREEN_BAC = 1;
00332
const
int
GREY_BAC = 2;
00333
00334
00335
00336
00337
#ifdef Timers_8bit
00338
int
ResolutionLow = 255;
00339
int
ResolutionHigh= 255;
00340
#endif
00341
00342
#ifdef Timers_8_11bit
00343
int
ResolutionLow = 255;
00344
int
ResolutionHigh= 1985;
00345
#endif
00346
00347
#ifdef Timers_11bit
00348
int
ResolutionLow = 1985;
00349
int
ResolutionHigh= 1985;
00350
#endif
00351
00352
#ifdef Timers_8bit
00353
00354
#else
00355
//*************************Define for 11bit timer ************************************************
00356
#ifndef cbi_mix
00357
#define cbi_mix(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
00358
#endif
00359
#ifndef sbi_mix
00360
#define sbi_mix(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
00361
#endif
00362
//************************************************************************************************
00363
#endif
00364
00365
// ------------- FOR Standart Shield for MEGA2560 ------------------------------
00366
#ifdef Standard_shield
00367
00368
const
int
ledPinRoyBlue = 11;
// 8/11bit timer, Timer1
00369
const
int
ledPinUV = A1;
// NC
00370
const
int
ledPinWhite = 12;
// 8/11bit timer, Timer1
00371
const
int
ledPinYellow = A2;
// NC
00372
const
int
ledPinTV = 10;
// 8bit timer, Timer2
00373
const
int
ledPinBlue = 7;
// 8/11bit timer, Timer4
00374
const
int
ledPinCyan = 8;
// 8/11bit timer, Timer4
00375
const
int
ledPinMoon = 13;
// 8bit timer, Timer0
00376
const
int
ledPinRed = 9;
// 8bit timer, Timer2
00377
00378
const
int
Heatsink1_FansPWM = 44;
// Fan-PWM0 Heatsink1 Fan, Timer5
00379
const
int
Heatsink3_FansPWM = 45;
// Fan-PWM2 Heatsink3 Fan, Timer5
00380
const
int
Heatsink2_FansPWM = 46;
// Fan-PWM1 Heatsink2 Fan, Timer5
00381
00382
const
int
tempAlarmPin = A3;
// Buzzer Alarm for Temperature error
00383
const
int
tempHeatPin = 47;
// power switch0 Heater on/off (set thermostat on heater to highest desired level)
00384
const
int
tempChillPin = 48;
// power switch1 Chiller on/off (set thermostat on chiller to lowest desired level)
00385
const
int
PowerSwitch2 = A3;
// power switch2, temporary NU
00386
const
int
PowerSwitch3 = A4;
// power switch2, temporary NU
00387
00388
const
int
SDchipSelect = 53;
//SD card attached to SPI bus as follows: MISO -pin 50, MOSI -pin 51, CLK- pin 52
00389
00390
const
int
Temp_SensorBus0 = A15;
00391
// DS18B20 Temperature sensors plugged into pin 51 (Water, Hood, & Sump)
00392
OneWire OneWireBus(Temp_SensorBus0);
//DS18B20 Temperature sensors pin
00393
00394
# endif
00395
00396
// ------------- FOR AQUA SHIELD V2 -------------------------------
00397
#ifdef Aqua_shield_v2
00398
00399
const
int
ledPinCyan = 2;
//PWM0/0-10V 8/11bit timer, Timer3
00400
const
int
ledPinUV = 4;
//PWM1/0-10V 8bit timer, Timer0
00401
const
int
ledPinWhite = 12;
//PWM2/0-10V 8/11bit timer, Timer1
00402
const
int
ledPinRoyBlue = 13;
//PWM3/0-10V 8bit timer, Timer0
00403
const
int
ledPinBlue = 5;
//PWM4/0-10V 8/11bit timer, Timer3
00404
const
int
ledPinRed = 6;
//PWM5/0-10V 8/11bit timer, Timer4
00405
const
int
ledPinTV = 10;
//PWM6/0-10V 8bit timer, Timer2
00406
const
int
ledPinYellow = 11;
//PWM7/0-10V 8/11bit timer, Timer1
00407
const
int
ledPinMoon = 3;
//PWM8 Moon, 8/11bit timer, Timer3
00408
00409
const
int
Heatsink1_FansPWM = 44;
//Fan-PWM0 Heatsink1 Fan, Timer5
00410
const
int
Heatsink2_FansPWM = 46;
//Fan-PWM1 Heatsink2 Fan, Timer5
00411
const
int
Heatsink3_FansPWM = 45;
//Fan-PWM2 Heatsink3 Fan, Timer5
00412
00413
const
int
tempHeatPin = A9;
// power switch0 Heater on/off (set thermostat on heater to highest desired level)
00414
const
int
tempChillPin = A11;
// power switch1 Chiller on/off (set thermostat on chiller to lowest desired level)
00415
const
int
PowerSwitch2 = A13;
// power switch2
00416
const
int
tempAlarmPin = 7;
// Buzzer Alarm for Temperature error
00417
const
int
AnalogIN = A14;
00418
00419
const
int
WirelessSPI_CS = A8;
00420
const
int
WirelessW_CE = A10;
00421
const
int
WirelessW_IRQ = A12;
00422
00423
const
int
SDchipSelect = 53;
//SD card attached to SPI bus as follows: MISO -pin 50, MOSI -pin 51, CLK- pin 52
00424
const
int
Temp_SensorBus0 = A15;
00425
OneWire OneWireBus(Temp_SensorBus0);
//DS18B20 Temperature sensors pin
00426
const
int
BackLite = 13;
00427
00428
// not used
00429
//const int WaveMakerTop = A0; //Hydor Koralia Evolution (Top Plug)
00430
//const int WaveMakerBottom = A1; //Hydor Koralia Evolution (Bottom Plug)
00431
//const int autoFeeder = A2; //Automatic Fish Feeder
00432
#endif
00433
00434
// ------------- FOR AQUA SHIELD V3 -------------------------------
00435
#ifdef Aqua_shield_v3
00436
00437
const
int
ledPinCyan = 2;
//PWM0/0-10V 11bit timer, Timer3
00438
const
int
ledPinUV = 3;
//PWM1/0-10V 11bit timer, Timer3
00439
const
int
ledPinWhite = 12;
//PWM2/0-10V 11bit timer, Timer1
00440
const
int
ledPinRoyBlue = 7;
//PWM3/0-10V 11bit timer, Timer4
00441
const
int
ledPinBlue = 5;
//PWM4/0-10V 11bit timer, Timer3
00442
const
int
ledPinRed = 6;
//PWM5/0-10V 11bit timer, Timer4
00443
const
int
ledPinTV = 8;
//PWM6/0-10V 11bit timer, Timer4
00444
const
int
ledPinYellow = 11;
//PWM7/0-10V 11bit timer, Timer1
00445
const
int
ledPinMoon = 4;
//PWM8 moon, 8bit timer, Timer0
00446
00447
const
int
Heatsink1_FansPWM = 44;
//Fan-PWM0 Heatsink1 Fan, Timer5
00448
const
int
Heatsink2_FansPWM = 9;
//Fan-PWM1 Heatsink2 Fan, Timer2
00449
const
int
Heatsink3_FansPWM = 10;
//Fan-PWM2 Heatsink3 Fan, Timer2
00450
00451
const
int
tempHeatPin = A9;
// power switch0 Heater on/off (set thermostat on heater to highest desired level)
00452
const
int
tempChillPin = 46;
// power switch1 Chiller on/off (set thermostat on chiller to lowest desired level)
00453
const
int
PowerSwitch2 = 45;
// power switch2
00454
const
int
PowerSwitch3 = A14;
// power switch3
00455
const
int
tempAlarmPin = A11;
// Buzzer Alarm for Temperature error
00456
00457
const
int
WirelessSPI_CS = A8;
00458
const
int
WirelessW_CE = A10;
00459
const
int
WirelessW_IRQ = A12;
00460
00461
const
int
Temp_SensorBus0 = A15;
00462
const
int
Temp_SensorBus1 = A13;
00463
00464
OneWire OneWireBus(Temp_SensorBus0);
//DS18B20 Temperature sensors pin - first sensor bus
00465
//OneWire OneWireBus1(Temp_SensorBus1); //DS18B20 Temperature sensors pin - second sensor bus
00466
const
int
SDchipSelect = 53;
//SD card attached to SPI bus as follows: MISO -pin 50, MOSI -pin 51, CLK- pin 52
00467
const
int
BackLite = 13;
//PWMx 8bit timer, Timer0
00468
#endif
00469
00470
SdFat sd;
00471
SdFile myFile;
00472
#define error(s) sd.errorHalt_P(PSTR(s))
00473
00474
// Pass our oneWire reference to Dallas Temperature.
00475
DallasTemperature sensors(&OneWireBus);
00476
DeviceAddress tempDeviceAddress;
00477
DeviceAddress Heatsink1Thermometer;
00478
DeviceAddress Heatsink2Thermometer;
00479
DeviceAddress waterThermometer;
00480
00481
byte
resolution = 11;
00482
unsigned
long
lastTempRequest = 0;
00483
int
delayInMillis = 0;
00484
00485
float
tempW = 0;
//Water temperature values
00486
float
tempH1 = 0;
//Heatsink temperature
00487
float
tempH2 = 0;
//Heatsink2 heatsink temperature
00488
float
setTempToBeginHeatsink1FanC=0.0;
//Temperature to Turn on Heatsink1 Fans (in Degrees C)
00489
float
setTempToBeginHeatsink2FanC=0.0;
//Temperature to Turn on Heatsink2 Fan (in Degrees C)
00490
float
setTempToBeginHeatsink1FanF=0.0;
//Temperature to Turn on Heatsink1 Fans (in Degrees F)
00491
float
setTempToBeginHeatsink2FanF=0.0;
//Temperature to Turn on Heatsink2 Fan (in Degrees F)
00492
byte
setTempToSoundAlarmC=0;
//Temperature to Heatsink Sound alarm (in Degrees C)
00493
byte
setTempToSoundAlarmF=0;
//Temperature to Heatsink Sound alarm (in Degrees F)
00494
byte
WaterTempErrorCount=0;
//Error temp read counter
00495
byte
Heatsink1TempErrorCount=0;
//Error temp read counter
00496
byte
Heatsink2TempErrorCount=0;
//Error temp read counter
00497
float
tempH1Store = 25;
00498
float
tempH2Store = 25;
00499
00500
float
temp2beHFan;
//Temporary Temperature Values
00501
float
temp2beSFan;
//Temporary Temperature Values
00502
00503
int
Heatsink1TempInterval = 0;
//Used for PWM Duty calculations
00504
int
Heatsink2TempInterval = 0;
//Used for PWM Duty calculations
00505
byte
Heatsink1PWM = 0;
//Used for PWM Duty calculations
00506
byte
Heatsink2PWM = 0;
//Used for PWM Duty calculations
00507
00508
float
setTempC = 0.0;
//Desired Water Temperature (User input in program)
00509
float
setTempF = 0.0;
00510
float
offTempC = 0.0;
//Desired Water Temp. Offsets for Heater & Chiller (User input in program)
00511
float
offTempF = 0.0;
00512
float
alarmTempC = 0.0;
//Temperature the Alarm will sound (User input in program)
00513
float
alarmTempF = 0.0;
00514
boolean tempCoolflag = 0;
//1 if cooling on
00515
boolean tempHeatflag = 0;
//1 if heating on
00516
boolean tempAlarmflagW = 0;
//1 if alarm on
00517
boolean tempAlarmflagH1 = 0;
//1 if alarm on
00518
boolean tempAlarmflagH2 = 0;
//1 if alarm on
00519
boolean AlarmflagON =
false
;
00520
byte
AlarmLevel = 0;
00521
boolean SoftStartON= 0;
00522
00523
float
temp2beS;
//Temporary Temperature Values
00524
float
temp2beO;
//Temporary Temperature Values
00525
float
temp2beA;
//Temporary Temperature Values
00526
byte
setTempScale = 0;
//Celsius=0 || Fahrenheit=1 (change in prog)
00527
String degC_F;
//Used in the Conversion of Celsius to Fahrenheit
00528
float
MaxTempW;
// maximal day temperature
00529
float
MaxTempH1;
00530
float
MaxTempH2;
00531
00532
byte
setDimLEDsOnOff = 0;
//If/When LEDs reach a certain temp they can dim down (feature off by default)
00533
byte
setLEDsDimTempC = 0;
//Default value is 0, set this value in program
00534
byte
setLEDsDimTempF = 0;
//Conversion of C-F
00535
byte
TempLEDsDimTemp;
//Temporary LED Dimming Temp
00536
byte
setLEDsDimPercent = 0;
//Choose value to failsafe dim LEDs in program
00537
byte
TempLEDsDimPercent;
//Temporary LED Dimming Percent
00538
float
PercentDim = 0.0;
//Converts saved value in EEPROM to a percentage
00539
float
PercentSoftStart = 0.0;
//change from 0 to 1 with 0.1 increment, every 5sec after programm is started
00540
00541
//int tempLED=setLEDsDimTempC+5;
00542
00543
float
LC = 29.53059;
//1 Lunar Cycle = 29.53059 days
00544
String LP;
//LP = Lunar Phase - variable used to print out Moon Phase
00545
double
AG;
00546
byte
tMaxI;
//Maximum Illumination of Moon (User Defined/Set in Prog. -- Default = 0)
00547
byte
tMinI;
//Minimum Illumination of Moon (User Defined/Set in Prog. -- Default = 0)
00548
byte
MinI = 10;
00549
byte
MaxI = 90;
//Highest Value (0-255) at which Led is Still OFF, or the Value
00550
//you wish the New Moon to Shine (it will increase from here to MaxI)
00551
00552
00553
//extern unsigned int WeatherPic[0xBD1]; // солнце, туча, гром
00554
00555
unsigned
int
*MoonPic;
//Pointer to the Lunar Phase Pics
00556
extern
unsigned
int
//Lunar Phase Pics
00557
New_Moon[0xD24],
00558
Waxing_Crescent[0xD24],
00559
First_Quarter[0xD24],
00560
Waxing_Gibbous[0xD24],
00561
Full_Moon[0xD24],
00562
Waning_Gibbous[0xD24],
00563
Last_Quarter[0xD24],
00564
Waning_Crescent[0xD24];
00565
00566
// text string for all windows header
00567
prog_char Header_Text_string0[] PROGMEM =
"Do you want to save"
;
// "String 0" etc are strings to store - change to suit.
00568
prog_char Header_Text_string1[] PROGMEM =
" changes"
;
00569
prog_char Header_Text_string2[] PROGMEM =
" before exit?"
;
00570
prog_char Header_Text_string3[] PROGMEM =
"TV DR CW BL RBL UV CY YE Moon"
;
00571
prog_char Header_Text_string4[] PROGMEM =
"Change LED Output Values"
;
00572
prog_char Header_Text_string5[] PROGMEM =
"Change Blue LED Output Values"
;
//NU
00573
prog_char Header_Text_string6[] PROGMEM =
"Change Royal Blue LED Output Values"
;
//NU
00574
prog_char Header_Text_string7[] PROGMEM =
"Change DeepRed LED Output Values"
;
//NU
00575
prog_char Header_Text_string8[] PROGMEM =
"Change UltraViolet LED Output Values"
;
//NU
00576
prog_char Header_Text_string9[] PROGMEM =
"Change TrueViolet LED Output Values"
;
//NU
00577
prog_char Header_Text_string10[] PROGMEM =
"Change Cyan LED Output Values"
;
//NU
00578
prog_char Header_Text_string11[] PROGMEM =
"Change Yellow LED Output Values"
;
//NU
00579
prog_char Header_Text_string12[] PROGMEM =
"Make a selection above. Choose"
;
00580
prog_char Header_Text_string13[] PROGMEM =
"any Two-Hour Increment"
;
00581
prog_char Header_Text_string14[] PROGMEM =
"then you can adjust values."
;
00582
prog_char Header_Text_string15[] PROGMEM =
"Choose Option"
;
00583
prog_char Header_Text_string16[] PROGMEM =
"Time and Date Settings"
;
00584
prog_char Header_Text_string17[] PROGMEM =
"H2O Temperature Control Settings"
;
00585
prog_char Header_Text_string18[] PROGMEM =
"LED Testing Options"
;
00586
prog_char Header_Text_string19[] PROGMEM =
"Rapid (x120) Test LED Array"
;
00587
prog_char Header_Text_string20[] PROGMEM =
"Individual LED Outputs: Color Choices"
;
00588
prog_char Header_Text_string21[] PROGMEM =
"View/Change Moon LED Min & Max Output"
;
00589
00590
prog_char Header_Text_string22[] PROGMEM =
"View/Change Wavemaker Settings"
;
00591
prog_char Header_Text_string23[] PROGMEM =
"Alternating Flow Mode Settings"
;
00592
prog_char Header_Text_string24[] PROGMEM =
"Synchronous Flow Mode Settings"
;
00593
prog_char Header_Text_string25[] PROGMEM =
"Automatic Fish Feeder Page"
;
00594
prog_char Header_Text_string26[] PROGMEM =
"Set Feeding Time 1"
;
00595
prog_char Header_Text_string27[] PROGMEM =
"Set Feeding Time 2"
;
00596
prog_char Header_Text_string28[] PROGMEM =
"Set Feeding Time 3"
;
00597
prog_char Header_Text_string29[] PROGMEM =
"Set Feeding Time 4"
;
00598
00599
prog_char Header_Text_string30[] PROGMEM =
"View/Change General Settings: Page 1"
;
00600
prog_char Header_Text_string31[] PROGMEM =
"View/Change General Settings: Page 2"
;
00601
prog_char Header_Text_string32[] PROGMEM =
"View/Change Fans Startup Temperatures"
;
00602
prog_char Header_Text_string33[] PROGMEM =
"View/Change LEDs' Dimming Temperature"
;
00603
prog_char Header_Text_string34[] PROGMEM =
"View/Change Screensaver Settings"
;
00604
prog_char Header_Text_string35[] PROGMEM =
"Jarduino AQUA Controller v1.40 Oleg mod"
;
00605
prog_char Header_Text_string36[] PROGMEM =
"View/Change General Settings: Page 3"
;
00606
prog_char Header_Text_string37[] PROGMEM =
"Config Clouds and Thunderstorm"
;
00607
prog_char Header_Text_string38[] PROGMEM =
"Clouds Setting"
;
00608
prog_char Header_Text_string39[] PROGMEM =
"Thunderstorm Setting"
;
00609
00610
00611
char
* Header_Text_table [] PROGMEM = {
00612
Header_Text_string0,
00613
Header_Text_string1,
00614
Header_Text_string2,
00615
Header_Text_string3,
00616
Header_Text_string4,
00617
Header_Text_string5,
00618
Header_Text_string6,
00619
Header_Text_string7,
00620
Header_Text_string8,
00621
Header_Text_string9,
00622
Header_Text_string10,
00623
Header_Text_string11,
00624
Header_Text_string12,
00625
Header_Text_string13,
00626
Header_Text_string14,
00627
Header_Text_string15,
00628
Header_Text_string16,
00629
Header_Text_string17,
00630
Header_Text_string18,
00631
Header_Text_string19,
00632
Header_Text_string20,
00633
Header_Text_string21,
00634
Header_Text_string22,
00635
Header_Text_string23,
00636
Header_Text_string24,
00637
Header_Text_string25,
00638
Header_Text_string26,
00639
Header_Text_string27,
00640
Header_Text_string28,
00641
Header_Text_string29,
00642
Header_Text_string30,
00643
Header_Text_string31,
00644
Header_Text_string32,
00645
Header_Text_string33,
00646
Header_Text_string34,
00647
Header_Text_string35,
00648
Header_Text_string36,
00649
Header_Text_string37,
00650
Header_Text_string38,
00651
Header_Text_string39
00652
};
00653
00654
prog_char Text_string0[] PROGMEM =
"Writing to file Backup.txt"
;
00655
prog_char Text_string1[] PROGMEM =
"Backup done. "
;
00656
prog_char Text_string2[] PROGMEM =
" N.C "
;
00657
prog_char Text_string3[] PROGMEM =
" Water "
;
00658
prog_char Text_string4[] PROGMEM =
"H.Sink1"
;
00659
prog_char Text_string5[] PROGMEM =
"H.Sink2"
;
00660
prog_char Text_string6[] PROGMEM =
"Detect Dallas Sensors"
;
00661
prog_char Text_string7[] PROGMEM =
"Backup setting to SD Card"
;
00662
prog_char Text_string8[] PROGMEM =
"Reset setting to DEFAULT"
;
00663
prog_char Text_string9[] PROGMEM =
"Found: "
;
00664
prog_char Text_string10[] PROGMEM =
"Dallas Sensors"
;
00665
prog_char Text_string11[] PROGMEM =
"Sensor N"
;
00666
prog_char Text_string12[] PROGMEM =
" connect to"
;
00667
prog_char Text_string13[] PROGMEM =
"Heatsink N1 FAN Startup temperature"
;
00668
prog_char Text_string14[] PROGMEM =
"Heatsink N2 FAN Startup temperature"
;
00669
prog_char Text_string15[] PROGMEM =
"20--50C"
;
00670
prog_char Text_string16[] PROGMEM =
"68--120F"
;
00671
prog_char Text_string17[] PROGMEM =
"Heatsink Sound Alarm temperature"
;
00672
prog_char Text_string18[] PROGMEM =
"40-99C"
;
00673
prog_char Text_string19[] PROGMEM =
"104-210F"
;
00674
prog_char Text_string20[] PROGMEM =
"Desired Temperature: "
;
00675
prog_char Text_string21[] PROGMEM =
"Temperature Offset: 0.1-5"
;
00676
prog_char Text_string22[] PROGMEM =
"Alarm Offset: 0.1-9.9"
;
00677
prog_char Text_string23[] PROGMEM =
"50-104F"
;
00678
prog_char Text_string24[] PROGMEM =
"10-40C"
;
00679
00680
prog_char Text_string25[] PROGMEM =
"Feeding Time 1 "
;
00681
prog_char Text_string26[] PROGMEM =
"Feeding Time 2 "
;
00682
prog_char Text_string27[] PROGMEM =
"Feeding Time 3 "
;
00683
prog_char Text_string28[] PROGMEM =
"Feeding Time 4 "
;
00684
00685
prog_char Text_string29[] PROGMEM =
"ON"
;
00686
prog_char Text_string30[] PROGMEM =
"OFF"
;
00687
prog_char Text_string31[] PROGMEM =
"This time has not"
;
00688
prog_char Text_string32[] PROGMEM =
"been scheduled"
;
00689
prog_char Text_string33[] PROGMEM =
"Feed Fish Now!"
;
00690
prog_char Text_string34[] PROGMEM =
"Now Feeding"
;
00691
prog_char Text_string35[] PROGMEM =
"TrueViolet"
;
00692
prog_char Text_string36[] PROGMEM =
"DeepRed"
;
00693
prog_char Text_string37[] PROGMEM =
"White"
;
00694
prog_char Text_string38[] PROGMEM =
"Blue"
;
00695
prog_char Text_string39[] PROGMEM =
"Lunar"
;
00696
prog_char Text_string40[] PROGMEM =
"Royal Blue"
;
00697
prog_char Text_string41[] PROGMEM =
"UltraViolet"
;
00698
prog_char Text_string42[] PROGMEM =
"Cyan"
;
00699
prog_char Text_string43[] PROGMEM =
"Yellow"
;
00700
prog_char Text_string44[] PROGMEM =
"Curves Colors"
;
00701
prog_char Text_string45[] PROGMEM =
"Set Minimum"
;
00702
prog_char Text_string46[] PROGMEM =
"Illumination"
;
00703
prog_char Text_string47[] PROGMEM =
"(0...100%)"
;
00704
prog_char Text_string48[] PROGMEM =
"Set Maximum"
;
00705
prog_char Text_string49[] PROGMEM =
"New Moon"
;
00706
prog_char Text_string50[] PROGMEM =
"Full Moon"
;
00707
prog_char Text_string51[] PROGMEM =
"LED ARRAY"
;
00708
prog_char Text_string52[] PROGMEM =
"LUNAR PHASE"
;
00709
prog_char Text_string53[] PROGMEM =
"MONITORS & ALERTS"
;
00710
prog_char Text_string54[] PROGMEM =
"% of Full"
;
00711
prog_char Text_string55[] PROGMEM =
"Changed!"
;
00712
prog_char Text_string56[] PROGMEM =
" OFF "
;
00713
prog_char Text_string57[] PROGMEM =
"Overheat only"
;
00714
prog_char Text_string58[] PROGMEM =
" ON "
;
00715
00716
prog_char Text_string59[] PROGMEM =
" 0%"
;
00717
prog_char Text_string60[] PROGMEM =
" 25%"
;
00718
prog_char Text_string61[] PROGMEM =
" 50%"
;
00719
prog_char Text_string62[] PROGMEM =
" 75%"
;
00720
prog_char Text_string63[] PROGMEM =
"100%"
;
00721
00722
prog_char Text_string64[] PROGMEM =
" Blank "
;
00723
prog_char Text_string65[] PROGMEM =
" Anl. Clock"
;
00724
prog_char Text_string66[] PROGMEM =
" Dig. Clock"
;
00725
prog_char Text_string67[] PROGMEM =
"Temperature"
;
00726
prog_char Text_string68[] PROGMEM =
": "
;
00727
prog_char Text_string69[] PROGMEM =
" Temp:"
;
00728
00729
00730
char
* Text_table [] PROGMEM = {
00731
Text_string0,
00732
Text_string1,
00733
Text_string2,
00734
Text_string3,
00735
Text_string4,
00736
Text_string5,
00737
Text_string6,
00738
Text_string7,
00739
Text_string8,
00740
Text_string9,
00741
Text_string10,
00742
Text_string11,
00743
Text_string12,
00744
Text_string13,
00745
Text_string14,
00746
Text_string15,
00747
Text_string16,
00748
Text_string17,
00749
Text_string18,
00750
Text_string19,
00751
Text_string20,
00752
Text_string21,
00753
Text_string22,
00754
Text_string23,
00755
Text_string24,
00756
Text_string25,
00757
Text_string26,
00758
Text_string27,
00759
Text_string28,
00760
Text_string29,
00761
Text_string30,
00762
Text_string31,
00763
Text_string32,
00764
Text_string33,
00765
Text_string34,
00766
Text_string35,
00767
Text_string36,
00768
Text_string37,
00769
Text_string38,
00770
Text_string39,
00771
Text_string40,
00772
Text_string41,
00773
Text_string42,
00774
Text_string43,
00775
Text_string44,
00776
Text_string45,
00777
Text_string46,
00778
Text_string47,
00779
Text_string48,
00780
Text_string49,
00781
Text_string50,
00782
Text_string51,
00783
Text_string52,
00784
Text_string53,
00785
Text_string54,
00786
Text_string55,
00787
Text_string56,
00788
Text_string57,
00789
Text_string58,
00790
Text_string59,
00791
Text_string60,
00792
Text_string61,
00793
Text_string62,
00794
Text_string63,
00795
Text_string64,
00796
Text_string65,
00797
Text_string66,
00798
Text_string67,
00799
Text_string68,
00800
Text_string69
00801
};
00802
00803
char
* print_text[] PROGMEM = {
00804
"<< BACK"
,
// print_text[0]
00805
"NEXT >>"
,
// print_text[1]
00806
"SAVE"
,
// print_text[2]
00807
"CANCEL"
,
// print_text[3]
00808
"Dim LEDs Temp."
,
// print_text[4]
00809
"Screensaver"
,
// print_text[5]
00810
"Display MAX Temp."
,
// print_text[6]
00811
"LED Soft Start"
,
// print_text[7]
00812
"Please press on the shield Reset Button"
,
// print_text[8]
00813
"or turn OFF "
,
// print_text[9]
00814
"and then turn ON the controller"
,
// print_text[10]
00815
"Please WAIT, cleaning EEPROM memory"
,
// print_text[11]
00816
"Alarm Buzzer Function"
,
// print_text[12]
00817
"Choose ScreenSaver type"
,
// print_text[13]
00818
"Screen Lock ON/OFF"
,
// print_text[14]
00819
"Wait:"
,
// print_text[15]
00820
"minutes"
,
// print_text[16]
00821
"Brightness of the TFT"
,
// print_text[17]
00822
"Clouds"
,
// print_text[18]
00823
"Thunderstorm"
,
// print_text[19]
00824
"Test Weather"
,
// print_text[20]
00825
"Setting"
,
// print_text[21]
00826
"ON"
,
// print_text[22]
00827
"OFF"
,
// print_text[23]
00828
"Periodicity and duration of clouds are"
,
// print_text[24]
00829
"configured automatically, based on the"
,
// print_text[25]
00830
"random number generator"
,
// print_text[26]
00831
"Clouds for day"
,
// print_text[27]
00832
"(1...5 time)"
,
// print_text[28]
00833
"Maximum duration of"
,
// print_text[29]
00834
"cloud at a time"
,
// print_text[30]
00835
"15...90 min"
,
// print_text[31]
00836
"Quantity of cloudy"
,
// print_text[32]
00837
"days per week"
,
// print_text[33]
00838
"Storm generated randomly only the"
,
// print_text[34]
00839
"presence of clouds"
,
// print_text[35]
00840
"The maximum duration of"
,
// print_text[36]
00841
"a Thunderstorm"
,
// print_text[37]
00842
"Tunderstorm at night"
,
// print_text[38]
00843
"Start"
,
// print_text[39]
00844
"Stop"
// print_text[40]
00845
};
00846
00847
00848
char
buffer[40];
00849
int
PrintStringIndex;
00850
00851
int
dispScreen=0;
// 0-Main Screen
00852
// 1-Menu
00853
// 2-Clock and data Setup screen
00854
// 3-H2O Temp Control
00855
// 4-LED Testing Options
00856
// 5-Rapid (x120) Test LED Arrays
00857
// 6-Test Individual LED Colors
00858
// 7-Change LED values
00859
// 8-SHOW LED OUTPUT VALUES CURVE SCREEN
00860
// 9-Change Selected Color Array Values
00861
// 10-Wavemaker
00862
// 11-Wavemaker Settings
00863
// 12-AUTOMATIC FISH FEEDER PAGE
00864
// 13-SET AUTOMATIC FISH FEEDER TIMES
00865
// 14-GENERAL SETTINGS (PAGE 1)
00866
// 15-GENERAL SETTINGS (PAGE 2)
00867
// 16-CHANGE Heatsink1 FAN TEMP
00868
// 17-DIM LEDs AT TEMP
00869
// 18-SET SCREENSAVER WAIT TIME
00870
// 19-not used
00871
// 20-GENERAL SETTINGS (PAGE 3)
00872
// 21-Dallas Detect page
00873
// 22-Backup EEPROM to SD CARD
00874
// 23-Preset Setting
00875
// 24 -ScreenSaver
00876
// 25-Weather Control
00877
// 26-Cloud Control
00878
// 27-Storm Control
00879
// 28-Weather Test
00880
00881
//**************Weather ****************
00882
00883
byte
TempCount = 0;
00884
int
timer;
00885
byte
clouDonOff = 0;
// для отображения включения облаков (0 -off, 1 on)
00886
byte
storMonOff = 0;
// для отображения включения грозы (0 -off, 1 on)
00887
//extern unsigned int oblaka[0x441];
00888
//extern unsigned int groza2[0x441];
00889
byte
weezleONoff = 0;
// 1 - включение погоды
00890
float
PercentDimLW = 0.0;
00891
float
PercentDimLW1 = 0.0;
00892
int
DimCloudMin = 10;
// изменяя эту величину мы делаем тучи темнее или светлее (0...100) %
00893
int
DimCloudMax = 100;
// изменяя эту величину мы делаем тучи темнее или светлее (0...100) %
00894
int
CloudTime;
00895
int
CloudStartTime;
00896
00897
int
dimmW = 10;
00898
float
DimCloud = 100;
// для плавного перехода в облака
00899
float
RampRatio = 1;
00900
byte
weeStart = 0;
// 0-обычный свет, 1-переход в облака, 2-выход из облаков
00901
float
value = 0;
// изменение яркости при облачности
00902
int
valueH = 0;
00903
int
valueH1 = 0;
00904
byte
valHH=0;
00905
long
previousMillisFive_One = 0;
00906
int
Five_One = 5000;
00907
byte
stormGR;
// гроза 1-да, 0-нет
00908
int
time1=0;
00909
byte
weezON;
00910
00911
byte
dayL=1;
00912
byte
dayLtmp;
00913
00914
byte
timOBL=5;
// облака 3 раза в день
00915
byte
timOBLtmp;
00916
byte
CloudDayQantity = 3;
00917
byte
CloudDuration = 45;
00918
byte
CloudWeekQantity = 3;
00919
int
timOBL1=0, timOBL2=0, timOBL3=0, timOBL4=0, timOBL5=0;
// время срабатывания облочности
00920
int
deltaOBL1, deltaOBL2, deltaOBL3, deltaOBL4, deltaOBL5;
// продолжительность облачности
00921
byte
OBLoNoff=0;
00922
00923
byte
deltaOBL=60;
00924
byte
deltaOBLtmp;
00925
int
timGroz1, timGroz2, timGroz3;
// время срабатывания грозы
00926
int
deltaGroz1, deltaGroz2, deltaGroz3;
// продолжительность грозы
00927
00928
byte
razOBL=3;
00929
byte
razOBLtmp=25;
00930
00931
byte
kkT = 0;
00932
byte
kk1=0, kk2=0, kk3=0, kk4=0,kk5=0;
00933
byte
kf1=0, kf2=0, kf3=0, kf4=0, kf5=0;
00934
00935
int
tew=0;
// для теста
00936
int
timOBL1temp;
00937
int
deltaOBL1temp;
00938
int
timerGR1temp;
00939
int
deltaGR1temp;
00940
00941
byte
GROZA=0;
00942
int
GROZAday=0;
00943
byte
GR1=0, GR2=0, GR3=0, GR4=0, GR5=0;
00944
byte
GR6=0;
00945
int
PercentDimLW1temp;
00946
int
timGROZ=2;
00947
int
timGROZtmp;
00948
int
timerGR1=0, timerGR2=0, timerGR3=0, timerGR4=0, timerGR5=0, timerGR6=0;
00949
int
deltaGR1, deltaGR2, deltaGR3, deltaGR4, deltaGR5, deltaGR6;
00950
byte
kfg1=1, kfg2=1, kfg3=1, kfg4=1, kfg5=1, kfg6=1;
00951
00952
byte
GROZANight=0;
00953
byte
NightGR=0;
00954
00955
int
Moln=0;
00956
00957
long
GROZaMillis =0;
00958
byte
dayOBL[7] = {0, 0, 0, 0, 0, 0, 0} ;
// для настройки облачности на неделю
00959
byte
OBLday;
00960
00961
00962
int
x, y;
//touch coordinates
00963
00964
long
previousMillisLED = 0;
//Used in the Test LED Array Function
00965
long
previousMillisWave = 0;
//Used in the WaveMaker Function wave_output()
00966
long
previousMillisFive = 0;
//Used in the Main Loop (Checks Time,Temp,LEDs,Screen)
00967
long
previousMillisOne = 0;
//Used in the Main Loop (LEDs level)
00968
long
previousMillisAlarm = 0;
//Used in the Alarm
00969
00970
boolean waveMakerOff =
false
;
//For Turning ON/OFF WaveMaker
00971
boolean waveMakerTest =
false
;
//For Testing Wave Settings
00972
long
wPump1, wPump2;
//Total Alternating Times
00973
long
intervalAlt = wPump1;
//Changing Interval for Alternating Mode
00974
long
wOnForT, wOffForT;
//Total Synchronous-Pulse Times
00975
long
intervalSynch = wOnForT;
//Changing Interval for Synch-Pulse Mode
00976
int
PumpTstate = LOW;
//Used to set the Top Powerhead ON or OFF
00977
int
PumpBstate = LOW;
//Used to set the Bottom Powerhead ON or OFF
00978
00979
int
WAVE, Pump1m, Pump1s, Pump2m,
//EEPROM vars
00980
Pump2s, Synch, OnForTm, OnForTs,
00981
OffForTm, OffForTs;
00982
int
MODE = WAVE;
00983
int
MIN1=0, SEC1=0, MIN2=0, SEC2=0,
//Used in the Wavemaker viewWaveTimes()
00984
minY1, minY2;
00985
int
Min1=0, Sec1=0, Min2=0, Sec2=0;
//Used in the Wavemaker viewWaveTimesPage() & wave+/-
00986
int
min1X=91, sec1X=237,
//Used in the Wavemaker waveModePlusMinus()
00987
min2X=91, sec2X=237,
00988
tTime1=0, tTime2=0;
00989
int
WaveCorrector = 2;
//Fix for halving of wave seconds (Change to "1" if
00990
//your wave seconds are doubled)
00991
00992
long
previousMillisCt = 0;
//stores the last update for the Countdown Timer
00993
long
intervalCt = 1000;
//One Second Interval for Countdown Timer
00994
int
countDown = 5*60 + 0;
//Countdown for 5 minutes and zero seconds
00995
int
MIN_O = 5;
//Start the Time at 5 (for looks only)
00996
int
SEC_T = 0;
00997
int
SEC_O = 0;
00998
00999
byte
LedChangTime = 0;
//LED change page, time and values
01000
byte
oldLCT ;
01001
01002
int
min_cnt;
// Used to determine the place in the color arrays
01003
byte
temp_sector;
// used in led test arrays, min_cnt/15
01004
01005
boolean LEDtestTick =
false
;
// for Rapid led test, speed up clock
01006
boolean firstTouch =
false
;
// for exit from screensaver #oleg
01007
boolean SliderSwitch =
false
;
// slider
01008
int
TopSldY ;
// top slider
01009
int
BotSldY ;
// bot slider
01010
01011
byte
ButtonShift;
01012
01013
boolean LedShannelFlag_on_off;
// flag led on/off channel status
01014
01015
byte
LedShannelStatusByte =255;
// ON=1/OFF=0 channel, one bit - one channel
01016
byte
GlobalStatus1Byte= 0x0;
// bit 0 for Y/N button in reset default function
01017
// bit 1 used in HOT led function
01018
// bit 2 =1 for detect pressing button Yes/No
01019
// bit 3 =1 if led setting changed
01020
// GlobalStatus1Byte.4 = StartUPFan2 ;
01021
// GlobalStatus1Byte.5 = StartUPFan2_Timeout;
01022
// GlobalStatus1Byte.6 = StartUPFan1 ;
01023
// GlobalStatus1Byte.7)= StartUPFan1_Timeout;
01024
01025
byte
GlobalStatus2Byte=0x0;
// byte Led preset status
01026
// bit 0 - preset 1 (ON=1/OFF=0)
01027
// bit 1 - preset 2
01028
// bit 2 - preset 3
01029
// bit 3 - preset 4
01030
01031
byte
GlobalStatus3Byte=0x0;
// byte weather day on/off status
01032
// bit 0 - start/stop test
01033
// bit 1 - tuesday;
01034
// bit 2 - wednesday;
01035
// bit 3 - thursday;
01036
// bit 4 - friday;
01037
// bit 5 - saturday;
01038
// bit 6 - sunday;
01039
// bit 7 - xxxx;
01040
01041
01042
byte
StartTime;
01043
byte
StopTime;
01044
byte
LightDay;
01045
byte
counterB1=0;
01046
byte
counterB2=0;
01047
byte
counterB3=0;
01048
byte
numberOfDevices=0;
// quantity of Dallas sensor connected to board
01049
int
EndScale;
01050
unsigned
long
previousMillis1sec;
01051
01052
int
whiteLed, blueLed, rblueLed,
//previous LED output values
01053
redLed, uvLed, tvLed, cyLed, yeLed;
01054
int
bled_out, wled_out, rbled_out,
//current LED output values
01055
rled_out, uvled_out,
01056
moonled_out, tvled_out,
01057
cyled_out, yeled_out;
01058
int
bcol_out, wcol_out, rbcol_out,
//Current LED output values for Test Ind. Color LEDs
01059
rcol_out, uvcol_out, tvcol_out,
01060
mooncol_out, cycol_out, yelcol_out;
01061
int
tv_out, b_out, w_out, rb_out, r_out, uv_out, moon_out, cy_out, yel_out;
// led values for write to PWM
01062
01063
01064
byte
AddressShift;
// shift address preset in EEPROM
01065
01066
byte
COLOR=0, WHITE=1, BLUE=2, ROYAL=3,
//Used to Determine View/Change Color LED Values
01067
RED=4, ULTRA=5, TV=6, MOON=7,
01068
CYAN=8, YELLOW=9;
01069
01070
boolean colorLEDtest =
false
;
//if TRUE - led test, FALSE - regular mode
01071
byte
sbR, sbG, sbB;
01072
int
sbX1, sbX2;
//Used in the Slider Bars
01073
int
tSlide=0;
01074
boolean DrawStaticElement =
false
;
//Allows selection of changing LED values
01075
01076
01077
byte
feedTime;
01078
byte
FEEDTime1, FEEDTime2,
01079
FEEDTime3, FEEDTime4;
01080
01081
byte
feedFish1H, feedFish1M,
//Times to feed the fish
01082
feedFish2H, feedFish2M,
01083
feedFish3H, feedFish3M,
01084
feedFish4H, feedFish4M;
01085
01086
byte
MAX_Temp_on_off = 0;
//OFF=0 || ON=1 (change in prog)
01087
byte
fiveTillBackOn1, fiveTillBackOn2,
01088
fiveTillBackOn3, fiveTillBackOn4;
01089
boolean FeedWaveCtrl_1 =
false
;
01090
boolean FeedWaveCtrl_2 =
false
;
01091
boolean FeedWaveCtrl_3 =
false
;
01092
boolean FeedWaveCtrl_4 =
false
;
01093
01094
byte
tvled[96] = {
01095
0, 0, 0, 0, 0, 0, 0, 0,
//0 - 1
01096
0, 0, 0, 0, 0, 0, 0, 0,
//2 - 3
01097
0, 0, 0, 0, 0, 0, 0, 0,
//4 - 5
01098
0, 0, 0, 0, 0, 0, 0, 0,
//6 - 7
01099
0, 0, 0, 0, 0, 0, 0, 0,
//8 - 9
01100
0, 0, 0, 0, 2, 5, 8, 10,
//10 - 11
01101
20, 40, 60, 70, 70, 70, 70, 70,
//12 - 13
01102
70, 70, 70, 70, 70, 70, 70, 70,
//14 - 15
01103
70, 70, 70, 70, 70, 70, 70, 70,
//16 - 17
01104
70, 70, 70, 70, 70, 70, 70, 70,
//18 - 19
01105
80, 80, 80, 80, 70, 60, 50, 40,
//20 - 21
01106
30, 20, 7, 2, 0, 0, 0, 0
//22 - 23
01107
};
01108
//ROYAL BLUE Dimming Values
01109
byte
rbled[96] = {
01110
0, 0, 0, 0, 0, 0, 0, 0,
//0 - 1
01111
0, 0, 0, 0, 0, 0, 0, 0,
//2 - 3
01112
0, 0, 0, 0, 0, 0, 0, 0,
//4 - 5
01113
0, 0, 0, 0, 0, 0, 0, 0,
//6 - 7
01114
0, 0, 0, 0, 0, 0, 0, 0,
//8 - 9
01115
0, 0, 0, 0, 2, 5, 8, 10,
//10 - 11
01116
20, 40, 60, 70, 70, 70, 70, 70,
//12 - 13
01117
70, 70, 70, 70, 70, 70, 70, 70,
//14 - 15
01118
70, 70, 70, 70, 70, 70, 70, 70,
//16 - 17
01119
70, 70, 70, 70, 70, 70, 70, 70,
//18 - 19
01120
70, 70, 70, 70, 60, 50, 40, 30,
//20 - 21
01121
20, 10, 5, 1, 0, 0, 0, 0
//22 - 23
01122
};
01123
//REGULAR BLUE Dimming Values
01124
byte
bled[96] = {
01125
0, 0, 0, 0, 0, 0, 0, 0,
//0 - 1
01126
0, 0, 0, 0, 0, 0, 0, 0,
//2 - 3
01127
0, 0, 0, 0, 0, 0, 0, 0,
//4 - 5
01128
0, 0, 0, 0, 0, 0, 0, 0,
//6 - 7
01129
0, 0, 0, 0, 0, 0, 0, 0,
//8 - 9
01130
0, 0, 0, 0, 2, 5, 10, 20,
//10 - 11
01131
25, 30, 40, 50, 60, 70, 70, 70,
//12 - 13
01132
70, 70, 70, 70, 70, 70, 70, 70,
//14 - 15
01133
70, 70, 70, 70, 70, 70, 70, 70,
//16 - 17
01134
70, 70, 70, 70, 70, 70, 70, 70,
//18 - 19
01135
70, 70, 70, 70, 50, 40, 30, 20,
//20 - 21
01136
10, 8, 5, 1, 0, 0, 0, 0
//22 - 23
01137
};
01138
//ULTRA VIOLET (UV) Dimming Values
01139
byte
uvled[96] = {
01140
0, 0, 0, 0, 0, 0, 0, 0,
//0 - 1
01141
0, 0, 0, 0, 0, 0, 0, 0,
//2 - 3
01142
0, 0, 0, 0, 0, 0, 0, 0,
//4 - 5
01143
0, 0, 0, 0, 0, 0, 0, 0,
//6 - 7
01144
0, 0, 0, 0, 0, 0, 0, 0,
//8 - 9
01145
0, 0, 0, 0, 2, 10, 20, 30,
//10 - 11
01146
40, 50, 60, 70, 80, 90, 90, 90,
//12 - 13
01147
90, 90, 90, 90, 90, 90, 90, 90,
//14 - 15
01148
90, 90, 90, 90, 90, 90, 90, 90,
//16 - 17
01149
90, 90, 90, 90, 90, 90, 90, 90,
//18 - 19
01150
80, 70, 60, 50, 40, 40, 30, 20,
//20 - 21
01151
10, 8, 5, 1, 0, 0, 0, 0
//22 - 23
01152
};
01153
//Cyan Dimming Values
01154
byte
cyled[96] = {
01155
0, 0, 0, 0, 0, 0, 0, 0,
//0 - 1
01156
0, 0, 0, 0, 0, 0, 0, 0,
//2 - 3
01157
0, 0, 0, 0, 0, 0, 0, 0,
//4 - 5
01158
0, 0, 0, 0, 0, 0, 0, 0,
//6 - 7
01159
0, 0, 0, 0, 0, 0, 0, 0,
//8 - 9
01160
0, 0, 0, 0, 2, 5, 10, 20,
//10 - 11
01161
25, 30, 40, 50, 60, 70, 70, 70,
//12 - 13
01162
70, 70, 70, 70, 70, 70, 70, 70,
//14 - 15
01163
70, 70, 70, 70, 70, 70, 70, 70,
//16 - 17
01164
70, 70, 70, 70, 70, 70, 70, 70,
//18 - 19
01165
70, 70, 70, 70, 50, 30, 20, 20,
//20 - 21
01166
8, 5, 0, 0, 0, 0, 0, 0
//22 - 23
01167
};
01168
//WHITE Dimming Values (White LED array in RAM)
01169
byte
wled[96] = {
01170
0, 0, 0, 0, 0, 0, 0, 0,
//0 - 1
01171
0, 0, 0, 0, 0, 0, 0, 0,
//2 - 3
01172
0, 0, 0, 0, 0, 0, 0, 0,
//4 - 5
01173
0, 0, 0, 0, 0, 0, 0, 0,
//6 - 7
01174
0, 0, 0, 0, 0, 0, 0, 0,
//8 - 9
01175
0, 0, 0, 0, 1, 10, 20, 30,
//10 - 11
01176
40, 50, 60, 70, 70, 70, 70, 70,
//12 - 13
01177
70, 70, 70, 70, 70, 70, 70, 70,
//14 - 15
01178
70, 70, 70, 70, 70, 70, 70, 70,
//16 - 17
01179
70, 70, 70, 70, 70, 70, 70, 70,
//18 - 19
01180
65, 60, 55, 50, 45, 40, 35, 30,
//20 - 21
01181
20, 10, 5, 1, 0, 0, 0, 0
//22 - 23
01182
};
01183
01184
01185
//RED Dimming Values
01186
byte
rled[96] = {
01187
0, 0, 0, 0, 0, 0, 0, 0,
//0 - 1
01188
0, 0, 0, 0, 0, 0, 0, 0,
//2 - 3
01189
0, 0, 0, 0, 0, 0, 0, 0,
//4 - 5
01190
0, 0, 0, 0, 0, 0, 0, 0,
//6 - 7
01191
0, 0, 0, 0, 0, 0, 0, 0,
//8 - 9
01192
0, 0, 0, 0, 1, 10, 20, 30,
//10 - 11
01193
40, 30, 20, 20, 20, 20, 20, 20,
//12 - 13
01194
20, 20, 20, 20, 20, 20, 20, 20,
//14 - 15
01195
20, 20, 20, 20, 20, 20, 20, 20,
//16 - 17
01196
20, 20, 20, 20, 20, 20, 20, 20,
//18 - 19
01197
20, 30, 40, 40, 40, 40, 35, 30,
//20 - 21
01198
20, 10, 5, 1, 0, 0, 0, 0
//22 - 23
01199
};
01200
// Yellow Dimming Values
01201
byte
yeled[96] = {
01202
0, 0, 0, 0, 0, 0, 0, 0,
//0 - 1
01203
0, 0, 0, 0, 0, 0, 0, 0,
//2 - 3
01204
0, 0, 0, 0, 0, 0, 0, 0,
//4 - 5
01205
0, 0, 0, 0, 0, 0, 0, 0,
//6 - 7
01206
0, 0, 0, 0, 0, 0, 0, 0,
//8 - 9
01207
0, 0, 0, 0, 1, 10, 20, 30,
//10 - 11
01208
40, 50, 60, 70, 70, 70, 70, 70,
//12 - 13
01209
70, 70, 70, 70, 70, 70, 70, 70,
//14 - 15
01210
70, 70, 70, 70, 70, 70, 70, 70,
//16 - 17
01211
70, 70, 70, 70, 70, 70, 70, 70,
//18 - 19
01212
65, 60, 55, 50, 45, 40, 35, 30,
//20 - 21
01213
20, 10, 5, 1, 0, 0, 0, 0
//22 - 23
01214
};
01215
01216
byte
tled[96];
//Temporary Array to Hold changed LED Values
01217
01218
01219
/**************************** CHOOSE OPTION MENU BUTTONS *****************************/
01220
01221
const
int
temC[]= {10, 29, 155, 59};
//"H2O TEMP CONTROL" settings
01222
const
int
WeatCtrl[]= {10, 69, 155, 99};
//"Weather CONTROL" settings
01223
const
int
CloudCtrl[]= {185, 19, 305, 39};
//"Cloud Setting"
01224
const
int
CloudCtrlON[]= {130, 19, 174, 39};
//"Cloud Setting ON/OFF"
01225
const
int
StormCtrl[]= {185, 49, 305, 69};
//"Storm Setting"
01226
const
int
StormCtrlON[]= {130, 49, 174, 69};
//"Storm Setting ON/OFF"
01227
const
int
StormCtrlONNight[]= {200, 124, 244, 144};
//"Storm night ON/OFF"
01228
01229
const
int
ButMns[]= {0, 0, 22, 22};
// universal +/- button counter, defaul coordinate, 22x22 size
01230
01231
/*
01232
const int GrM[]= {200, 104-16, 220, 124-16};
01233
const int GrP[]= {290, 104-16, 310, 124-16};
01234
const int OzM[]= {200, 132-8, 220, 152-8};
01235
const int OzP[]= {290, 132-8, 310, 152-8};
01236
const int P0M[]= {200, 160+3, 220, 180+3};
01237
const int P0P[]= {290, 160+3, 310, 180+3};
01238
*/
01239
01240
//const int wave[]= {10, 109, 155, 139}; //"Wavemaker CONTROL" settings
01241
//const int gSet[]= {10, 149, 155, 179}; //"GENERAL SETTINGS" page
01242
const
int
gSet[]= {165, 149, 310, 179};
//"GENERAL SETTINGS" page
01243
const
int
tesT[]= {165, 29, 310, 59};
//"LED TESTING OPTIONS" menu
01244
const
int
ledChM[]= {165, 69, 310, 99};
//"CHANGE LED VALUES" menu
01245
//const int aFeed[]= {165, 109, 310, 139}; //"AUTOMATIC FEEDER" menu
01246
//const int about[]= {165, 149, 310, 179}; //"ABOUT" program information
01247
01248
const
int
prsM[]= {10, 200, 155, 220};
// Preset
01249
/**************************** TIME AND DATE SCREEN BUTTONS ***************************/
01250
const
int
houU[]= {110, 22, 135, 47};
//hour up
01251
const
int
minU[]= {180, 22, 205, 47};
//min up
01252
const
int
ampmU[]= {265, 22, 290, 47};
//AM/PM up
01253
const
int
houD[]= {110, 73, 135, 98};
//hour down
01254
const
int
minD[]= {180, 73, 205, 98};
//min down
01255
const
int
ampmD[]= {265, 73, 290, 98};
//AM/PM down
01256
const
int
dayU[]= {110, 112, 135, 137};
//day up
01257
const
int
monU[]= {180, 112, 205, 137};
//month up
01258
const
int
yeaU[]= {265, 112, 290, 137};
//year up
01259
const
int
dayD[]= {110, 162, 135, 187};
//day down
01260
const
int
monD[]= {180, 162, 205, 187};
//month down
01261
const
int
yeaD[]= {265, 162, 290, 187};
//year down
01262
/*************************** H2O TEMP CONTROL SCREEN BUTTONS *************************/
01263
const
int
temM[]= {90, 49, 115, 74};
//temp. minus
01264
const
int
temP[]= {205, 49, 230, 74};
//temp. plus
01265
const
int
offM[]= {90, 99, 115, 124};
//offset minus
01266
const
int
offP[]= {205, 99, 230, 124};
//offset plus
01267
const
int
almM[]= {90, 149, 115, 174};
//alarm minus
01268
const
int
almP[]= {205, 149, 230, 174};
//alarm plus
01269
const
int
Beep[]= {30, 50};
//Beep ON/OFF
01270
01271
/**************************** LED TESTING MENU BUTTONS *******************************/
01272
const
int
tstLA[] = {40, 59-25, 280, 99-25};
//"Test LED Array Output" settings
01273
const
int
cntIL[] = {40, 109-25, 280, 149-25};
//"Control Individual Leds" settings
01274
const
int
PrButL[] = {40, 159-25, 280, 199-25};
//"Preset Leds" settings
01275
01276
/********************** TEST LED ARRAY OUTPUT SCREEN BUTTONS *************************/
01277
const
int
stsT[]= {110, 105, 200, 175};
//start/stop
01278
const
int
tenM[]= {20, 120, 90, 160};
//-10s
01279
const
int
tenP[]= {220, 120, 290, 160};
//+10s
01280
/******************** TEST INDIVIDUAL LED VALUES SCREEN BUTTONS **********************/
01281
//See at the end of these buttons for the button functions
01282
/****************** CHANGE INDIVIDUAL LED VALUES SCREEN BUTTONS **********************/
01283
//These Buttons are made within the function
01284
/************************* CHANGE LED VALUES MENU BUTTONS ****************************/
01285
const
int
btCIL[]= {5, 188, 90, 220};
//back to Change Individual LEDs Screen
01286
const
int
ledChV[]= {110, 200, 210, 220};
//LED Change Values
01287
const
int
eeprom[]= {215, 200, 315, 220};
//Save to EEPROM (Right Button)
01288
const
int
MINiM[]= {17, 147, 42, 172};
//MinI minus
01289
const
int
MINiP[]= {116, 147, 141, 172};
//MinI plus
01290
const
int
MAXiM[]= {179, 147, 204, 172};
//MaxI minus
01291
const
int
MAXiP[]= {278, 147, 303, 172};
//MaxI plus
01292
/********************* WAVEMAKER SCREEN & STETTINGS BUTTONS **************************/
01293
//Many Wavemaker Buttons are made within the function(s)
01294
const
int
pump1Mm[]= {21, 70, 46, 95};
//Pump 1 minute minus
01295
const
int
pump1Mp[]= {120, 70, 145, 95};
//Pump 1 minute plus
01296
const
int
pump1Sm[]= {175, 70, 200, 95};
//Pump 1 second minus
01297
const
int
pump1Sp[]= {274, 70, 299, 95};
//Pump 1 second plus
01298
const
int
pump2Mm[]= {21, 147, 46, 172};
//Pump 2 minute minus
01299
const
int
pump2Mp[]= {120, 147, 145, 172};
//Pump 2 minute plus
01300
const
int
pump2Sm[]= {175, 147, 200, 172};
//Pump 2 second minus
01301
const
int
pump2Sp[]= {274, 147, 299, 172};
//Pump 2 second plus
01302
/************************* AUTOMATIC FISH FEEDER BUTTONS *****************************/
01303
//These Buttons are made within the function
01304
/******************* SET AUTOMATIC FISH FEEDING TIMES BUTTONS ************************/
01305
const
int
houP[]= {110, 38, 135, 63};
//hour up
01306
const
int
minP[]= {180, 38, 205, 63};
//min up
01307
const
int
ampmP[]= {265, 38, 290, 63};
//AM/PM up
01308
const
int
houM[]= {110, 89, 135, 114};
//hour down
01309
const
int
minM[]= {180, 89, 205, 114};
//min down
01310
const
int
ampmM[]= {265, 89, 290, 114};
//AM/PM down
01311
/***************************** MISCELLANEOUS BUTTONS *********************************/
01312
const
int
backGS[]= {4, 200, 78, 220};
//BACK
01313
const
int
nextGS[]= {83, 200, 157, 220};
//NEXT
01314
const
int
prSAVEgs[]= {162, 200, 236, 220};
//SAVE
01315
const
int
canCgs[]= {241, 200, 315, 220};
//CANCEL
01316
//const int touchLock[]= {4, 200, 78, 220}; //Touch #oleg
01317
const
int
touchLock[]= {4, 210, 64, 230};
//Touch #oleg
01318
const
int
Again[]= {241, 200, 315, 220};
//Touch #oleg
01319
01320
const
int
HoodFanTm[]= {80, 40, 105, 64};
//Hood Fan Temp - // heatsink 1
01321
const
int
HoodFanTp[]= {195, 40, 220, 64};
//Hood Fan Temp +
01322
const
int
SumpFanTm[]= {80, 99, 105, 123};
//Sump Fan Temp - //heatsink 2
01323
const
int
SumpFanTp[]= {195, 99, 220, 123};
//Sump Fan Temp +
01324
const
int
SoundAlarmTm[]= {80, 158, 105, 182};
//Sound Alarm Temp -
01325
const
int
SoundAlarmTp[]= {195, 158, 220, 182};
//Sound Alarm Temp +
01326
01327
const
int
back[]= {5, 200, 105, 220};
//BACK
01328
const
int
prSAVE[]= {110, 200, 210, 220};
//SAVE
01329
const
int
canC[]= {215, 200, 315, 220};
//CANCEL
01330
01331
const
int
StopDay[]= {230, 0, 315, 14};
// NEXT TIME
01332
const
int
StartDay[]= {5, 0, 85, 14};
// Prev TIME
01333
const
int
Yes[]= {110, 125, 150, 145};
// Yes
01334
const
int
No[]= {170, 125, 210, 145};
// No
01335
01336
const
int
LedPres1[]= {5, 0, 80, 14};
// Led Preset 1 button
01337
const
int
LedPres2[]= {83, 0, 158, 14};
// Led Preset 2 button
01338
const
int
LedPres3[]= {161, 0, 236, 14};
// Led Preset 3 button
01339
const
int
LedPres4[]= {239, 0, 314, 14};
// Led Preset 4 button
01340
01341
01342
void
drawUpButtonSlide(
int
x,
int
y)
01343
{
01344
myGLCD.setColor(64, 64, 128);
01345
myGLCD.fillRoundRect(x, y, x+30, y+22);
01346
myGLCD.setColor(255, 255, 255);
01347
myGLCD.drawRoundRect(x, y, x+30, y+22);
01348
myGLCD.setColor(128, 128, 255);
01349
for
(
int
i=0; i<15; i++)
01350
myGLCD.drawLine(x+5+(i/1.5), y+18-i, x+26-(i/1.5), y+18-i);
01351
}
01352
void
drawDownButtonSlide(
int
x,
int
y)
01353
{
01354
myGLCD.setColor(64, 64, 128);
01355
myGLCD.fillRoundRect(x, y, x+30, y+22);
01356
myGLCD.setColor(255, 255, 255);
01357
myGLCD.drawRoundRect(x, y, x+30, y+22);
01358
myGLCD.setColor(128, 128, 255);
01359
for
(
int
i=0; i<15; i++)
01360
myGLCD.drawLine(x+5+(i/1.5), y+4+i, x+26-(i/1.5), y+4+i);
01361
}
01362
01363
void
drawUpButton(
int
x,
int
y)
01364
{
01365
myGLCD.setColor(0, 0, 255);
01366
myGLCD.fillRoundRect(x, y, x+25, y+25);
01367
myGLCD.setColor(255, 255, 255);
01368
myGLCD.drawRoundRect(x, y, x+25, y+25);
01369
for
(
int
i=0; i<15; i++)
01370
myGLCD.drawLine(x+3+(i/1.5), y+19-i, x+22-(i/1.5), y+19-i);
01371
}
01372
void
drawDownButton(
int
x,
int
y)
01373
{
01374
myGLCD.setColor(0, 0, 255);
01375
myGLCD.fillRoundRect(x, y, x+25, y+25);
01376
myGLCD.setColor(255, 255, 255);
01377
myGLCD.drawRoundRect(x, y, x+25, y+25);
01378
for
(
int
i=0; i<15; i++)
01379
myGLCD.drawLine(x+3+(i/1.5), y+6+i, x+22-(i/1.5), y+6+i);
01380
}
01381
01382
/*
01383
void printButton(char* text, int x1, int y1, int x2, int y2, boolean fontsize = false)
01384
{
01385
int stl = strlen(text);
01386
int fx, fy;
01387
01388
myGLCD.setColor(0, 0, 255);
01389
myGLCD.fillRoundRect (x1, y1, x2, y2);
01390
myGLCD.setColor(255, 255, 255);
01391
myGLCD.drawRoundRect (x1, y1, x2, y2);
01392
01393
myGLCD.setBackColor(0, 0, 255);
01394
if (fontsize) {
01395
myGLCD.setFont(BigFont);
01396
fx = x1+(((x2 - x1+1)-(stl*16))/2);
01397
fy = y1+(((y2 - y1+1)-16)/2);
01398
myGLCD.print(text, fx, fy);
01399
}
01400
else {
01401
myGLCD.setFont(SmallFont);
01402
fx = x1+(((x2 - x1)-(stl*8))/2);
01403
fy = y1+(((y2 - y1-1)-8)/2);
01404
myGLCD.print(text, fx, fy);
01405
}
01406
}
01407
*/
01408
/*
01409
void printButton(char* text, int x1, int y1, int x2, int y2, boolean fontsize = false, boolean background = false)
01410
{
01411
int stl = strlen(text);
01412
int fx, fy;
01413
01414
if (background == true) { // green background, black font
01415
myGLCD.setColor(0, 255, 0);
01416
myGLCD.fillRoundRect (x1, y1, x2, y2);
01417
myGLCD.setColor(255, 255, 255);
01418
myGLCD.drawRoundRect (x1, y1, x2, y2);
01419
myGLCD.setBackColor(0, 255, 0);
01420
myGLCD.setColor(0, 0, 0);
01421
}
01422
else { myGLCD.setColor(0, 0, 255); // blue background, white font
01423
myGLCD.fillRoundRect (x1, y1, x2, y2);
01424
myGLCD.setColor(255, 255, 255);
01425
myGLCD.drawRoundRect (x1, y1, x2, y2);
01426
myGLCD.setBackColor(0, 0, 255);}
01427
01428
if (fontsize) {
01429
myGLCD.setFont(BigFont);
01430
fx = x1+(((x2 - x1+1)-(stl*16))/2);
01431
fy = y1+(((y2 - y1+1)-16)/2);
01432
myGLCD.print(text, fx, fy);
01433
}
01434
else {
01435
myGLCD.setFont(SmallFont);
01436
fx = x1+(((x2 - x1)-(stl*8))/2);
01437
fy = y1+(((y2 - y1-1)-8)/2);
01438
myGLCD.print(text, fx, fy);
01439
}
01440
}
01441
*/
01442
void
printButton(
char
* text,
int
x1,
int
y1,
int
x2,
int
y2, boolean fontsize =
false
,
int
background =0 )
01443
{
01444
int
stl = strlen(text);
01445
int
fx, fy;
01446
01447
if
(background == 0) {
01448
myGLCD.setColor(0, 0, 255);
// blue background, white font
01449
myGLCD.fillRoundRect (x1, y1, x2, y2);
01450
myGLCD.setColor(255, 255, 255);
01451
myGLCD.drawRoundRect (x1, y1, x2, y2);
01452
myGLCD.setBackColor(0, 0, 255);}
01453
01454
if
(background == 1) {
// green background, black font
01455
myGLCD.setColor(0, 255, 0);
01456
myGLCD.fillRoundRect (x1, y1, x2, y2);
01457
myGLCD.setColor(255, 255, 255);
01458
myGLCD.drawRoundRect (x1, y1, x2, y2);
01459
myGLCD.setBackColor(0, 255, 0);
01460
myGLCD.setColor(0, 0, 0); }
01461
01462
if
(background == 2) {
01463
myGLCD.setColor(64, 64, 64);
// grey background, white font
01464
myGLCD.fillRoundRect (x1, y1, x2, y2);
01465
myGLCD.setColor(255, 255, 255);
01466
myGLCD.drawRoundRect (x1, y1, x2, y2);
01467
myGLCD.setBackColor(64, 64, 64);}
01468
01469
if
(fontsize) {
01470
myGLCD.setFont(BigFont);
01471
fx = x1+(((x2 - x1+1)-(stl*16))/2);
01472
fy = y1+(((y2 - y1+1)-16)/2);
01473
myGLCD.print(text, fx, fy);
01474
}
01475
else
{
01476
myGLCD.setFont(SmallFont);
01477
fx = x1+(((x2 - x1)-(stl*8))/2);
01478
fy = y1+(((y2 - y1-1)-8)/2);
01479
myGLCD.print(text, fx, fy);
01480
}
01481
}
01482
01483
01484
void
printButtonTouch(
char
* text,
int
x1,
int
y1,
int
x2,
int
y2, boolean fontsize =
false
, boolean background =
false
)
01485
{
01486
int
stl = strlen(text);
01487
int
fx, fy;
01488
01489
if
(background ==
true
) {
// green background, black font
01490
myGLCD.setColor(0, 255, 0);
01491
myGLCD.fillRoundRect (x1, y1, x2, y2);
01492
myGLCD.setColor(255, 255, 255);
01493
myGLCD.drawRoundRect (x1, y1, x2, y2);
01494
myGLCD.setBackColor(0, 255, 0);
01495
myGLCD.setColor(0, 0, 0);
01496
}
01497
else
{ myGLCD.setColor(0, 0, 150);
// blue background, white font
01498
myGLCD.fillRoundRect (x1, y1, x2, y2);
01499
myGLCD.setColor(150, 150, 150);
01500
myGLCD.drawRoundRect (x1, y1, x2, y2);
01501
myGLCD.setBackColor(0, 0, 150);}
01502
01503
if
(fontsize) {
01504
myGLCD.setFont(BigFont);
01505
fx = x1+(((x2 - x1+1)-(stl*16))/2);
01506
fy = y1+(((y2 - y1+1)-16)/2);
01507
myGLCD.print(text, fx, fy);
01508
}
01509
else
{
01510
myGLCD.setFont(SmallFont);
01511
fx = x1+(((x2 - x1)-(stl*8))/2);
01512
// fy = y1+(((y2 - y1-1)-8)/2);
01513
fy = y1+(((y2 - y1-2)-8)/2);
01514
myGLCD.print(text, fx, fy);
01515
}
01516
}
01517
/*
01518
void printButtonVertical(char* text, int x1, int y1, boolean fontsize = false, boolean background = false)
01519
{
01520
int stl = strlen(text);
01521
int fx, fy;
01522
01523
if (background == true) { // green background, black font
01524
myGLCD.setColor(0, 255, 0);
01525
myGLCD.fillRoundRect (x1, y1, x1+20, y1+10+stl*8+10);
01526
myGLCD.setColor(255, 255, 255);
01527
myGLCD.setBackColor(0, 255, 0);
01528
myGLCD.setColor(0, 0, 0);
01529
myGLCD.drawRoundRect (x1, y1, x1+20, y1+10+stl*8+10);
01530
}
01531
else { myGLCD.setColor(0, 0, 255); // blue background, white font
01532
myGLCD.fillRoundRect (x1, y1, x1+20, y1+10+stl*8+10);
01533
myGLCD.setColor(255, 255, 255);
01534
myGLCD.setBackColor(0, 0, 255);
01535
myGLCD.drawRoundRect (x1, y1, x1+20, y1+10+stl*8+10);
01536
}
01537
01538
if (fontsize) {
01539
myGLCD.setFont(BigFont);
01540
fx = x1+(x1+20-x1)/2-9;
01541
fy = y1+ 10+ stl*16;
01542
myGLCD.print(text, fx, fy, 270);
01543
}
01544
else {
01545
myGLCD.setFont(SmallFont);
01546
fx = x1+(x1+20-x1)/2-6;
01547
fy = y1+ 10+ stl*8;
01548
myGLCD.print(text, fx, fy, 270);
01549
}
01550
}
01551
*/
01552
01553
void
waitForIt(
int
x1,
int
y1,
int
x2,
int
y2)
// Draw a red frame while a button is touched
01554
{
01555
myGLCD.setColor(255, 0, 0);
01556
myGLCD.drawRoundRect (x1, y1, x2, y2);
01557
waitForTouchRelease();
01558
myGLCD.setColor(255, 255, 255);
01559
myGLCD.drawRoundRect (x1, y1, x2, y2);
01560
}
01561
01562
void
waitForIt_Wo_Touch(
int
x1,
int
y1,
int
x2,
int
y2)
// Draw a red frame while a button is touched
01563
{
01564
myGLCD.setColor(255, 0, 0);
01565
myGLCD.drawRoundRect (x1, y1, x2, y2);
01566
//waitForTouchRelease();
01567
delay(150);
01568
myGLCD.setColor(255, 255, 255);
01569
myGLCD.drawRoundRect (x1, y1, x2, y2);
01570
}
01571
/**************************** END OF PRIMARY BUTTONS **********************************/
01572
01573
01574
/********************************* EEPROM FUNCTIONS ***********************************/
01575
01576
01577
struct
config_t
01578
{
01579
int
tempset;
01580
int
tempFset;
01581
int
tempoff;
01582
int
tempFoff;
01583
int
tempalarm;
01584
int
tempFalarm;
01585
int
tempSoundAlarmC;
01586
int
tempSoundAlarmF;
01587
} tempSettings;
01588
01589
struct
config_m
01590
{
01591
int
MinI_t;
01592
int
MaxI_t;
01593
} MinMaxIsettings;
01594
01595
struct
config_L
01596
{
01597
int
DimLEDsOnOff;
01598
int
LEDsDimTempC;
01599
int
LEDsDimTempF;
01600
int
LEDsDimPercent;
01601
} LEDsFailsafeSettings;
01602
01603
struct
config_w
01604
{
01605
int
waveMode;
01606
int
altPump1m;
01607
int
altPump1s;
01608
int
altPump2m;
01609
int
altPump2s;
01610
int
synchMode;
01611
int
synchPumpOnM;
01612
int
synchPumpOnS;
01613
int
synchPumpOffM;
01614
int
synchPumpOffS;
01615
} WAVEsettings;
01616
01617
struct
config_g
01618
{
01619
int
calendarFormat;
01620
int
ShowHideDOW;
01621
int
timeFormat;
01622
int
tempScale;
01623
int
Heatsink1FanTempC;
01624
int
Heatsink1FanTempF;
01625
int
Heatsink2FanTempC;
01626
int
Heatsink2FanTempF;
01627
int
SCREENsaverONOFF;
01628
int
ScreensaverBrigthnessCount;
01629
int
ScreensaverClockType;
01630
int
ScreensaverTimer;
01631
int
MAX_Temp_on_off;
01632
int
SoftStartON;
01633
int
AlarmLevel;
01634
int
ScreenLock;
01635
} GENERALsettings;
01636
01637
struct
config_f
01638
{
01639
int
feedFish1h;
01640
int
feedFish1m;
01641
int
feedFish2h;
01642
int
feedFish2m;
01643
int
feedFish3h;
01644
int
feedFish3m;
01645
int
feedFish4h;
01646
int
feedFish4m;
01647
int
feedTime1;
01648
int
feedTime2;
01649
int
feedTime3;
01650
int
feedTime4;
01651
} FEEDERsettings;
01652
01653
struct
config_preset
01654
{
01655
byte
tvcol_out;
01656
byte
rcol_out;
01657
byte
wcol_out;
01658
byte
bcol_out;
01659
byte
rbcol_out;
01660
byte
uvcol_out;
01661
byte
cycol_out;
01662
byte
yelcol_out;
01663
} LedPresetSetting;
01664
01665
void
EraseAllEEPROM_SaveDefault()
//check memory for my code format #oleg
01666
{
01667
int
k = EEPROM.read(0);
01668
if
(k!=127) {
01669
myGLCD.setColor(0, 0, 0);
01670
setFont(SMALL, 255, 0, 0, 0, 0, 0);
01671
myGLCD.print(print_text[11], CENTER, 120);
// "Please WAIT, cleaning memory"
01672
for
(
int
i = 0; i < 4095; i++)
01673
{EEPROM.write(i, 0);
01674
if
(i ==0) {EEPROM.write(0,127);}
01675
if
((i==0)|| (i==512)|| (i==1024)||(i==1536)||(i==2048)||(i==2560)||(i==3072)||(i==3584)||(i==4094))
01676
{myGLCD.printNumI(i, CENTER, 140); }
01677
}
01678
COLOR=0;
01679
SaveLEDToEEPROM();
// save default
01680
EEPROM.write(780, 0xFF);
// enable all led channel
01681
01682
//******* set some values to default ***********************
01683
setTempC= 26;
01684
setTempF =78.8;
01685
offTempC=offTempF= 0.2;
01686
alarmTempC=alarmTempF= 4;
01687
setTempToSoundAlarmC=setTempToSoundAlarmF= 4;
01688
setTempToBeginHeatsink1FanC=setTempToBeginHeatsink1FanF =30;
01689
setTempToBeginHeatsink2FanC=setTempToBeginHeatsink2FanF =30;
01690
setTempToSoundAlarmC=60;
01691
setTempToSoundAlarmF=140;
01692
MinI = 20;
// minimum moon brightness
01693
MaxI = 80;
// maximum moon brightness
01694
01695
SaveMoonLEDToEEPROM();
01696
SaveGenSetsToEEPROM();
01697
SaveTempToEEPROM();
01698
}
01699
}
01700
01701
01702
01703
01704
void
SaveLEDToEEPROM()
// COLOR=0, WHITE=1, BLUE=2, ROYAL=3,
01705
// RED=4, ULTRA=5, TV=6, MOON=7,
01706
// CYAN=8, YELLOW=9;
01707
{
01708
EEPROM.write(0, 127);
//to determine if data available in EEPROM, write to first byte "127"
01709
if
((COLOR==1) || (COLOR==0)) {
01710
for
(
int
i=1; i<97; i++)
01711
{ EEPROM.write(i+(96*0), wled[i-1]);}
// xled[] address must be from 1 to 96
01712
}
01713
if
((COLOR==2) || (COLOR==0)) {
01714
for
(
int
i=1; i<97; i++)
01715
{ EEPROM.write(i+(96*1), bled[i-1]);}
// xled[] address must be from 1 to 96
01716
}
01717
if
((COLOR==3) || (COLOR==0)) {
01718
for
(
int
i=1; i<97; i++)
01719
{EEPROM.write(i+(96*2), rbled[i-1]);}
01720
}
01721
if
((COLOR==4) || (COLOR==0)) {
01722
for
(
int
i=1; i<97; i++)
01723
{EEPROM.write(i+(96*3), rled[i-1]);}
01724
}
01725
if
((COLOR==5) || (COLOR==0)) {
01726
for
(
int
i=1; i<97; i++)
01727
{EEPROM.write(i+(96*4), uvled[i-1]);}
01728
}
01729
if
((COLOR==6) || (COLOR==0)) {
01730
for
(
int
i=1; i<97; i++)
01731
{EEPROM.write(i+(96*5), tvled[i-1]);}
01732
}
01733
if
((COLOR==8) || (COLOR==0)) {
01734
for
(
int
i=1; i<97; i++)
01735
{EEPROM.write(i+(96*6), cyled[i-1]);}
01736
}
01737
if
((COLOR==9) || (COLOR==0)) {
01738
for
(
int
i=1; i<97; i++)
01739
{EEPROM.write(i+(96*7), yeled[i-1]);}
01740
}
01741
// if (COLOR==0) {EEPROM.write(780, 0xFF);} // LedShannelStatusByte = 0xFF, all channel is ON
01742
// EEPROM.write(780, LedShannelStatusByte);
01743
}
01744
01745
01746
void
SaveOnOffLedStatus(boolean LedShannelFlag_on_off=
false
)
01747
{
if
(LedShannelFlag_on_off ==
true
)
01748
{
if
(COLOR==1) {bitSet(LedShannelStatusByte,0); }
01749
if
(COLOR==2) {bitSet(LedShannelStatusByte,1); }
01750
if
(COLOR==3) {bitSet(LedShannelStatusByte,2); }
01751
if
(COLOR==4) {bitSet(LedShannelStatusByte,3); }
01752
if
(COLOR==5) {bitSet(LedShannelStatusByte,4); }
01753
if
(COLOR==6) {bitSet(LedShannelStatusByte,5); }
01754
if
(COLOR==8) {bitSet(LedShannelStatusByte,6); }
01755
if
(COLOR==9) {bitSet(LedShannelStatusByte,7); }
01756
}
else
01757
{
if
(COLOR==1) {bitClear(LedShannelStatusByte,0);}
01758
if
(COLOR==2) {bitClear(LedShannelStatusByte,1); }
01759
if
(COLOR==3) {bitClear(LedShannelStatusByte,2); }
01760
if
(COLOR==4) {bitClear(LedShannelStatusByte,3); }
01761
if
(COLOR==5) {bitClear(LedShannelStatusByte,4); }
01762
if
(COLOR==6) {bitClear(LedShannelStatusByte,5); }
01763
if
(COLOR==8) {bitClear(LedShannelStatusByte,6); }
01764
if
(COLOR==9) {bitClear(LedShannelStatusByte,7); }
01765
}
01766
EEPROM.write(780, LedShannelStatusByte);
01767
}
01768
01769
01770
void
ReadOnOffLedStatus()
// if reader bit =0 LedShannelFlag_on_off = false, else LedShannelFlag_on_off = true;
01771
{
if
(COLOR==1) {LedShannelFlag_on_off = bitRead(LedShannelStatusByte,0); }
01772
if
(COLOR==2) {LedShannelFlag_on_off = bitRead(LedShannelStatusByte,1); }
01773
if
(COLOR==3) {LedShannelFlag_on_off = bitRead(LedShannelStatusByte,2); }
01774
if
(COLOR==4) {LedShannelFlag_on_off = bitRead(LedShannelStatusByte,3); }
01775
if
(COLOR==5) {LedShannelFlag_on_off = bitRead(LedShannelStatusByte,4); }
01776
if
(COLOR==6) {LedShannelFlag_on_off = bitRead(LedShannelStatusByte,5); }
01777
if
(COLOR==8) {LedShannelFlag_on_off = bitRead(LedShannelStatusByte,6); }
01778
if
(COLOR==9) {LedShannelFlag_on_off = bitRead(LedShannelStatusByte,7); }
01779
}
01780
01781
void
SaveMoonLEDToEEPROM()
// shift all bytes on 200
01782
{
01783
MinMaxIsettings.MinI_t =
int
(MinI);
01784
MinMaxIsettings.MaxI_t =
int
(MaxI);
01785
EEPROM_writeAnything(600+200, MinMaxIsettings);
01786
}
01787
01788
void
SaveLEDsFailsafeToEEPROM()
01789
{
01790
LEDsFailsafeSettings.DimLEDsOnOff =
int
(setDimLEDsOnOff);
01791
LEDsFailsafeSettings.LEDsDimTempC =
int
(setLEDsDimTempC);
01792
LEDsFailsafeSettings.LEDsDimTempF =
int
(setLEDsDimTempF);
01793
LEDsFailsafeSettings.LEDsDimPercent =
int
(setLEDsDimPercent);
01794
EEPROM_writeAnything(610+200, LEDsFailsafeSettings);
01795
}
01796
01797
void
SaveWaveToEEPROM()
01798
{
01799
WAVEsettings.waveMode =
int
(WAVE);
01800
WAVEsettings.altPump1m =
int
(Pump1m);
01801
WAVEsettings.altPump1s =
int
(Pump1s);
01802
WAVEsettings.altPump2m =
int
(Pump2m);
01803
WAVEsettings.altPump2s =
int
(Pump2s);
01804
WAVEsettings.synchMode =
int
(Synch);
01805
WAVEsettings.synchPumpOnM =
int
(OnForTm);
01806
WAVEsettings.synchPumpOnS =
int
(OnForTs);
01807
WAVEsettings.synchPumpOffM =
int
(OffForTm);
01808
WAVEsettings.synchPumpOffS =
int
(OffForTs);
01809
EEPROM_writeAnything(620+200, WAVEsettings);
01810
}
01811
01812
void
SaveTempToEEPROM()
01813
{
01814
tempSettings.tempset =
int
(setTempC*10);
01815
tempSettings.tempFset =
int
(setTempF*10);
01816
tempSettings.tempoff =
int
(offTempC*10);
01817
tempSettings.tempFoff =
int
(offTempF*10);
01818
tempSettings.tempalarm =
int
(alarmTempC*10);
01819
tempSettings.tempFalarm =
int
(alarmTempF*10);
01820
tempSettings.tempSoundAlarmC =
int
(setTempToSoundAlarmC);
01821
tempSettings.tempSoundAlarmF =
int
(setTempToSoundAlarmF);
01822
EEPROM_writeAnything(640+200, tempSettings);
01823
}
01824
01825
void
SaveGenSetsToEEPROM()
01826
{
01827
GENERALsettings.calendarFormat =
int
(setCalendarFormat);
01828
GENERALsettings.ShowHideDOW =
int
(displayDOW);
01829
GENERALsettings.timeFormat =
int
(setTimeFormat);
01830
GENERALsettings.tempScale =
int
(setTempScale);
01831
GENERALsettings.Heatsink1FanTempC =
int
(setTempToBeginHeatsink1FanC*10);
01832
GENERALsettings.Heatsink1FanTempF =
int
(setTempToBeginHeatsink1FanF*10);
01833
GENERALsettings.Heatsink2FanTempC =
int
(setTempToBeginHeatsink2FanC*10);
01834
GENERALsettings.Heatsink2FanTempF =
int
(setTempToBeginHeatsink2FanF*10);
01835
GENERALsettings.SCREENsaverONOFF =
int
(setScreensaverOnOff);
01836
GENERALsettings.ScreensaverBrigthnessCount =
int
(BrigthnessCount);
01837
GENERALsettings.ScreensaverClockType =
int
(ClockType);
01838
GENERALsettings.ScreensaverTimer =
int
(setSSmintues);
01839
GENERALsettings.MAX_Temp_on_off =
int
(MAX_Temp_on_off);
01840
GENERALsettings.SoftStartON =
int
(SoftStartON);
01841
GENERALsettings.AlarmLevel =
int
(AlarmLevel);
01842
GENERALsettings.ScreenLock =
int
(setLockScreen);
01843
EEPROM_writeAnything(660+200, GENERALsettings);
01844
}
01845
01846
void
SaveFeedTimesToEEPROM()
01847
{
01848
FEEDERsettings.feedFish1h =
int
(feedFish1H);
01849
FEEDERsettings.feedFish1m =
int
(feedFish1M);
01850
FEEDERsettings.feedFish2h =
int
(feedFish2H);
01851
FEEDERsettings.feedFish2m =
int
(feedFish2M);
01852
FEEDERsettings.feedFish3h =
int
(feedFish3H);
01853
FEEDERsettings.feedFish3m =
int
(feedFish3M);
01854
FEEDERsettings.feedFish4h =
int
(feedFish4H);
01855
FEEDERsettings.feedFish4m =
int
(feedFish4M);
01856
FEEDERsettings.feedTime1 =
int
(FEEDTime1);
01857
FEEDERsettings.feedTime2 =
int
(FEEDTime2);
01858
FEEDERsettings.feedTime3 =
int
(FEEDTime3);
01859
FEEDERsettings.feedTime4 =
int
(FEEDTime4);
01860
EEPROM_writeAnything(680+200, FEEDERsettings);
01861
}
01862
01863
01864
void
SaveDallasAddress ()
01865
{
01866
for
(
byte
i = 0; i < 8; i++)
01867
{ EEPROM.write(900+i, Heatsink1Thermometer [i]);
// sensor address
01868
EEPROM.write(900+i+9, Heatsink2Thermometer [i]);
01869
EEPROM.write(900+i+18, waterThermometer [i]);
01870
}
01871
EEPROM.write(900+8, counterB1);
// config byte
01872
EEPROM.write(900+17, counterB2);
01873
EEPROM.write(900+26, counterB3);
01874
}
01875
01876
void
SaveLEDPresetToEEPROM()
01877
{
01878
LedPresetSetting.wcol_out = wcol_out;
01879
LedPresetSetting.bcol_out = bcol_out;
01880
LedPresetSetting.rbcol_out = rbcol_out;
01881
LedPresetSetting.rcol_out = rcol_out;
01882
LedPresetSetting.uvcol_out = uvcol_out;
01883
LedPresetSetting.tvcol_out = tvcol_out;
01884
LedPresetSetting.cycol_out = cycol_out;
01885
LedPresetSetting.yelcol_out = yelcol_out;
01886
EEPROM_writeAnything(1000 + AddressShift, LedPresetSetting);
01887
}
01888
01889
void
ReadLEDPresetFromEEPROM()
01890
{
01891
EEPROM_readAnything(1000 + AddressShift, LedPresetSetting);
01892
wcol_out = LedPresetSetting.wcol_out;
01893
bcol_out = LedPresetSetting.bcol_out;
01894
rbcol_out = LedPresetSetting.rbcol_out;
01895
rcol_out = LedPresetSetting.rcol_out;
01896
uvcol_out = LedPresetSetting.uvcol_out;
01897
tvcol_out = LedPresetSetting.tvcol_out;
01898
cycol_out= LedPresetSetting.cycol_out;
01899
yelcol_out = LedPresetSetting.yelcol_out;
01900
}
01901
01902
01903
01904
void
ReadLedFromEEPROM()
01905
// COLOR=0 - read all colours
01906
// WHITE=1, BLUE=2, ROYAL=3, RED=4,
01907
// ULTRA=5, TV=6, MOON=7;
01908
// CYAN=8, YELLOW=9
01909
{
01910
byte
k = EEPROM.read(0);
01911
int
Temp;
01912
if
(k==127) {
01913
if
((COLOR==1) || (COLOR==0)) {
01914
for
(
byte
i=1; i<97; i++)
01915
{ Temp = EEPROM.read(i+(96*0));
01916
if
(Temp >100) {Temp = 100;}
01917
wled[i-1] = Temp;}
01918
}
01919
if
((COLOR==2) || (COLOR==0)) {
01920
for
(
byte
i=1; i<97; i++)
01921
{ Temp = EEPROM.read(i+(96*1));
01922
if
(Temp >100) {Temp = 100;}
01923
bled[i-1] = Temp;}
01924
}
01925
if
((COLOR==3) || (COLOR==0)) {
01926
for
(
byte
i=1; i<97; i++)
01927
{ Temp = EEPROM.read(i+(96*2));
01928
if
(Temp >100) {Temp = 100;}
01929
rbled[i-1] = Temp;}
01930
}
01931
if
((COLOR==4) || (COLOR==0)) {
01932
for
(
byte
i=1; i<97; i++)
01933
{ Temp = EEPROM.read(i+(96*3));
01934
if
(Temp >100) {Temp = 100;}
01935
rled[i-1] = Temp;}
01936
}
01937
if
((COLOR==5) || (COLOR==0)) {
01938
for
(
byte
i=1; i<97; i++)
01939
{ Temp = EEPROM.read(i+(96*4));
01940
if
(Temp >100) {Temp = 100;}
01941
uvled[i-1] = Temp;}
01942
}
01943
if
((COLOR==6) || (COLOR==0)) {
01944
for
(
byte
i=1; i<97; i++)
01945
{ Temp = EEPROM.read(i+(96*5));
01946
if
(Temp >100) {Temp = 100;}
01947
tvled[i-1] = Temp;}
01948
}
01949
if
((COLOR==8) || (COLOR==0)) {
01950
for
(
byte
i=1; i<97; i++)
01951
{ Temp = EEPROM.read(i+(96*6));
01952
if
(Temp >100) {Temp = 100;}
01953
cyled[i-1] = Temp;}
01954
}
01955
if
((COLOR==9) || (COLOR==0)) {
01956
for
(
byte
i=1; i<97; i++)
01957
{ Temp = EEPROM.read(i+(96*7));
01958
if
(Temp >100) {Temp = 100;}
01959
yeled[i-1] = Temp;}
01960
}
01961
if
((COLOR==7) || (COLOR==0)) {
01962
EEPROM_readAnything(600+200, MinMaxIsettings);
// read moon values 200bytes shift for new colours
01963
MinI = MinMaxIsettings.MinI_t;
01964
if
( MinI>100 ) {MinI= 10;}
// set default = 10
01965
MaxI = MinMaxIsettings.MaxI_t;
01966
if
( MaxI>100 ) {MaxI= 90;}
// set default = 90
01967
}
01968
LedShannelStatusByte = EEPROM.read(780);
01969
}
01970
01971
EEPROM_readAnything(610+200, LEDsFailsafeSettings);
01972
setDimLEDsOnOff = LEDsFailsafeSettings.DimLEDsOnOff;
01973
if
(setDimLEDsOnOff >1) {setDimLEDsOnOff=1;}
// set default = 1
01974
setLEDsDimTempC = LEDsFailsafeSettings.LEDsDimTempC;
01975
if
( setLEDsDimTempC>99 || setLEDsDimTempC<40 ) {setLEDsDimTempC=50;}
// set default = 50C
01976
setLEDsDimTempF = LEDsFailsafeSettings.LEDsDimTempF;
01977
if
( setLEDsDimTempF>210 || setLEDsDimTempF<104) {setLEDsDimTempF=122;}
// set default = 122F
01978
setLEDsDimPercent = LEDsFailsafeSettings.LEDsDimPercent;
01979
if
( setLEDsDimPercent>80 || setLEDsDimPercent<10 ) {setLEDsDimPercent=50;}
// set default = 50%
01980
}
01981
01982
01983
void
ReadFromEEPROM()
// read from eeprom all data exclude LED SETTING
01984
{
01985
int
k = EEPROM.read(0);
01986
char
tempString[3];
01987
01988
EEPROM_readAnything(620+200, WAVEsettings);
01989
WAVE = WAVEsettings.waveMode;
01990
if
(WAVE <0 || WAVE >4) {WAVE=0;}
// set default = 0 all OFF
01991
Pump1m = WAVEsettings.altPump1m;
01992
Pump1s = WAVEsettings.altPump1s;
01993
Pump2m = WAVEsettings.altPump2m;
01994
Pump2s = WAVEsettings.altPump2s;
01995
Synch = WAVEsettings.synchMode;
01996
OnForTm = WAVEsettings.synchPumpOnM;
01997
OnForTs = WAVEsettings.synchPumpOnS;
01998
OffForTm = WAVEsettings.synchPumpOffM;
01999
OffForTs = WAVEsettings.synchPumpOffS;
02000
02001
// all these default set if error reading from eeprom
02002
EEPROM_readAnything(640+200, tempSettings);
02003
setTempC = tempSettings.tempset;
02004
setTempC /=10;
02005
if
(setTempC <10 || setTempC >40) {setTempC=26.0;}
// set default = 26 C
02006
setTempF = tempSettings.tempFset;
02007
setTempF /=10;
02008
if
(setTempF <50 || setTempF >104) {setTempF=78.8;}
// set default = 78.8 F
02009
offTempC = tempSettings.tempoff;
02010
offTempC /=10;
02011
if
(offTempC <0 || offTempC >5) {offTempC=1.0;}
// set default = 1 C
02012
offTempF = tempSettings.tempFoff;
02013
offTempF /=10;
02014
if
(offTempF <32 || offTempF >41) {offTempF=33.8;}
// set default = 33.8 F
02015
alarmTempC = tempSettings.tempalarm;
02016
alarmTempC /= 10;
02017
if
(alarmTempC == 255) {alarmTempC = 255;}
02018
else
{
if
(alarmTempC <0 || alarmTempC >9.9) {alarmTempC=5.0;}}
// set default = 5 C
02019
alarmTempF = tempSettings.tempFalarm;
02020
alarmTempF /= 10;
02021
if
(alarmTempF == 255) {alarmTempF = 255;}
02022
else
{
if
(alarmTempF <32 || alarmTempF >49.8) {alarmTempF=41.0;}}
// set default = 41 F
02023
setTempToSoundAlarmC = tempSettings.tempSoundAlarmC;
02024
if
(setTempToSoundAlarmC ==255) {setTempToSoundAlarmC = 255;}
// Sound is OFF
02025
else
{
02026
if
(setTempToSoundAlarmC <40 || setTempToSoundAlarmC >99) {setTempToSoundAlarmC=50;}}
// set default = 50 C
02027
setTempToSoundAlarmF = tempSettings.tempSoundAlarmF;
02028
if
(setTempToSoundAlarmF ==255) {setTempToSoundAlarmC = 255;}
// OFF alarm
02029
else
{
02030
if
(setTempToSoundAlarmF <104 || setTempToSoundAlarmF >210) {setTempToSoundAlarmF=122;}}
// set default = 122 F
02031
02032
02033
EEPROM_readAnything(660+200, GENERALsettings);
02034
setCalendarFormat = GENERALsettings.calendarFormat;
//DD/MM/YYYY=0 || Month DD, YYYY=1 (change in prog)
02035
if
(setCalendarFormat >1) {setCalendarFormat=0;}
// set default = DD/MM/YYYY
02036
displayDOW = GENERALsettings.ShowHideDOW;
//Hide=0 || Show=1 (change in prog)
02037
if
(displayDOW >1) {displayDOW=1;}
// set default = 1
02038
setTimeFormat = GENERALsettings.timeFormat;
//24HR=0 || 12HR=1 (change in prog)
02039
if
(setTimeFormat >1 ) {setTimeFormat=0;}
// set default = 0
02040
setTempScale = GENERALsettings.tempScale;
02041
if
(setTempScale >1) {setTempScale=0;}
// Celsius=0 || Fahrenheit=1 -C, set default =0 if eeprom error
02042
setTempToBeginHeatsink1FanC = GENERALsettings.Heatsink1FanTempC;
02043
setTempToBeginHeatsink1FanC /= 10;
02044
if
(setTempToBeginHeatsink1FanC <20 || setTempToBeginHeatsink1FanC >50) {setTempToBeginHeatsink1FanC=29.0;}
// set default = 29 C
02045
setTempToBeginHeatsink1FanF = GENERALsettings.Heatsink1FanTempF;
02046
setTempToBeginHeatsink1FanF /= 10;
02047
if
(setTempToBeginHeatsink1FanF <68 || setTempToBeginHeatsink1FanF >122) {setTempToBeginHeatsink1FanF=84.2;}
// set default = 84.2F
02048
02049
setTempToBeginHeatsink2FanC = GENERALsettings.Heatsink2FanTempC;
02050
setTempToBeginHeatsink2FanC /= 10;
02051
if
(setTempToBeginHeatsink2FanC <20 || setTempToBeginHeatsink2FanC >50) {setTempToBeginHeatsink2FanC=29.0;}
// set default = 29 C
02052
setTempToBeginHeatsink2FanF = GENERALsettings.Heatsink2FanTempF;
02053
setTempToBeginHeatsink2FanF /= 10;
02054
if
(setTempToBeginHeatsink2FanF <68 || setTempToBeginHeatsink2FanF >122) {setTempToBeginHeatsink2FanF=84.2;}
// set default = 84.2F
02055
setScreensaverOnOff = GENERALsettings.SCREENsaverONOFF;
//OFF=0 || ON=1
02056
if
(setScreensaverOnOff >1) {setScreensaverOnOff=1;}
02057
BrigthnessCount = GENERALsettings.ScreensaverBrigthnessCount;
02058
if
(BrigthnessCount >4) {BrigthnessCount=4;}
02059
if
(BrigthnessCount <0) {BrigthnessCount=4;}
02060
ClockType = GENERALsettings.ScreensaverClockType;
//ClockType = 0/1/2/3/ -> Blank/An.Clock/Dig.Clock/Temperature
02061
if
(ClockType >3) {ClockType=1;}
02062
setSSmintues = GENERALsettings.ScreensaverTimer;
//
02063
if
(setSSmintues <1 || setSSmintues >99) {setSSmintues=20;}
// 1....99 min
02064
MAX_Temp_on_off = GENERALsettings.MAX_Temp_on_off;
//OFF=0 || ON=1
02065
if
(MAX_Temp_on_off >1) {MAX_Temp_on_off=1;}
02066
SoftStartON = GENERALsettings.SoftStartON;
//OFF=0 || ON=1
02067
if
(SoftStartON >1) {SoftStartON=1;}
02068
AlarmLevel = GENERALsettings.AlarmLevel;
//All OFF=0, OverHeat=1, All ON=2
02069
if
(AlarmLevel >2) {AlarmLevel=0;}
02070
setLockScreen = GENERALsettings.ScreenLock;
//OFF=0 || ON=1
02071
if
(setLockScreen >1) {setLockScreen=1;}
02072
02073
02074
EEPROM_readAnything(680+200, FEEDERsettings);
02075
feedFish1H = FEEDERsettings.feedFish1h;
02076
if
(feedFish1H >24) {feedFish1H=20;}
// 0....24 h
02077
feedFish1M = FEEDERsettings.feedFish1m;
02078
if
(feedFish1M >60) {feedFish1M=0;}
// 0....60 min
02079
feedFish2H = FEEDERsettings.feedFish2h;
02080
if
(feedFish2H >24) {feedFish2H=20;}
// 0....24 h
02081
feedFish2M = FEEDERsettings.feedFish2m;
02082
if
(feedFish2M >60) {feedFish2M=0;}
// 0....60 min
02083
feedFish3H = FEEDERsettings.feedFish3h;
02084
if
(feedFish3H >24) {feedFish3H=20;}
// 0....24 h
02085
feedFish3M = FEEDERsettings.feedFish3m;
02086
if
(feedFish3M >60) {feedFish3M=0;}
// 0....60 min
02087
feedFish4H = FEEDERsettings.feedFish4h;
02088
if
(feedFish4H >24) {feedFish4H=20;}
// 0....24 h
02089
feedFish4M = FEEDERsettings.feedFish4m;
02090
if
(feedFish4M >60) {feedFish4M=0;}
// 0....60 min
02091
FEEDTime1 = FEEDERsettings.feedTime1;
02092
if
(FEEDTime1 >1) {FEEDTime1=0;}
02093
FEEDTime2 = FEEDERsettings.feedTime2;
02094
if
(FEEDTime2 >1) {FEEDTime2=0;}
02095
FEEDTime3 = FEEDERsettings.feedTime3;
02096
if
(FEEDTime3 >1) {FEEDTime3=0;}
02097
FEEDTime4 = FEEDERsettings.feedTime4;
02098
if
(FEEDTime4 >1) {FEEDTime4=0;}
02099
}
02100
02101
void
ReadDallasAddress ()
02102
{
02103
for
(
byte
i = 0; i < 8; i++)
02104
{ Heatsink1Thermometer [i] = EEPROM.read(900+i);
// sensor address
02105
Heatsink2Thermometer [i] = EEPROM.read(900+i+9);
02106
waterThermometer [i] = EEPROM.read(900+i+18);
02107
}
02108
counterB1 = EEPROM.read(900+8);
// config byte
02109
counterB2 = EEPROM.read(900+17);
02110
counterB3 = EEPROM.read(900+26);
02111
}
02112
02113
/***************************** END OF EEPROM FUNCTIONS ********************************/
02114
02115
02116
/********************************** RTC FUNCTIONS *************************************/
02117
void
TimeDateBar(boolean refreshAll=
false
)
02118
{
02119
int
Hour12;
02120
// String ampm;
02121
t = rtc.getTime();
02122
02123
//Date
02124
setFont(SMALL, 255, 255, 0, 64, 64, 64);
02125
if
((setCalendarFormat==0) && (displayDOW==1))
02126
{ myGLCD.print(
" "
, 48, 227);
02127
myGLCD.print(rtc.getDateStr(FORMAT_LONG, FORMAT_LITTLEENDIAN,
'/'
), 56, 227);
02128
myGLCD.print(
" "
, 136, 227);
02129
t.dow=calcDOW(t.date, t.mon, t.year);
02130
showDOWonBar(t.dow);
02131
}
02132
if
((setCalendarFormat==1) && (displayDOW==1))
02133
{ myGLCD.print(rtc.getMonthStr(FORMAT_SHORT), 56, 227);
//3 letter Month
02134
myGLCD.print(
" "
, 80, 227);
02135
myGLCD.printNumI(t.date, 88, 227);
02136
if
(t.date<10)
02137
{ myGLCD.print(
", "
, 96, 227);
02138
myGLCD.printNumI(t.year, 112, 227);
02139
myGLCD.print(
" "
, 144, 227);}
02140
else
02141
{ myGLCD.print(
", "
, 104, 227);
02142
myGLCD.printNumI(t.year, 120, 227);
02143
myGLCD.print(
" "
, 152, 227);
02144
}
02145
t.dow=calcDOW(t.date, t.mon, t.year);
02146
showDOWonBar(t.dow);
02147
}
02148
if
((setCalendarFormat==0) && (displayDOW==0))
02149
{ myGLCD.print(
" "
, 13, 227);
02150
myGLCD.print(rtc.getDateStr(FORMAT_LONG, FORMAT_LITTLEENDIAN,
'/'
), 45, 227);
02151
myGLCD.print(
" "
, 125, 227);}
02152
if
((setCalendarFormat==1) && (displayDOW==0))
02153
{ myGLCD.print(
" "
, 5, 227);
02154
myGLCD.print(rtc.getMonthStr(FORMAT_SHORT), 37, 227);
//3 letter Month
02155
myGLCD.print(
" "
, 61, 227);
02156
myGLCD.printNumI(t.date, 69, 227);
02157
if
(t.date<10)
02158
{ myGLCD.print(
", "
, 77, 227);
02159
myGLCD.printNumI(t.year, 93, 227);
02160
myGLCD.print(
" "
, 125, 227);}
02161
else
02162
{ myGLCD.print(
", "
, 85, 227);
02163
myGLCD.printNumI(t.year, 101, 227);
02164
myGLCD.print(
" "
, 133, 227);
02165
}
02166
}
02167
02168
//Time
02169
if
(setTimeFormat==1)
02170
{
02171
// if(t.hour < 12){ ampm= " AM "; } //Adding the AM/PM sufffix
02172
// else { ampm= " PM "; }
02173
02174
if
(t.hour < 12){ myGLCD.print(
" AM "
, 260, 227);}
//Adding the AM/PM sufffix
02175
else
{myGLCD.print(
" PM "
, 260, 227);}
02176
02177
if
(t.hour==0) { Hour12 = 12; }
//12 HR Format
02178
else
{
02179
if
(t.hour>12) { Hour12 = t.hour-12; }
02180
else
{ Hour12 = t.hour; }}
02181
02182
if
(Hour12<10)
02183
{ myGLCD.print(
" "
, 220, 227);
02184
myGLCD.printNumI(Hour12, 228, 227);}
02185
else
02186
{ myGLCD.printNumI(Hour12, 220, 227);}
02187
myGLCD.print(
":"
, 236, 227);
02188
if
(t.min<10)
02189
{ myGLCD.printNumI(0, 244, 227);
02190
myGLCD.printNumI(t.min, 252, 227);}
02191
else
02192
{ myGLCD.printNumI(t.min, 244, 227);}
02193
// myGLCD.print(ampm, 260, 227);
02194
}
02195
else
02196
{ myGLCD.print(rtc.getTimeStr(FORMAT_SHORT), 220, 227);
//24 HR Format
02197
myGLCD.print(
" "
, 260, 227);}
02198
}
02199
02200
02201
byte
calcDOW(
byte
d,
byte
m,
int
y)
02202
{
02203
int
dow;
02204
byte
mArr[12] = {6,2,2,5,0,3,5,1,4,6,2,4};
02205
02206
dow = (y % 100);
02207
dow = dow*1.25;
02208
dow += d;
02209
dow += mArr[m-1];
02210
if
(((y % 4)==0) && (m<3))
02211
dow -= 1;
02212
while
(dow>7)
02213
dow -= 7;
02214
02215
return
dow;
02216
}
02217
02218
void
showDOW_ScreenSaver(
byte
dow)
// show day of week on screensaver
02219
{
02220
char
* str[] = {
"MON"
,
"TUE"
,
"WED"
,
"THU"
,
"FRI"
,
"SAT"
,
"SUN"
};
02221
02222
setFont(SMALL, 200, 200, 200, 0, 0, 0);
// blue on black
02223
myGLCD.print(str[dow-1], SS_DOW_x, 157);
02224
}
02225
02226
void
showDOW(
byte
dow)
// show day of week on menu setting time/date
02227
{
02228
char
* str[] = {
"MON"
,
"TUE"
,
"WED"
,
"THU"
,
"FRI"
,
"SAT"
,
"SUN"
};
02229
setFont(SMALL, 255, 255, 255, 0, 0, 0);
// white on black
02230
myGLCD.print(
" "
, 17, 178);
02231
myGLCD.print(str[dow-1], 41, 178);
02232
}
02233
02234
02235
void
showDOWonBar(
byte
dow)
// show day of week on main windows bottom string
02236
{
02237
char
* str[] = {
"MON,"
,
"TUE,"
,
"WED,"
,
"THU,"
,
"FRI,"
,
"SAT,"
,
"SUN,"
};
02238
myGLCD.print(str[dow-1], 16, 227);
// yellow on gray
02239
}
02240
02241
byte
validateDate(
byte
d,
byte
m, word y)
02242
{
02243
byte
mArr[12] = {31,0,31,30,31,30,31,31,30,31,30,31};
02244
byte
od;
02245
02246
if
(m==2)
02247
{
if
((y % 4)==0)
02248
{
if
(d==30)
02249
od=1;
02250
else
if
(d==0)
02251
od=29;
02252
else
02253
od=d;
02254
}
02255
else
02256
{
if
(d==29)
02257
od=1;
02258
else
if
(d==0)
02259
od=28;
02260
else
02261
od=d;
02262
}
02263
}
02264
else
02265
{
if
(d==0)
02266
od=mArr[m-1];
02267
else
if
(d==(mArr[m-1]+1))
02268
od=1;
02269
else
02270
od=d;
02271
}
02272
return
od;
02273
}
02274
02275
02276
byte
validateDateForMonth(
byte
d,
byte
m, word y)
02277
{
02278
byte
mArr[12] = {31,0,31,30,31,30,31,31,30,31,30,31};
02279
byte
od;
02280
boolean dc=
false
;
02281
02282
if
(m==2)
02283
{
if
((y % 4)==0)
02284
{
if
(d>29)
02285
{ d=29;}
02286
}
02287
else
02288
{
if
(d>28)
02289
{ d=28;}
02290
}
02291
}
02292
else
02293
{
if
(d>mArr[m-1])
02294
{ d=mArr[m-1];}
02295
}
02296
return
d;
02297
}
02298
/********************************* END OF RTC FUNCTIONS *******************************/
02299
02300
#ifdef Timers_11bit
02301
/************************************* Calculate LED LEVELS 8/11 bit ******************/
02302
void
LED_levels_output()
02303
{
02304
int
sector, sstep, t1, t2 ;
02305
02306
if
(colorLEDtest==
true
)
02307
{
02308
tvled_out = map(tvcol_out, 0, 100, 0, ResolutionHigh);
// new value 0-100%,
02309
rbled_out = map(rbcol_out, 0, 100, 0, ResolutionHigh);
02310
uvled_out = map(uvcol_out, 0, 100, 0, ResolutionHigh);
02311
rled_out = map(rcol_out, 0, 100, 0, ResolutionHigh);
// ResolutionHigh = 2000
02312
wled_out = map(wcol_out, 0, 100, 0, ResolutionHigh);
02313
bled_out = map(bcol_out, 0, 100, 0, ResolutionHigh);
02314
cyled_out = map(cycol_out, 0, 100, 0, ResolutionHigh);
02315
yeled_out = map(yelcol_out, 0, 100, 0, ResolutionHigh);
02316
moonled_out = map(mooncol_out, 0, 100, 0, 255);
02317
}
02318
else
02319
{
02320
if
(min_cnt>=1440) {min_cnt=1;}
// 24 hours of minutes
02321
sector = min_cnt/15;
// divided by gives sector -- 15 minute
02322
sstep = min_cnt%15;
// remainder gives add on to sector value
02323
t1 =sector;
02324
if
(t1==95) {t2=0;}
02325
else
{t2 = t1+1;}
02326
02327
if
(sstep==0)
02328
{
02329
tvled_out = map(tvled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02330
rbled_out = map(rbled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02331
uvled_out = map(uvled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02332
rled_out = map(rled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02333
wled_out = map(wled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02334
bled_out = map(bled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02335
cyled_out = map(cyled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02336
yeled_out = map(yeled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02337
}
else
02338
{
02339
tvled_out = check(tvled[t1]*20, tvled[t2]*20, sstep);
02340
rbled_out = check(rbled[t1]*20, rbled[t2]*20, sstep);
02341
uvled_out = check(uvled[t1]*20, uvled[t2]*20, sstep);
02342
rled_out = check(rled[t1]*20, rled[t2]*20, sstep);
02343
wled_out = check(wled[t1]*20, wled[t2]*20, sstep);
02344
bled_out = check(bled[t1]*20, bled[t2]*20, sstep);
02345
cyled_out = check(cyled[t1]*20, cyled[t2]*20, sstep);
02346
yeled_out = check(yeled[t1]*20, yeled[t2]*20, sstep);
02347
}
02348
02349
float
lunarCycle = moonPhase(t.year, t.mon, t.date);
//get a value for the lunar cycle
02350
moonled_out = map ((MinI *(1 - lunarCycle) + MaxI * lunarCycle + 0.5), 0, 100, 0, 255);
//ResolutionLow = 255 for MOON
02351
}
02352
02353
if
(setDimLEDsOnOff==1) {HOT_LEDs();}
//
02354
if
(SoftStartON ==1) {Soft_Start_Led();}
// increase led brigtness after start programm during 50sec
02355
02356
wheaterDim ();
02357
02358
if
(clouDonOff ==1) {
//wled_out = wled_out*PercentDimLW;
02359
tvled_out = PercentDimLW*tvled_out;
02360
bled_out = PercentDimLW*bled_out;
02361
wled_out = PercentDimLW*wled_out;
02362
rbled_out = PercentDimLW*rbled_out;
02363
rled_out = PercentDimLW*rled_out;
02364
uvled_out = PercentDimLW*uvled_out;
02365
cyled_out = PercentDimLW*cyled_out;
02366
yeled_out = PercentDimLW*yeled_out;
02367
}
02368
02369
02370
// check channel status ON/OFF
02371
if
(bitRead(LedShannelStatusByte,0)==
false
) {wled_out=0;}
// WHITE=1 (COLOR) bit 0
02372
if
(bitRead(LedShannelStatusByte,1)==
false
) {bled_out=0;}
// BLUE=2 (COLOR) bit 1
02373
if
(bitRead(LedShannelStatusByte,2)==
false
) {rbled_out=0;}
// ROYAL=3 (COLOR) bit 2
02374
if
(bitRead(LedShannelStatusByte,3)==
false
) {rled_out=0;}
// RED=4 (COLOR) bit 3
02375
if
(bitRead(LedShannelStatusByte,4)==
false
) {uvled_out=0;}
// ULTRA=5 (COLOR) bit 4
02376
if
(bitRead(LedShannelStatusByte,5)==
false
) {tvled_out=0;}
// TV=6 (COLOR) bit 5
02377
if
(bitRead(LedShannelStatusByte,6)==
false
) {cyled_out=0;}
// CYAN=8 (COLOR) bit 6
02378
if
(bitRead(LedShannelStatusByte,7)==
false
) {yeled_out=0;}
// YELLOW=9(COLOR) bit 7
02379
// end check
02380
02381
02382
if
(RECOM_RCD) {
02383
rb_out = rbled_out;
// 11bit, 0-2000 value
02384
uv_out = uvled_out;
02385
tv_out = tvled_out;
02386
r_out = rled_out;
02387
w_out = wled_out;
02388
b_out = bled_out;
02389
cy_out = cyled_out;
02390
yel_out = yeled_out;
02391
moon_out = moonled_out;
02392
02393
}
else
{
02394
rb_out = ResolutionHigh - rbled_out;
02395
uv_out = ResolutionHigh - uvled_out;
02396
tv_out = ResolutionHigh - tvled_out;
02397
r_out = ResolutionHigh - rled_out;
02398
w_out = ResolutionHigh - wled_out;
02399
b_out = ResolutionHigh - bled_out;
02400
cy_out = ResolutionHigh - cyled_out;
02401
yel_out = ResolutionHigh - yeled_out;
02402
moon_out = moonled_out;
02403
}
02404
02405
// if (clouDonOff ==1) {w_out = w_out*PercentDimLW;}
02406
02407
02408
//----------- 11 bit PWM outputs ----------------------------------------
02409
02410
if
( rb_out ) sbi_mix(TCCR4A, COM4B1);
else
cbi_mix(TCCR4A, COM4B1);
// T4B port 7
02411
if
( uv_out ) sbi_mix(TCCR3A, COM3C1);
else
cbi_mix(TCCR3A, COM3C1);
// T3C port 3
02412
if
( tv_out ) sbi_mix(TCCR4A, COM4C1);
else
cbi_mix(TCCR4A, COM4C1);
// T4C port 8
02413
if
( r_out ) sbi_mix(TCCR4A, COM4A1);
else
cbi_mix(TCCR4A, COM4A1);
// T4A port 6
02414
if
( w_out ) sbi_mix(TCCR1A, COM1B1);
else
cbi_mix(TCCR1A, COM1B1);
// T1B port 12
02415
if
( b_out ) sbi_mix(TCCR3A, COM3A1);
else
cbi_mix(TCCR3A, COM3A1);
// T3A port 5
02416
if
( cy_out ) sbi_mix(TCCR3A, COM3B1);
else
cbi_mix(TCCR3A, COM3B1);
// T3B port 2
02417
if
( yel_out ) sbi_mix(TCCR1A, COM1A1);
else
cbi_mix(TCCR1A, COM1A1);
// T1A port 11
02418
02419
// ----------- reload Output Compare Register ---------------------------
02420
02421
OCR4B = rb_out;
02422
OCR3C = uv_out;
02423
OCR4C = tv_out;
02424
OCR4A = r_out;
02425
OCR1B = w_out;
02426
OCR3A = b_out;
02427
OCR3B = cy_out;
02428
OCR1A = yel_out;
02429
02430
analogWrite(ledPinMoon, moon_out);
// 8 bit MOON PWM
02431
//Serial.print ("w_out="); Serial.println (w_out); //+
02432
02433
/*
02434
Serial.print ("rb_out="); Serial.println (rb_out);
02435
Serial.print ("uv_out="); Serial.println (uv_out);
02436
Serial.print ("tv_out="); Serial.println (tv_out);
02437
Serial.print ("r_out="); Serial.println (r_out);
02438
Serial.print ("w_out="); Serial.println (w_out); //+
02439
Serial.print ("b_out="); Serial.println (b_out);
02440
Serial.print ("cy_out="); Serial.println (cy_out);
02441
Serial.print ("yel_out="); Serial.println (yel_out); //+
02442
Serial.print ("moon_out="); Serial.println (moon_out); //+
02443
*/
02444
02445
}
02446
#endif
02447
02448
02449
#ifdef Timers_8_11bit
02450
/************************************* Calculate LED LEVELS 8/11 bit ******************/
02451
#ifdef Standard_shield
02452
void
LED_levels_output()
02453
{
02454
int
sector, sstep, t1, t2 ;
02455
02456
if
(colorLEDtest==
true
)
02457
{
02458
tvled_out = map(tvcol_out, 0, 100, 0, ResolutionLow);
// new value 0-100%, ResolutionLow=255
02459
rled_out = map(rcol_out, 0, 100, 0, ResolutionLow);
//
02460
moonled_out = map(mooncol_out, 0, 100, 0, ResolutionLow);
02461
02462
rbled_out = map(rbcol_out, 0, 100, 0, ResolutionHigh);
// new value 0-100%, ResolutionHigh=1990
02463
wled_out = map(wcol_out, 0, 100, 0, ResolutionHigh);
02464
bled_out = map(bcol_out, 0, 100, 0, ResolutionHigh);
02465
cyled_out = map(cycol_out, 0, 100, 0, ResolutionHigh);
02466
}
02467
else
02468
{
02469
if
(min_cnt>=1440) {min_cnt=1;}
// 24 hours of minutes
02470
sector = min_cnt/15;
// divided by gives sector -- 15 minute
02471
sstep = min_cnt%15;
// remainder gives add on to sector value
02472
t1 =sector;
02473
if
(t1==95) {t2=0;}
02474
else
{t2 = t1+1;}
02475
02476
if
(sstep==0)
02477
{
02478
tvled_out = map(tvled[t1],0, 100, 0, ResolutionLow);
// new value 0-100%
02479
rled_out = map(rled[t1],0, 100, 0, ResolutionLow);
// new value 0-100%
02480
02481
rbled_out = map(rbled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02482
wled_out = map(wled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02483
bled_out = map(bled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02484
cyled_out = map(cyled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02485
}
else
02486
{
02487
tvled_out = check(map(tvled[t1],0, 100, 0, ResolutionLow), map(tvled[t2],0, 100, 0, ResolutionLow), sstep);
02488
rled_out = check(map(rled[t1],0, 100, 0, ResolutionLow), map(rled[t2],0, 100, 0, ResolutionLow), sstep);
02489
02490
rbled_out = check(rbled[t1]*20, rbled[t2]*20, sstep);
02491
wled_out = check(wled[t1]*20, wled[t2]*20, sstep);
02492
bled_out = check(bled[t1]*20, bled[t2]*20, sstep);
02493
cyled_out = check(cyled[t1]*20, cyled[t2]*20, sstep);
02494
}
02495
02496
float
lunarCycle = moonPhase(t.year, t.mon, t.date);
//get a value for the lunar cycle
02497
moonled_out = map ((MinI *(1 - lunarCycle) + MaxI * lunarCycle + 0.5), 0, 100, 0, ResolutionLow);
02498
}
02499
02500
if
(setDimLEDsOnOff==1) {HOT_LEDs();}
//
02501
if
(SoftStartON ==1) {Soft_Start_Led();}
// increase led brigtness after start programm during 50sec
02502
02503
// check channel status ON/OFF
02504
if
(bitRead(LedShannelStatusByte,0)==
false
) {wled_out=0;}
// WHITE=1 (COLOR) bit 0
02505
if
(bitRead(LedShannelStatusByte,1)==
false
) {bled_out=0;}
// BLUE=2 (COLOR) bit 1
02506
if
(bitRead(LedShannelStatusByte,2)==
false
) {rbled_out=0;}
// ROYAL=3 (COLOR) bit 2
02507
if
(bitRead(LedShannelStatusByte,3)==
false
) {rled_out=0;}
// RED=4 (COLOR) bit 3
02508
if
(bitRead(LedShannelStatusByte,4)==
false
) {uvled_out=0;}
// ULTRA=5 (COLOR) bit 4
02509
if
(bitRead(LedShannelStatusByte,5)==
false
) {tvled_out=0;}
// TV=6 (COLOR) bit 5
02510
if
(bitRead(LedShannelStatusByte,6)==
false
) {cyled_out=0;}
// CYAN=8 (COLOR) bit 6
02511
if
(bitRead(LedShannelStatusByte,7)==
false
) {yeled_out=0;}
// YELLOW=9(COLOR) bit 7
02512
// end check
02513
02514
if
(RECOM_RCD) {
02515
tv_out = tvled_out;
02516
r_out = rled_out;
// 8bit, 0-255 value
02517
moon_out = moonled_out;
02518
02519
rb_out = rbled_out;
// 11bit, 0-2000 value
02520
w_out = wled_out;
02521
b_out = bled_out;
02522
cy_out = cyled_out;
02523
02524
}
else
{
02525
tv_out = ResolutionLow - tvled_out;
02526
r_out = ResolutionLow - rled_out;
02527
moon_out = moonled_out;
02528
02529
rb_out = ResolutionHigh - rbled_out;
02530
w_out = ResolutionHigh - wled_out;
02531
b_out = ResolutionHigh - bled_out;
02532
cy_out = ResolutionHigh - cyled_out;
02533
}
02534
02535
//----------- 8 bit PWM outputs --------------
02536
analogWrite(ledPinTV, tv_out);
02537
analogWrite(ledPinRed, r_out);
02538
analogWrite(ledPinMoon, moon_out);
02539
02540
//----------- 11 bit PWM outputs ----------------------------------------
02541
if
( rb_out ) sbi_mix(TCCR1A, COM1A1);
else
cbi_mix(TCCR1A, COM1A1);
// T1A port 11
02542
if
( w_out ) sbi_mix(TCCR1A, COM1B1);
else
cbi_mix(TCCR1A, COM1B1);
// T1B port 12
02543
if
( b_out ) sbi_mix(TCCR4A, COM4B1);
else
cbi_mix(TCCR4A, COM4B1);
// T4B port 7
02544
if
( cy_out ) sbi_mix(TCCR4A, COM4C1);
else
cbi_mix(TCCR4A, COM4C1);
// T4C port 8
02545
02546
// ----------- reload Output Compare Register ---------------------------
02547
OCR1A = rb_out;
02548
OCR1B = w_out;
02549
OCR4B = b_out;
02550
OCR4C = cy_out;
02551
}
02552
02553
#else
02554
void
LED_levels_output()
02555
{
02556
int
sector, sstep, t1, t2 ;
02557
02558
if
(colorLEDtest==
true
)
02559
{
02560
tvled_out = map(tvcol_out, 0, 100, 0, ResolutionLow);
// new value 0-100%, ResolutionLow=255
02561
rbled_out = map(rbcol_out, 0, 100, 0, ResolutionLow);
02562
uvled_out = map(uvcol_out, 0, 100, 0, ResolutionLow);
02563
02564
rled_out = map(rcol_out, 0, 100, 0, ResolutionHigh);
// ResolutionHigh = 2000
02565
wled_out = map(wcol_out, 0, 100, 0, ResolutionHigh);
02566
bled_out = map(bcol_out, 0, 100, 0, ResolutionHigh);
02567
cyled_out = map(cycol_out, 0, 100, 0, ResolutionHigh);
02568
yeled_out = map(yelcol_out, 0, 100, 0, ResolutionHigh);
02569
moonled_out = map(mooncol_out, 0, 100, 0, ResolutionHigh);
02570
}
02571
else
02572
{
02573
if
(min_cnt>=1440) {min_cnt=1;}
// 24 hours of minutes
02574
sector = min_cnt/15;
// divided by gives sector -- 15 minute
02575
sstep = min_cnt%15;
// remainder gives add on to sector value
02576
t1 =sector;
02577
if
(t1==95) {t2=0;}
02578
else
{t2 = t1+1;}
02579
02580
if
(sstep==0)
02581
{
02582
tvled_out = map(tvled[t1],0, 100, 0, ResolutionLow);
// new value 0-100%
02583
rbled_out = map(rbled[t1],0, 100, 0, ResolutionLow);
// new value 0-100%
02584
uvled_out = map(uvled[t1],0, 100, 0, ResolutionLow);
// new value 0-100%
02585
02586
rled_out = map(rled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02587
wled_out = map(wled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02588
bled_out = map(bled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02589
cyled_out = map(cyled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02590
yeled_out = map(yeled[t1],0, 100, 0, ResolutionHigh);
// new value 0-100%
02591
}
else
02592
{
02593
tvled_out = check(map(tvled[t1],0, 100, 0, ResolutionLow), map(tvled[t2],0, 100, 0, ResolutionLow), sstep);
02594
rbled_out = check(map(rbled[t1],0, 100, 0, ResolutionLow), map(rbled[t2],0, 100, 0, ResolutionLow), sstep);
02595
uvled_out = check(map(uvled[t1],0, 100, 0, ResolutionLow), map(uvled[t2],0, 100, 0, ResolutionLow), sstep);
02596
02597
rled_out = check(rled[t1]*20, rled[t2]*20, sstep);
02598
wled_out = check(wled[t1]*20, wled[t2]*20, sstep);
02599
bled_out = check(bled[t1]*20, bled[t2]*20, sstep);
02600
cyled_out = check(cyled[t1]*20, cyled[t2]*20, sstep);
02601
yeled_out = check(yeled[t1]*20, yeled[t2]*20, sstep);
02602
}
02603
02604
float
lunarCycle = moonPhase(t.year, t.mon, t.date);
//get a value for the lunar cycle
02605
moonled_out = map ((MinI *(1 - lunarCycle) + MaxI * lunarCycle + 0.5), 0, 100, 0, ResolutionHigh);
02606
}
02607
02608
if
(setDimLEDsOnOff==1) {HOT_LEDs();}
//
02609
if
(SoftStartON ==1) {Soft_Start_Led();}
// increase led brigtness after start programm during 50sec
02610
02611
// check channel status ON/OFF
02612
if
(bitRead(LedShannelStatusByte,0)==
false
) {wled_out=0;}
// WHITE=1 (COLOR) bit 0
02613
if
(bitRead(LedShannelStatusByte,1)==
false
) {bled_out=0;}
// BLUE=2 (COLOR) bit 1
02614
if
(bitRead(LedShannelStatusByte,2)==
false
) {rbled_out=0;}
// ROYAL=3 (COLOR) bit 2
02615
if
(bitRead(LedShannelStatusByte,3)==
false
) {rled_out=0;}
// RED=4 (COLOR) bit 3
02616
if
(bitRead(LedShannelStatusByte,4)==
false
) {uvled_out=0;}
// ULTRA=5 (COLOR) bit 4
02617
if
(bitRead(LedShannelStatusByte,5)==
false
) {tvled_out=0;}
// TV=6 (COLOR) bit 5
02618
if
(bitRead(LedShannelStatusByte,6)==
false
) {cyled_out=0;}
// CYAN=8 (COLOR) bit 6
02619
if
(bitRead(LedShannelStatusByte,7)==
false
) {yeled_out=0;}
// YELLOW=9(COLOR) bit 7
02620
// end check
02621
02622
if
(RECOM_RCD) {
02623
rb_out = rbled_out;
// 8bit, 0-255 value
02624
uv_out = uvled_out;
02625
tv_out = tvled_out;
02626
02627
r_out = rled_out;
// 11bit, 0-2000 value
02628
w_out = wled_out;
02629
b_out = bled_out;
02630
cy_out = cyled_out;
02631
yel_out = yeled_out;
02632
moon_out = moonled_out;
02633
02634
}
else
{
02635
rb_out = ResolutionLow - rbled_out;
02636
uv_out = ResolutionLow - uvled_out;
02637
tv_out = ResolutionLow - tvled_out;
02638
02639
r_out = ResolutionHigh - rled_out;
02640
w_out = ResolutionHigh - wled_out;
02641
b_out = ResolutionHigh - bled_out;
02642
cy_out = ResolutionHigh - cyled_out;
02643
yel_out = ResolutionHigh - yeled_out;
02644
moon_out = moonled_out;
02645
}
02646
02647
//----------- 8 bit PWM outputs --------------
02648
analogWrite(ledPinRoyBlue, rb_out);
02649
analogWrite(ledPinUV, uv_out);
02650
// analogWrite(ledPinMoon, uv_out); // for Pasha
02651
analogWrite(ledPinTV, tv_out);
02652
02653
//----------- 11 bit PWM outputs ----------------------------------------
02654
if
( r_out ) sbi_mix(TCCR4A, COM4A1);
else
cbi_mix(TCCR4A, COM4A1);
02655
if
( w_out ) sbi_mix(TCCR1A, COM1B1);
else
cbi_mix(TCCR1A, COM1B1);
02656
if
( b_out ) sbi_mix(TCCR3A, COM3A1);
else
cbi_mix(TCCR3A, COM3A1);
02657
if
( cy_out ) sbi_mix(TCCR3A, COM3B1);
else
cbi_mix(TCCR3A, COM3B1);
02658
if
( yel_out ) sbi_mix(TCCR1A, COM1A1);
else
cbi_mix(TCCR1A, COM1A1);
02659
if
( moon_out ) sbi_mix(TCCR3A, COM3C1);
else
cbi_mix(TCCR3A, COM3C1);
02660
// ----------- reload Output Compare Register ---------------------------
02661
02662
OCR4A = r_out;
02663
OCR1B = w_out;
02664
OCR3A = b_out;
02665
OCR3B = cy_out;
02666
OCR1A = yel_out;
02667
OCR3C = moon_out;
02668
}
02669
#endif
02670
#endif
02671
02672
02673
#ifdef Timers_8bit
02674
/************************************* LED LEVELS *************************************/
02675
void
LED_levels_output()
02676
{
02677
int
sector, sstep, t1, t2 ;
02678
02679
if
(colorLEDtest==
true
)
02680
{
02681
tvled_out = map(tvcol_out, 0, 100, 0, 255);
// new value 0-100%
02682
rled_out = map(rcol_out, 0, 100, 0, 255);
02683
wled_out = map(wcol_out, 0, 100, 0, 255);
02684
bled_out = map(bcol_out, 0, 100, 0, 255);
02685
rbled_out = map(rbcol_out, 0, 100, 0, 255);
02686
uvled_out = map(uvcol_out, 0, 100, 0, 255);
02687
cyled_out = map(cycol_out, 0, 100, 0, 255);
02688
yeled_out = map(yelcol_out, 0, 100, 0, 255);
02689
moonled_out = map(mooncol_out, 0, 100, 0, 255);
02690
}
02691
else
02692
{
02693
if
(min_cnt>=1440) {min_cnt=1;}
// 24 hours of minutes
02694
sector = min_cnt/15;
// divided by gives sector -- 15 minute
02695
sstep = min_cnt%15;
// remainder gives add on to sector value
02696
t1 =sector;
02697
if
(t1==95) {t2=0;}
02698
else
{t2 = t1+1;}
02699
02700
if
(sstep==0)
02701
{
02702
tvled_out = map(tvled[t1],0, 100, 0, 255);
// new value 0-100%
02703
bled_out = map(bled[t1],0, 100, 0, 255);
// new value 0-100%
02704
wled_out = map(wled[t1],0, 100, 0, 255);
// new value 0-100%
02705
rbled_out = map(rbled[t1],0, 100, 0, 255);
// new value 0-100%
02706
rled_out = map(rled[t1],0, 100, 0, 255);
// new value 0-100%
02707
uvled_out = map(uvled[t1],0, 100, 0, 255);
// new value 0-100%
02708
cyled_out = map(cyled[t1],0, 100, 0, 255);
// new value 0-100%
02709
yeled_out = map(yeled[t1],0, 100, 0, 255);
// new value 0-100%
02710
}
else
02711
{
02712
tvled_out = check(&tvled[t1], &tvled[t2], sstep);
02713
tvled_out = map (tvled_out, 0, 100, 0, 255);
02714
02715
bled_out = check(&bled[t1], &bled[t2], sstep);
02716
bled_out = map (bled_out, 0, 100, 0, 255);
02717
02718
wled_out = check(&wled[t1], &wled[t2], sstep);
02719
wled_out = map (wled_out, 0, 100, 0, 255);
02720
02721
rbled_out = check(&rbled[t1], &rbled[t2], sstep);
02722
rbled_out = map (rbled_out, 0, 100, 0, 255);
02723
02724
rled_out = check(&rled[t1], &rled[t2], sstep);
02725
rled_out = map (rled_out, 0, 100, 0, 255);
02726
02727
uvled_out = check(&uvled[t1], &uvled[t2], sstep);
02728
uvled_out = map (uvled_out, 0, 100, 0, 255);
02729
02730
cyled_out = check(&cyled[t1], &cyled[t2], sstep);
02731
cyled_out = map (cyled_out, 0, 100, 0, 255);
02732
02733
yeled_out = check(&yeled[t1], &yeled[t2], sstep);
02734
yeled_out = map (yeled_out, 0, 100, 0, 255);
02735
}
02736
02737
float
lunarCycle = moonPhase(t.year, t.mon, t.date);
//get a value for the lunar cycle
02738
// moonled_out = MinI *(1 - lunarCycle) + MaxI * lunarCycle + 0.5; //MaximumIllumination * % of Full Moon (0-255)
02739
moonled_out = map ((MinI *(1 - lunarCycle) + MaxI * lunarCycle + 0.5), 0, 100, 0, 255);
02740
}
02741
02742
if
(setDimLEDsOnOff==1) {HOT_LEDs();}
//
02743
if
(SoftStartON ==1) {Soft_Start_Led();}
// increase led brigtness after start programm during 50sec
02744
02745
if
(bitRead(LedShannelStatusByte,0)==
false
) {wled_out=0;}
02746
if
(bitRead(LedShannelStatusByte,1)==
false
) {bled_out=0;}
02747
if
(bitRead(LedShannelStatusByte,2)==
false
) {rbled_out=0;}
02748
if
(bitRead(LedShannelStatusByte,3)==
false
) {rled_out=0;}
02749
if
(bitRead(LedShannelStatusByte,4)==
false
) {uvled_out=0;}
02750
if
(bitRead(LedShannelStatusByte,5)==
false
) {tvled_out=0;}
02751
if
(bitRead(LedShannelStatusByte,6)==
false
) {cyled_out=0;}
02752
if
(bitRead(LedShannelStatusByte,7)==
false
) {yeled_out=0;}
02753
// end check
02754
02755
if
(RECOM_RCD ==
true
) {
// 0-255 PWM or 0-10V
02756
tv_out = tvled_out;
02757
b_out = bled_out;
02758
w_out = wled_out;
02759
rb_out = rbled_out;
02760
r_out = rled_out;
02761
uv_out = uvled_out;
02762
cy_out = cyled_out;
02763
yel_out = yeled_out;
02764
moon_out = moonled_out;
02765
}
else
{
// 255-0 PWM or 10V-0v - inverse output
02766
tv_out = 255 - tvled_out;
02767
b_out = 255 - bled_out;
02768
w_out = 255 - wled_out;
02769
rb_out = 255 - rbled_out;
02770
r_out = 255 - rled_out;
02771
uv_out = 255 - uvled_out;
02772
cy_out = 255 - cyled_out;
02773
yel_out = 255 - yeled_out;
02774
// moon_out = 255 - moonled_out;
02775
moon_out = moonled_out;
02776
}
02777
analogWrite(ledPinTV, tv_out);
02778
analogWrite(ledPinRed, r_out);
02779
analogWrite(ledPinWhite, w_out);
02780
analogWrite(ledPinBlue, b_out);
02781
analogWrite(ledPinRoyBlue, rb_out);
02782
analogWrite(ledPinUV, uv_out);
02783
analogWrite(ledPinCyan, cy_out);
02784
analogWrite(ledPinYellow, yel_out);
02785
analogWrite(ledPinMoon, moon_out);
02786
// analogWrite(ledPinMoon, uv_out); // for Pasha
02787
02788
/*
02789
Serial.print ("rb_out="); Serial.println (rb_out);
02790
Serial.print ("uv_out="); Serial.println (uv_out);
02791
Serial.print ("tv_out="); Serial.println (tv_out);
02792
Serial.println (" ");
02793
Serial.print ("r_out="); Serial.println (r_out);
02794
Serial.print ("w_out="); Serial.println (w_out); //+
02795
Serial.print ("b_out="); Serial.println (b_out);
02796
Serial.print ("cy_out="); Serial.println (cy_out);
02797
Serial.print ("yel_out="); Serial.println (yel_out); //+
02798
Serial.print ("moon_out="); Serial.println (moon_out); //+
02799
Serial.println (" ");
02800
*/
02801
}
02802
#endif
02803
02804
#ifdef Timers_8bit
02805
int
check(
byte
*pt1,
byte
*pt2,
int
lstep)
02806
{
02807
int
result;
02808
float
fresult;
02809
02810
if
(*pt1==*pt2) {result = *pt1;}
// No change
02811
else
if
(*pt1<*pt2)
//Increasing brightness
02812
{ fresult = ((
float
(*pt2-*pt1)/15.0) *
float
(lstep))+
float
(*pt1);
02813
result =
int
(fresult);
02814
}
02815
//Decreasing brightness
02816
else
{fresult = -((
float
(*pt1-*pt2)/15.0) *
float
(lstep))+
float
(*pt1);
02817
result =
int
(fresult);
02818
}
02819
return
result;
02820
}
02821
#else
02822
int
check(
int
pt1,
int
pt2,
int
lstep)
02823
{
02824
int
result;
02825
float
fresult;
02826
02827
if
(pt1==pt2) {result = pt1;}
// No change
02828
else
if
(pt1<pt2)
//Increasing brightness
02829
{ fresult = ((
float
(pt2-pt1)/900) *
float
(lstep*60+t.sec))+
float
(pt1);
02830
result =
int
(fresult);
02831
}
02832
//Decreasing brightness
02833
else
{fresult = -((
float
(pt1-pt2)/900) *
float
(lstep*60+t.sec))+
float
(pt1);
02834
result =
int
(fresult);
02835
}
02836
return
result;
02837
}
02838
#endif
02839
/********************************* END OF LED LEVELS **********************************/
02840
02841
02842
/************************************ WAVE OUTPUT *************************************/
02843
/*
02844
void wave_output()
02845
{
02846
unsigned long currentMillis = millis();
02847
02848
if (WAVE==1) //Alternating Mode
02849
{
02850
if (waveMakerTest==true)
02851
{
02852
wPump1 = ((Min1*60)+Sec1*WaveCorrector);
02853
wPump1 = wPump1*1000;
02854
wPump2 = ((Min2*60)+Sec2*WaveCorrector);
02855
wPump2 = wPump2*1000;
02856
}
02857
else
02858
{
02859
wPump1 = ((Pump1m*60)+Pump1s*WaveCorrector);
02860
wPump1 = wPump1*1000;
02861
wPump2 = ((Pump2m*60)+Pump2s*WaveCorrector);
02862
wPump2 = wPump2*1000;
02863
}
02864
02865
if (currentMillis - previousMillisWave > intervalAlt)
02866
{
02867
previousMillisWave = currentMillis;
02868
02869
if (wPump1==wPump2) { wPump2 = wPump2+1;}
02870
02871
if (intervalAlt==wPump1)
02872
{ intervalAlt=wPump2;
02873
PumpTstate = LOW;
02874
PumpBstate = HIGH;}
02875
else
02876
{ intervalAlt=wPump1;
02877
PumpTstate = HIGH;
02878
PumpBstate = LOW;}
02879
}
02880
}
02881
if ((WAVE==2) && (Synch==1)) //Synchronous - Constanly ON
02882
{
02883
PumpTstate = HIGH;
02884
PumpBstate = HIGH;
02885
} else
02886
02887
if ((WAVE==2) && (Synch==2)) //Synchronous - Pulsating
02888
{
02889
if (waveMakerTest==true)
02890
{
02891
wOnForT = ((Min1*60)+Sec1*WaveCorrector);
02892
wOnForT = wOnForT*1000;
02893
wOffForT = ((Min2*60)+Sec2*WaveCorrector);
02894
wOffForT = wOffForT*1000;
02895
}
02896
else
02897
{
02898
wOnForT = (OnForTm*60)+OnForTs*WaveCorrector;
02899
wOnForT = wOnForT*1000;
02900
wOffForT = (OffForTm*60)+OffForTs*WaveCorrector;
02901
wOffForT = wOffForT*1000;
02902
}
02903
02904
if (currentMillis - previousMillisWave > intervalSynch)
02905
{
02906
previousMillisWave = currentMillis;
02907
02908
if (wOnForT==wOffForT) { wOffForT = wOffForT+1;}
02909
02910
if (intervalSynch==wOnForT)
02911
{ intervalSynch=wOffForT;
02912
PumpTstate = LOW;
02913
PumpBstate = LOW;}
02914
else
02915
{ intervalSynch=wOnForT;
02916
PumpTstate = HIGH;
02917
PumpBstate = HIGH;}
02918
}
02919
}
02920
digitalWrite(WaveMakerTop, PumpTstate);
02921
digitalWrite(WaveMakerBottom, PumpBstate);
02922
}
02923
*/
02924
02925
02926
02927
02928
/********************************* END OF WAVE OUTPUT *********************************/
02929
02930
void
DetectDallalsSensors(boolean refreshSensor=
true
)
02931
{
02932
02933
if
(refreshSensor==
true
)
02934
{
02935
myGLCD.setColor(64, 64, 64);
//Draw Dividers in Grey
02936
myGLCD.drawLine(0, 93, 319, 93);
02937
myGLCD.drawRect(0, 196, 319, 194);
//Bottom Horizontal Divider
02938
02939
myGLCD.setColor(0, 0, 255);
// draw buttor REFRESH rectangle
02940
myGLCD.fillRoundRect(200, 20, 300, 40);
02941
myGLCD.setColor(255, 255, 255);
02942
myGLCD.drawRoundRect(200, 20, 300, 40);
02943
setFont(SMALL, 255, 255, 255, 0, 0, 255);
02944
myGLCD.print(
"Refresh"
, 226, 24);
02945
02946
printButton(
"<< BACK"
, back[0], back[1], back[2], back[3], SMALL);
02947
printButton(
"SAVE"
, prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3], SMALL);
02948
printButton(
"CANCEL"
, canC[0], canC[1], canC[2], canC[3], SMALL);
02949
setFont(SMALL, 0, 255, 0, 0, 0, 0);
02950
// myGLCD.print("Found: ", 5, 24);
02951
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[9])));
02952
myGLCD.print(buffer, 5, 24);
02953
// myGLCD.print("Dallas Sensors", 77, 24);
02954
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[10])));
02955
myGLCD.print(buffer, 77, 24);
02956
}
02957
02958
if
(refreshSensor==
false
) {
02959
myGLCD.setColor(0, 0, 0);
// clear button and text area after pressing refresh
02960
myGLCD.fillRoundRect(4, 95, 318, 190);
02961
myGLCD.fillRoundRect(4, 45, 318, 92);}
02962
02963
sensors.begin();
// start sensors
02964
numberOfDevices = sensors.getDeviceCount();
// find devices
02965
02966
setFont(SMALL, 0, 255, 0, 0, 0, 0);
02967
myGLCD.printNumI(numberOfDevices, 5+56, 24);
// print number
02968
02969
if
(numberOfDevices == 0) {counterB1=0; counterB2=0; counterB3=0;}
// set all counter N.C,
02970
tempAlarmflagW =
false
;
// clear all error flag
02971
tempAlarmflagH1 =
false
;
02972
tempAlarmflagH2 =
false
;
02973
AlarmflagON =
false
;
02974
digitalWrite(tempAlarmPin, LOW);
// OFF Sound
02975
02976
for
(
byte
i = 0; i < 8; i++)
// clear previos sensor ID value
02977
{ Heatsink1Thermometer[i]=0 ;
02978
waterThermometer[i]=0 ;
02979
Heatsink2Thermometer[i]=0 ; }
02980
02981
for
(
byte
k=0; k<numberOfDevices; k++)
02982
{
02983
myGLCD.setColor(0, 0, 255);
02984
myGLCD.fillRoundRect(165, 83+20+30*k, 225, 83+40+30*k);
02985
myGLCD.setColor(255, 255, 255);
02986
myGLCD.drawRoundRect(165, 83+20+30*k, 225, 83+40+30*k);
02987
setFont(SMALL, 255, 255, 255, 0, 0, 255);
02988
if
(k==0) {
// print button text
02989
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[2+counterB1])));
// counterBX = 0/1/2/3 -> NC/Water/H.Sink1/H.Sink2
02990
myGLCD.print(buffer, 169, 83+24+30*k);}
02991
02992
if
(k==1) {
02993
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[2+counterB2])));
// counterBX = 0/1/2/3 -> NC/Water/H.Sink1/H.Sink2
02994
myGLCD.print(buffer, 169, 83+24+30*k); }
02995
02996
if
(k==2) {
02997
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[2+counterB3])));
// counterBX = 0/1/2/3 -> NC/Water/H.Sink1/H.Sink2
02998
myGLCD.print(buffer, 169, 83+24+30*k);}
02999
}
03000
03001
setFont(SMALL, 0, 255, 0, 0, 0, 0);
03002
for
(
byte
k=0; k<numberOfDevices; k++)
03003
{
03004
03005
if
(sensors.getAddress(tempDeviceAddress, k))
03006
{
03007
float
tempC = sensors.getTempC(tempDeviceAddress);
03008
03009
// connect sensor 1...3 to output Water/Heatsink1/Heatsink2
03010
if
(k==0) {
03011
for
(
byte
i=0; i<8; i++) {
03012
if
(counterB1 == 1) {waterThermometer[i] = tempDeviceAddress[i];}
03013
if
(counterB1 == 2) {Heatsink1Thermometer[i] = tempDeviceAddress[i];}
03014
if
(counterB1 == 3) {Heatsink2Thermometer[i] = tempDeviceAddress[i];}
03015
}
03016
}
03017
if
(k==1) {
03018
for
(
byte
i=0; i<8; i++) {
03019
if
(counterB2 == 1) {waterThermometer[i] = tempDeviceAddress[i];}
03020
if
(counterB2 == 2) {Heatsink1Thermometer[i] = tempDeviceAddress[i];}
03021
if
(counterB2 == 3) {Heatsink2Thermometer[i] = tempDeviceAddress[i];}
03022
}
03023
}
03024
if
(k==2) {
03025
for
(
byte
i=0; i<8; i++) {
03026
if
(counterB3 == 1) {waterThermometer[i] = tempDeviceAddress[i];}
03027
if
(counterB3 == 2) {Heatsink1Thermometer[i] = tempDeviceAddress[i];}
03028
if
(counterB3 == 3) {Heatsink2Thermometer[i] = tempDeviceAddress[i];}
03029
}
03030
}
03031
03032
myGLCD.printNumF( tempC, 1, 230+40, k*30+83+24);
// print temperature from current sensor
03033
myGLCD.print(
"Temp="
, 230, k*30+83+24);
03034
myGLCD.print(
"C"
, 230+40+32+6, k*30+83+24);
03035
myGLCD.drawCircle(230+40+32+2, k*30+83+26, 1);
03036
03037
// myGLCD.print("Sensor N", 5, k*15+48);
03038
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[11])));
03039
myGLCD.print(buffer, 5, k*15+48);
03040
myGLCD.printNumI(k+1, 5+64, k*15+48);
03041
// myGLCD.print("Sensor N", 5, k*30+83+24);
03042
myGLCD.print(buffer, 5, k*30+83+24);
03043
myGLCD.printNumI(k+1, 5+64, k*30+83+24);
03044
myGLCD.print(
":"
, 5+64+8, k*15+48);
03045
// myGLCD.print(" connect to", 5+64+8, k*30+83+24);
03046
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[12])));
03047
myGLCD.print(buffer, 5+64+8, k*30+83+24);
03048
03049
for
(
byte
i = 0; i < 8; i++)
// print sensors unic ID
03050
{
03051
byte
result;
03052
byte
temp = tempDeviceAddress[i];
03053
result = temp/16;
// first char convert HEX to ASCII for print
03054
if
(result == 15) {myGLCD.print(
"F"
, i*24+88, k*15+48);}
03055
if
(result == 14) {myGLCD.print(
"E"
, i*24+88, k*15+48);}
03056
if
(result == 13) {myGLCD.print(
"D"
, i*24+88, k*15+48);}
03057
if
(result == 12) {myGLCD.print(
"C"
, i*24+88, k*15+48);}
03058
if
(result == 11) {myGLCD.print(
"B"
, i*24+88, k*15+48);}
03059
if
(result == 10) {myGLCD.print(
"A"
, i*24+88, k*15+48);}
03060
if
(result < 10 ) {myGLCD.printNumI(result, i*24+88, k*15+48);}
03061
03062
result = temp - (temp/16)*16;
// second char convert HEX to ASCII for print
03063
if
(result == 15) {myGLCD.print(
"F"
, i*24+8+88, k*15+48);}
03064
if
(result == 14) {myGLCD.print(
"E"
, i*24+8+88, k*15+48);}
03065
if
(result == 13) {myGLCD.print(
"D"
, i*24+8+88, k*15+48);}
03066
if
(result == 12) {myGLCD.print(
"C"
, i*24+8+88, k*15+48);}
03067
if
(result == 11) {myGLCD.print(
"B"
, i*24+8+88, k*15+48);}
03068
if
(result == 10) {myGLCD.print(
"A"
, i*24+8+88, k*15+48);}
03069
if
(result < 10 ) {myGLCD.printNumI(result, i*24+8+88, k*15+48);}
03070
if
(i<7) {myGLCD.print(
":"
, i*24+16+88, k*15+48);}
03071
}
03072
}
03073
}
03074
}
03075
03076
03077
/*
03078
void printTemperature(DeviceAddress deviceAddress)
03079
{
03080
float tempC = sensors.getTempC(deviceAddress);
03081
Serial.print("Temp C: ");
03082
Serial.print(tempC);
03083
Serial.print(" Temp F: ");
03084
Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit
03085
}
03086
*/
03087
03088
/*
03089
void printAddress(DeviceAddress deviceAddress)
03090
{
03091
for (byte i = 0; i < 8; i++)
03092
{ Serial.print(deviceAddress[i], HEX);}
03093
}
03094
*/
03095
03096
void
Backup()
03097
{
03098
printButton(
"<< BACK"
, back[0], back[1], back[2], back[3], SMALL);
03099
printButton(
"CANCEL"
, canC[0], canC[1], canC[2], canC[3], SMALL);
03100
03101
myGLCD.setColor(0, 0, 255);
03102
myGLCD.fillRoundRect(205, 40+34, 305, 60+34);
03103
myGLCD.fillRoundRect(15, 40+34, 115, 60+34);
03104
myGLCD.setColor(255, 255, 255);
03105
myGLCD.drawRoundRect(205, 40+34, 305, 60+34);
03106
myGLCD.drawRoundRect(15, 40+34, 115, 60+34);
03107
setFont(SMALL, 255, 255, 255, 0, 0, 255);
03108
myGLCD.print(
"BACKUP"
, 226+5, 44+34);
03109
myGLCD.print(
"RESTORE"
,15+20, 44+34);
03110
03111
myGLCD.setColor(64, 64, 64);
//Draw Dividers in Grey
03112
myGLCD.drawLine(0, 60, 319, 60);
03113
03114
setFont(SMALL, 0, 255, 0, 0, 0, 0);
03115
myGLCD.print(
"Initializing SD card..."
, 5, 24);
03116
03117
// initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
03118
// breadboards. use SPI_FULL_SPEED for better performance.
03119
if
(!sd.init(SPI_HALF_SPEED, SDchipSelect)) {
03120
sd.initErrorPrint();
03121
setFont(SMALL, 255, 0, 0, 0, 0, 0);
03122
myGLCD.print(
"initialization failed!"
, 5, 24+12+5);
03123
}
else
{myGLCD.print(
"initialization done. "
, 5, 24+12+5);}
03124
03125
/*
03126
if (!sd.begin(SDchipSelect, SPI_SIXTEENTH_SPEED)) {
03127
setFont(SMALL, 255, 0, 0, 0, 0, 0);
03128
myGLCD.print("initialization failed!", 5, 24+12+5);
03129
return;
03130
}
03131
myGLCD.print("initialization done. ", 5, 24+12+5);
03132
*/
03133
}
03134
03135
03136
03137
/******************************** TEMPERATURE FUNCTIONS *******************************/
03138
//----------------- CHECK TEMPERATURE -------------------
03139
void
checkTempC()
03140
{
03141
if
((millis() - lastTempRequest) >= delayInMillis)
03142
{
03143
digitalWrite(Temp_SensorBus0, LOW);
03144
tempW = (sensors.getTempC(waterThermometer));
//read water temperature
03145
tempH1 = (sensors.getTempC(Heatsink1Thermometer));
//read Heatsink1's heatsink temperature
03146
tempH2 = (sensors.getTempC(Heatsink2Thermometer));
//read Heatsink2's heatsink temperature
03147
03148
// sensors.requestTemperatures(); // immediately after fetching the temperature we request a new sample in the async modus
03149
delayInMillis = 750 / (1 << (12 - resolution));
03150
lastTempRequest = millis();
03151
03152
digitalWrite(Temp_SensorBus0, HIGH);
03153
sensors.requestTemperatures();
// call sensors.requestTemperatures() to issue a global
03154
// temperature request to all devices on the bus
03155
}
03156
}
03157
03158
03159
void
WaterTempCheckFunction()
03160
{
03161
String deg;
03162
if
(setTempScale==1) {deg =
"F"
;}
//Print deg C or deg F
03163
else
{deg =
"C"
;}
03164
degC_F=deg;
03165
char
bufferDeg[2];
03166
degC_F.toCharArray(bufferDeg,2);
03167
03168
//--------------- check Water temp and ON/OFF heater-chiller -----------------
03169
if
(counterB1 ==1 || counterB2 ==1 || counterB3 ==1)
// check Water temperature if B1 or B2 or B3 = 1 (Water)
03170
{
03171
if
(tempW == -127 || tempW == -196 || tempW <10 || tempW >40)
//sensor disconnected
03172
{
03173
tempW = 0;
// temporary store error value
03174
if
(WaterTempErrorCount >=12)
03175
{
03176
digitalWrite(tempHeatPin, LOW);
// off heater and chiller
03177
digitalWrite(tempChillPin, LOW);
03178
if
(AlarmLevel ==2) {tempAlarmflagW =
true
;}
//turn on sound alarm if possible
03179
tempCoolflag=
false
;
03180
tempHeatflag=
false
;
03181
}
03182
if
(WaterTempErrorCount <=12) {WaterTempErrorCount +=1;}
03183
}
03184
else
03185
{
03186
WaterTempErrorCount = 0;
//reset error counter
03187
if
(tempW !=0)
// No GPIO function on error
03188
{
03189
if
(alarmTempC>0)
//turn on alarm
03190
{
if
((tempW>=(setTempC+offTempC+alarmTempC)) || (tempW<=(setTempC-offTempC-alarmTempC)))
03191
{ tempAlarmflagW =
true
;}}
03192
03193
if
(tempW<(setTempC+offTempC+alarmTempC) && tempW>(setTempC-offTempC-alarmTempC))
03194
{
//turn off alarm after OverHeating/OverCooling
03195
tempAlarmflagW =
false
;
03196
if
(dispScreen==0)
03197
{
03198
myGLCD.setColor(0, 0, 0);
03199
myGLCD.fillRect(182, 203, 315, 221);
// clear alarm notices
03200
}
03201
AlarmflagON =
false
;
03202
digitalWrite(tempAlarmPin, LOW); }
// OFF alarm
03203
03204
if
(tempW<(setTempC+offTempC) && tempW>(setTempC-offTempC))
//turn off chiller/heater, Water temp is NORMAL T< SET+offset
03205
{ tempCoolflag=
false
;
03206
tempHeatflag=
false
;
03207
digitalWrite(tempHeatPin, LOW);
03208
digitalWrite(tempChillPin, LOW);
03209
if
(dispScreen==0)
03210
{ myGLCD.setColor(0, 0, 0);
//clear cooler/heater notices
03211
myGLCD.fillRect(200, 190, 280, 203);}
03212
}
03213
03214
if
(tempW >=(setTempC+offTempC))
//turn on chiller
03215
{
03216
tempCoolflag=
true
;
03217
tempHeatflag=
false
;
03218
digitalWrite(tempHeatPin, LOW);
//turn off heater pin
03219
digitalWrite(tempChillPin, HIGH);
//turn on chiller pin
03220
03221
}
03222
if
(tempW<=(setTempC-offTempC))
//turn an heater
03223
{
03224
tempHeatflag=
true
;
03225
tempCoolflag=
false
;
03226
digitalWrite(tempChillPin, LOW);
//turn off chiller pin
03227
digitalWrite(tempHeatPin, HIGH);
//turn on heater pin
03228
}
03229
}
03230
}
03231
03232
}
else
{digitalWrite(tempHeatPin, LOW);
//turn off heater if sensor not present
03233
digitalWrite(tempChillPin, LOW);
//turn off chiller
03234
tempCoolflag=
false
;
03235
tempHeatflag=
false
; }
03236
03237
03238
// ------- display Water temp Messages -------------------
03239
03240
if
(dispScreen==0)
// display value only in main window
03241
{
03242
if
(counterB1 ==1 || counterB2 ==1 || counterB3 ==1)
03243
{
03244
// if (tempW == -127 || tempW == -196 ) //range in deg C no matter what
03245
03246
if
(WaterTempErrorCount >=12)
03247
{ setFont(SMALL, 255, 0, 0, 0, 0, 0);
03248
myGLCD.print(
"ERROR "
, 260+8, 148);
03249
tempCoolflag=
false
;
03250
tempHeatflag=
false
;
03251
myGLCD.setColor(0, 0, 0);
//clear cooler/heater notices
03252
myGLCD.fillRect(200, 190, 280, 203);
03253
}
else
03254
{
03255
03256
if
(tempW !=0)
// no display function if temp =0
03257
{
03258
if
(setTempScale==1) { tempW = ((tempW*1.8) + 32.05);}
//C to F with rounding
03259
03260
if
(tempCoolflag==
true
)
//Water temperature too HIGH
03261
{ setFont(SMALL, 255, 255, 0, 0, 0, 0);
03262
myGLCD.print(
"Chiller ON"
, 200, 191);}
03263
else
03264
if
(tempHeatflag==
true
)
//Water temperature too LOW
03265
{ setFont(SMALL, 255, 255, 0 , 0, 0, 0);
03266
myGLCD.print(
"Heater ON "
, 200, 191);}
03267
03268
setFont(SMALL, 0, 0, 0, 0, 0, 0);
03269
myGLCD.print(
" "
,300 , 148);
03270
setFont(SMALL, 0, 255, 0, 0, 0, 0);
03271
myGLCD.printNumF( tempW, 1, 260+8, 148);
// print water temp
03272
myGLCD.drawCircle(304, 148, 1);
03273
myGLCD.print(bufferDeg, 309, 148);
03274
03275
//------------------ Display MAX Temp ----------------------------
03276
if
(MAX_Temp_on_off ==1)
// Display ON
03277
{
03278
if
(tempW >= MaxTempW){ MaxTempW = tempW;}
// store max temp
03279
setFont(SMALL, 0, 255, 0, 0, 0, 0);
03280
myGLCD.printNumF(MaxTempW, 1, 105 ,191);
03281
}
03282
}
03283
}
03284
}
03285
03286
//-------- Clear Max Temp every morning --------------------
03287
if
(min_cnt/15 == StartTime) {
03288
MaxTempW=0; MaxTempH1=0; MaxTempH2=0; }
03289
}
03290
}
03291
03292
void
FanTempCheckFunction()
03293
{
03294
03295
byte
ShiftDrawY;
03296
String deg;
03297
if
(setTempScale==1) {deg =
"F"
;}
//Print deg C or deg F
03298
else
{deg =
"C"
;}
03299
degC_F=deg;
03300
char
bufferDeg[2];
03301
degC_F.toCharArray(bufferDeg,2);
03302
03303
//------------Fan Controller for Heatsink1 -----------------
03304
if
(counterB1 ==2 || counterB2 ==2 || counterB3 ==2)
// check Heatsink 1 temperature if B1 or B2 or B3 = 2
03305
{
03306
03307
// Heatsink1TempInterval = (tempH1 - setTempToBeginHeatsink1FanC); //Sets the interval to start from 0
03308
03309
if
((tempH1Store-tempH1)>10 || (tempH1Store-tempH1)<-10) {
03310
if
(Heatsink1TempErrorCount <=12) {Heatsink1TempErrorCount +=1;}
03311
}
else
{Heatsink1TempErrorCount=0;
03312
tempH1Store = tempH1;
03313
}
03314
if
(Heatsink1TempErrorCount == 0) {
03315
Heatsink1TempInterval = (tempH1 - setTempToBeginHeatsink1FanC);
//Sets the interval to start from 0
03316
}
03317
if
(Heatsink1TempErrorCount !=0) {tempH1=0;}
03318
03319
// if (Heatsink1TempInterval >=20 )
03320
if
(Heatsink1TempInterval >=20 || Heatsink1TempErrorCount >=12 )
// Set maximal value PWM =255 if current temp >= setTempToBeginHeatsink2FanC+20C
03321
{Heatsink1TempInterval =20; }
// or error counter >12
03322
03323
03324
if
(Heatsink1TempInterval <= -1) { Heatsink1PWM =0;
03325
analogWrite(Heatsink1_FansPWM, Heatsink1PWM);
03326
bitClear(GlobalStatus1Byte,6);
// GlobalStatus1Byte.6 = StartUPFan1 ;
03327
bitClear(GlobalStatus1Byte,7);}
// GlobalStatus1Byte.6 = StartUPFan1_Timeout;
03328
03329
if
(Heatsink1TempInterval >=1)
03330
{
03331
Heatsink1PWM = map (Heatsink1TempInterval, -1 , 20, 100, 255);
// maximum PWM = setTempToBeginHeatsink2FanC+20C, minimum speed 40% of max
03332
if
(bitRead(GlobalStatus1Byte,7) ==
false
) {
// set flag startup process
03333
analogWrite(Heatsink1_FansPWM, 255);
03334
unsigned
long
cMillis = millis();
03335
previousMillisAlarm = cMillis;
// reset 1 sec timer for fan startup process
03336
bitSet(GlobalStatus1Byte,6);}
03337
03338
else
{ analogWrite(Heatsink1_FansPWM, Heatsink1PWM);
03339
}
03340
}
03341
03342
//---------------------- Sound alarm Section ------------------------------
03343
/*
03344
if (setTempScale ==0 ) {
03345
if (tempH1 >= setTempToSoundAlarmC)
03346
{tempAlarmflagH1 = true; analogWrite(Heatsink1_FansPWM, 255);} // Alarm on overheat led, set maximum fan speed
03347
else
03348
{tempAlarmflagH1 = false; digitalWrite(tempAlarmPin, LOW);} // OFF alarm
03349
03350
if ((tempH1 == -127) && (AlarmLevel ==2)) //All OFF=0, OverHeat=1, All ON=2
03351
{ tempAlarmflagH1 = true; analogWrite(Heatsink1_FansPWM, 255);} // alarm on disconnect or error read sensor
03352
*/
03353
if
(setTempScale ==0 ) {
03354
if
(tempH1 >= setTempToSoundAlarmC )
03355
{tempAlarmflagH1 =
true
; analogWrite(Heatsink1_FansPWM, 255);}
// Alarm on overheat led, set maximum fan speed
03356
else
03357
{tempAlarmflagH1 =
false
; digitalWrite(tempAlarmPin, LOW);}
// OFF alarm
03358
03359
if
((tempH1 == 0) && (AlarmLevel ==2) && Heatsink1TempErrorCount >12)
//All OFF=0, OverHeat=1, All ON=2
03360
{ tempAlarmflagH1 =
true
; analogWrite(Heatsink1_FansPWM, 255);}
// alarm on disconnect or error read sensor
03361
}
03362
03363
/*
03364
if (setTempScale ==1 ) {
03365
if (tempH1 >= setTempToSoundAlarmF)
03366
{tempAlarmflagH1 = true; analogWrite(Heatsink1_FansPWM, 255);} // set maximum fan speed
03367
else
03368
{tempAlarmflagH1 = false; digitalWrite(tempAlarmPin, LOW);} // OFF alarm
03369
if ((tempH1 == -196) && (AlarmLevel ==2))
03370
{tempAlarmflagH1 = true; analogWrite(Heatsink1_FansPWM, 255);}
03371
}
03372
*/
03373
03374
if
(setTempScale ==1 ) {
03375
if
(tempH1 >= setTempToSoundAlarmF)
03376
{tempAlarmflagH1 =
true
; analogWrite(Heatsink1_FansPWM, 255);}
// set maximum fan speed
03377
else
03378
{tempAlarmflagH1 =
false
; digitalWrite(tempAlarmPin, LOW);}
// OFF alarm
03379
if
((tempH1 == -196) && (AlarmLevel ==2) && Heatsink1TempErrorCount >12)
03380
{tempAlarmflagH1 =
true
; analogWrite(Heatsink1_FansPWM, 255);}
03381
}
03382
/*
03383
if (setTempScale ==0 ) {
03384
if (tempH1 >= setTempToSoundAlarmC || tempH1 == -127) {tempAlarmflagH1 = true;
03385
analogWrite(Heatsink1_FansPWM, 255);} // set maximum fan speed}
03386
else {tempAlarmflagH1 = false; digitalWrite(tempAlarmPin, LOW);}} // OFF alarm
03387
if (setTempScale ==1 ) {
03388
if (tempH1 >= setTempToSoundAlarmF || tempH1 == -196) {tempAlarmflagH1 = true;
03389
analogWrite(Heatsink1_FansPWM, 255);} // set maximum fan speed
03390
else {tempAlarmflagH1 = false; digitalWrite(tempAlarmPin, LOW);}} // OFF alarm
03391
*/
03392
}
03393
03394
//-------- Display Heatsink1 temperature ----------------------
03395
03396
if
(dispScreen==0)
// display value only in main window
03397
{
03398
if
(counterB1 ==2 || counterB2 ==2 || counterB3 ==2)
03399
{
03400
if
(((counterB1 + counterB2 + counterB3) == 2) || ((counterB1 + counterB2 + counterB3) == 5)) {ShiftDrawY= 0;}
03401
if
(((counterB1 + counterB2 + counterB3) == 3) || ((counterB1 + counterB2 + counterB3) == 6)) {ShiftDrawY= +13;}
03402
03403
if
(setTempScale==1) { tempH1 = ((tempH1*1.8) + 32.05);}
// display in F
03404
03405
// if (tempH1 == -127 || tempH1 == -196)
03406
if
(Heatsink1TempErrorCount >12)
03407
{ setFont(SMALL, 255, 0, 0, 0, 0, 0);
03408
myGLCD.print(
"ERROR "
, 260+8, 148+ShiftDrawY);
// sensor disconnected
03409
}
else
03410
{
03411
03412
if
(tempH1 !=0) {
03413
setFont(SMALL, 0, 0, 0, 0, 0, 0);
03414
myGLCD.print(
" "
,300 , 148+ShiftDrawY);
03415
setFont(SMALL, 0, 255, 0, 0, 0, 0);
03416
myGLCD.printNumF( tempH1, 1, 260+8, 148+ShiftDrawY);
//Heatsink1 temperature (No Flags)
03417
myGLCD.drawCircle(304, 148+ShiftDrawY+2, 1);
03418
myGLCD.print(bufferDeg, 309, 148+ShiftDrawY);
03419
03420
//-------------- Display Day MAX TEMP ------------------
03421
if
(MAX_Temp_on_off ==1)
// Display ON
03422
{
03423
if
(tempH1 >= MaxTempH1){ MaxTempH1 = tempH1;}
// store max temp
03424
myGLCD.printNumF(MaxTempH1, 1, 105 ,202);
03425
}
03426
}
03427
}
03428
}
03429
}
03430
//--------------Fan Controller for Heatsink2 ---------------------------------------------------------
03431
03432
if
(counterB1 ==3 || counterB2 ==3 || counterB3 ==3)
// check Heatsink 2 temperature if B1 or B2 or B3 = 3
03433
{
03434
03435
if
((tempH2Store-tempH2)>10 || (tempH2Store-tempH2)<-10) {
03436
if
(Heatsink2TempErrorCount <=12) {Heatsink2TempErrorCount +=1;}
03437
}
else
{Heatsink2TempErrorCount=0;
03438
tempH2Store = tempH2;
03439
}
03440
if
(Heatsink2TempErrorCount == 0) {
03441
Heatsink2TempInterval = (tempH2 - setTempToBeginHeatsink2FanC);
//Sets the interval to start from 0
03442
}
03443
if
(Heatsink2TempErrorCount !=0) {tempH2=0;}
03444
03445
if
(Heatsink2TempInterval >=20 || Heatsink2TempErrorCount >=12 )
// Set maximal value PWM =255 if current temp >= setTempToBeginHeatsink2FanC+20C
03446
{Heatsink2TempInterval =20; }
03447
03448
/*
03449
Heatsink2TempInterval = (tempH2 - setTempToBeginHeatsink2FanC); //Sets the interval to start from 0
03450
03451
if (Heatsink2TempInterval >=20 )
03452
{Heatsink2TempInterval =20; } // Set maximal value PWM =255 if current temp >= setTempToBeginHeatsink2FanC+20C
03453
*/
03454
if
(Heatsink2TempInterval <= -1) { Heatsink2PWM =0;
03455
analogWrite(Heatsink2_FansPWM, Heatsink2PWM);
03456
bitClear(GlobalStatus1Byte,4);
// GlobalStatus1Byte.4 = StartUPFan2 ;
03457
bitClear(GlobalStatus1Byte,5); }
// GlobalStatus1Byte.5 = StartUPFan2_Timeout;
03458
03459
if
(Heatsink2TempInterval >=1)
03460
{
03461
Heatsink2PWM = map (Heatsink2TempInterval, -1 , 20, 100, 255);
// maximum PWM = setTempToBeginHeatsink2FanC+20C
03462
if
(bitRead(GlobalStatus1Byte,5) ==
false
) {
// set flag startup process
03463
analogWrite(Heatsink2_FansPWM, 255);
03464
03465
unsigned
long
cMillis = millis();
03466
previousMillisAlarm = cMillis;
// reset 1 sec timer for fan startup process
03467
bitSet(GlobalStatus1Byte,4);}
03468
03469
else
{ analogWrite(Heatsink2_FansPWM, Heatsink2PWM); }
03470
}
03471
03472
//---------------------- Sound alarm Section ------------------------------
03473
/*
03474
if (setTempScale ==0 ) {
03475
if (tempH2 >= setTempToSoundAlarmC) {tempAlarmflagH2 = true; analogWrite(Heatsink2_FansPWM, 255);} // set maximum fan speed
03476
else {tempAlarmflagH2 = false; digitalWrite(tempAlarmPin, LOW);} // OFF alarm
03477
if ((tempH2 == -127) && (AlarmLevel ==2)) {tempAlarmflagH2 = true; analogWrite(Heatsink2_FansPWM, 255);}
03478
}
03479
03480
if (setTempScale ==1 ) {
03481
if (tempH2 >= setTempToSoundAlarmF) {tempAlarmflagH2 = true; analogWrite(Heatsink2_FansPWM, 255);} // set maximum fan speed
03482
else {tempAlarmflagH2 = false; digitalWrite(tempAlarmPin, LOW);} // OFF alarm
03483
if ((tempH1 == -196) && (AlarmLevel ==2)) {tempAlarmflagH2 = true; analogWrite(Heatsink2_FansPWM, 255);}
03484
}
03485
*/
03486
if
(setTempScale ==0 ) {
03487
if
(tempH2 >= setTempToSoundAlarmC )
03488
{tempAlarmflagH2 =
true
; analogWrite(Heatsink2_FansPWM, 255);}
// Alarm on overheat led, set maximum fan speed
03489
else
03490
{tempAlarmflagH2 =
false
; digitalWrite(tempAlarmPin, LOW);}
// OFF alarm
03491
03492
if
((tempH2 == 0) && (AlarmLevel ==2) && Heatsink2TempErrorCount >12)
//All OFF=0, OverHeat=1, All ON=2
03493
{ tempAlarmflagH2 =
true
; analogWrite(Heatsink2_FansPWM, 255);}
// alarm on disconnect or error read sensor
03494
}
03495
03496
if
(setTempScale ==1 ) {
03497
if
(tempH2 >= setTempToSoundAlarmF)
03498
{tempAlarmflagH2 =
true
; analogWrite(Heatsink2_FansPWM, 255);}
// set maximum fan speed
03499
else
03500
{tempAlarmflagH2 =
false
; digitalWrite(tempAlarmPin, LOW);}
// OFF alarm
03501
if
((tempH1 == -196) && (AlarmLevel ==2) && Heatsink2TempErrorCount >12)
03502
{tempAlarmflagH2 =
true
; analogWrite(Heatsink2_FansPWM, 255);}
03503
}
03504
/*
03505
if (setTempScale ==0 ) {
03506
if (tempH2 >= setTempToSoundAlarmC || tempH2 == -127) {tempAlarmflagH2 = true;
03507
analogWrite(Heatsink2_FansPWM, 255);} // set maximum fan speed}
03508
else {tempAlarmflagH2 = false; digitalWrite(tempAlarmPin, LOW);}} // OFF alarm
03509
if (setTempScale ==1 ) {
03510
if (tempH2 >= setTempToSoundAlarmF || tempH2 == -196) {tempAlarmflagH2 = true;
03511
analogWrite(Heatsink2_FansPWM, 255);} // set maximum fan speed
03512
else {tempAlarmflagH2 = false; digitalWrite(tempAlarmPin, LOW);}} // OFF alarm
03513
*/
03514
}
03515
03516
//-------- Display Heatsink2 temperature -----------
03517
if
(dispScreen==0)
// display value only in main window
03518
{
03519
if
(counterB1 ==3 || counterB2 ==3 || counterB3 ==3)
03520
{
03521
if
((counterB1 + counterB2 + counterB3) == 3) {ShiftDrawY= 0;}
03522
if
(((counterB1 + counterB2 + counterB3) == 4) || ((counterB1 + counterB2 + counterB3) == 5)) {ShiftDrawY= +13;}
03523
if
((counterB1 + counterB2 + counterB3) == 6) {ShiftDrawY= +26;}
03524
03525
if
(setTempScale==1) { tempH2 = ((tempH2*1.8) + 32.05); }
// display in F
03526
03527
if
(Heatsink2TempErrorCount >12)
03528
// if (tempH2 == -127 || tempH2 == -196)
03529
{ setFont(SMALL, 255, 0, 0, 0, 0, 0);
03530
myGLCD.print(
"ERROR "
, 260+8, 148+ShiftDrawY);
// sensor disconnected
03531
}
else
03532
{
03533
if
(tempH2 !=0) {
03534
setFont(SMALL, 0, 0, 0, 0, 0, 0);
03535
myGLCD.print(
" "
,300 , 148+ShiftDrawY);
03536
setFont(SMALL, 0, 255, 0, 0, 0, 0);
03537
myGLCD.printNumF( tempH2, 1, 260+8, 148+ShiftDrawY);
//Heatsink2 temperature (No Flags)
03538
myGLCD.drawCircle(304, 148+ShiftDrawY+2, 1);
03539
myGLCD.print(bufferDeg, 309, 148+ShiftDrawY);
03540
//-------------- Display Day MAX TEMP ------------------
03541
if
(MAX_Temp_on_off ==1)
// Display ON
03542
{
03543
if
(tempH2 >= MaxTempH2){ MaxTempH2 = tempH2;}
// store max temp
03544
myGLCD.printNumF(MaxTempH2, 1, 105 ,214);
03545
}
03546
}
03547
}
03548
}
03549
}
03550
}
03551
03552
03553
void
Alarm()
03554
{
03555
unsigned
long
cMillis = millis();
03556
if
(cMillis - previousMillisAlarm > 700)
03557
{ previousMillisAlarm = cMillis;
03558
//----------- FAN start UP -----------------------------------------
03559
if
(bitRead(GlobalStatus1Byte,6) ==
true
)
// startup for FAN1
03560
{ bitClear(GlobalStatus1Byte,6);
03561
bitSet(GlobalStatus1Byte,7); }
03562
03563
if
(bitRead(GlobalStatus1Byte,4) ==
true
)
// startup for FAN2
03564
{ bitClear(GlobalStatus1Byte,4);
03565
bitSet(GlobalStatus1Byte,5); }
03566
03567
//------------- Sound Alarm & Display alarm -------------------------------------
03568
if
((counterB1 + counterB2 + counterB3 !=0))
// no sound alarm if dallas sensor not installed, ie counterB1=counterB2=counterB3=0
03569
{
03570
if
(tempAlarmflagW ==
true
|| tempAlarmflagH1 ==
true
|| tempAlarmflagH2 ==
true
)
03571
{
03572
if
(AlarmflagON ==
false
)
//true)
03573
{
if
(AlarmLevel >=1) {digitalWrite(tempAlarmPin, HIGH);}
// ON alarm
03574
if
(dispScreen == 0){
03575
setFont(LARGE, 255, 0, 0, 0, 0, 0);
03576
myGLCD.print(
"ALARM"
, 185+16, 204);}
03577
AlarmflagON =
true
;}
//false; }
03578
else
{
// if (AlarmflagON == false)
03579
// {
03580
if
(AlarmLevel >=1) {digitalWrite(tempAlarmPin, LOW);}
// OFF alarm
03581
if
(dispScreen == 0){
03582
setFont(LARGE, 255, 0, 0, 0, 0, 0);
03583
myGLCD.print(
" "
, 185+16, 204);}
03584
AlarmflagON =
false
;
//true;
03585
// }
03586
}
03587
}
03588
else
{
if
(AlarmflagON ==
true
) {
03589
setFont(LARGE, 255, 0, 0, 0, 0, 0);
03590
myGLCD.print(
" "
, 185+16, 204);
03591
AlarmflagON =
false
;
//true;
03592
}
03593
}
03594
}
03595
/*
03596
//------------- Display ALARM -----------------------------------------
03597
if (counterB1 + counterB2 + counterB3 !=0)
03598
{
03599
if (tempAlarmflagW == true || tempAlarmflagH1 == true || tempAlarmflagH2 == true)
03600
{ setFont(LARGE, 255, 0, 0, 0, 0, 0);
03601
myGLCD.print("ALARM!!", 185, 204);}
03602
}
03603
*/
03604
}
03605
}
03606
03607
03608
/*************************** END OF TEMPERATURE FUNCTIONS *****************************/
03609
03610
//************ Soft Led Start function **************************************
03611
void
Soft_Start_Led()
// increase led brigtness after start programm during 50sec
03612
{
03613
if
(PercentSoftStart < 1)
03614
{
03615
03616
#ifdef Timers_8bit
03617
PercentSoftStart +=0.1;
03618
#else
03619
PercentSoftStart +=0.02;
03620
#endif
03621
03622
tvled_out = PercentSoftStart*tvled_out;
03623
bled_out = PercentSoftStart*bled_out;
03624
wled_out = PercentSoftStart*wled_out;
03625
rbled_out = PercentSoftStart*rbled_out;
03626
rled_out = PercentSoftStart*rled_out;
03627
uvled_out = PercentSoftStart*uvled_out;
03628
cyled_out = PercentSoftStart*cyled_out;
03629
yeled_out = PercentSoftStart*yeled_out;
03630
}
03631
}
03632
03633
/**************************** DIM LEDs WHEN HOT FUNCTION ******************************/
03634
void
HOT_LEDs()
03635
{
03636
if
(tempH1>=setLEDsDimTempC+1 || tempH2>=setLEDsDimTempC+1)
// || tempW>=setLEDsDimTempC+1)
03637
{ bitSet(GlobalStatus1Byte,1); }
03638
03639
if
(tempH1<=setLEDsDimTempC-1 && tempH2<=setLEDsDimTempC-1)
// && tempW<=setLEDsDimTempC-1)
03640
{bitClear(GlobalStatus1Byte,1);}
03641
03642
if
(bitRead(GlobalStatus1Byte,1) ==
true
) {
03643
PercentDim = setLEDsDimPercent*0.01;
03644
tvled_out = PercentDim*tvled_out;
03645
bled_out = PercentDim*bled_out;
03646
wled_out = PercentDim*wled_out;
03647
rbled_out = PercentDim*rbled_out;
03648
rled_out = PercentDim*rled_out;
03649
uvled_out = PercentDim*uvled_out;
03650
cyled_out = PercentDim*cyled_out;
03651
yeled_out = PercentDim*yeled_out;
03652
}
03653
03654
}
03655
/*************************END OF DIM LEDs WHEN HOT FUNCTION ***************************/
03656
03657
03658
/******************************* LUNAR PHASE FUNCTION *********************************/
03659
float
moonPhase(
int
moonYear,
int
moonMonth,
int
moonDay)
03660
{
03661
float
phase;
03662
double
IP;
03663
long
YY, MM, K1, K2, K3, JulianDay;
03664
YY = moonYear - floor((12 - moonMonth) / 10);
03665
MM = moonMonth + 9;
03666
if
(MM >= 12)
03667
{ MM = MM - 12; }
03668
K1 = floor(365.25 * (YY + 4712));
03669
K2 = floor(30.6 * MM + 0.5);
03670
K3 = floor(floor((YY / 100) + 49) * 0.75) - 38;
03671
JulianDay = K1 + K2 + moonDay + 59;
03672
if
(JulianDay > 2299160)
03673
{ JulianDay = JulianDay - K3; }
03674
IP = MyNormalize((JulianDay - 2451550.1) / LC);
03675
AG = IP*LC;
03676
phase = 0;
03677
03678
//Determine the Moon Illumination %
03679
if
((AG >= 0) && (AG <= LC/2))
//FROM New Moon 0% TO Full Moon 100%
03680
{ phase = (2*AG)/LC; }
03681
if
((AG > LC/2) && (AG <= LC))
//FROM Full Moon 100% TO New Moon 0%
03682
{ phase = 2*(LC-AG)/LC; }
03683
03684
//Determine the Lunar Phase
03685
if
((AG >= 0) && (AG <= 1.85))
//New Moon; ~0-12.5% illuminated
03686
{ LP =
" New Moon "
;
03687
MoonPic = New_Moon; }
03688
if
((AG > 1.85) && (AG <= 5.54))
//New Crescent; ~12.5-37.5% illuminated
03689
{ LP =
"Waxing Crescent"
;
03690
MoonPic = Waxing_Crescent; }
03691
if
((AG > 5.54) && (AG <= 9.23))
//First Quarter; ~37.5-62.5% illuminated
03692
{ LP =
" First Quarter "
;
03693
MoonPic = First_Quarter; }
03694
if
((AG > 9.23) && (AG <= 12.92))
//Waxing Gibbous; ~62.5-87.5% illuminated
03695
{ LP =
"Waxing Gibbous "
;
03696
MoonPic = Waxing_Gibbous; }
03697
if
((AG > 12.92) && (AG <= 16.61))
//Full Moon; ~87.5-100-87.5% illuminated
03698
{ LP =
" Full Moon "
;
03699
MoonPic = Full_Moon; }
03700
if
((AG > 16.61) && (AG <= 20.30))
//Waning Gibbous; ~87.5-62.5% illuminated
03701
{ LP =
"Waning Gibbous "
;
03702
MoonPic = Waning_Gibbous; }
03703
if
((AG > 20.30) && (AG <= 23.99))
//Last Quarter; ~62.5-37.5% illuminated
03704
{ LP =
" Last Quarter "
;
03705
MoonPic = Last_Quarter; }
03706
if
((AG > 23.99) && (AG <= 27.68))
//Old Crescent; ~37.5-12.5% illuminated
03707
{ LP =
"Waning Crescent"
;
03708
MoonPic = Waning_Crescent; }
03709
if
((AG >= 27.68) && (AG <= LC))
//New Moon; ~12.5-0% illuminated
03710
{ LP =
" New Moon "
;
03711
MoonPic = New_Moon; }
03712
03713
return
phase;
03714
}
03715
03716
double
MyNormalize(
double
v)
03717
{
03718
v = v - floor(v);
03719
if
(v < 0)
03720
v = v + 1;
03721
return
v;
03722
}
03723
/**************************** END OF LUNAR PHASE FUNCTION *****************************/
03724
03725
03726
/********************************* MISC. FUNCTIONS ************************************/
03727
void
clearScreen()
03728
{
03729
myGLCD.setColor(0, 0, 0);
03730
myGLCD.fillRect(1, 14, 318, 226);
03731
}
03732
03733
03734
void
printHeader()
03735
{
03736
setFont(SMALL, 255, 255, 0, 255, 255, 0);
03737
myGLCD.fillRect (0, 0, 318, 14);
03738
myGLCD.setColor(0, 0, 0);
03739
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Header_Text_table[PrintStringIndex])));
03740
myGLCD.print(buffer, CENTER, 1 );
03741
}
03742
03743
/*
03744
void printHeader(char* headline)
03745
{
03746
setFont(SMALL, 255, 255, 0, 255, 255, 0);
03747
myGLCD.fillRect (0, 0, 318, 14);
03748
myGLCD.setColor(0, 0, 0);
03749
myGLCD.print(headline, CENTER, 1);
03750
}
03751
*/
03752
03753
void
setFont(boolean font,
byte
cr,
byte
cg,
byte
cb,
byte
br,
byte
bg,
byte
bb)
03754
{
03755
myGLCD.setBackColor(br, bg, bb);
//font background black
03756
myGLCD.setColor(cr, cg, cb);
//font color white
03757
if
(font==LARGE)
03758
myGLCD.setFont(BigFont);
//font size LARGE
03759
else
if
(font==SMALL)
03760
myGLCD.setFont(SmallFont);
03761
}
03762
03763
03764
void
waitForTouchRelease()
03765
{
03766
while
(myTouch.dataAvailable()==
true
)
//Wait for release
03767
myTouch.read();
03768
}
03769
03770
int
LedToPercent (
int
Led_out,
int
resolution)
//returns LED output in % with rounding to the nearest whole number
03771
{
03772
int
result;
03773
float
Temp_in = Led_out;
03774
float
Temp = 100*Temp_in/resolution;
03775
result = map(Led_out, 0, resolution, 0, 100);
03776
if
((Temp - result) >= 0.5) {result +=1;};
// rounding to the nearest whole number
03777
03778
return
result;
03779
}
03780
03781
03782
void
SmallLedBarGraph(
int
Led_out,
int
resolution,
byte
shift_X,
byte
cR,
byte
cG,
byte
cB)
03783
{
03784
int
bar = map(Led_out, 0, resolution, 131, 31);
// Top end bar - Y=31, Bot end bar Y=131
03785
if
(bar <31 ){bar=31;}
03786
if
(bar >131){bar=131;}
03787
myGLCD.setColor(0, 0, 0);
03788
myGLCD.fillRect(31+shift_X, bar, 31+10+shift_X, 31);
//hide end of last bar (Top end bar)
03789
myGLCD.setColor(cR, cG, cB);
03790
myGLCD.drawRect(31+shift_X, 131, 31+10+shift_X, 130);
// %bar place holder
03791
myGLCD.fillRect(31+shift_X, 130, 31+10+shift_X, bar);
// percentage bar
03792
}
03793
03794
// led bar graph in main window
03795
void
drawBarGraph()
03796
{
03797
myGLCD.setColor(255, 255, 255);
//static LED Chart
03798
setFont(SMALL, 255, 255, 255, 0, 0, 0);
03799
03800
myGLCD.drawRect(26, 132, 143, 133);
//x-line
03801
myGLCD.drawRect(26, 132, 27, 31);
//y-line
03802
myGLCD.setColor(128, 128, 128);
03803
for
(
int
i=0; i<10; i++)
//tick-marks
03804
{ myGLCD.drawLine(28, (i*10)+32, 30, (i*10)+32);
03805
for
(
int
k=0; k<12; k++)
03806
myGLCD.drawPixel(29+(k*10), 32+(i*10));}
03807
03808
myGLCD.print(
"100"
, 2, 27);
03809
myGLCD.print(
"90"
, 10, 37);
03810
myGLCD.print(
"80"
, 10, 47);
03811
myGLCD.print(
"70"
, 10, 57);
03812
myGLCD.print(
"60"
, 10, 67);
03813
myGLCD.print(
"50"
, 10, 77);
03814
myGLCD.print(
"40"
, 10, 87);
03815
myGLCD.print(
"30"
, 10, 97);
03816
myGLCD.print(
"20"
, 10, 107);
03817
myGLCD.print(
"10"
, 10, 117);
03818
myGLCD.print(
"0"
, 18, 127);
03819
}
03820
03821
int
SliderBarsForChange(
int
TopSldY,
int
BopSldY,
int
y,
int
sbR,
int
sbG,
int
sbB,
int
sbX1,
int
sbX2)
03822
{
// Slider bar vertical size: TopSldY/BotSldY
03823
// Y - value, sbR/sbG/sbB - colour
03824
int
TempY;
// sbX1/sbX2 - horisontal size
03825
if
(y<=TopSldY) {y=TopSldY;}
03826
if
(y>=BotSldY) {y=BotSldY;}
03827
03828
if
(SliderSwitch ==
true
) {
// for slider update after pressing up/down button
03829
if
(tSlide<=0) {tSlide=0;}
// and for first time open slider windows
03830
if
(tSlide>=100) {tSlide=100;}
03831
y = map(tSlide, 0, 100, BotSldY, TopSldY);
// mapping 0-100 counter to slider size and draw
03832
TempY = tSlide;
// for display value in %
03833
}
03834
03835
myGLCD.setColor(0, 0, 0);
03836
myGLCD.fillRect(sbX1+1, y, sbX2-1, TopSldY);
//hide the bar (for white bar rectangle)
03837
//myGLCD.fillRect(sbX1+1, y, sbX2-1, TopSldY+1); //hide the bar (for color bar rectangle)
03838
myGLCD.setColor(sbR, sbG, sbB);
//Slider Bar Color
03839
myGLCD.fillRect(sbX1+1, y, sbX2-1, BotSldY);
//draw the bar where you touch
03840
03841
if
(SliderSwitch ==
false
) {
// for TOUCH function, convert touch coordinate to 0-100%
03842
TempY = map(y, BotSldY, TopSldY, 0, 100);
// mapping slider size to 0-100%
03843
if
(TempY>=100) {TempY=100;}
// slider change from 0% to 100%
03844
if
(TempY<=0) {TempY=0;}
03845
}
03846
03847
if
(LedShannelFlag_on_off ==
false
)
03848
{setFont(LARGE, 200, 200, 200, 0, 0, 0);
03849
myGLCD.print(
"O"
, sbX1-8+((sbX2- sbX1))/2, TopSldY-34 + (BotSldY -TopSldY)/2);
03850
myGLCD.print(
"F"
, sbX1-8+((sbX2- sbX1))/2, TopSldY-10 + (BotSldY -TopSldY)/2);
03851
myGLCD.print(
"F"
, sbX1-8+((sbX2- sbX1))/2, TopSldY+14 + (BotSldY -TopSldY)/2);
03852
}
03853
03854
// setFont(SMALL, sbR, sbG, sbB, 0, 0, 0); // set printed text colour
03855
setFont(SMALL, 255, 255, 255, 0, 0, 0);
// set printed text colour
03856
if
(TempY<10)
03857
{myGLCD.print(
" "
, sbX1+0, BotSldY+2);
03858
myGLCD.printNumI(TempY, sbX1+16, BotSldY+2); myGLCD.print(
"%"
, sbX1+24, BotSldY+2);}
03859
if
((TempY>=10) && (TempY<100))
03860
{myGLCD.print(
" "
, sbX1+0, BotSldY+2);
03861
myGLCD.printNumI(TempY, sbX1+8, BotSldY+2); myGLCD.print(
"%"
, sbX1+24, BotSldY+2);}
03862
if
(TempY>=100)
03863
{myGLCD.printNumI(TempY, sbX1+0, BotSldY+2); myGLCD.print(
"%"
, sbX1+24, BotSldY+2);}
03864
03865
tSlide = TempY;
// temporary store previos value
03866
return
TempY;
03867
}
03868
03869
void
DrawAnalogClock(boolean refreshAll=
false
)
03870
{
03871
if
(refreshAll ==
true
){
03872
TempSSminutes = 0;
03873
myGLCD.setColor(0, 0, 200);
03874
myGLCD.setBackColor(0, 0, 0);
03875
myGLCD.drawRoundRect (90, 10, 310, 230);
// draw clock frame
03876
myGLCD.drawRoundRect (91, 11, 309, 229);
03877
myGLCD.drawRoundRect (92, 12, 308, 228);
03878
myGLCD.drawRoundRect (93, 13, 307, 227);
03879
03880
drawDOWDATE();
// draw DOW and frame
03881
03882
myGLCD.setFont(BigFont);
03883
myGLCD.setColor(200, 200, 200);
03884
myGLCD.print(
"3"
, clockCenterX+87, clockCenterY-8);
03885
myGLCD.print(
"9"
, clockCenterX-100, clockCenterY-8);
03886
myGLCD.print(
"6"
, clockCenterX-8, clockCenterY+87);
03887
myGLCD.print(
"12"
, clockCenterX-16, clockCenterY-85-16);
03888
03889
for
(
int
i=0; i<12; i++)
03890
{
if
((i % 3)!=0) drawMark(i); }
03891
}
03892
03893
t.dow=calcDOW(t.date, t.mon, t.year);
03894
if
(t.min == 0) { drawDOWDATE(); }
// update DOW every new hour
03895
if
(t.min != TempSSminutes) {
// update DOW every 1min
03896
drawMin(t.min);
// drawing the clock hands
03897
drawHour(t.hour, t.min);
// drawing the clock hands
03898
TempSSminutes = t.min;
03899
03900
myGLCD.setColor(255, 255, 0);
03901
myGLCD.drawCircle(clockCenterX, clockCenterY, 6);
03902
myGLCD.fillCircle(clockCenterX, clockCenterY, 6);
03903
myGLCD.setColor(0, 255, 0);
03904
myGLCD.drawCircle(clockCenterX, clockCenterY, 4);
03905
myGLCD.fillCircle(clockCenterX, clockCenterY, 4);
03906
03907
}
03908
03909
}
03910
03911
void
drawMark(
int
h)
03912
{
03913
float
x1, y1, x2, y2;
03914
03915
h=h*30;
03916
h=h+270;
03917
03918
x1=110*cos(h*0.0175);
03919
y1=110*sin(h*0.0175);
03920
x2=100*cos(h*0.0175);
03921
y2=100*sin(h*0.0175);
03922
myGLCD.setFont(SmallFont);
03923
myGLCD.setColor(200, 200, 200);
03924
myGLCD.print(
"*"
, (x1+x2)/2 +clockCenterX, (y1+y2)/2 +clockCenterY);
03925
03926
}
03927
03928
void
drawDOWDATE()
03929
{
03930
myGLCD.setColor(0, 0, 200);
03931
myGLCD.setBackColor(0, 0, 0);
03932
myGLCD.drawRect(176, 152, 228, 172);
// draw dow/date frame
03933
myGLCD.drawRect(177, 153, 227, 171);
03934
myGLCD.drawLine (205, 152, 205, 172);
03935
myGLCD.drawLine (206, 152, 206, 172);
03936
03937
myGLCD.setColor(200, 200, 200);
03938
myGLCD.setFont(SmallFont);
03939
SS_DOW_x=180;
03940
showDOW_ScreenSaver(t.dow);
03941
03942
if
(t.date <10) { myGLCD.print(
" "
, 210, 157);
03943
myGLCD.printNumI(t.date, 218, 157);}
03944
else
{ myGLCD.printNumI(t.date, 210, 157);}
03945
}
03946
03947
void
drawHandClock (
float
x1,
float
x2,
float
x3,
float
x4,
float
y1,
float
y2,
float
y3,
float
y4, boolean cycle=
false
)
03948
{
03949
if
(cycle ==
true
){
03950
for
(
int
i=-1 ; i<=1; i++) {
03951
myGLCD.drawLine(x1+clockCenterX+i, y1+clockCenterY+i, x3+clockCenterX+i, y3+clockCenterY+i);
03952
myGLCD.drawLine(x3+clockCenterX+i, y3+clockCenterY+i, x2+clockCenterX+i, y2+clockCenterY+i);
03953
myGLCD.drawLine(x2+clockCenterX+i, y2+clockCenterY+i, x4+clockCenterX+i, y4+clockCenterY+i);
03954
myGLCD.drawLine(x4+clockCenterX+i, y4+clockCenterY+i, x1+clockCenterX+i, y1+clockCenterY+i);}}
03955
03956
else
{myGLCD.drawLine(x1+clockCenterX, y1+clockCenterY, x3+clockCenterX, y3+clockCenterY);
03957
myGLCD.drawLine(x3+clockCenterX, y3+clockCenterY, x2+clockCenterX, y2+clockCenterY);
03958
myGLCD.drawLine(x2+clockCenterX, y2+clockCenterY, x4+clockCenterX, y4+clockCenterY);
03959
myGLCD.drawLine(x4+clockCenterX, y4+clockCenterY, x1+clockCenterX, y1+clockCenterY);}
03960
}
03961
03962
void
drawMin(
int
m)
03963
{
03964
float
x1, y1, x2, y2, x3, y3, x4, y4;
03965
int
pm = m-1;
03966
03967
if
(pm==-1)
03968
pm=59;
03969
pm=pm*6;
03970
pm=pm+270;
03971
03972
x1=80*cos(pm*0.0175);
03973
y1=80*sin(pm*0.0175);
03974
x2=5*cos(pm*0.0175);
03975
y2=5*sin(pm*0.0175);
03976
x3=30*cos((pm+4)*0.0175);
03977
y3=30*sin((pm+4)*0.0175);
03978
x4=30*cos((pm-4)*0.0175);
03979
y4=30*sin((pm-4)*0.0175);
03980
03981
myGLCD.setColor(0, 0, 0);
// clear previos hands clock
03982
drawHandClock (x1, x2, x3, x4, y1, y2, y3, y4,
true
);
03983
03984
if
((t.min >20 && t.min <40))
// redraw dow/date frame
03985
{drawDOWDATE();}
// redraw dow/date frame
03986
03987
m=m*6;
03988
m=m+270;
03989
03990
x1=80*cos(m*0.0175);
03991
y1=80*sin(m*0.0175);
03992
x2=5*cos(m*0.0175);
03993
y2=5*sin(m*0.0175);
03994
x3=30*cos((m+4)*0.0175);
03995
y3=30*sin((m+4)*0.0175);
03996
x4=30*cos((m-4)*0.0175);
03997
y4=30*sin((m-4)*0.0175);
03998
03999
myGLCD.setColor(0, 255, 0);
// draw current hands clock
04000
drawHandClock (x1, x2, x3, x4, y1, y2, y3, y4,
false
);
04001
04002
}
04003
04004
void
drawHour(
int
h,
int
m)
04005
{
04006
float
x1, y1, x2, y2, x3, y3, x4, y4;
04007
int
ph = h;
04008
04009
if
(m==0)
04010
{
04011
ph=((ph-1)*30)+((m+59)/2);
04012
}
04013
else
04014
{
04015
ph=(ph*30)+((m-1)/2);
04016
}
04017
ph=ph+270;
04018
04019
x1=60*cos(ph*0.0175);
04020
y1=60*sin(ph*0.0175);
04021
x2=5*cos(ph*0.0175);
04022
y2=5*sin(ph*0.0175);
04023
x3=20*cos((ph+5)*0.0175);
04024
y3=20*sin((ph+5)*0.0175);
04025
x4=20*cos((ph-5)*0.0175);
04026
y4=20*sin((ph-5)*0.0175);
04027
04028
myGLCD.setColor(0, 0, 0);
// clear previos hands clock
04029
drawHandClock (x1, x2, x3, x4, y1, y2, y3, y4,
true
);
04030
04031
if
((t.hour >16 && t.hour <20))
// redraw dow/date frame
04032
{drawDOWDATE();}
// redraw dow/date frame
04033
04034
h=(h*30)+(m/2);
04035
h=h+270;
04036
04037
x1=60*cos(h*0.0175);
04038
y1=60*sin(h*0.0175);
04039
x2=5*cos(h*0.0175);
04040
y2=5*sin(h*0.0175);
04041
x3=20*cos((h+5)*0.0175);
04042
y3=20*sin((h+5)*0.0175);
04043
x4=20*cos((h-5)*0.0175);
04044
y4=20*sin((h-5)*0.0175);
04045
04046
myGLCD.setColor(255, 255, 0);
// draw current hands clock
04047
drawHandClock (x1, x2, x3, x4, y1, y2, y3, y4,
false
);
04048
04049
}
04050
04051
void
DrawTemperatureScreen(boolean refreshAll=
false
)
04052
{
04053
String deg;
04054
if
(setTempScale==1) {deg =
"F"
;}
//Print deg C or deg F
04055
else
{deg =
"C"
;}
04056
degC_F=deg;
04057
char
bufferDeg[2];
04058
degC_F.toCharArray(bufferDeg,2);
04059
int
ShiftDrawY =0;
04060
myGLCD.setFont(BigFont);
04061
myGLCD.setColor(0, 0, 255);
04062
myGLCD.setBackColor(0, 0, 0);
04063
04064
if
(refreshAll==
true
) {
04065
if
(counterB1 ==1 || counterB2 ==1 || counterB3 ==1)
04066
{
04067
if
(tempW !=0) {
04068
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[3])));
// "Water"
04069
myGLCD.print(buffer, 48 , 100);
04070
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[68])));
// ": "
04071
myGLCD.print(buffer, 144 , 100);
04072
myGLCD.printNumF( tempW, 1, 176, 100);
// print water temp
04073
myGLCD.drawCircle(240, 100, 1);
04074
myGLCD.print(bufferDeg, 245, 100);
04075
}
04076
}
04077
04078
if
(counterB1 ==2 || counterB2 ==2 || counterB3 ==2)
04079
{
04080
if
(((counterB1 + counterB2 + counterB3) == 2) || ((counterB1 + counterB2 + counterB3) == 5)) {ShiftDrawY= 0;}
04081
if
(((counterB1 + counterB2 + counterB3) == 3) || ((counterB1 + counterB2 + counterB3) == 6)) {ShiftDrawY= 20;}
04082
if
(tempH1 !=0) {
04083
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[4])));
// "H1"
04084
myGLCD.print(buffer, 32 , 100+ShiftDrawY);
04085
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[68])));
// ": "
04086
myGLCD.print(buffer, 144, 100+ShiftDrawY);
04087
myGLCD.printNumF( tempH1, 1, 176, 100+ShiftDrawY);
// print H1 temp
04088
myGLCD.drawCircle(240, 100+ShiftDrawY, 1);
04089
myGLCD.print(bufferDeg, 245, 100+ShiftDrawY);
04090
}
04091
}
04092
04093
04094
if
(counterB1 ==3 || counterB2 ==3 || counterB3 ==3)
04095
{
04096
if
((counterB1 + counterB2 + counterB3) == 3) {ShiftDrawY= 0;}
04097
if
(((counterB1 + counterB2 + counterB3) == 4) || ((counterB1 + counterB2 + counterB3) == 5)) {ShiftDrawY= 20;}
04098
if
((counterB1 + counterB2 + counterB3) == 6) {ShiftDrawY= 40;}
04099
if
(tempH2 !=0) {
04100
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[5])));
// "H2"
04101
myGLCD.print(buffer, 32 , 100+ShiftDrawY);
04102
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[68])));
// ": "
04103
myGLCD.print(buffer, 144, 100+ShiftDrawY);
04104
myGLCD.printNumF( tempH2, 1, 176, 100+ShiftDrawY);
// print H2 temp
04105
myGLCD.drawCircle(240, 100+ShiftDrawY, 1);
04106
myGLCD.print(bufferDeg, 245, 100+ShiftDrawY);
04107
}
04108
}
04109
}
04110
}
04111
04112
void
DrawDigitalClock(boolean refreshAll=
false
)
04113
{
04114
if
(refreshAll==
true
&& setTimeFormat==0) {
04115
myGLCD.setColor(0, 0, 200);
04116
myGLCD.setBackColor(0, 0, 0);
04117
myGLCD.drawRoundRect (77, 67, 243, 158);
// draw clock frame for 24HR format
04118
myGLCD.drawRoundRect (76, 68, 244, 159);
// draw clock frame
04119
myGLCD.drawRoundRect (75, 69, 245, 160);
// draw clock frame
04120
myGLCD.fillCircle(141, 88, 4);
// draw : symbol
04121
myGLCD.fillCircle(141, 112, 4);
// draw : symbol beetween hour and min
04122
}
04123
04124
if
(setTimeFormat==0)
//display 24HR Format
04125
{
04126
myGLCD.setColor(0, 0, 255);
04127
myGLCD.setBackColor(0, 0, 0);
04128
04129
04130
#ifdef Graph16_lib
04131
myGLCD.setFont(SevenSegNumFontPlus);
04132
#else
04133
myGLCD.setFont(SevenSegNumFont);
04134
#endif
04135
04136
// myGLCD.setFont(SevenSegNumFont);
04137
// myGLCD.setFont(DotMatrix_XL_Num);
04138
myGLCD.print(rtc.getTimeStr(FORMAT_SHORT), CENTER, 75);
// print time
04139
myGLCD.setFont(BigFont);
04140
myGLCD.print(rtc.getDateStr(FORMAT_LONG), 80, 137);
04141
}
04142
04143
if
(refreshAll==
true
&& setTimeFormat==1) {
04144
myGLCD.setColor(0, 0, 200);
04145
myGLCD.setBackColor(0, 0, 0);
04146
myGLCD.drawRoundRect (77, 67, 263, 158);
// draw clock frame for 12HR format
04147
myGLCD.drawRoundRect (76, 68, 264, 159);
// draw clock frame
04148
myGLCD.drawRoundRect (75, 69, 265, 160);
// draw clock frame
04149
}
04150
04151
if
(setTimeFormat==1)
//display 12HR Format
04152
{
04153
myGLCD.setColor(0, 0, 255);
04154
myGLCD.setBackColor(0, 0, 0);
04155
// myGLCD.setFont(SevenSegNumFont);
04156
04157
#ifdef Graph16_lib
04158
myGLCD.setFont(SevenSegNumFontPlus);
04159
#else
04160
myGLCD.setFont(SevenSegNumFont);
04161
#endif
04162
04163
if
(t.hour==0)
//Display HOUR
04164
{ myGLCD.print(
"12"
, 61, 75);}
04165
04166
if
((t.hour>=1) && (t.hour<=9))
04167
{ myGLCD.setColor(0, 0, 0);
04168
myGLCD.fillRect(61, 95, 92, 145);
04169
myGLCD.setColor(0, 0, 255);
04170
myGLCD.printNumI(t.hour, 93, 75);}
04171
04172
if
((t.hour>=10) && (t.hour<=12))
04173
{ myGLCD.printNumI(t.hour, 61, 75);}
04174
04175
if
((t.hour>=13) && (t.hour<=21))
04176
{ myGLCD.setColor(0, 0, 0);
04177
myGLCD.fillRect(61, 95, 92, 145);
04178
myGLCD.setColor(0, 0, 255);
04179
myGLCD.printNumI(t.hour-12, 93, 75);}
04180
if
(t.hour>=22)
04181
myGLCD.printNumI(t.hour-12, 61, 75);
04182
04183
myGLCD.fillCircle(141, 88, 4);
// draw : symbol
04184
myGLCD.fillCircle(141, 112, 4);
// draw : symbol beetween hour and min
04185
04186
myGLCD.printNumI(t.min, 157, 75, 2,
'0'
);
//Display MINUTES
04187
04188
setFont(LARGE, 0, 0, 255, 0, 0, 0);
04189
if
((t.hour>=0) && (t.hour<=11))
//Display AM/PM
04190
{ myGLCD.print(
"AM"
, 225, 79);}
04191
else
04192
{ myGLCD.print(
"PM"
, 225, 79);}
04193
04194
myGLCD.setFont(BigFont);
04195
myGLCD.print(rtc.getDateStr(FORMAT_LONG), 80, 137);
04196
}
04197
04198
04199
}
04200
void
screenSaverBrightness()
04201
{
if
(BrigthnessCount <= 0) {analogWrite(BackLite, 0); }
04202
if
(BrigthnessCount == 1) {analogWrite(BackLite, 63); }
04203
if
(BrigthnessCount == 2) {analogWrite(BackLite, 127); }
04204
if
(BrigthnessCount == 3) {analogWrite(BackLite, 191); }
04205
if
(BrigthnessCount >= 4) {analogWrite(BackLite, 255); }
04206
}
04207
04208
void
screenSaver()
// Make the Screen Go ScreenSaver after so long
04209
{ myGLCD.setColor(0, 0, 150);
04210
setScreenSaverTimer = setSSmintues * 12;
// 5sec*12=1 min, convert minutes to 5sec stepping
04211
04212
04213
if
((setScreensaverOnOff==1) && (tempAlarmflagW==
false
))
04214
{
if
(screenSaverCounter <= setScreenSaverTimer) {screenSaverCounter++;}
// increment screen saver time
04215
//screenSaverCounter +=6; } // test only
04216
04217
if
(screenSaverCounter==setScreenSaverTimer)
04218
{ dispScreen=24;
04219
myGLCD.clrScr();
04220
screenSaverBrightness();
04221
if
(ClockType==1) {DrawAnalogClock(
true
);}
//display TIME in screensaver
04222
if
(ClockType==2) {DrawDigitalClock(
true
);}
//display TIME in screensaver
04223
if
(ClockType==3) {DrawTemperatureScreen(
true
);}
//display Temperature in screensaver
04224
// "Blank" screensaver
04225
if
(setLockScreen ==1)
04226
{ButtonShift = random (0, 200);
04227
printButtonTouch(
"Touch"
, touchLock[0], touchLock[1]-ButtonShift, touchLock[2], touchLock[3]-ButtonShift, SMALL);}
04228
}
04229
04230
if
(screenSaverCounter > setScreenSaverTimer)
04231
{
04232
if
(ClockType==1) {DrawAnalogClock(
false
);}
//display TIME in screensaver
04233
if
(ClockType==2) {DrawDigitalClock(
false
);}
//display TIME in screensaver
04234
if
(ClockType==3) {DrawTemperatureScreen(
true
);}
//display Temperature in screensaver
04235
// "Blank" screensaver
04236
04237
if
(setLockScreen ==1)
04238
{
04239
firstTouch =
false
;
// clear touch flag and button "Again" after timeout 5sec, if no pressed AGAIN
04240
myGLCD.setColor(0, 0, 0);
04241
// myGLCD.fillRect(Again[0], Again[1], Again[2]+2, Again[3]+2); // clear button "Again"
04242
myGLCD.fillRect(touchLock[0], 240-(touchLock[1]-ButtonShift-3), touchLock[2], 240-(touchLock[3]-ButtonShift+3));
04243
04244
myGLCD.fillRect(touchLock[0], touchLock[1]-ButtonShift-3, touchLock[2], touchLock[3]-ButtonShift+3);
// clear button TOUCH
04245
ButtonShift = random (0, 200);
04246
printButtonTouch(
"Touch"
, touchLock[0], touchLock[1]-ButtonShift, touchLock[2], touchLock[3]-ButtonShift, SMALL);
04247
screenSaverBrightness();
04248
}
04249
}
04250
}
04251
}
04252
04253
void
ScreensaverSelect()
04254
{
04255
printButton(
" "
, 206, 20, 310, 40, SMALL);
04256
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04257
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[64+ClockType])));
// ClockType = 0/1/2/3/ -> Blanc/An.Clock/Dig.Clock/Temperature
04258
myGLCD.print(buffer, 214, 24);
04259
04260
printButton(
" "
, 206, 82, 260, 102, SMALL);
// print button "background brightness"
04261
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04262
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[59+BrigthnessCount])));
// counter = 0/1/2/3/4 -> 0%-25%-50%-75%-100%
04263
myGLCD.print(buffer, 217, 86);
04264
}
04265
04266
04267
void
genSetSelect_1()
04268
{
04269
04270
if
(setCalendarFormat==0)
//Calendar Format Buttons
04271
{ myGLCD.setColor(0, 0, 255);
04272
myGLCD.fillRoundRect(185, 49, 305, 69);
04273
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04274
myGLCD.print(
" DD/MM/YYYY "
, 199, 53);
04275
}
04276
else
{myGLCD.setColor(0, 0, 255);
04277
myGLCD.fillRoundRect(185, 49, 305, 69);
04278
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04279
myGLCD.print(
"MTH DD, YYYY"
, 199, 53);
04280
}
04281
04282
if
(displayDOW==1)
//Show/Hide the Day of the Week
04283
{ myGLCD.setColor(0, 0, 255);
04284
myGLCD.fillRoundRect(185, 79, 229, 99);
04285
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04286
myGLCD.print(
" ON "
, 193, 83);
04287
}
04288
else
04289
{ myGLCD.setColor(0, 0, 255);
04290
myGLCD.fillRoundRect(185, 79, 229, 99);
04291
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04292
myGLCD.print(
"OFF"
, 199, 83);
04293
}
04294
04295
if
(setTimeFormat==0)
//Time Format Buttons
04296
{ myGLCD.setColor(0, 0, 255);
04297
myGLCD.fillRoundRect(185, 109, 229, 129);
04298
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04299
myGLCD.print(
"24HR"
, 191, 113);
04300
}
04301
else
04302
{ myGLCD.setColor(0, 0, 255);
04303
myGLCD.fillRoundRect(185, 109, 229, 129);
04304
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04305
myGLCD.print(
"12HR"
, 191, 113);
04306
}
04307
04308
if
(setTempScale==0)
//Temperature Scale Buttons
04309
{ myGLCD.setColor(0, 0, 255);
04310
myGLCD.fillRoundRect(185, 139, 229, 159);
04311
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04312
myGLCD.print(
"C"
, 205, 142);
04313
myGLCD.drawCircle(200, 144, 1);
04314
}
04315
else
04316
{myGLCD.setColor(0, 0, 255);
04317
myGLCD.fillRoundRect(185, 139, 229, 159);
04318
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04319
myGLCD.print(
"F"
, 205, 142);
04320
myGLCD.drawCircle(200, 144, 1);
04321
}
04322
04323
myGLCD.setColor(0, 0, 255);
//Change Time/Date Button
04324
myGLCD.fillRoundRect(185, 19, 305, 39);
04325
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04326
myGLCD.print(
" Time/Date"
, 199, 23);
04327
04328
myGLCD.setColor(0, 0, 255);
//Change Fan Startup Temps Button
04329
myGLCD.fillRoundRect(185, 169, 305, 189);
04330
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04331
myGLCD.print(
"Change Temp"
, 199, 173);
04332
04333
myGLCD.setColor(255, 255, 255);
04334
myGLCD.drawRoundRect(185, 19, 305, 39);
// time and date
04335
myGLCD.drawRoundRect(185, 49, 305, 69);
// calendar
04336
myGLCD.drawRoundRect(185, 79, 229, 99);
// day of week
04337
myGLCD.drawRoundRect(185, 109, 229, 129);
// 12/24
04338
myGLCD.drawRoundRect(185, 139, 229, 159);
// C/F
04339
myGLCD.drawRoundRect(185, 169, 305, 189);
// fan
04340
04341
}
04342
04343
04344
void
genSetSelect_2()
04345
{
04346
04347
if
(setDimLEDsOnOff==1)
04348
{ myGLCD.setColor(0, 0, 255);
04349
myGLCD.fillRoundRect(130, 19, 174, 39);
04350
myGLCD.fillRoundRect(185, 19, 305, 39);
04351
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04352
myGLCD.print(
" ON "
, 138, 23);
04353
myGLCD.print(
"Change Temp"
, 203, 23);
04354
}
04355
else
04356
{ myGLCD.setColor(0, 0, 255);
04357
myGLCD.fillRoundRect(130, 19, 174, 39);
04358
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04359
myGLCD.print(
"OFF"
, 144, 23);
04360
04361
myGLCD.setColor(64, 64, 64);
04362
myGLCD.fillRoundRect(185, 19, 305, 39);
04363
setFont(SMALL, 255, 255, 255, 64, 64, 64);
04364
myGLCD.print(
"Change Temp"
, 203, 23);
04365
}
04366
04367
if
(setScreensaverOnOff==1)
//Screensaver Buttons
04368
{ myGLCD.setColor(0, 0, 255);
04369
myGLCD.fillRoundRect(130, 49, 174, 69);
04370
myGLCD.fillRoundRect(185, 49, 305, 69);
04371
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04372
myGLCD.print(
" ON "
, 138, 53);
04373
// myGLCD.print("Setting", 217, 53);
04374
myGLCD.print(print_text[21], 217, 53);
04375
}
04376
else
04377
{ myGLCD.setColor(0, 0, 255);
04378
myGLCD.fillRoundRect(130, 49, 174, 69);
04379
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04380
myGLCD.print(
"OFF"
, 144, 53);
04381
04382
myGLCD.setColor(64, 64, 64);
04383
myGLCD.fillRoundRect(185, 49, 305, 69);
04384
setFont(SMALL, 255, 255, 255, 64, 64, 64);
04385
// myGLCD.print("Setting", 217, 53);
04386
myGLCD.print(print_text[21], 217, 53);
04387
}
04388
04389
if
(MAX_Temp_on_off ==1)
// Display MAX TEMP is ON
04390
{ myGLCD.setColor(0, 0, 255);
04391
myGLCD.fillRoundRect(185, 79, 229, 99);
04392
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04393
myGLCD.print(
" ON "
, 193, 83);
04394
}
04395
else
04396
{ myGLCD.setColor(0, 0, 255);
04397
myGLCD.fillRoundRect(185, 79, 229, 99);
04398
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04399
myGLCD.print(
"OFF"
, 199, 83);
04400
}
04401
04402
if
(SoftStartON ==1)
// Display MAX TEMP is ON
04403
{ myGLCD.setColor(0, 0, 255);
04404
myGLCD.fillRoundRect(185, 109, 229, 129);
04405
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04406
myGLCD.print(
" ON "
, 193, 113);
04407
}
04408
else
04409
{ myGLCD.setColor(0, 0, 255);
04410
myGLCD.fillRoundRect(185, 109, 229, 129);
04411
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04412
myGLCD.print(
"OFF"
, 199, 113);
04413
}
04414
//----------------ALARM LEVEL -------------------------------
04415
myGLCD.setColor(0, 0, 255);
04416
myGLCD.fillRoundRect(185, 139, 305, 159);
04417
myGLCD.drawRoundRect(185, 139, 305, 159);
04418
setFont(SMALL, 255, 255, 255, 0, 0, 255);
04419
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[56+AlarmLevel])));
//
04420
myGLCD.print(buffer, 193, 143);
04421
04422
04423
myGLCD.setColor(255, 255, 255);
04424
myGLCD.drawRoundRect(130, 19, 174, 39);
// dim led on/off
04425
myGLCD.drawRoundRect(185, 19, 305, 39);
// dim led
04426
myGLCD.drawRoundRect(130, 49, 174, 69);
// screen saver on/off
04427
myGLCD.drawRoundRect(185, 49, 305, 69);
// screen saver
04428
myGLCD.drawRoundRect(185, 79, 229, 99);
// Max Temp
04429
myGLCD.drawRoundRect(185, 109, 229, 129);
// Soft Start
04430
myGLCD.drawRoundRect(185, 139, 305, 159);
// Buzzer ON/OFF
04431
}
04432
04433
/*
04434
void feedingTimeOnOff()
04435
{
04436
if ((feedTime==1) && (FEEDTime1==1))
04437
{ myGLCD.setColor(0, 255, 0);
04438
myGLCD.fillRoundRect(70, 150, 250, 170);
04439
setFont(SMALL, 0, 0, 0, 0, 255, 0);
04440
// myGLCD.print("Feeding Time 1 ON", 94, 154);}
04441
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[25])));
04442
myGLCD.print(buffer, 94, 154);
04443
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[29])));
04444
myGLCD.print(buffer, 94+120, 154);}
04445
04446
if ((feedTime==1) && (FEEDTime1==0))
04447
{ myGLCD.setColor(255, 0, 0);
04448
myGLCD.fillRoundRect(70, 150, 250, 170);
04449
setFont(SMALL, 255, 255, 255, 255, 0, 0);
04450
// myGLCD.print("Feeding Time 1 OFF", 90, 154);}
04451
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[25])));
04452
myGLCD.print(buffer, 90, 154);
04453
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[30])));
04454
myGLCD.print(buffer, 90+120, 154);}
04455
04456
if ((feedTime==2) && (FEEDTime2==1))
04457
{ myGLCD.setColor(0, 255, 0);
04458
myGLCD.fillRoundRect(70, 150, 250, 170);
04459
setFont(SMALL, 0, 0, 0, 0, 255, 0);
04460
// myGLCD.print("Feeding Time 2 ON", 94, 154);}
04461
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[26])));
04462
myGLCD.print(buffer, 94, 154);
04463
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[29])));
04464
myGLCD.print(buffer, 94+120, 154);}
04465
04466
if ((feedTime==2) && (FEEDTime2==0))
04467
{ myGLCD.setColor(255, 0, 0);
04468
myGLCD.fillRoundRect(70, 150, 250, 170);
04469
setFont(SMALL, 255, 255, 255, 255, 0, 0);
04470
// myGLCD.print("Feeding Time 2 OFF", 90, 154);}
04471
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[26])));
04472
myGLCD.print(buffer, 90, 154);
04473
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[30])));
04474
myGLCD.print(buffer, 90+120, 154);}
04475
04476
if ((feedTime==3) && (FEEDTime3==1))
04477
{ myGLCD.setColor(0, 255, 0);
04478
myGLCD.fillRoundRect(70, 150, 250, 170);
04479
setFont(SMALL, 0, 0, 0, 0, 255, 0);
04480
// myGLCD.print("Feeding Time 3 ON", 94, 154);}
04481
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[27])));
04482
myGLCD.print(buffer, 94, 154);
04483
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[29])));
04484
myGLCD.print(buffer, 94+120, 154);}
04485
04486
if ((feedTime==3) && (FEEDTime3==0))
04487
{ myGLCD.setColor(255, 0, 0);
04488
myGLCD.fillRoundRect(70, 150, 250, 170);
04489
setFont(SMALL, 255, 255, 255, 255, 0, 0);
04490
// myGLCD.print("Feeding Time 3 OFF", 90, 154);}
04491
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[27])));
04492
myGLCD.print(buffer, 90, 154);
04493
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[30])));
04494
myGLCD.print(buffer, 90+120, 154);}
04495
04496
if ((feedTime==4) && (FEEDTime4==1))
04497
{ myGLCD.setColor(0, 255, 0);
04498
myGLCD.fillRoundRect(70, 150, 250, 170);
04499
setFont(SMALL, 0, 0, 0, 0, 255, 0);
04500
// myGLCD.print("Feeding Time 4 ON", 94, 154);}
04501
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[28])));
04502
myGLCD.print(buffer, 94, 154);
04503
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[29])));
04504
myGLCD.print(buffer, 94+120, 154);}
04505
04506
if ((feedTime==4) && (FEEDTime4==0))
04507
{ myGLCD.setColor(255, 0, 0);
04508
myGLCD.fillRoundRect(70, 150, 250, 170);
04509
setFont(SMALL, 255, 255, 255, 255, 0, 0);
04510
// myGLCD.print("Feeding Time 4 OFF", 90, 154);}
04511
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[28])));
04512
myGLCD.print(buffer, 90, 154);
04513
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[30])));
04514
myGLCD.print(buffer, 90+120, 154);}
04515
04516
myGLCD.setColor(255, 255, 255);
04517
myGLCD.drawRoundRect(70, 150, 250, 170);
04518
}
04519
*/
04520
04521
/******************************* END OF MISC. FUNCTIONS *******************************/
04522
04523
04524
/*********************** MAIN SCREEN ********** dispScreen = 0 ************************/
04525
void
mainScreen(boolean refreshAll=
false
)
04526
{
04527
int
ledLevel, bar;
04528
String oldval, deg;
04529
char
buffer_Led_Out[8];
04530
04531
TimeDateBar(
true
);
04532
04533
oldval = day;
//refresh day if different
04534
day = String(t.date);
04535
if
((oldval!=day) || refreshAll)
04536
{
04537
myGLCD.setColor(64, 64, 64);
//Draw Borders & Dividers in Grey
04538
myGLCD.drawRect(0, 0, 319, 239);
//Outside Border
04539
myGLCD.drawRect(158, 14, 160, 226);
//Vertical Divider
04540
myGLCD.drawRect(160, 125, 319, 127);
//Horizontal Divider
04541
myGLCD.drawRect(0, 188, 158, 190);
//Horizontal Divider
04542
myGLCD.fillRect(0, 0, 319, 14);
//Top Bar
04543
myGLCD.setColor(0, 0, 0);
04544
myGLCD.drawLine(159, 126, 161, 126);
//Horizontal Divider Separator
04545
setFont(SMALL, 255, 255, 0, 64, 64, 64);
04546
// myGLCD.print("Jarduino AQUA Controller V1.2 Oleg mod", CENTER, 1);
04547
PrintStringIndex=35;
04548
printHeader ();
04549
setFont(SMALL, 255, 255, 255, 0, 0, 0);
04550
// myGLCD.print("LED ARRAY", 52, 15);
04551
// myGLCD.print("LUNAR PHASE", 196, 20);
04552
// myGLCD.print("MONITORS & ALERTS", 174, 133);
04553
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[51])));
04554
myGLCD.print(buffer, 52, 15);
04555
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[52])));
04556
myGLCD.print(buffer, 196, 20);
04557
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[53])));
04558
myGLCD.print(buffer, 174, 133);
04559
04560
float
lunarCycle = moonPhase(t.year, t.mon, t.date);
//get a value for the lunar cycle
04561
myGLCD.drawBitmap(211, 35, 58, 58, MoonPic, 1);
//Moon Phase Picture (middle 240,64)
04562
setFont(SMALL, 176, 176, 176, 0, 0, 0);
04563
char
bufferLP[16];
04564
LP.toCharArray(bufferLP, 16);
04565
myGLCD.print(bufferLP, 180, 96);
//Print Moon Phase Description to LCD
04566
if
((lunarCycle*100) < 1)
//Print % of Full to LCD
04567
{ myGLCD.print(
" 0.0"
, 188, 108); }
04568
else
{ myGLCD.printNumF(lunarCycle*100, 1, 188, 108);}
04569
// myGLCD.print("% of Full", 220, 108);
04570
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[54])));
04571
myGLCD.print(buffer, 220, 108);
04572
}
04573
04574
04575
if
((tvLed!=tvled_out) || refreshAll)
//refresh TV led display
04576
{
04577
tvLed = tvled_out;
04578
ledLevel = LedToPercent(tvled_out, ResolutionLow);
04579
// oldval = "TV: " + String(ledLevel) + "% ";
04580
oldval = ChName[10] + String(ledLevel) + ChName[9];
04581
oldval.toCharArray(buffer_Led_Out, 6);
04582
SmallLedBarGraph(tvled_out, ResolutionLow, 0, rgbCh6[0], rgbCh6[1], rgbCh6[2]);
// led_out, resoluton, Xshift, bar color
04583
setFont(SMALL, 0, 255, 0, 0, 0, 0);
04584
myGLCD.print(ChName[6], 10, 137);
04585
myGLCD.print(buffer_Led_Out, 10+16, 137);
04586
04587
}
04588
#ifdef Standard_shield
04589
if
((redLed!=rled_out) || refreshAll)
//refresh red led display
04590
{
04591
redLed = rled_out;
04592
ledLevel = LedToPercent(rled_out, ResolutionLow);
04593
oldval = ChName[10] + String(ledLevel) + ChName[9];
04594
oldval.toCharArray(buffer_Led_Out, 6);
04595
SmallLedBarGraph(rled_out, ResolutionLow, 14, rgbCh5[0], rgbCh5[1], rgbCh5[2]);
// led_out, resoluton, Xshift, bar color
04596
setFont(SMALL, 0, 255, 0, 0, 0, 0);
04597
myGLCD.print(ChName[5], 10, 149);
04598
myGLCD.print(buffer_Led_Out, 10+16, 149);
04599
}
04600
#else
04601
if
((redLed!=rled_out) || refreshAll)
//refresh red led display
04602
{
04603
redLed = rled_out;
04604
ledLevel = LedToPercent(rled_out, ResolutionHigh);
04605
// oldval = "DR: " + String(ledLevel) + "% ";
04606
oldval = ChName[10] + String(ledLevel) + ChName[9];
04607
oldval.toCharArray(buffer_Led_Out, 6);
04608
SmallLedBarGraph(rled_out, ResolutionHigh, 14, rgbCh5[0], rgbCh5[1], rgbCh5[2]);
// led_out, resoluton, Xshift, bar color
04609
setFont(SMALL, 0, 255, 0, 0, 0, 0);
04610
myGLCD.print(ChName[5], 10, 149);
04611
myGLCD.print(buffer_Led_Out, 10+16, 149);
04612
}
04613
#endif
04614
04615
if
((whiteLed!=wled_out) || refreshAll)
//refresh white led display
04616
{
04617
whiteLed = wled_out;
04618
ledLevel = LedToPercent(wled_out, ResolutionHigh);
04619
// oldval = "CW: " + String(ledLevel) + "% ";
04620
oldval = ChName[10] + String(ledLevel) + ChName[9];
04621
oldval.toCharArray(buffer_Led_Out, 6);
04622
SmallLedBarGraph(wled_out, ResolutionHigh, 28, rgbCh2[0], rgbCh2[1], rgbCh2[2]);
// led_out, resoluton, Xshift, bar color
04623
setFont(SMALL, 0, 255, 0, 0, 0, 0);
04624
myGLCD.print(ChName[2], 10, 161);
04625
myGLCD.print(buffer_Led_Out, 10+16, 161);
04626
}
04627
04628
if
((blueLed!=bled_out) || refreshAll)
//refresh blue led displays
04629
{
04630
blueLed = bled_out;
04631
ledLevel = LedToPercent(bled_out, ResolutionHigh);
04632
// oldval = "Bl: " + String(ledLevel) + "% ";
04633
oldval = ChName[10] + String(ledLevel) + ChName[9];
04634
oldval.toCharArray(buffer_Led_Out, 6);
04635
SmallLedBarGraph(bled_out, ResolutionHigh, 42, rgbCh4[0], rgbCh4[1], rgbCh4[2]);
// led_out, resoluton, Xshift, bar color
04636
setFont(SMALL, 0, 255, 0, 0, 0, 0);
04637
myGLCD.print(ChName[4], 10, 173);
04638
myGLCD.print(buffer_Led_Out, 10+16, 173);
04639
}
04640
04641
#ifdef Standard_shield
04642
if
((rblueLed!=rbled_out) || refreshAll)
//refresh royal blue led display
04643
{
04644
rblueLed = rbled_out;
04645
#ifdef Timers_8bit
04646
ledLevel = LedToPercent(rbled_out, ResolutionLow);
04647
oldval = ChName[10] + String(ledLevel) + ChName[9];
04648
oldval.toCharArray(buffer_Led_Out, 6);
04649
SmallLedBarGraph(rbled_out, ResolutionLow, 56, rgbCh3[0], rgbCh3[1], rgbCh3[2]);
// led_out, resoluton, Xshift, bar color
04650
#endif
04651
#ifdef Timers_8_11bit
04652
ledLevel = LedToPercent(rbled_out, ResolutionHigh);
04653
oldval = ChName[10] + String(ledLevel) + ChName[9];
04654
oldval.toCharArray(buffer_Led_Out, 6);
04655
SmallLedBarGraph(rbled_out, ResolutionHigh, 56, rgbCh3[0], rgbCh3[1], rgbCh3[2]);
// led_out, resoluton, Xshift, bar color
04656
#endif
04657
setFont(SMALL, 0, 255, 0, 0, 0, 0);
04658
myGLCD.print(ChName[3], 85, 137);
04659
myGLCD.print(buffer_Led_Out, 85+16, 137);
04660
}
04661
#else
04662
if
((rblueLed!=rbled_out) || refreshAll)
//refresh royal blue led display
04663
{
04664
rblueLed = rbled_out;
04665
ledLevel = LedToPercent(rbled_out, ResolutionLow);
04666
// oldval = "RB: " + String(ledLevel) + "% ";
04667
oldval = ChName[10] + String(ledLevel) + ChName[9];
04668
oldval.toCharArray(buffer_Led_Out, 8);
04669
SmallLedBarGraph(rbled_out, ResolutionLow, 56, rgbCh3[0], rgbCh3[1], rgbCh3[2]);
// led_out, resoluton, Xshift, bar color
04670
setFont(SMALL, 0, 255, 0, 0, 0, 0);
04671
myGLCD.print(ChName[3], 85, 137);
04672
myGLCD.print(buffer_Led_Out, 85+16, 137);
04673
04674
}
04675
#endif
04676
04677
if
((uvLed!=uvled_out) || refreshAll)
//refresh UV led display
04678
{
04679
uvLed = uvled_out;
04680
ledLevel = LedToPercent(uvled_out, ResolutionLow);
04681
// oldval = "UV: " + String(ledLevel) + "% ";
04682
oldval = ChName[10] + String(ledLevel) + ChName[9];
04683
oldval.toCharArray(buffer_Led_Out, 6);
04684
SmallLedBarGraph(uvled_out, ResolutionLow, 70, rgbCh1[0], rgbCh1[1], rgbCh1[2]);
// led_out, resoluton, Xshift, bar color
04685
setFont(SMALL, 0, 255, 0, 0, 0, 0);
04686
myGLCD.print(ChName[1], 85, 149);
04687
myGLCD.print(buffer_Led_Out, 85+16, 149);
04688
}
04689
04690
if
((cyLed!=cyled_out) || refreshAll)
//refresh Cyan led display
04691
{
04692
cyLed = cyled_out;
04693
ledLevel = LedToPercent(cyled_out, ResolutionHigh);
04694
// oldval = "CY: " + String(ledLevel) + "% ";
04695
oldval = ChName[10] + String(ledLevel) + ChName[9];
04696
oldval.toCharArray(buffer_Led_Out, 6);
04697
SmallLedBarGraph(cyled_out, ResolutionHigh, 84, rgbCh0[0], rgbCh0[1], rgbCh0[2]);
// led_out, resoluton, Xshift, bar color
04698
setFont(SMALL, 0, 255, 0, 0, 0, 0);
04699
myGLCD.print(ChName[0], 85, 161);
04700
myGLCD.print(buffer_Led_Out, 85+16, 161);
04701
}
04702
04703
if
((yeLed!=yeled_out) || refreshAll)
// Yellow led
04704
{
04705
yeLed = yeled_out;
04706
ledLevel = LedToPercent(yeled_out, ResolutionHigh);
04707
// oldval = "YE: " + String(ledLevel) + "% ";
04708
oldval = ChName[10] + String(ledLevel) + ChName[9];
04709
oldval.toCharArray(buffer_Led_Out, 6);
04710
SmallLedBarGraph(yeled_out, ResolutionHigh, 98, rgbCh7[0], rgbCh7[1], rgbCh7[2]);
// led_out, resoluton, Xshift, bar color
04711
setFont(SMALL, 0, 255, 0, 0, 0, 0);
04712
myGLCD.print(ChName[7], 85, 173);
04713
myGLCD.print(buffer_Led_Out, 85+16, 173);
04714
}
04715
04716
04717
if
((tvLed=tvled_out) || (redLed=rled_out) ||(whiteLed=wled_out) || (blueLed=bled_out) ||
04718
(rblueLed=rbled_out) || (uvLed=uvled_out) || (cyLed=cyled_out) || (yeLed=yeled_out) || refreshAll)
04719
04720
{drawBarGraph();}
//refresh all static led bar
04721
04722
04723
// ------------- display temperature ------------------
04724
if
(setTempScale==1) {deg =
"F"
;}
//Print deg C or deg F
04725
else
{deg =
"C"
;}
04726
degC_F=deg;
04727
char
bufferDeg[2];
04728
degC_F.toCharArray(bufferDeg,2);
04729
04730
int
ShiftDrawY =0;
04731
04732
04733
if
(refreshAll )
04734
{
04735
04736
if
(counterB1 ==1 || counterB2 ==1 || counterB3 ==1)
04737
{ setFont(SMALL, 0, 255, 0, 0, 0 , 0);
04738
// myGLCD.print("Water Temp:", 169+8, 148);
04739
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[3])));
// "Water"
04740
myGLCD.print(buffer, 169, 148);
04741
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[69])));
// " Temp:"
04742
myGLCD.print(buffer, 217, 148);
04743
if
(MAX_Temp_on_off ==1)
04744
{myGLCD.print(
"Max Temp W:"
, 5, 191);}
04745
}
04746
04747
if
(counterB1 ==2 || counterB2 ==2 || counterB3 ==2)
04748
{
04749
if
(((counterB1 + counterB2 + counterB3) == 2) || ((counterB1 + counterB2 + counterB3) == 5)) {ShiftDrawY= 0;}
04750
if
(((counterB1 + counterB2 + counterB3) == 3) || ((counterB1 + counterB2 + counterB3) == 6)) {ShiftDrawY= +13;}
04751
setFont(SMALL, 0, 255, 0, 0, 0 , 0);
04752
// myGLCD.print("H.Sink1 Temp:", 161 , 148+ShiftDrawY);
04753
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[4])));
// "H.Sink1"
04754
myGLCD.print(buffer, 161 , 148+ShiftDrawY);
04755
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[69])));
// " Temp:"
04756
myGLCD.print(buffer, 217 , 148+ShiftDrawY);
04757
if
(MAX_Temp_on_off ==1)
04758
{myGLCD.print(
"Max Temp H1:"
, 5, 202);}
04759
}
04760
if
(counterB1 ==3 || counterB2 ==3 || counterB3 ==3)
04761
{
04762
if
((counterB1 + counterB2 + counterB3) == 3) {ShiftDrawY= 0;}
04763
if
(((counterB1 + counterB2 + counterB3) == 4) || ((counterB1 + counterB2 + counterB3) == 5)) {ShiftDrawY= +13;}
04764
if
((counterB1 + counterB2 + counterB3) == 6) {ShiftDrawY= +26;}
04765
setFont(SMALL, 0, 255, 0, 0, 0 , 0);
04766
// myGLCD.print("H.Sink2 Temp:", 161, 148+ShiftDrawY);
04767
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[5])));
// "H.Sink2"
04768
myGLCD.print(buffer, 161 , 148+ShiftDrawY);
04769
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[69])));
// " Temp:"
04770
myGLCD.print(buffer, 217 , 148+ShiftDrawY);
04771
if
(MAX_Temp_on_off ==1)
04772
{myGLCD.print(
"Max Temp H2:"
, 5, 214);}
04773
}
04774
calculateStartTime();
04775
}
04776
WaterTempCheckFunction();
// ON/OFF chiller, heater and display TEMP value and messages
04777
FanTempCheckFunction();
// ON/OFF heatsink fans
04778
}
04779
04780
04781
//*********************** EXIT from ScreenSaver ********************
04782
void
Exit_From_ScreenSaver()
04783
{
04784
myTouch.read();
04785
04786
#ifdef Mirror_X
04787
x=320-myTouch.getX();
04788
#else
04789
x=myTouch.getX();
04790
#endif
04791
04792
#ifdef Mirror_Y
04793
y=240-myTouch.getY();
04794
#else
04795
y=myTouch.getY();
04796
#endif
04797
if
(setLockScreen ==1)
04798
{
04799
if
((x>=touchLock[0]) && (x<=touchLock[2]) && (y>=(touchLock[1]-ButtonShift)) && (y<=(touchLock[3]-ButtonShift)) && (firstTouch ==
false
))
04800
{
04801
waitForIt(touchLock[0], touchLock[1]-ButtonShift, touchLock[2], touchLock[3]-ButtonShift);
// wait for press "TOUCH" button
04802
unsigned
long
currentMillis = millis();
04803
previousMillisFive = currentMillis;
//start new 5sec interval
04804
myGLCD.setColor(0, 0, 0);
04805
myGLCD.fillRect(touchLock[0], touchLock[1]-ButtonShift-3, touchLock[2], touchLock[3]-ButtonShift+3);
// clear button TOUCH
04806
firstTouch =
true
;
04807
// printButtonTouch("Again", Again[0], Again[1], Again[2], Again[3], SMALL, GREEN_BAC);
04808
printButtonTouch(
"Again"
, touchLock[0], 240-(touchLock[3]-ButtonShift), touchLock[2], 240-(touchLock[1]-ButtonShift), SMALL, GREEN_BAC);
//mirror button
04809
}
04810
}
04811
04812
// if ((x>=Again[0]) && (x<=Again[2]) && (y>=Again[1]) && (y<=Again[3]) && (firstTouch == true))
04813
// {
04814
// waitForIt(Again[0], Again[1], Again[2], Again[3]); // wait for press "AGAIN" button
04815
04816
if
(setLockScreen ==1)
04817
{
04818
if
((x>=touchLock[0]) && (x<=touchLock[2]) && (y>=240-(touchLock[3]-ButtonShift)) && (y<=240-(touchLock[1]-ButtonShift)) && (firstTouch ==
true
))
04819
{
04820
waitForIt(touchLock[0], 240-(touchLock[3]-ButtonShift), touchLock[2], 240-(touchLock[1]-ButtonShift));
// wait for press "AGAIN" button
04821
firstTouch =
false
;
04822
screenSaverCounter=0;
04823
dispScreen=0;
04824
clearScreen();
04825
myGLCD.setColor(64, 64, 64);
04826
myGLCD.fillRect(0, 226, 319, 239);
//Bottom Bar
04827
mainScreen(
true
);
04828
}
04829
}
04830
else
{ clearScreen();
04831
analogWrite(BackLite, 255);
// set normal brightness
04832
screenSaverCounter=0;
04833
dispScreen=0;
04834
myGLCD.setColor(64, 64, 64);
04835
myGLCD.fillRect(0, 226, 319, 239);
//Bottom Bar
04836
mainScreen(
true
);
04837
}
04838
}
04839
04840
/******************************** END OF MAIN SCREEN **********************************/
04841
void
screenReturn()
//Auto Return to MainScreen() after 2min timeout, exept screensaver
04842
{
04843
if
(dispScreen!=24)
// no exit to main from screensaver
04844
{
04845
if
(dispScreen!=0)
04846
{
04847
if
(myTouch.dataAvailable())
04848
{ processMyTouch(); returnTimer=0; }
04849
else
{ returnTimer++; }
04850
04851
if
(returnTimer>=24)
// return after timeout 120sec -> 120/5 = 24 i.e 5sec steps
04852
{ returnTimer=0;
04853
dispScreen=0;
04854
if
((GlobalStatus2Byte & 0x0F) ==0 ) {colorLEDtest =
false
;}
// clear led test flag if all presert is OFF
04855
04856
clearScreen();
04857
myGLCD.setColor(64, 64, 64);
04858
myGLCD.fillRect(0, 226, 319, 239);
04859
mainScreen(
true
);
04860
}
04861
}
04862
}
04863
}
04864
04865
04866
/*********************** MENU SCREEN ********** dispScreen = 1 ************************/
04867
void
menuScreen()
04868
{
04869
// printHeader("Choose Option");
04870
PrintStringIndex=15;
04871
printHeader ();
04872
04873
myGLCD.setColor(64, 64, 64);
04874
myGLCD.drawRect(0, 196, 319, 194);
04875
printButton(
"CANCEL"
, canC[0], canC[1], canC[2], canC[3], SMALL);
04876
04877
// printButton("Time and Date", tanD[0], tanD[1], tanD[2], tanD[3]);
04878
printButton(
"H2O Temp Control"
, temC[0], temC[1], temC[2], temC[3]);
04879
printButton(
"Weather Control"
,WeatCtrl[0],WeatCtrl[1],WeatCtrl[2],WeatCtrl[3]);
04880
// printButton("WaveMaker", wave[0], wave[1], wave[2], wave[3]);
04881
printButton(
"General Settings"
, gSet[0], gSet[1], gSet[2], gSet[3]);
04882
printButton(
"LED Testing"
, tesT[0], tesT[1], tesT[2], tesT[3]);
04883
printButton(
"Change LED Values"
, ledChM[0], ledChM[1], ledChM[2], ledChM[3]);
04884
// printButton("Automatic Feeder", aFeed[0], aFeed[1], aFeed[2], aFeed[3]);
04885
// printButton("About", about[0], about[1], about[2], about[3]);
04886
04887
// draw correct button in main menu windows
04888
if
((GlobalStatus2Byte & 0x0F) == 0) {printButton(
"Preset OFF"
, prsM[0],prsM[1],prsM[2],prsM[3], SMALL);
04889
if
((min_cnt/15 >= StartTime-1) && (min_cnt/15 <= StopTime))
04890
{digitalWrite(PowerSwitch2, LOW);}
//ON driver before StartTime - 15min
04891
else
{digitalWrite(PowerSwitch2, HIGH);}}
//OFF driver before StartTime}
04892
04893
if
((GlobalStatus2Byte & 0x0F) == 1) {printButton(
"Preset 1 ON"
, prsM[0],prsM[1],prsM[2],prsM[3], SMALL, GREEN_BAC); digitalWrite(PowerSwitch2, LOW);}
04894
if
((GlobalStatus2Byte & 0x0F) == 2) {printButton(
"Preset 2 ON"
, prsM[0],prsM[1],prsM[2],prsM[3], SMALL, GREEN_BAC); digitalWrite(PowerSwitch2, LOW);}
04895
if
((GlobalStatus2Byte & 0x0F) == 4) {printButton(
"Preset 3 ON"
, prsM[0],prsM[1],prsM[2],prsM[3], SMALL, GREEN_BAC); digitalWrite(PowerSwitch2, LOW);}
04896
if
((GlobalStatus2Byte & 0x0F) == 8) {printButton(
"Preset 4 ON"
, prsM[0],prsM[1],prsM[2],prsM[3], SMALL, GREEN_BAC); digitalWrite(PowerSwitch2, LOW);}
04897
04898
}
04899
/********************************* END OF MENU SCREEN *********************************/
04900
04901
04902
/************** TIME and DATE SCREEN ********** dispScreen = 2 ************************/
04903
void
clockScreen(boolean refreshAll=
true
)
04904
{
04905
if
(refreshAll)
04906
{
04907
rtcSetMin=t.min; rtcSetHr=t.hour;
04908
rtcSetDy=t.date; rtcSetMon=t.mon; rtcSetYr=t.year;
04909
04910
// printHeader("Time and Date Settings");
04911
PrintStringIndex=16;
04912
printHeader ();
04913
04914
myGLCD.setColor(64, 64, 64);
//Draw Dividers in Grey
04915
myGLCD.drawRect(0, 196, 319, 194);
//Bottom Horizontal Divider
04916
myGLCD.drawLine(0, 104, 319, 104);
//Middle Horizontal Divider
04917
printButton(
"<< BACK"
, back[0], back[1], back[2], back[3], SMALL);
04918
printButton(
"SAVE"
, prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3], SMALL);
04919
printButton(
"CANCEL"
, canC[0], canC[1], canC[2], canC[3], SMALL);
04920
04921
drawUpButton(houU[0], houU[1]);
//hour up
04922
drawUpButton(minU[0], minU[1]);
//min up
04923
drawDownButton(houD[0], houD[1]);
//hour down
04924
drawDownButton(minD[0], minD[1]);
//min down
04925
if
(setTimeFormat==1)
04926
{ drawUpButton(ampmU[0], ampmU[1]);
//AM/PM up
04927
drawDownButton(ampmD[0], ampmD[1]);}
//AM/PM down
04928
04929
drawUpButton(dayU[0], dayU[1]);
//day up
04930
drawUpButton(monU[0], monU[1]);
//month up
04931
drawUpButton(yeaU[0], yeaU[1]);
//year up
04932
drawDownButton(dayD[0], dayD[1]);
//day down
04933
drawDownButton(monD[0], monD[1]);
//month down
04934
drawDownButton(yeaD[0], yeaD[1]);
//year down
04935
xTimeH=107; yTime=52; xColon=xTimeH+42;
04936
xTimeM10=xTimeH+70; xTimeM1=xTimeH+86; xTimeAMPM=xTimeH+155;
04937
timeChange();
04938
}
04939
04940
timeDispH=rtcSetHr; timeDispM=rtcSetMin;
04941
xTimeH=107; yTime=52; xColon=xTimeH+42;
04942
xTimeM10=xTimeH+70; xTimeM1=xTimeH+86; xTimeAMPM=xTimeH+155;
04943
// timeChange();
04944
timeCorrectFormat();
04945
04946
if
(refreshAll)
04947
{
04948
setFont(LARGE, 0, 0, 255, 0, 0, 0);
04949
myGLCD.print(
"Date"
, 20, 142);
04950
setFont(LARGE, 255, 255, 255, 0, 0, 0);
04951
myGLCD.print(
"/"
, 149, 142);
04952
myGLCD.print(
"/"
, 219, 142);
04953
if
(setCalendarFormat==0)
//DD/MM/YYYY Format
04954
{
04955
setFont(SMALL, 0, 0, 255, 0, 0, 0);
04956
myGLCD.print(
"(DD/MM/YYYY)"
, 5, 160);
04957
}
04958
if
(setCalendarFormat==1)
//MM/DD/YYYY Format
04959
{
04960
setFont(SMALL, 0, 0, 255, 0, 0, 0);
04961
myGLCD.print(
"(MM/DD/YYYY)"
, 5, 160);
04962
}
04963
}
04964
if
(setCalendarFormat==0)
//DD/MM/YYYY Format
04965
{
04966
// setFont(SMALL, 0, 0, 255, 0, 0, 0);
04967
// myGLCD.print("(DD/MM/YYYY)", 5, 160);
04968
setFont(LARGE, 255, 255, 255, 0, 0, 0);
04969
if
((rtcSetDy>=0) && (rtcSetDy<=9))
//Set DAY
04970
{ myGLCD.print(
"0"
, 107, 142);
04971
myGLCD.printNumI(rtcSetDy, 123, 142);}
04972
else
{ myGLCD.printNumI(rtcSetDy, 107, 142);}
04973
if
((rtcSetMon>=0) && (rtcSetMon<=9))
//Set MONTH
04974
{ myGLCD.print(
"0"
, 177, 142);
04975
myGLCD.printNumI(rtcSetMon, 193, 142);}
04976
else
{ myGLCD.printNumI(rtcSetMon, 177, 142);}
04977
}
else
04978
if
(setCalendarFormat==1)
//MM/DD/YYYY Format
04979
{
04980
// setFont(SMALL, 0, 0, 255, 0, 0, 0);
04981
// myGLCD.print("(MM/DD/YYYY)", 5, 160);
04982
setFont(LARGE, 255, 255, 255, 0, 0, 0);
04983
if
((rtcSetMon>=0) && (rtcSetMon<=9))
//Set MONTH
04984
{ myGLCD.print(
"0"
, 107, 142);
04985
myGLCD.printNumI(rtcSetMon, 123, 142);}
04986
else
{ myGLCD.printNumI(rtcSetMon, 107, 142);}
04987
if
((rtcSetDy>=0) && (rtcSetDy<=9))
//Set DAY
04988
{ myGLCD.print(
"0"
, 177, 142);
04989
myGLCD.printNumI(rtcSetDy, 193, 142);}
04990
else
{ myGLCD.printNumI(rtcSetDy, 177, 142);}
04991
}
04992
myGLCD.printNumI(rtcSetYr, 247, 142);
//Set YEAR
04993
}
04994
04995
void
timeChange()
04996
{
04997
setFont(LARGE, 0, 0, 255, 0, 0, 0);
04998
myGLCD.print(
"Time"
, 20, yTime);
04999
05000
if
(setTimeFormat==0)
//24HR Format
05001
{ setFont(SMALL, 0, 0, 255, 0, 0, 0);
05002
myGLCD.print(
"(24HR)"
, 29, yTime+18);}
05003
05004
if
(setTimeFormat==1)
//12HR Format
05005
{ setFont(SMALL, 0, 0, 255, 0, 0, 0);
05006
myGLCD.print(
"(12HR)"
, 29, yTime+18);}
05007
05008
// timeCorrectFormat();
05009
}
05010
05011
void
timeCorrectFormat()
05012
{
05013
setFont(LARGE, 255, 255, 255, 0, 0, 0);
05014
myGLCD.print(
":"
, xColon, yTime);
05015
if
(setTimeFormat==0)
//24HR Format
05016
{
05017
setFont(LARGE, 255, 255, 255, 0, 0, 0);
05018
if
((timeDispH>=0) && (timeDispH<=9))
//Set HOUR
05019
{ myGLCD.print(
"0"
, xTimeH, yTime);
05020
myGLCD.printNumI(timeDispH, xTimeH+16, yTime);}
05021
else
{ myGLCD.printNumI(timeDispH, xTimeH, yTime);}
05022
}
05023
if
(setTimeFormat==1)
//12HR Format
05024
{
05025
setFont(LARGE, 255, 255, 255, 0, 0, 0);
05026
if
(timeDispH==0)
//Set HOUR
05027
{ myGLCD.print(
"12"
, xTimeH, yTime);}
05028
if
((timeDispH>=1) && (timeDispH<=9))
05029
{ myGLCD.print(
"0"
, xTimeH, yTime);
05030
myGLCD.printNumI(timeDispH, xTimeH+16, yTime);}
05031
if
((timeDispH>=10) && (timeDispH<=12))
05032
{ myGLCD.printNumI(timeDispH, xTimeH, yTime);}
05033
if
((timeDispH>=13) && (timeDispH<=21))
05034
{ myGLCD.print(
"0"
, xTimeH, yTime);
05035
myGLCD.printNumI(timeDispH-12, xTimeH+16, yTime);}
05036
if
(timeDispH>=22)
05037
{ myGLCD.printNumI(timeDispH-12, xTimeH, yTime);}
05038
05039
if
(AM_PM==1)
05040
{ myGLCD.print(
"AM"
, xTimeAMPM, yTime); }
05041
if
(AM_PM==2)
05042
{ myGLCD.print(
"PM"
, xTimeAMPM, yTime); }
05043
}
05044
if
((timeDispM>=0) && (timeDispM<=9))
//Set MINUTES
05045
{ myGLCD.print(
"0"
, xTimeM10, yTime);
05046
myGLCD.printNumI(timeDispM, xTimeM1, yTime);}
05047
else
{ myGLCD.printNumI(timeDispM, xTimeM10, yTime);}
05048
}
05049
/**************************** END OF TIME and DATE SCREEN *****************************/
05050
05051
05052
/*********** H2O TEMP CONTROL SCREEN ********** dispScreen = 3 ************************/
05053
void
tempScreen(boolean refreshAll=
false
)
05054
{
05055
// String deg;
05056
if
(refreshAll)
05057
{
05058
if
((setTempC==0) && (setTempScale==0)) {
05059
setTempC = 26.1; }
//change to 26.1 deg C
05060
if
(((setTempF==0) || (setTempF==setTempC)) && (setTempScale==1)) {
05061
setTempF = 79.0; }
//change to 79.0 deg F
05062
05063
if
(setTempScale==1) {
05064
temp2beS = setTempF;
05065
temp2beO = offTempF;
05066
temp2beA = alarmTempF; }
05067
else
{
05068
temp2beS = setTempC;
05069
temp2beO = offTempC;
05070
temp2beA = alarmTempC; }
05071
05072
// printHeader("H2O Temperature Control Settings");
05073
PrintStringIndex=17;
05074
printHeader ();
05075
05076
myGLCD.setColor(64, 64, 64);
//Draw Dividers in Grey
05077
myGLCD.drawRect(0, 196, 319, 194);
//Bottom Horizontal Divider
05078
printButton(
"<< BACK"
, back[0], back[1], back[2], back[3], SMALL);
05079
printButton(
"SAVE"
, prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3], SMALL);
05080
printButton(
"CANCEL"
, canC[0], canC[1], canC[2], canC[3], SMALL);
05081
05082
setFont(SMALL, 255, 255, 255, 0, 0, 0);
05083
// myGLCD.print("Desired Temperature: ", 52, 34);
05084
// myGLCD.print("Temperature Offset: 0.1-5", 60, 84);
05085
// myGLCD.print("Alarm Offset: 0.1-9.9", 76, 134);
05086
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[20])));
05087
myGLCD.print(buffer, 52, 34);
05088
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[21])));
05089
myGLCD.print(buffer, 60, 84);
05090
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[22])));
05091
myGLCD.print(buffer, 76, 134);
05092
05093
if
(setTempScale==1) {
05094
// myGLCD.print("50-104F",218, 34);
05095
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[23])));
05096
myGLCD.print(buffer, 218, 34);
05097
}
05098
else
{
05099
// myGLCD.print("10-40C",218,34);
05100
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[24])));
05101
myGLCD.print(buffer, 218, 34);
05102
}
05103
05104
printButton(
"-"
, temM[0], temM[1], temM[2], temM[3],
true
);
//temp minus
05105
printButton(
"+"
, temP[0], temP[1], temP[2], temP[3],
true
);
//temp plus
05106
printButton(
"-"
, offM[0], offM[1], offM[2], offM[3],
true
);
//offset minus
05107
printButton(
"+"
, offP[0], offP[1], offP[2], offP[3],
true
);
//offset plus
05108
printButton(
"-"
, almM[0], almM[1], almM[2], almM[3],
true
);
//alarm minus
05109
printButton(
"+"
, almP[0], almP[1], almP[2], almP[3],
true
);
//alarm plus
05110
// printButtonVertical(" BEEP OFF ", Beep[0], Beep[1], SMALL);
05111
05112
}
05113
05114
setFont(LARGE, 255, 255, 255, 0, 0, 0);
05115
if
(setTempScale==1 && temp2beS <100 ) {myGLCD.print(
" "
,189,54);}
05116
myGLCD.printNumF(temp2beS, 1, 125, 54);
05117
myGLCD.printNumF(temp2beO, 1, 139, 104);
05118
myGLCD.printNumF(temp2beA, 1, 139, 154);
05119
05120
}
05121
/************************** END of H20 TEMP CONTROL SCREEN ****************************/
05122
05123
05124
/********** LED TESTING OPTIONS SCREEN ******** dispScreen = 4 ************************/
05125
void
ledTestOptionsScreen()
05126
{
05127
// printHeader("LED Testing Options");
05128
PrintStringIndex=18;
05129
printHeader ();
05130
05131
myGLCD.setColor(64, 64, 64);
//Draw Dividers in Grey
05132
myGLCD.drawRect(0, 196, 319, 194);
//Bottom Horizontal Divider
05133
printButton(
"<< BACK"
, back[0], back[1], back[2], back[3], SMALL);
05134
printButton(
"CANCEL"
, canC[0], canC[1], canC[2], canC[3], SMALL);
05135
05136
printButton(
"Rapid (x120) Test LED Array"
, tstLA[0], tstLA[1], tstLA[2], tstLA[3]);
05137
printButton(
"Control Individual Leds"
, cntIL[0], cntIL[1], cntIL[2], cntIL[3]);
05138
printButton(
"Preset Setting"
, PrButL[0], PrButL[1], PrButL[2], PrButL[3]);
05139
}
05140
/*************************** END OF LED TEST OPTIONS SCREEN ***************************/
05141
05142
05143
void
AllColourGraph()
// used in "rapid test" and "All color graph "
05144
{
05145
05146
myGLCD.setColor(0, 0, 0);
05147
myGLCD.fillRect(0, 0, 319, 15);
// clear only header
05148
myGLCD.setColor(64, 64, 64);
//Draw Dividers in Grey
05149
myGLCD.drawRect(0, 196, 319, 194);
//Bottom Horizontal Divider
05150
printButton(
"<< BACK"
, back[0], back[1], back[2], back[3], SMALL);
05151
printButton(
"CANCEL"
, canC[0], canC[1], canC[2], canC[3], SMALL);
05152
if
(dispScreen ==5)
// rapid test window
05153
{printButton(
"START"
, ledChV[0], ledChV[1], ledChV[2], ledChV[3], SMALL);}
// button start/stop test oly in rapid test window
05154
05155
calculateStartTime();
// calculate SUNRISE time
05156
calculateStopTime();
// calculate SUNSET time
05157
05158
/*
05159
byte i;
05160
for (i=95; i>0; i--) // find "StopTime"
05161
{
05162
if (tvled[i]!=0 && bitRead(LedShannelStatusByte,5)== true) {goto ext_SStlbl;}
05163
if (bled[i]!=0 && bitRead(LedShannelStatusByte,1)== true) {goto ext_SStlbl;}
05164
if (wled[i]!=0 && bitRead(LedShannelStatusByte,0)== true) {goto ext_SStlbl;}
05165
if (rbled[i]!=0 && bitRead(LedShannelStatusByte,2)== true) {goto ext_SStlbl;}
05166
if (rled[i]!=0 && bitRead(LedShannelStatusByte,3)== true) {goto ext_SStlbl;}
05167
if (uvled[i]!=0 && bitRead(LedShannelStatusByte,4)== true) {goto ext_SStlbl;}
05168
if (cyled[i]!=0 && bitRead(LedShannelStatusByte,6)== true) {goto ext_SStlbl;}
05169
if (yeled[i]!=0 && bitRead(LedShannelStatusByte,7)== true) {goto ext_SStlbl;}
05170
}
05171
ext_SStlbl:
05172
StopTime=i+1;
05173
*/
05174
05175
if
(LedShannelStatusByte==0) {StartTime=0; StopTime=95;}
// draw graph if all led is OFF
05176
05177
drawLedStaticChartP1 ();
05178
05179
// repeat 9 time
05180
for
(
byte
i=1; i<=9; i++)
05181
{ COLOR = i;
05182
if
(i==1) {
05183
for
(
byte
i=0; i<96; i++)
05184
tled[i] = wled[i]; sbR= rgbCh2[0]; sbG= rgbCh2[1]; sbB= rgbCh2[2];}
05185
if
(i==2) {
05186
for
(
byte
i=0; i<96; i++)
05187
tled[i] = bled[i]; sbR= rgbCh4[0]; sbG= rgbCh4[1]; sbB= rgbCh4[2];}
05188
if
(i==3) {
05189
for
(
byte
i=0; i<96; i++)
05190
tled[i] = rbled[i]; sbR= rgbCh3[0]; sbG= rgbCh3[1]; sbB= rgbCh3[2];}
05191
if
(i==4) {
05192
for
(
byte
i=0; i<96; i++)
05193
tled[i] = rled[i]; sbR= rgbCh5[0]; sbG= rgbCh5[1]; sbB= rgbCh5[2];}
05194
if
(i==5) {
05195
for
(
byte
i=0; i<96; i++)
05196
tled[i] = uvled[i]; sbR= rgbCh1[0]; sbG= rgbCh1[1]; sbB= rgbCh1[2];}
05197
if
(i==6) {
05198
for
(
byte
i=0; i<96; i++)
05199
tled[i] = tvled[i]; sbR= rgbCh6[0]; sbG= rgbCh6[1]; sbB= rgbCh6[2];}
05200
if
(i==8) {
05201
for
(
byte
i=0; i<96; i++)
05202
tled[i] = cyled[i]; sbR= rgbCh0[0]; sbG= rgbCh0[1]; sbB= rgbCh0[2];}
05203
if
(i==9) {
05204
for
(
byte
i=0; i<96; i++)
05205
tled[i] = yeled[i]; sbR= rgbCh7[0]; sbG= rgbCh7[1]; sbB= rgbCh7[2];}
05206
05207
if
(i!=7) { ReadOnOffLedStatus();
05208
if
(LedShannelFlag_on_off ==
true
)
05209
{ draw_one_led_graph(); }
05210
else
{ EndScale=290;}
// for draw tick scale if all led is OFF
05211
}
05212
}
05213
drawLedStaticChartP2 ();
05214
}
05215
05216
void
draw_one_led_graph()
05217
{
byte
stepScale = (294 - 26)/(StopTime-StartTime);
// 26 and 294 - left / right
05218
myGLCD.setColor(sbR, sbG, sbB);
05219
for
(
byte
i=StartTime; i<StopTime; i++)
// draw led value graph (curve)
05220
{
int
tempLineS;
//start segment of line
05221
int
tempLineE;
//stop segment of line
05222
int
XStep = map((i-StartTime), 0, (StopTime-StartTime), 26, 294);
05223
05224
tempLineS=tled[i];
05225
if
(tempLineS > 100) {tempLineS =100;}
05226
tempLineE=tled[i+1];
05227
if
(tempLineE > 100) {tempLineE =100;}
05228
tempLineS= map (tempLineS, 0, 100, BotSldY, TopSldY);
// mapping 0-100 value to chart size
05229
tempLineE= map (tempLineE, 0, 100, BotSldY, TopSldY);
05230
05231
myGLCD.drawLine(XStep, tempLineS, XStep+stepScale, tempLineE );
05232
myGLCD.drawLine(XStep, tempLineS+1, XStep+stepScale, tempLineE+1 );
05233
EndScale = XStep+stepScale;
05234
}
05235
}
05236
void
drawLedStaticChartP1 ()
// draw TOP ON/OFF time and X/Y border
05237
{
05238
05239
TopSldY=20; BotSldY=170;
// graph vertical size
05240
LightDay= (StopTime-StartTime)/4*10;
// light day in HOUR * 10
05241
int
Temp = 10*(StopTime-StartTime)/4;
// rounding to the nearest whole number if "light day" similar 3.4 or 3.75 etc...
05242
if
((Temp - LightDay)>=5) {LightDay= (StopTime-StartTime)/4+1;}
05243
else
{LightDay= (StopTime-StartTime)/4;}
05244
05245
myGLCD.setColor(255, 255, 255);
//static LED Chart
05246
setFont(SMALL, 255, 255, 255, 0, 0, 0);
05247
myGLCD.drawRect(26, BotSldY, 27, TopSldY);
//print y-line
05248
for
(
byte
i=1; i<11; i++)
05249
{ myGLCD.drawLine(28, (i*(BotSldY-TopSldY)/10+5), 30, (i*(BotSldY-TopSldY)/10+5));}
// Y tick-marks
05250
05251
myGLCD.drawRect(26, BotSldY, 318, BotSldY+1);
//print x-line
05252
05253
for
(
byte
i=0; i<=10; i++)
// print 0-100 vertical scale
05254
{
if
(i==0) {myGLCD.printNumI(0, 18, ((BotSldY-TopSldY)/10*(11-i)));}
05255
if
(i==10) {myGLCD.printNumI(100, 2, (BotSldY-TopSldY)/10*(11-i));}
05256
else
{myGLCD.printNumI(i*10, 10, (BotSldY-TopSldY)/10*(11-i));}
05257
}
05258
05259
myGLCD.setColor(255, 255, 255);
05260
myGLCD.drawRect(1, 1, 106, 14);
// print white border for ON TIME
05261
myGLCD.drawRect(205, 1, 318, 14);
// print white border for OFF TIME
05262
setFont(SMALL, 0, 0, 0, 0, 255, 0);
05263
myGLCD.print(
"ON TIME-"
,2, 2); myGLCD.print(
" "
, 66, 2);
// print ON TIME (on TOP)
05264
if
((StartTime/4)<=9) {myGLCD.printNumI((StartTime/4), 66+8, 2);}
05265
else
{myGLCD.printNumI((StartTime/4), 66, 2);}
05266
myGLCD.print(
":"
, 82, 2); myGLCD.printNumI((StartTime*15)%60, 90, 2, 2,
'00'
);
05267
/*
05268
setFont(SMALL, 255, 255, 255, 0, 0, 0);
05269
myGLCD.printNumI(StartTime/4, 8, BotSldY+8, 2, '00'); // print start time on scale
05270
myGLCD.print(":", 24, BotSldY+8);
05271
myGLCD.printNumI((StartTime*15)%60, 32, BotSldY+8, 2, '00');
05272
*/
05273
setFont(SMALL, 0, 0, 0, 0, 255, 0);
05274
myGLCD.print(
"OFF TIME-"
,206, 2); myGLCD.print(
" "
, 278, 2);
// print OFF TIME (on TOP)
05275
if
((StopTime/4)<=9) {myGLCD.printNumI((StopTime/4), 278+8, 2);}
05276
else
{myGLCD.printNumI((StopTime/4), 278, 2); }
05277
myGLCD.print(
":"
, 294, 2); myGLCD.printNumI((StopTime*15)%60, 302, 2, 2,
'00'
);
05278
}
05279
05280
void
drawLedStaticChartP2 ()
// draw BOT ON/OFF time and X/Y scale and tick mark
05281
{
05282
/*
05283
byte Temp = StartTime/4+2;
05284
byte DeltaI;
05285
if ((StartTime*15)%60 == 0) {DeltaI=4;}
05286
if ((StartTime*15)%60 == 15) {DeltaI=4;}
05287
if ((StartTime*15)%60 == 30) {DeltaI=3;}
05288
if ((StartTime*15)%60 == 45) {DeltaI=2;}
05289
*/
05290
05291
myGLCD.setColor(255, 255, 255);
05292
myGLCD.drawRect(26, BotSldY, 318, BotSldY+1);
//print x-line
05293
if
(LightDay<=7)
// print X-tick and dot background
05294
{
for
(
byte
i=0; i<(StopTime-StartTime)+2; i++)
// i-horisontal count, X tick-marks with 15min resolution
05295
{
int
XStep = map(i, 0, (StopTime-StartTime), 26, EndScale);
05296
myGLCD.setColor(255, 255, 255);
05297
myGLCD.drawLine(XStep, BotSldY+3, XStep, BotSldY-3);
05298
05299
for
(
byte
k=1; k<=10; k++)
// k - vertical count
05300
{ myGLCD.setColor(180, 180, 180);
05301
myGLCD.drawPixel(XStep, k*(BotSldY-TopSldY)/10+5);}}}
05302
05303
if
(LightDay>7 && LightDay<=12)
05304
{
for
(
byte
i=0; i<(StopTime-StartTime)/2+2; i++)
//X tick-marks with 30min resolution
05305
{
int
XStep = map(i, 0, (StopTime-StartTime)/2, 26, EndScale);
05306
myGLCD.setColor(255, 255, 255);
05307
myGLCD.drawLine(XStep, BotSldY+3, XStep, BotSldY-3);
// X mark on horisontal scale
05308
/*
05309
if ( i>= DeltaI && i<((StopTime-StartTime)/2-2)) {
05310
if (i%2 ==0 ){
05311
setFont(SMALL, 255, 255, 255, 0, 0, 0);
05312
myGLCD.printNumI(Temp, XStep-6, BotSldY+8, 2, '00');
05313
Temp +=1;
05314
Serial.print("i="); Serial.println(i);
05315
// Serial.print("DeltaI="); Serial.println(DeltaI);
05316
} }
05317
*/
05318
for
(
byte
k=1; k<=10; k++)
// k - vertical count
05319
{ myGLCD.setColor(180, 180, 180);
05320
myGLCD.drawPixel(XStep, k*(BotSldY-TopSldY)/10+5);}}}
05321
05322
if
(LightDay>12 && LightDay<=24)
05323
{
for
(
byte
i=0; i<(StopTime-StartTime)/4+4; i++)
//X tick-marks with 1hour resolution
05324
{
int
XStep = map(i, 0, (StopTime-StartTime)/4, 26, EndScale);
05325
myGLCD.setColor(255, 255, 255);
05326
myGLCD.drawLine(XStep, BotSldY+3, XStep, BotSldY-3);
05327
for
(
byte
k=1; k<=10; k++)
// k - vertical count
05328
{ myGLCD.setColor(180, 180, 180);
05329
myGLCD.drawPixel(XStep, k*(BotSldY-TopSldY)/10+5);}}}
05330
05331
05332
setFont(SMALL, 255, 255, 255, 0, 0, 0);
05333
myGLCD.printNumI(StartTime/4, 8, BotSldY+8, 2,
'00'
);
// print start time on scale
05334
myGLCD.print(
":"
, 24, BotSldY+8);
05335
myGLCD.printNumI((StartTime*15)%60, 32, BotSldY+8, 2,
'00'
);
05336
05337
setFont(SMALL, 255, 255, 255, 0, 0, 0);
05338
myGLCD.printNumI(StopTime/4, EndScale-16, BotSldY+8);
// print stop time on scale
05339
myGLCD.print(
":"
, EndScale, BotSldY+5);
05340
myGLCD.printNumI((StopTime*15)%60, EndScale+8, BotSldY+8, 2,
'00'
);
05341
05342
}
05343
05344
void
drawTestLedArrayScale()
05345
{
05346
int
i=0;
// start scale is constant
05347
min_cnt = StartTime*15;
05348
05349
while
(LEDtestTick==
true
&& i<= ((StopTime-StartTime)*15)/2)
// LEDtestTick== true - start test
05350
{
05351
unsigned
long
currentMillis = millis();
05352
if
(myTouch.dataAvailable())
05353
{ processMyTouch();}
05354
05355
if
(currentMillis - previousMillisLED > 1000)
//change time every 1s
05356
{previousMillisLED = currentMillis;
05357
05358
int
XStep = map(i, 0, ((StopTime-StartTime)*15)/2, 26, EndScale);
05359
myGLCD.setColor(255, 255, 255);
05360
myGLCD.drawRect(136, 1, 177, 14);
05361
setFont(SMALL, 0, 0, 0, 0, 255, 0);
05362
myGLCD.print(
" "
, 137, 2);
05363
if
(((min_cnt/15)/4)<=9) {myGLCD.printNumI((min_cnt/15)/4, 145, 2);}
05364
else
{myGLCD.printNumI((min_cnt/15)/4, 137, 2);}
05365
myGLCD.print(
":"
, 153, 2); myGLCD.printNumI(min_cnt%60, 161, 2, 2,
'00'
);
05366
myGLCD.setColor(0, 255, 0);
05367
myGLCD.drawLine(XStep, BotSldY+8, XStep, BotSldY+3 );
05368
LED_levels_output();
05369
min_cnt+=2 ;
// two minutes increment
05370
i +=1;
05371
}
05372
}
05373
printButton(
"START"
, ledChV[0], ledChV[1], ledChV[2], ledChV[3], SMALL);
// buton start/stop test
05374
LEDtestTick =
false
;
// end test, enable button BACK/Cancel
05375
}
05376
05377
void
calculateStartTime()
05378
{
05379
byte
i;
05380
for
(i=0; i<=95; i++)
// find "StartTime"
05381
{
05382
if
(tvled[i]!=0 && bitRead(LedShannelStatusByte,5)==
true
) {
goto
ext_Stlbl;}
05383
if
(bled[i]!=0 && bitRead(LedShannelStatusByte,1)==
true
) {
goto
ext_Stlbl;}
05384
if
(wled[i]!=0 && bitRead(LedShannelStatusByte,0)==
true
) {
goto
ext_Stlbl;}
05385
if
(rbled[i]!=0 && bitRead(LedShannelStatusByte,2)==
true
) {
goto
ext_Stlbl;}
05386
if
(rled[i]!=0 && bitRead(LedShannelStatusByte,3)==
true
) {
goto
ext_Stlbl;}
05387
if
(uvled[i]!=0 && bitRead(LedShannelStatusByte,4)==
true
) {
goto
ext_Stlbl;}
05388
if
(cyled[i]!=0 && bitRead(LedShannelStatusByte,6)==
true
) {
goto
ext_Stlbl;}
05389
if
(yeled[i]!=0 && bitRead(LedShannelStatusByte,7)==
true
) {
goto
ext_Stlbl;}
05390
}
05391
ext_Stlbl:
05392
StartTime=i-1;
05393
if
(StartTime == 255) {StartTime=0;}
05394
}
05395
05396
void
calculateStopTime()
05397
{
05398
byte
i;
05399
for
(i=95; i>0; i--)
// find "StopTime"
05400
{
05401
if
(tvled[i]!=0 && bitRead(LedShannelStatusByte,5)==
true
) {
goto
ext_SStlbl;}
05402
if
(bled[i]!=0 && bitRead(LedShannelStatusByte,1)==
true
) {
goto
ext_SStlbl;}
05403
if
(wled[i]!=0 && bitRead(LedShannelStatusByte,0)==
true
) {
goto
ext_SStlbl;}
05404
if
(rbled[i]!=0 && bitRead(LedShannelStatusByte,2)==
true
) {
goto
ext_SStlbl;}
05405
if
(rled[i]!=0 && bitRead(LedShannelStatusByte,3)==
true
) {
goto
ext_SStlbl;}
05406
if
(uvled[i]!=0 && bitRead(LedShannelStatusByte,4)==
true
) {
goto
ext_SStlbl;}
05407
if
(cyled[i]!=0 && bitRead(LedShannelStatusByte,6)==
true
) {
goto
ext_SStlbl;}
05408
if
(yeled[i]!=0 && bitRead(LedShannelStatusByte,7)==
true
) {
goto
ext_SStlbl;}
05409
}
05410
ext_SStlbl:
05411
StopTime=i+1;
05412
}
05413
05414
05415
/********* TEST INDIVIDUAL LED(S) SCREEN ****** dispScreen = 6 ************************/
05416
void
testIndLedScreen(boolean refreshTest=
false
)
05417
{
05418
05419
TopSldY=53; BotSldY=TopSldY+100;
05420
if
(refreshTest==
true
)
05421
{
05422
myGLCD.setColor(0, 0, 0);
05423
myGLCD.fillRect(0, 0, 319, 15);
// clear only header
05424
setFont(SMALL, 255, 255, 255, 0, 0, 0);
05425
// myGLCD.print("TV DR CW BL RBL UV CY YE Moon", 15, 15);
05426
// PrintStringIndex=3; // print string from Flash
05427
// strcpy_P(buffer, (char*)pgm_read_word_near(&(Header_Text_table[PrintStringIndex]))); // print string number 3 from flash
05428
// myGLCD.print(buffer, 15, 15 );
05429
05430
myGLCD.print(ChName[6], 15, 15 );
// TV
05431
myGLCD.print(ChName[5], 15+35, 15 );
// DR
05432
myGLCD.print(ChName[2], 15+70, 15 );
// CW
05433
myGLCD.print(ChName[4], 15+105, 15 );
// BL
05434
myGLCD.print(ChName[3], 15+140, 15 );
// RBL
05435
myGLCD.print(ChName[1], 15+175, 15 );
// UV
05436
myGLCD.print(ChName[0], 15+210, 15 );
// CY
05437
myGLCD.print(ChName[7], 15+245, 15 );
// Ye
05438
myGLCD.print(ChName[8], 15+270, 15 );
// Moon
05439
05440
05441
for
(
byte
b=0; b<9; b++)
//UP Buttons
05442
{ drawUpButtonSlide((b*35)+4, TopSldY-26); }
05443
for
(
byte
b=0; b<9; b++)
//DOWN Buttons
05444
{ drawDownButtonSlide((b*35)+4, TopSldY+115);}
05445
05446
temp_sector= min_cnt/15;
// read current time sector only first time
05447
05448
myGLCD.setColor(64, 64, 64);
//Draw Dividers in Grey
05449
myGLCD.drawRect(0, 196, 319, 194);
//Bottom Horizontal Divider
05450
printButton(
"<< BACK"
, back[0], back[1], back[2], back[3], SMALL);
05451
printButton(
"PREV SECT"
, ledChV[0], ledChV[1], ledChV[2], ledChV[3], SMALL);
05452
printButton(
"NEXT SECT"
, canC[0], canC[1], canC[2], canC[3], SMALL);
05453
printButton(
"SunSet"
, StopDay[0], StopDay[1], StopDay[2], StopDay[3], SMALL);
// top buttons
05454
printButton(
"SunRise"
, StartDay[0], StartDay[1], StartDay[2], StartDay[3], SMALL);
// top buttons
05455
}
05456
05457
if
(refreshTest==
true
)
05458
{
05459
myGLCD.setColor(255, 255, 255);
//Draw white rectangle
05460
myGLCD.drawRect(88, 0, 227, 14);
05461
myGLCD.setColor(0, 255, 0);
//fill sector background in green
05462
myGLCD.fillRect(89, 1, 226, 14);
05463
//---------- display current TIME sector = min_cnt/15, convert to hour min_cnt/15)/4, to min. (min_cnt/15)*15)%60
05464
setFont(SMALL, 0, 0, 0, 0, 255, 0);
// print SECTOR TIME on TOP
05465
myGLCD.print(
"TIME SECTOR : "
,91, 2);
05466
}
05467
setFont(SMALL, 0, 0, 0, 0, 255, 0);
05468
if
((temp_sector/4)<=9) {
05469
myGLCD.print(
" "
,91+96, 2);
05470
myGLCD.printNumI(temp_sector/4, 91+104, 2);}
// Start sector is min_cnt/15
05471
else
{myGLCD.printNumI(temp_sector/4, 91+96, 2);}
05472
myGLCD.printNumI((temp_sector*15)%60, 91+120, 2, 2,
'00'
);
// min 00/15/30/45 in hour
05473
05474
05475
tv_out = tvled[temp_sector];
// read setting from buffer
05476
b_out = bled[temp_sector];
05477
w_out = wled[temp_sector];
05478
rb_out = rbled[temp_sector];
05479
r_out = rled[temp_sector];
05480
uv_out = uvled[temp_sector];
05481
cy_out = cyled[temp_sector];
05482
yel_out = yeled[temp_sector];
05483
05484
for
(
byte
i=0; i<9; i++)
// draw white bar outline rectangle
05485
{ sbX1=(i*35)+4; sbX2=(i*35)+34;
05486
setFont(SMALL, 255, 255, 255, 0, 0, 0);
05487
myGLCD.drawRect(sbX1, TopSldY-1, sbX2, BotSldY);}
05488
05489
for
(
byte
i=0; i<9; i++)
//print Slider Bar current values
05490
{
05491
sbX1=(i*35)+4; sbX2=(i*35)+34;
05492
SliderSwitch =
true
;
05493
05494
if
(i==0)
05495
{ LedShannelFlag_on_off =
true
;
05496
if
(bitRead(LedShannelStatusByte,5) ==
false
) {tv_out=0; LedShannelFlag_on_off =
false
; }
05497
sbR= rgbCh6[0]; sbG= rgbCh6[1]; sbB= rgbCh6[2]; tSlide= tv_out;
// TV colour
05498
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05499
tvcol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05500
05501
if
(i==1)
05502
{ LedShannelFlag_on_off =
true
;
05503
if
(bitRead(LedShannelStatusByte,3) ==
false
) {r_out=0; LedShannelFlag_on_off =
false
; }
05504
sbR= rgbCh5[0]; sbG= rgbCh5[1]; sbB= rgbCh5[2]; tSlide= r_out;
// DR colour
05505
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05506
rcol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05507
05508
if
(i==2)
05509
{ LedShannelFlag_on_off =
true
;
05510
if
(bitRead(LedShannelStatusByte,0) ==
false
) {w_out=0; LedShannelFlag_on_off =
false
; }
05511
sbR= rgbCh2[0]; sbG= rgbCh2[1]; sbB= rgbCh2[2]; tSlide= w_out;
// CW colour
05512
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05513
wcol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05514
05515
if
(i==3)
05516
{ LedShannelFlag_on_off =
true
;
05517
if
(bitRead(LedShannelStatusByte,1) ==
false
) {b_out=0; LedShannelFlag_on_off =
false
; }
05518
sbR= rgbCh4[0]; sbG= rgbCh4[1]; sbB= rgbCh4[2]; tSlide= b_out;
// BL colour
05519
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05520
bcol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05521
05522
if
(i==4)
05523
{ LedShannelFlag_on_off =
true
;
05524
if
(bitRead(LedShannelStatusByte,2) ==
false
) {rb_out=0; LedShannelFlag_on_off =
false
; }
05525
sbR= rgbCh3[0]; sbG= rgbCh3[1]; sbB= rgbCh3[2]; tSlide = rb_out;
// RBL colour
05526
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05527
rbcol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05528
05529
if
(i==5)
05530
{ LedShannelFlag_on_off =
true
;
05531
if
(bitRead(LedShannelStatusByte,4) ==
false
) {uv_out=0; LedShannelFlag_on_off =
false
; }
05532
sbR= rgbCh1[0]; sbG= rgbCh1[1]; sbB= rgbCh1[2]; tSlide= uv_out;
// UV colour
05533
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05534
uvcol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05535
05536
if
(i==6)
05537
{ LedShannelFlag_on_off =
true
;
05538
if
(bitRead(LedShannelStatusByte,6) ==
false
) {cy_out=0; LedShannelFlag_on_off =
false
; }
05539
sbR= rgbCh0[0]; sbG= rgbCh0[1]; sbB= rgbCh0[2]; tSlide= cy_out ;
// CY colour
05540
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05541
cycol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05542
05543
if
(i==7)
05544
{ LedShannelFlag_on_off =
true
;
05545
if
(bitRead(LedShannelStatusByte,7) ==
false
) {yel_out=0; LedShannelFlag_on_off =
false
; }
05546
sbR= rgbCh7[0]; sbG= rgbCh7[1]; sbB= rgbCh7[2]; tSlide= yel_out;
// Yellow colour
05547
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05548
yelcol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05549
05550
if
(i==8)
05551
{ sbR= rgbCh8[0]; sbG= rgbCh8[1]; sbB= rgbCh8[2]; tSlide= map (moon_out, 0, 255, 0, 100);
// MOON colour
05552
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05553
mooncol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05554
}
05555
LedShannelFlag_on_off =
true
;
05556
}
05557
05558
05559
void
PresetLedScreen(boolean refreshPresetscreen =
false
)
05560
{
05561
if
(refreshPresetscreen ==
true
)
05562
{
05563
myGLCD.setColor(0, 0, 0);
05564
myGLCD.fillRect(0, 0, 319, 15);
// clear only header
05565
setFont(SMALL, 255, 255, 255, 0, 0, 0);
05566
// myGLCD.print("TV DR CW BL RBL UV CY YE Moon", 15, 15);
05567
PrintStringIndex=3;
// print string from Flash
05568
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Header_Text_table[PrintStringIndex])));
// print string number 3 from flash
05569
myGLCD.print(buffer, 15+18, 15 );
05570
myGLCD.print(
" "
, 300, 15);
// clean last text (Moon)
05571
calculateStopTime() ;
05572
TopSldY=53; BotSldY=TopSldY+100;
05573
05574
for
(
byte
b=0; b<8; b++)
//UP Buttons
05575
{ drawUpButtonSlide((b*35)+4+18, TopSldY-26);}
05576
for
(
byte
b=0; b<8; b++)
//DOWN Buttons
05577
{ drawDownButtonSlide((b*35)+4+18, TopSldY+115);}
05578
05579
temp_sector= min_cnt/15;
// read current time sector only first time
05580
05581
for
(
byte
i=0; i<8; i++)
// draw white bar outline rectangle
05582
{ sbX1=(i*35)+4+18; sbX2=(i*35)+34+18;
05583
setFont(SMALL, 255, 255, 255, 0, 0, 0);
05584
myGLCD.drawRect(sbX1, TopSldY-1, sbX2, BotSldY);}
05585
}
05586
05587
SliderSwitch =
true
;
05588
05589
if
((GlobalStatus2Byte & 0x0F) ==0 ) {
// no preset
05590
tvcol_out =0;
// TV colour
05591
rcol_out =0;
// DR colour
05592
wcol_out =0;
// CW colour
05593
bcol_out =0;
// BL colour
05594
rbcol_out =0;
// RBL colour
05595
uvcol_out =0;
// UV colour
05596
cycol_out =0;
// CY colour
05597
yelcol_out =0;
// Yellow colour
05598
colorLEDtest =
false
;
05599
}
05600
05601
for
(
byte
i=0; i<8; i++)
//print Slider Bar current values
05602
{
05603
sbX1=(i*35)+4+18; sbX2=(i*35)+34+18;
05604
if
(i==0)
05605
{ LedShannelFlag_on_off =
true
;
05606
if
(bitRead(LedShannelStatusByte,5) ==
false
) {tvcol_out=0; LedShannelFlag_on_off =
false
; }
05607
sbR= rgbCh6[0]; sbG= rgbCh6[1]; sbB= rgbCh6[2]; tSlide= tvcol_out;
// TV colour
05608
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05609
tvcol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05610
05611
if
(i==1)
05612
{ LedShannelFlag_on_off =
true
;
05613
if
(bitRead(LedShannelStatusByte,3) ==
false
) {rcol_out=0; LedShannelFlag_on_off =
false
; }
05614
sbR= rgbCh5[0]; sbG= rgbCh5[1]; sbB= rgbCh5[2]; tSlide= rcol_out;
// DR colour
05615
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05616
rcol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05617
05618
if
(i==2)
05619
{ LedShannelFlag_on_off =
true
;
05620
if
(bitRead(LedShannelStatusByte,0) ==
false
) {wcol_out=0; LedShannelFlag_on_off =
false
; }
05621
sbR= rgbCh2[0]; sbG= rgbCh2[1]; sbB= rgbCh2[2]; tSlide= wcol_out;
// CW colour
05622
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05623
wcol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05624
05625
if
(i==3)
05626
{ LedShannelFlag_on_off =
true
;
05627
if
(bitRead(LedShannelStatusByte,1) ==
false
) {bcol_out=0; LedShannelFlag_on_off =
false
; }
05628
sbR= rgbCh4[0]; sbG= rgbCh4[1]; sbB= rgbCh4[2]; tSlide= bcol_out;
// BL colour
05629
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05630
bcol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05631
05632
if
(i==4)
05633
{ LedShannelFlag_on_off =
true
;
05634
if
(bitRead(LedShannelStatusByte,2) ==
false
) {rbcol_out=0; LedShannelFlag_on_off =
false
; }
05635
sbR= rgbCh3[0]; sbG= rgbCh3[1]; sbB= rgbCh3[2]; tSlide = rbcol_out;
// RBL colour
05636
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05637
rbcol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05638
05639
if
(i==5)
05640
{ LedShannelFlag_on_off =
true
;
05641
if
(bitRead(LedShannelStatusByte,4) ==
false
) {uvcol_out=0; LedShannelFlag_on_off =
false
; }
05642
sbR= rgbCh1[0]; sbG= rgbCh1[1]; sbB= rgbCh1[2]; tSlide= uvcol_out;
// UV colour
05643
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05644
uvcol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05645
05646
if
(i==6)
05647
{ LedShannelFlag_on_off =
true
;
05648
if
(bitRead(LedShannelStatusByte,6) ==
false
) {cycol_out=0; LedShannelFlag_on_off =
false
; }
05649
sbR= rgbCh0[0]; sbG= rgbCh0[1]; sbB= rgbCh0[2]; tSlide= cycol_out ;
// CY colour
05650
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05651
cycol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05652
05653
if
(i==7)
05654
{ LedShannelFlag_on_off =
true
;
05655
if
(bitRead(LedShannelStatusByte,7) ==
false
) {yelcol_out=0; LedShannelFlag_on_off =
false
; }
05656
sbR= rgbCh7[0]; sbG= rgbCh7[1]; sbB= rgbCh7[2]; tSlide= yelcol_out;
// Yellow colour
05657
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
05658
yelcol_out = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
05659
}
05660
LedShannelFlag_on_off =
true
;
05661
LED_levels_output();
// send calculated value to PWM
05662
05663
if
(refreshPresetscreen ==
true
)
05664
{
05665
myGLCD.setColor(64, 64, 64);
//Draw Dividers in Grey
05666
myGLCD.drawRect(0, 196, 319, 194);
//Bottom Horizontal Divider
05667
printButton(
"<< BACK"
, back[0], back[1], back[2], back[3], SMALL);
05668
printButton(
"SAVE"
, prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3], SMALL);
05669
printButton(
"CANCEL"
, canC[0], canC[1], canC[2], canC[3], SMALL);
05670
05671
if
(bitRead(GlobalStatus2Byte,0)== 1){printButton(
"Preset 1"
, LedPres1[0], LedPres1[1], LedPres1[2], LedPres1[3], SMALL, GREEN_BAC);}
// ON preset
05672
else
{printButton(
"Preset 1"
, LedPres1[0], LedPres1[1], LedPres1[2], LedPres1[3], SMALL);}
// OFF preset
05673
if
(bitRead(GlobalStatus2Byte,1)== 1){printButton(
"Preset 2"
, LedPres2[0], LedPres2[1], LedPres2[2], LedPres2[3], SMALL, GREEN_BAC);}
// ON preset
05674
else
{printButton(
"Preset 2"
, LedPres2[0], LedPres2[1], LedPres2[2], LedPres2[3], SMALL);}
// OFF preset
05675
if
(bitRead(GlobalStatus2Byte,2)== 1){printButton(
"Preset 3"
, LedPres3[0], LedPres3[1], LedPres3[2], LedPres3[3], SMALL, GREEN_BAC);}
// ON preset
05676
else
{printButton(
"Preset 3"
, LedPres3[0], LedPres3[1], LedPres3[2], LedPres3[3], SMALL);}
// OFF preset
05677
if
(bitRead(GlobalStatus2Byte,3)== 1){printButton(
"Preset 4"
, LedPres4[0], LedPres4[1], LedPres4[2], LedPres4[3], SMALL, GREEN_BAC);}
// ON preset
05678
else
{printButton(
"Preset 4"
, LedPres4[0], LedPres4[1], LedPres4[2], LedPres4[3], SMALL);}
// OFF preset
05679
05680
}
05681
}
05682
05683
05684
void
SaveAndExit ()
05685
{
05686
myGLCD.setColor(255, 255, 255);
05687
myGLCD.drawRoundRect(1, 53, 318, 153);
05688
myGLCD.setColor(100, 100, 100);
05689
myGLCD.fillRoundRect(2, 54, 317, 152);
05690
setFont(LARGE, 255, 255, 255, 100, 100, 100);
05691
// myGLCD.print("Do you want to save", 7, 63);
05692
// myGLCD.print("changes", 104, 83);
05693
// myGLCD.print("before exit?", 64, 103);
05694
for
(
int
PrintStringIndex = 0; PrintStringIndex <3; PrintStringIndex++)
05695
{ strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Header_Text_table[PrintStringIndex])));
05696
myGLCD.print(buffer, 7, 63+PrintStringIndex*20); }
05697
printButton(
"YES"
, Yes[0], Yes[1], Yes[2], Yes[3], SMALL);
05698
printButton(
"NO"
, No[0], No[1], No[2], No[3], SMALL);
05699
05700
// DisplayTimeSector(temp_sector);
05701
tv_out = tvled[temp_sector];
// read setting from buffer
05702
b_out = bled[temp_sector];
05703
w_out = wled[temp_sector];
05704
rb_out = rbled[temp_sector];
05705
r_out = rled[temp_sector];
05706
uv_out = uvled[temp_sector];
05707
cy_out = cyled[temp_sector];
05708
yel_out = yeled[temp_sector];
05709
05710
// check if channel on or off
05711
if
(bitRead(LedShannelStatusByte,0) ==
false
) {w_out=0;}
05712
if
(bitRead(LedShannelStatusByte,1) ==
false
) {b_out=0;}
05713
if
(bitRead(LedShannelStatusByte,2) ==
false
) {rb_out=0;}
05714
if
(bitRead(LedShannelStatusByte,3) ==
false
) {r_out=0;}
05715
if
(bitRead(LedShannelStatusByte,4) ==
false
) {uv_out=0;}
05716
if
(bitRead(LedShannelStatusByte,5) ==
false
) {tv_out=0;}
05717
if
(bitRead(LedShannelStatusByte,6) ==
false
) {cy_out=0;}
05718
if
(bitRead(LedShannelStatusByte,7) ==
false
) {yel_out=0;}
05719
05720
}
05721
05722
/******** SHOW LED COLOR CHOICES SCREEN ******* dispScreen = 7 ************************/
05723
void
ledColorViewScreen()
// print led & moon colour buttons
05724
{
05725
//ReadLedFromEEPROM(); //#oleg new read with convert 0-255 to 0%-100%
05726
// printHeader("Individual LED Outputs: Color Choices");
05727
PrintStringIndex=20;
05728
printHeader ();
05729
05730
myGLCD.setColor(64, 64, 64);
//Draw Dividers in Grey
05731
myGLCD.drawRect(0, 196, 319, 194);
//Bottom Horizontal Divider
05732
printButton(
"<< BACK"
, back[0], back[1], back[2], back[3], SMALL);
05733
printButton(
"CANCEL"
, canC[0], canC[1], canC[2], canC[3], SMALL);
05734
// first column
05735
myGLCD.setColor(rgbCh6[0], rgbCh6[1], rgbCh6[2]);
05736
myGLCD.fillRoundRect(10, 20, 150, 45);
//button size 25x140, vertical clearens 10pix
05737
setFont(SMALL, 0, 0, 0, rgbCh6[0], rgbCh6[1], rgbCh6[2]);
05738
//myGLCD.print("TrueViolet", 40, 26);
05739
myGLCD.print(ChButName[6], 40, 26);
05740
05741
myGLCD.setColor(rgbCh5[0], rgbCh5[1], rgbCh5[2]);
05742
myGLCD.fillRoundRect(10, 55, 150, 80);
05743
setFont(SMALL, 0, 0, 0, rgbCh5[0], rgbCh5[1], rgbCh5[2]);
05744
//myGLCD.print("DeepRed", 47, 61);
05745
myGLCD.print(ChButName[5], 47, 61);
05746
05747
myGLCD.setColor(rgbCh2[0], rgbCh2[1], rgbCh2[2]);
05748
myGLCD.fillRoundRect(10, 90, 150, 115);
05749
setFont(SMALL, 0, 0, 0, rgbCh2[0], rgbCh2[1], rgbCh2[2]);
05750
//myGLCD.print("White", 60, 96);
05751
myGLCD.print(ChButName[2], 60, 96);
05752
05753
myGLCD.setColor(rgbCh4[0], rgbCh4[1], rgbCh4[2]);
05754
myGLCD.fillRoundRect(10, 125, 150, 150);
05755
setFont(SMALL, 0, 0, 0, rgbCh4[0], rgbCh4[1], rgbCh4[2]);
05756
//myGLCD.print("Blue", 60, 131);
05757
myGLCD.print(ChButName[4], 60, 131);
05758
05759
myGLCD.setColor( rgbCh8[0], rgbCh8[1], rgbCh8[2]);
05760
myGLCD.fillRoundRect(10, 160, 150, 185);
05761
setFont(SMALL, 0, 0, 0, rgbCh8[0], rgbCh8[1], rgbCh8[2]);
// (R,G,B- font colour, R,G,B- fon colour )
05762
//myGLCD.print("Lunar", 60, 166);
05763
myGLCD.print(ChButName[8], 60, 166);
05764
05765
// second column
05766
myGLCD.setColor( rgbCh3[0], rgbCh3[1], rgbCh3[2]);
05767
myGLCD.fillRoundRect(170, 20, 310, 45);
05768
setFont(SMALL, 0, 0, 0, rgbCh3[0], rgbCh3[1], rgbCh3[2]);
05769
//myGLCD.print("Royal Blue", 196, 26);
05770
myGLCD.print(ChButName[3], 196, 26);
05771
05772
myGLCD.setColor(rgbCh1[0], rgbCh1[1], rgbCh1[2]);
05773
myGLCD.fillRoundRect(170, 55, 310, 80);
05774
setFont(SMALL, 0, 0, 0, rgbCh1[0], rgbCh1[1], rgbCh1[2]);
05775
//myGLCD.print("UltraViolet", 196, 61);
05776
myGLCD.print(ChButName[1], 196, 61);
05777
05778
myGLCD.setColor(rgbCh0[0], rgbCh0[1], rgbCh0[2]);
05779
myGLCD.fillRoundRect(170, 90, 310, 115);
05780
setFont(SMALL, 0, 0, 0, rgbCh0[0], rgbCh0[1], rgbCh0[2]);
05781
//myGLCD.print("Cyan", 220, 96);
05782
myGLCD.print(ChButName[0], 220, 96);
05783
05784
myGLCD.setColor(rgbCh7[0], rgbCh7[1], rgbCh7[2]);
05785
myGLCD.fillRoundRect(170, 125, 310, 150);
05786
setFont(SMALL, 0, 0, 0, rgbCh7[0], rgbCh7[1], rgbCh7[2]);
05787
//myGLCD.print("Yellow", 215, 131);
05788
myGLCD.print(ChButName[7], 215, 131);
05789
05790
myGLCD.setColor(200, 200, 200);
05791
myGLCD.fillRoundRect(170, 160, 310, 185);
05792
setFont(SMALL, 0, 0, 0, 200, 200, 200);
05793
//myGLCD.print("Curves Colors", 191, 166);
05794
myGLCD.print(ChButName[9], 191, 166);
05795
05796
myGLCD.setColor(255, 255, 255);
// draw button white border
05797
for
(
int
x=0; x<2; x++)
05798
{
for
(
int
y=0; y<5; y++)
05799
{ myGLCD.drawRoundRect((x*160)+10, (y*35)+20, (x*160)+150, (y*35)+45); }
05800
}
05801
//myGLCD.drawRoundRect(10, 160, 150, 185); // lunar button
05802
}
05803
/************************** END OF LED COLOR CHOICES SCREEN ***************************/
05804
05805
05806
/****** SHOW LED VALUES FOR CHOICE SCREEN ********** dispScreen = 8 *******************/
05807
void
ledValuesScreen()
//print TOP NAME bar & horisontal buttons, with timetable 12x8
05808
{
05809
myGLCD.setColor(0, 0, 0);
05810
myGLCD.fillRect(0, 0, 319, 15);
// clear only header
05811
05812
if
(COLOR==1) {
05813
for
(
byte
i=0; i<96; i++)
05814
{tled[i] = wled[i]; sbR= rgbCh2[0]; sbG= rgbCh2[1]; sbB= rgbCh2[2]; }}
05815
if
(COLOR==2) {
05816
for
(
byte
i=0; i<96; i++)
05817
{tled[i]=bled[i]; sbR= rgbCh4[0]; sbG= rgbCh4[1]; sbB= rgbCh4[2];}}
05818
if
(COLOR==3) {
05819
for
(
byte
i=0; i<96; i++)
05820
{tled[i] = rbled[i]; sbR= rgbCh3[0]; sbG= rgbCh3[1]; sbB= rgbCh3[2];}}
05821
if
(COLOR==4) {
05822
for
(
byte
i=0; i<96; i++)
05823
{tled[i] = rled[i]; sbR= rgbCh5[0]; sbG= rgbCh5[1]; sbB= rgbCh5[2];}}
05824
if
(COLOR==5) {
05825
for
(
byte
i=0; i<96; i++)
05826
{tled[i] = uvled[i]; sbR= rgbCh1[0]; sbG= rgbCh1[1]; sbB= rgbCh1[2];}}
05827
if
(COLOR==6) {
05828
for
(
byte
i=0; i<96; i++)
05829
{tled[i] = tvled[i]; sbR= rgbCh6[0]; sbG= rgbCh6[1]; sbB= rgbCh6[2];}}
05830
if
(COLOR==8) {
05831
for
(
byte
i; i<96; i++)
05832
{tled[i] = cyled[i]; sbR= rgbCh0[0]; sbG= rgbCh0[1]; sbB= rgbCh0[2];}}
05833
if
(COLOR==9) {
05834
for
(
byte
i=0; i<96; i++)
05835
{tled[i] = yeled[i]; sbR= rgbCh7[0]; sbG= rgbCh7[1]; sbB= rgbCh7[2];}}
05836
05837
ReadOnOffLedStatus();
05838
myGLCD.setColor(255, 255, 255);
//draw white border
05839
myGLCD.drawRoundRect(110, 0, 201, 17);
05840
myGLCD.setColor(0, 0, 255);
//print on/off button
05841
myGLCD.fillRoundRect(111, 1, 200, 16);
05842
setFont(SMALL, 255, 255, 255, 0, 0, 255 );
05843
if
(LedShannelFlag_on_off ==
true
) { myGLCD.print(
"LED ON"
, 129, 3);}
05844
else
{ myGLCD.print(
"LED OFF"
, 129, 3);}
05845
05846
for
(
byte
i=0; i<=95; i++)
// find START graph Time
05847
{
byte
TEMP=tled[i];
05848
if
(TEMP>0) { StartTime=i-1;
05849
if
(StartTime == 255) {StartTime=0;}
05850
break
; }}
05851
05852
for
(
byte
i=95; i>0; i-- )
// find STOP graph Time
05853
{
byte
TEMP=tled[i];
05854
if
(TEMP>0) {StopTime=i+1;
break
; }}
05855
05856
// byte stepScale = (294 - 26)/(StopTime-StartTime); // 26 and 318 - left / right
05857
drawLedStaticChartP1 ();
// calculate draw TOP ON/OFF time and X/Y border
05858
draw_one_led_graph();
05859
drawLedStaticChartP2 ();
// draw BOT ON/OFF time and X/Y scale and tick mark (15min/30min/1hour)
05860
05861
myGLCD.setColor(64, 64, 64);
05862
myGLCD.drawRect(0, 196, 319, 194);
05863
printButton(
"<< BACK"
, back[0], back[1], back[2], back[3], SMALL);
05864
printButton(
"CHANGE"
, ledChV[0], ledChV[1], ledChV[2], ledChV[3], SMALL);
05865
printButton(
"SAVE"
, eeprom[0], eeprom[1], eeprom[2], eeprom[3]);
05866
}
05867
05868
05869
/*************************** END OF SHOW LED VALUES SCREEN ****************************/
05870
05871
void
MoonPictureScreen()
// print moon picture& table
05872
{
05873
tMinI=MinI;
05874
tMaxI=MaxI;
05875
// printHeader("View/Change Moon LED Min & Max Output");
05876
PrintStringIndex=21;
05877
printHeader ();
05878
setFont(SMALL, 255, 255, 255, 0, 0, 0);
05879
// myGLCD.print("Set Minimum", 36, 20);
05880
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[45])));
05881
myGLCD.print(buffer, 36, 20);
05882
// myGLCD.print("Illumination", 32, 32);
05883
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[46])));
05884
myGLCD.print(buffer, 32, 32);
05885
myGLCD.drawBitmap(52, 47, 58, 58, New_Moon, 1);
//New Moon Picture
05886
// myGLCD.print("(0...100%)", 40, 132);
05887
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[47])));
05888
myGLCD.print(buffer, 40, 132);
05889
myGLCD.print(
"-1"
, 22, 177);
05890
myGLCD.print(
"+1"
, 121, 177);
05891
// myGLCD.print("Set Maximum", 196, 20);
05892
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[48])));
05893
myGLCD.print(buffer, 196, 20);
05894
// myGLCD.print("Illumination", 192, 32);
05895
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[46])));
05896
myGLCD.print(buffer, 192, 32);
05897
myGLCD.drawBitmap(211, 47, 58, 58, Full_Moon, 1);
//Full Moon Picture
05898
// myGLCD.print("(0...100%)", 202, 132);
05899
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[47])));
05900
myGLCD.print(buffer, 202, 132);
05901
myGLCD.print(
"-1"
, 184, 177);
05902
myGLCD.print(
"+1"
, 283, 177);
05903
setFont(SMALL, 176, 176, 176, 0, 0, 0);
05904
// myGLCD.print("New Moon", 48, 108);
05905
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[49])));
05906
myGLCD.print(buffer, 48, 108);
05907
// myGLCD.print("Full Moon", 204, 108);
05908
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[50])));
05909
myGLCD.print(buffer, 204, 108);
05910
05911
setFont(LARGE, 255, 255, 255, 0, 0, 0);
05912
myGLCD.print(
" "
, 55, 152);
05913
if
(tMinI<=9)
05914
{ myGLCD.printNumI(tMinI, 71, 152);}
05915
if
((tMinI>=10)&&(tMinI<=99))
05916
{ myGLCD.printNumI(tMinI, 63, 152);}
05917
if
(tMinI>=100)
05918
{ myGLCD.printNumI(tMinI, 55, 152);}
05919
05920
myGLCD.print(
" "
, 217, 152);
05921
if
(tMaxI<=9)
05922
{ myGLCD.printNumI(tMaxI, 233, 152);}
05923
if
((tMaxI>=10)&&(tMaxI<=99))
05924
{ myGLCD.printNumI(tMaxI, 225, 152);}
05925
if
(tMaxI>=100)
05926
{ myGLCD.printNumI(tMaxI, 217, 152);}
05927
05928
printButton(
"-"
, MINiM[0], MINiM[1], MINiM[2], MINiM[3],
true
);
//Minimum Illum. minus
05929
printButton(
"+"
, MINiP[0], MINiP[1], MINiP[2], MINiP[3],
true
);
//Minimum Illum. plus
05930
printButton(
"-"
, MAXiM[0], MAXiM[1], MAXiM[2], MAXiM[3],
true
);
//Max Illum. minus
05931
printButton(
"+"
, MAXiP[0], MAXiP[1], MAXiP[2], MAXiP[3],
true
);
//Max Illum. plus
05932
05933
myGLCD.setColor(64, 64, 64);
05934
myGLCD.drawRect(158, 14, 160, 194);
05935
myGLCD.drawRect(0, 196, 319, 194);
05936
myGLCD.setColor(0, 0, 0);
05937
myGLCD.drawLine(159, 193, 159, 195);
05938
printButton(
"<< BACK"
, back[0], back[1], back[2], back[3], SMALL);
05939
printButton(
"SAVE"
, prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3], SMALL);
05940
printButton(
"CANCEL"
, canC[0], canC[1], canC[2], canC[3], SMALL);
05941
}
05942
05943
void
MoonChangeScreen()
// + or - led brigtness value ---------
05944
{
05945
if
((x>=MINiM[0]) && (x<=MINiM[2]) && (y>=MINiM[1]) && (y<=MINiM[3]))
//press button "MinI minus"
05946
{
05947
// waitForIt(MINiM[0], MINiM[1], MINiM[2], MINiM[3]); // wait for press button
05948
tMinI -= 1;
05949
if
(tMinI == 255) {tMinI = 100; }
05950
MinI = tMinI;
05951
setFont(LARGE, 255, 255, 255, 0, 0, 0);
05952
myGLCD.print(
" "
, 55, 152);
05953
if
(tMinI<=9)
05954
{ myGLCD.printNumI(tMinI, 71, 152);}
05955
if
((tMinI>=10)&&(tMinI<=99))
05956
{ myGLCD.printNumI(tMinI, 63, 152);}
05957
if
(tMinI>=100)
05958
{ myGLCD.printNumI(tMinI, 55, 152);}
05959
delay(200);
05960
}
else
05961
05962
if
((x>=MINiP[0]) && (x<=MINiP[2]) && (y>=MINiP[1]) && (y<=MINiP[3]))
//press button "MinI plus"
05963
{
05964
// waitForIt(MINiP[0], MINiP[1], MINiP[2], MINiP[3]);
05965
tMinI += 1;
05966
if
(tMinI >100) {tMinI = 0; }
05967
MinI = tMinI;
05968
setFont(LARGE, 255, 255, 255, 0, 0, 0);
05969
myGLCD.print(
" "
, 55, 152);
05970
if
(tMinI<=9)
05971
{ myGLCD.printNumI(tMinI, 71, 152);}
05972
if
((tMinI>=10)&&(tMinI<=99))
05973
{ myGLCD.printNumI(tMinI, 63, 152);}
05974
if
(tMinI>=100)
05975
{ myGLCD.printNumI(tMinI, 55, 152);}
05976
delay(200);
05977
}
else
05978
05979
if
((x>=MAXiM[0]) && (x<=MAXiM[2]) && (y>=MAXiM[1]) && (y<=MAXiM[3]))
//press buton "MaxI minus"
05980
{
05981
// waitForIt(MAXiM[0], MAXiM[1], MAXiM[2], MAXiM[3]);
05982
tMaxI -= 1;
05983
if
(tMaxI == 255) { tMaxI = 100; }
05984
MaxI = tMaxI;
05985
setFont(LARGE, 255, 255, 255, 0, 0, 0);
05986
myGLCD.print(
" "
, 217, 152);
05987
if
(tMaxI<=9)
05988
{ myGLCD.printNumI(tMaxI, 233, 152);}
05989
if
((tMaxI>=10)&&(tMaxI<=99))
05990
{ myGLCD.printNumI(tMaxI, 225, 152);}
05991
if
(tMaxI>=100)
05992
{ myGLCD.printNumI(tMaxI, 217, 152);}
05993
delay(200);
05994
}
else
05995
if
((x>=MAXiP[0]) && (x<=MAXiP[2]) && (y>=MAXiP[1]) && (y<=MAXiP[3]))
//press button "MaxI plus"
05996
{
05997
// waitForIt(MAXiP[0], MAXiP[1], MAXiP[2], MAXiP[3]);
05998
tMaxI += 1;
05999
if
(tMaxI >100) {tMaxI = 0; }
06000
MaxI = tMaxI;
06001
setFont(LARGE, 255, 255, 255, 0, 0, 0);
06002
myGLCD.print(
" "
, 217, 152);
06003
if
(tMaxI<=9)
06004
{ myGLCD.printNumI(tMaxI, 233, 152);}
06005
if
((tMaxI>=10)&&(tMaxI<=99))
06006
{ myGLCD.printNumI(tMaxI, 225, 152);}
06007
if
(tMaxI>=100)
06008
{ myGLCD.printNumI(tMaxI, 217, 152);}
06009
delay(200);
06010
}
06011
}
06012
06013
/********** CHANGE LED VALUES SCREEN ********** dispScreen = 9 ************************/
06014
void
ledChangeScreen()
//print TOP timetable & Vertical buttons, w/o slider
06015
{
06016
if
(COLOR==1)
06017
{ PrintStringIndex=4;
06018
printHeader ();
06019
//printHeader("Change White LED Output Values");
06020
sbR= rgbCh2[0]; sbG= rgbCh2[1]; sbB= rgbCh2[2]; }
06021
if
(COLOR==2)
06022
{ PrintStringIndex=4;
//5;
06023
printHeader ();
06024
// printHeader("Change Blue LED Output Values");
06025
sbR= rgbCh4[0]; sbG= rgbCh4[1]; sbB= rgbCh4[2]; }
06026
if
(COLOR==3)
06027
{ PrintStringIndex=4;
//6;
06028
printHeader ();
06029
// printHeader("Change Royal Blue LED Output Values");
06030
sbR= rgbCh3[0]; sbG= rgbCh3[1]; sbB= rgbCh3[2]; }
06031
if
(COLOR==4)
06032
{ PrintStringIndex=4;
//7;
06033
printHeader ();
06034
// printHeader("Change Red LED Output Values");
06035
sbR= rgbCh5[0]; sbG= rgbCh5[1]; sbB= rgbCh5[2]; }
06036
if
(COLOR==5)
06037
{ PrintStringIndex=4;
//8;
06038
printHeader ();
06039
// printHeader("Change UltraViolet LED Output Values");
06040
sbR= rgbCh1[0]; sbG= rgbCh1[1]; sbB= rgbCh1[2]; }
06041
if
(COLOR==6)
06042
{ PrintStringIndex=4;
// 9;
06043
printHeader ();
06044
// printHeader("Change TrueViolet LED Output Values");
06045
sbR= rgbCh6[0]; sbG= rgbCh6[1]; sbB= rgbCh6[2]; }
06046
if
(COLOR==8)
06047
{ PrintStringIndex=4;
//10;
06048
printHeader ();
06049
// printHeader("Change Cyan LED Output Values");
06050
sbR=rgbCh0[0]; sbG=rgbCh0[1]; sbB= rgbCh0[2];}
06051
if
(COLOR==9)
06052
{ PrintStringIndex=4;
//11;
06053
printHeader ();
06054
// printHeader("Change Yellow LED Output Values");
06055
sbR= rgbCh7[0]; sbG= rgbCh7[1]; sbB= rgbCh7[2]; }
06056
06057
setFont(SMALL, 0, 255, 255, 0,0,0);
//Top time selector bar
06058
for
(
int
i=0; i<12; i++) {
06059
myGLCD.setColor(0, 255, 255);
06060
if
(i<5) {
06061
myGLCD.printNumI((i*2), (i*26)+15, 17);
06062
myGLCD.printNumI(((i*2)+1), (i*26)+15, 28);}
06063
else
{
06064
myGLCD.printNumI((i*2), (i*26)+11, 17);
06065
myGLCD.printNumI(((i*2)+1), (i*26)+11, 28);}
06066
myGLCD.setColor(100, 100, 100);
06067
myGLCD.drawRect((i*26)+4, 16 , (i*26)+30, 41);
06068
}
06069
06070
06071
myGLCD.setColor(0, 0, 0);
// clear bottom time|date bar
06072
myGLCD.fillRect(1, 226, 318, 240);
06073
06074
myGLCD.drawRect(4, 43, 30, 223);
//left menu bar
06075
myGLCD.setColor(0, 0, 255);
06076
myGLCD.fillRoundRect(8, 66, 26, 140);
//OK Button (long)
06077
myGLCD.fillRoundRect(8, 145, 26, 219);
06078
myGLCD.setColor(255, 255, 255);
06079
myGLCD.drawRoundRect(8, 66, 26, 140);
//OK Button (long)
06080
myGLCD.drawRoundRect(8, 145, 26, 219);
//CANCEL Button
06081
06082
setFont(SMALL, 255, 255, 255, 0, 0, 255);
06083
myGLCD.print(
"O"
, 14, 91);
06084
myGLCD.print(
"K"
, 14, 101);
06085
06086
myGLCD.print(
"C"
, 14, 152);
06087
myGLCD.print(
"A"
, 14, 162);
06088
myGLCD.print(
"N"
, 14, 172);
06089
myGLCD.print(
"C"
, 14, 182);
06090
myGLCD.print(
"E"
, 14, 192);
06091
myGLCD.print(
"L"
, 14, 202);
06092
06093
setFont(SMALL, 255, 0, 0, 0, 0, 0);
06094
// myGLCD.print("Make a selection above. Choose", 57, 110);
06095
// myGLCD.print("any Two-Hour Increment", 89, 122);
06096
// myGLCD.print("then you can adjust values.", 73, 134);
06097
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Header_Text_table[12])));
06098
myGLCD.print(buffer, 57, 110 );
06099
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Header_Text_table[13])));
06100
myGLCD.print(buffer, 89, 122 );
06101
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Header_Text_table[14])));
06102
myGLCD.print(buffer, 73, 134 );
06103
}
06104
/*************************** END OF CHANGE LED VALUES SCREEN **************************/
06105
06106
/*************************** Preset Function ******************************************/
06107
void
PresetSwitch ()
06108
{
06109
calculateStopTime() ;
06110
switch
((GlobalStatus2Byte & 0x0F)) {
06111
case
0:
06112
printButton(
"Preset 1 ON"
, prsM[0],prsM[1],prsM[2],prsM[3], SMALL, GREEN_BAC);
06113
GlobalStatus2Byte = (GlobalStatus2Byte & 0xF0 | 0x1);
06114
AddressShift = 0;
06115
ReadLEDPresetFromEEPROM();
06116
colorLEDtest =
true
;
06117
digitalWrite(PowerSwitch2, LOW);
// ON led driver
06118
break
;
06119
06120
case
1:
06121
printButton(
"Preset 2 ON"
, prsM[0],prsM[1],prsM[2],prsM[3], SMALL, GREEN_BAC);
06122
GlobalStatus2Byte = (GlobalStatus2Byte & 0xF0 | 0x2);
06123
AddressShift = 9;
06124
ReadLEDPresetFromEEPROM();
06125
colorLEDtest =
true
;
06126
digitalWrite(PowerSwitch2, LOW);
// ON led driver
06127
break
;
06128
06129
case
2:
06130
printButton(
"Preset 3 ON"
, prsM[0],prsM[1],prsM[2],prsM[3], SMALL, GREEN_BAC);
06131
GlobalStatus2Byte = (GlobalStatus2Byte & 0xF0 | 0x4);
06132
AddressShift = 18;
06133
ReadLEDPresetFromEEPROM();
06134
colorLEDtest =
true
;
06135
digitalWrite(PowerSwitch2, LOW);
// ON led driver
06136
break
;
06137
06138
case
4:
06139
printButton(
"Preset 4 ON"
, prsM[0],prsM[1],prsM[2],prsM[3], SMALL, GREEN_BAC);
06140
GlobalStatus2Byte = (GlobalStatus2Byte & 0xF0 | 0x8);
06141
AddressShift = 27;
06142
ReadLEDPresetFromEEPROM();
06143
colorLEDtest =
true
;
06144
digitalWrite(PowerSwitch2, LOW);
// ON led driver
06145
break
;
06146
06147
case
8:
06148
printButton(
"Preset OFF"
, prsM[0],prsM[1],prsM[2],prsM[3], SMALL);
06149
GlobalStatus2Byte = (GlobalStatus2Byte & 0xF0);
06150
colorLEDtest =
false
;
06151
if
((min_cnt/15 >= StartTime-1) && (min_cnt/15 <= StopTime))
06152
{digitalWrite(PowerSwitch2, LOW);}
//ON driver before StartTime - 15min
06153
else
{digitalWrite(PowerSwitch2, HIGH);}
//OFF driver before StartTime
06154
break
;
06155
}
06156
}
06157
06158
/************ WAVEMAKER SCREEN **************** dispScreen = 10 ***********************/
06159
/*
06160
void WaveMakerButtons()
06161
{
06162
myGLCD.setColor(255, 0, 0);
06163
myGLCD.fillRoundRect(5, 20, 155, 40); //Alternating Mode Button
06164
myGLCD.fillRoundRect(165, 20, 315, 40); //Synchronous Mode Button
06165
myGLCD.fillRoundRect(5, 46, 155, 66); //Feeding Mode Button
06166
myGLCD.fillRoundRect(165, 46, 315, 66); //Turn Pumps ON/OFF Button
06167
setFont(SMALL, 255, 255, 255, 255, 0, 0);
06168
myGLCD.print("Alternating Mode", 16, 24);
06169
myGLCD.print("Synchronous Mode", 176, 24);
06170
myGLCD.print("Feeding Mode", 32, 50);
06171
myGLCD.print("Turn Pumps OFF", 184, 50);
06172
}
06173
06174
void WaveMakerScreen()
06175
{
06176
// printHeader("View/Change Wavemaker Settings");
06177
PrintStringIndex=22;
06178
printHeader ();
06179
06180
myGLCD.setColor(64, 64, 64); //Draw Dividers in Grey
06181
myGLCD.drawRect(0, 70, 319, 72); //Top Horizontal Divider
06182
myGLCD.drawRect(0, 196, 319, 194); //Bottom Horizontal Divider
06183
printButton("<< BACK", back[0], back[1], back[2], back[3], SMALL);
06184
printButton("CANCEL", canC[0], canC[1], canC[2], canC[3], SMALL);
06185
06186
setFont(LARGE, 255, 255, 255, 0, 0, 0);
06187
myGLCD.print("Current Status:", CENTER, 80);
06188
}
06189
06190
void viewWaveTimes()
06191
{
06192
setFont(SMALL, 0, 255, 0, 0, 0, 0);
06193
int dynamicXm=135;
06194
if ((MIN1<=99) && (MIN1>=10)) {dynamicXm+=8;}
06195
if (MIN1<=9) {dynamicXm+=16;}
06196
myGLCD.printNumI(MIN1, dynamicXm, minY1);
06197
int dynamicXs=231;
06198
if (SEC1<=9) {dynamicXs+=8;}
06199
myGLCD.printNumI(SEC1, dynamicXs, minY1);
06200
dynamicXm=135;
06201
if ((MIN2<=99) && (MIN2>=10)) {dynamicXm+=8;}
06202
if (MIN2<=9) {dynamicXm+=16;}
06203
myGLCD.printNumI(MIN2, dynamicXm, minY2);
06204
dynamicXs=231;
06205
if (SEC2<=9) {dynamicXs+=8;}
06206
myGLCD.printNumI(SEC2, dynamicXs, minY2);
06207
}
06208
06209
void WaveMakerStatusScreen()
06210
{
06211
myGLCD.setColor(0, 0, 0); //Clear Status Area
06212
myGLCD.fillRect( 1, 96, 318, 193);
06213
06214
WaveMakerButtons();
06215
06216
if (WAVE==0)
06217
{
06218
setFont(LARGE, 255, 0, 0, 0, 0, 0);
06219
myGLCD.print("No Mode Saved!", CENTER, 100);
06220
setFont(SMALL, 255, 0, 0, 0, 0, 0);
06221
myGLCD.print("Make a selection above. Choose", CENTER, 130);
06222
myGLCD.print("either Alternating or Synchronous", CENTER, 142);
06223
myGLCD.print("then save your settings.", CENTER, 154);
06224
} else
06225
06226
if (WAVE==1)
06227
{
06228
myGLCD.setColor(0, 255, 0);
06229
myGLCD.fillRoundRect(5, 20, 155, 40);
06230
setFont(SMALL, 0, 0, 0, 0, 255, 0);
06231
myGLCD.print("Alternating Mode", 16, 24);
06232
myGLCD.setColor(255, 255, 255);
06233
myGLCD.drawRoundRect(5, 20, 155, 40);
06234
06235
setFont(LARGE, 0, 255, 0, 0, 0, 0);
06236
myGLCD.print("Alternating Flow", CENTER, 100);
06237
06238
myGLCD.print("Pump1->", 15, 140);
06239
myGLCD.print("min", 167, 140);
06240
myGLCD.print("sec", 255, 140);
06241
myGLCD.print("Pump2->", 15, 160);
06242
myGLCD.print("min", 167, 160);
06243
myGLCD.print("sec", 255, 160);
06244
06245
MIN1=Pump1m, SEC1=Pump1s, MIN2=Pump2m, SEC2=Pump2s;
06246
minY1=144, minY2=164;
06247
viewWaveTimes();
06248
} else
06249
06250
06251
if (WAVE==2)
06252
{
06253
myGLCD.setColor(0, 255, 0);
06254
myGLCD.fillRoundRect(165, 20, 315, 40);
06255
setFont(SMALL, 0, 0, 0, 0, 255, 0);
06256
myGLCD.print("Synchronous Mode", 176, 24);
06257
myGLCD.setColor(255, 255, 255);
06258
myGLCD.drawRoundRect(165, 20, 315, 40);
06259
06260
setFont(LARGE, 0, 255, 0, 0, 0, 0);
06261
myGLCD.print("Synchronous Flow", CENTER, 100);
06262
06263
if (Synch==1)
06264
{
06265
myGLCD.print("Constantly ON", CENTER, 116);
06266
setFont(SMALL, 255, 0, 0, 0, 0, 0);
06267
myGLCD.print("Both powerheads are ON constantly.", CENTER, 144);
06268
myGLCD.print("To change to Pulsating Mode, push", CENTER, 156);
06269
myGLCD.print("the Synchronous Mode button above", CENTER, 168);
06270
}
06271
if (Synch==2)
06272
{
06273
myGLCD.print("Pulsating Mode", CENTER, 116);
06274
06275
myGLCD.print("ON for", 15, 146);
06276
myGLCD.print("min", 167, 146);
06277
myGLCD.print("sec", 255, 146);
06278
myGLCD.print("OFF for", 15, 166);
06279
myGLCD.print("min", 167, 166);
06280
myGLCD.print("sec", 255, 166);
06281
06282
MIN1=OnForTm, SEC1=OnForTs, MIN2=OffForTm, SEC2=OffForTs;
06283
minY1=150, minY2=170;
06284
viewWaveTimes();
06285
}
06286
} else
06287
06288
06289
if (WAVE==3)
06290
{
06291
myGLCD.setColor(0, 255, 0);
06292
myGLCD.fillRoundRect(165, 46, 315, 66);
06293
setFont(SMALL, 0, 0, 0, 0, 255, 0);
06294
myGLCD.print("Turn Pumps ON", 188, 50);
06295
myGLCD.setColor(255, 255, 255);
06296
myGLCD.drawRoundRect(165, 46, 315, 66);
06297
06298
setFont(LARGE, 0, 255, 0, 0, 0, 0);
06299
myGLCD.print("Powerheads are OFF", CENTER, 100);
06300
setFont(SMALL, 0, 255, 0, 0, 0, 0);
06301
myGLCD.print("To turn the powerheads back ON", CENTER, 125);
06302
if (MODE==1) { myGLCD.print("and resume in Alternating Mode,", CENTER, 137);} else
06303
if (MODE==2) { myGLCD.print("and resume in Synchronous Mode,", CENTER, 137);}
06304
myGLCD.print("push the Turn Pumps ON button above", CENTER, 149);
06305
06306
waveMakerOff=true;
06307
digitalWrite(WaveMakerTop, LOW);
06308
digitalWrite(WaveMakerBottom, LOW);
06309
}
06310
06311
myGLCD.setColor(255, 255, 255);
06312
for (int x=0; x<2; x++)
06313
{ for (int y=0; y<2; y++)
06314
{ myGLCD.drawRoundRect((x*160)+5, (y*26)+20, (x*160)+155, (y*26)+40); }
06315
}
06316
06317
if (WAVE==4)
06318
{
06319
myGLCD.setColor(0, 255, 0);
06320
myGLCD.fillRoundRect(5, 46, 155, 66);
06321
setFont(SMALL, 0, 0, 0, 0, 255, 0);
06322
myGLCD.print("Feeding Mode", 32, 50);
06323
myGLCD.setColor(255, 255, 255);
06324
for (int x=0; x<2; x++)
06325
{ for (int y=0; y<2; y++)
06326
{ myGLCD.drawRoundRect((x*160)+5, (y*26)+20, (x*160)+155, (y*26)+40); }
06327
}
06328
06329
setFont(LARGE, 0, 255, 0, 0, 0, 0);
06330
myGLCD.print("Feeding", CENTER, 100);
06331
setFont(SMALL, 0, 255, 0, 0, 0, 0);
06332
myGLCD.print("Powerheads will remain OFF", CENTER, 125);
06333
myGLCD.print("for 5 minutes", CENTER, 137);
06334
if (MODE==1) { myGLCD.print("Alternating Mode will resume in:", CENTER, 155);} else
06335
if (MODE==2) { myGLCD.print("Synchronous Mode will resume in:", CENTER, 155);}
06336
06337
waveMakerOff=true;
06338
digitalWrite(WaveMakerTop, LOW);
06339
digitalWrite(WaveMakerBottom, LOW);
06340
}
06341
while (WAVE==4)
06342
{
06343
unsigned long currentMillis = millis();
06344
06345
if (myTouch.dataAvailable())
06346
{ processMyTouch();}
06347
06348
if(currentMillis - previousMillisCt >= intervalCt)
06349
{
06350
previousMillisCt = currentMillis;
06351
if(countDown>=0)
06352
{
06353
if (countDown<=30)
06354
{ myGLCD.setColor(0, 0, 0);
06355
myGLCD.fillRect(128, 173, 192, 189);}
06356
MIN_O= (countDown / 60) % 10;
06357
SEC_T= (countDown % 60) / 10;
06358
SEC_O= (countDown % 60) % 10;
06359
setFont(LARGE, 255, 0, 0, 0, 0, 0);
06360
myGLCD.printNumI(MIN_O, 128, 173);
06361
myGLCD.print(":", 144, 173);
06362
myGLCD.printNumI(SEC_T, 160, 173);
06363
myGLCD.printNumI(SEC_O, 176, 173);
06364
if(countDown==0)
06365
{
06366
WAVE=MODE;
06367
WaveMakerStatusScreen();
06368
}
06369
countDown--;
06370
checkTempC();
06371
TimeDateBar();
06372
}
06373
waveMakerOff=false;
06374
}
06375
}
06376
}
06377
*/
06378
/******************************* END OF WAVEMAKER SCREEN ******************************/
06379
06380
06381
/******** WAVEMAKER SETTINGS SCREEN ************** dispScreen = 11 ********************/
06382
/*
06383
void WaveMakerSettingsScreen()
06384
{
06385
myGLCD.setColor(64, 64, 64); //Draw Dividers in Grey
06386
myGLCD.drawRect(0, 196, 319, 194); //Bottom Horizontal Divider
06387
06388
myGLCD.setColor(0, 0, 255);
06389
myGLCD.fillRoundRect(5, 200, 105, 220); //BACK Button
06390
myGLCD.fillRoundRect(110, 200, 210, 220); //TEST Button
06391
myGLCD.fillRoundRect(215, 200, 315, 220); //SAVE Button
06392
06393
setFont(SMALL, 255, 255, 255, 0, 0, 255);
06394
myGLCD.print("<< BACK", 27, 204);
06395
myGLCD.print("TEST", 144, 204);
06396
myGLCD.print("SAVE", 241, 204);
06397
06398
myGLCD.setColor(255, 255, 255);
06399
for (int x=0; x<3; x++)
06400
{ myGLCD.drawRoundRect((x*105)+5, 200, (x*105)+105, 220); }
06401
06402
06403
setFont(LARGE, 255, 255, 255, 0, 0, 0);
06404
if (WAVE==1)
06405
{
06406
// printHeader("Alternating Flow Mode Settings");
06407
PrintStringIndex=23;
06408
printHeader ();
06409
myGLCD.setColor(64, 64, 64); //Draw Dividers in Grey
06410
myGLCD.drawRect(0, 38, 319, 40); //Top Horizontal Divider
06411
myGLCD.drawRect(0, 115, 319, 117); //Middle Horizontal Divider
06412
setFont(SMALL, 255, 0, 0, 0, 0, 0);
06413
myGLCD.print("Set how long each powerhead will be ON", CENTER, 20);
06414
setFont(SMALL, 0, 255, 0, 0, 0, 0);
06415
myGLCD.print("POWERHEAD 1", CENTER, 50);
06416
myGLCD.print("POWERHEAD 2", CENTER, 127);
06417
setFont(SMALL, 255, 255, 255, 0, 0, 0);
06418
myGLCD.print("Minutes", 57, 100);
06419
myGLCD.print("Seconds", 211, 100);
06420
myGLCD.print("Minutes", 57, 177);
06421
myGLCD.print("Seconds", 211, 177);
06422
06423
Min1=Pump1m, Sec1=Pump1s, Min2=Pump2m, Sec2=Pump2s;
06424
viewWaveTimesPage();
06425
}
06426
06427
if (WAVE==2)
06428
{
06429
// printHeader("Synchronous Flow Mode Settings");
06430
PrintStringIndex=24;
06431
printHeader ();
06432
myGLCD.setColor(64, 64, 64); //Draw Dividers in Grey
06433
myGLCD.drawRect(0, 44, 319, 46); //Top Horizontal Divider
06434
}
06435
}
06436
06437
void synchronousSynch()
06438
{
06439
myGLCD.setColor(0, 0, 0); //Clear Status Area
06440
myGLCD.fillRect( 1, 47, 318, 193);
06441
myGLCD.setColor(255, 0, 0);
06442
myGLCD.fillRoundRect(5, 20, 155, 40); //Constantly ON Mode Button
06443
myGLCD.fillRoundRect(165, 20, 315, 40); //Pulsating Mode Mode Button
06444
setFont(SMALL, 255, 255, 255, 255, 0, 0);
06445
myGLCD.print("Constantly ON", 28, 24);
06446
myGLCD.print("Pulsating Mode", 184, 24);
06447
for (int x=0; x<2; x++)
06448
{ myGLCD.drawRoundRect((x*160)+5, 20, (x*160)+155, 40); }
06449
06450
if (Synch==0)
06451
{
06452
setFont(LARGE, 255, 0, 0, 0, 0, 0);
06453
myGLCD.print("NO Synchronous Mode", CENTER, 80);
06454
myGLCD.print("has been selected!", CENTER, 100);
06455
setFont(SMALL, 255, 0, 0, 0, 0, 0);
06456
myGLCD.print("Choose either Constantly ON or", CENTER, 130);
06457
myGLCD.print("Pulsating Mode. Afterwards, you", CENTER, 142);
06458
myGLCD.print("can alter the settings.", CENTER, 154);
06459
} else
06460
06461
if (Synch==1)
06462
{
06463
myGLCD.setColor(0, 255, 0);
06464
myGLCD.fillRoundRect(5, 20, 155, 40);
06465
setFont(SMALL, 0, 0, 0, 0, 255, 0);
06466
myGLCD.print("Constantly ON", 28, 24);
06467
myGLCD.setColor(255, 255, 255);
06468
myGLCD.drawRoundRect(5, 20, 155, 40);
06469
06470
setFont(LARGE, 0, 255, 0, 0, 0, 0);
06471
myGLCD.print("Constantly ON Mode", CENTER, 80);
06472
myGLCD.print("has been selected!", CENTER, 100);
06473
setFont(SMALL, 255, 0, 0, 0, 0, 0);
06474
myGLCD.print("Both powerheads will remain", CENTER, 130);
06475
myGLCD.print("ON constantly. To change to", CENTER, 142);
06476
myGLCD.print("Pulsating Mode select it above.", CENTER, 154);
06477
} else
06478
06479
if (Synch==2)
06480
{
06481
myGLCD.setColor(0, 255, 0);
06482
myGLCD.fillRoundRect(165, 20, 315, 40);
06483
setFont(SMALL, 0, 0, 0, 0, 255, 0);
06484
myGLCD.print("Pulsating Mode", 184, 24);
06485
myGLCD.setColor(255, 255, 255);
06486
myGLCD.drawRoundRect(165, 20, 315, 40);
06487
06488
myGLCD.setColor(64, 64, 64); //Draw Dividers in Grey
06489
myGLCD.drawRect(0, 120, 319, 122); //Middle Horizontal Divider
06490
setFont(SMALL, 0, 255, 0, 0, 0, 0);
06491
myGLCD.print("POWERHEADS WIll RUN FOR", CENTER, 50);
06492
myGLCD.print("POWERHEADS WILL STOP FOR", CENTER, 127);
06493
setFont(SMALL, 255, 255, 255, 0, 0, 0);
06494
myGLCD.print("Minutes", 57, 100);
06495
myGLCD.print("Seconds", 211, 100);
06496
myGLCD.print("Minutes", 57, 177);
06497
myGLCD.print("Seconds", 211, 177);
06498
06499
Min1=OnForTm, Sec1=OnForTs, Min2=OffForTm, Sec2=OffForTs;
06500
viewWaveTimesPage();
06501
}
06502
}
06503
06504
void viewWaveTimesPage()
06505
{
06506
setFont(LARGE, 255, 255, 255, 0, 0, 0);
06507
if (Min1==0) { myGLCD.print("000", 59, 75); }
06508
if ((Min1>=1) && (Min1<=9))
06509
{ myGLCD.print("00", 59, 75);
06510
myGLCD.printNumI(Min1, 91, 75);}
06511
if ((Min1>=10) && (Min1<=99))
06512
{ myGLCD.print("0", 59, 75);
06513
myGLCD.printNumI(Min1, 75, 75);}
06514
if (Min1>=100) { myGLCD.printNumI(Min1, 59, 75);}
06515
06516
if (Sec1==0) { myGLCD.print("00", 221, 75); }
06517
if ((Sec1>=1) && (Sec1<=9))
06518
{ myGLCD.print("0", 221, 75);
06519
myGLCD.printNumI(Sec1, 237, 75);}
06520
if (Sec1>=10) { myGLCD.printNumI(Sec1, 221, 75);}
06521
06522
if (Min2==0) { myGLCD.print("000", 59, 152); }
06523
if ((Min2>=1) && (Min2<=9))
06524
{ myGLCD.print("00", 59, 152);
06525
myGLCD.printNumI(Min2, 91, 152);}
06526
if ((Min2>=10) && (Min2<=99))
06527
{ myGLCD.print("0", 59, 152);
06528
myGLCD.printNumI(Min2, 75, 152);}
06529
if (Min2>=100) { myGLCD.printNumI(Min2, 59, 152);}
06530
06531
if (Sec2==0) { myGLCD.print("00", 221, 152); }
06532
if ((Sec2>=1) && (Sec2<=9))
06533
{ myGLCD.print("0", 221, 152);
06534
myGLCD.printNumI(Sec2, 237, 152);}
06535
if (Sec2>=10) { myGLCD.printNumI(Sec2, 221, 152);}
06536
06537
printButton("-", pump1Mm[0], pump1Mm[1], pump1Mm[2], pump1Mm[3], LARGE);
06538
printButton("+", pump1Mp[0], pump1Mp[1], pump1Mp[2], pump1Mp[3], LARGE);
06539
printButton("-", pump1Sm[0], pump1Sm[1], pump1Sm[2], pump1Sm[3], LARGE);
06540
printButton("+", pump1Sp[0], pump1Sp[1], pump1Sp[2], pump1Sp[3], LARGE);
06541
printButton("-", pump2Mm[0], pump2Mm[1], pump2Mm[2], pump2Mm[3], LARGE);
06542
printButton("+", pump2Mp[0], pump2Mp[1], pump2Mp[2], pump2Mp[3], LARGE);
06543
printButton("-", pump2Sm[0], pump2Sm[1], pump2Sm[2], pump2Sm[3], LARGE);
06544
printButton("+", pump2Sp[0], pump2Sp[1], pump2Sp[2], pump2Sp[3], LARGE);
06545
}
06546
06547
void waveModePlusMinus()
06548
{
06549
setFont(LARGE, 255, 255, 255, 0, 0, 0);
06550
if ((y>=70) && (y<=95)) //First Row
06551
{
06552
if ((x>=21) && (x<=46)) //Pump 1 Minute Minus
06553
{
06554
waitForIt(21, 70, 46, 95);
06555
Min1 -= 1;
06556
if ((min1X>=10) && (Min1<=99)) {min1X=75; myGLCD.print("0", 59, 75);}
06557
if ((Min1<=9) && (Min1>0)) {min1X=91; myGLCD.print("00", 59, 75);}
06558
if (Min1<=0) {Min1=0; myGLCD.print("0", 91, 75);}
06559
setFont(LARGE, 255, 255, 255, 0, 0, 0);
06560
myGLCD.printNumI(Min1, min1X, 75);
06561
}
06562
if ((x>=120) && (x<=145)) //Pump 1 Minute Plus
06563
{
06564
waitForIt(120, 70, 145, 95);
06565
Min1 += 1;
06566
if ((Min1>=0) && (Min1<=9)) {min1X=91;}
06567
if (Min1>9) {min1X=75;}
06568
if (Min1>99) {min1X=59;}
06569
if (Min1>=999) {Min1=999;}
06570
setFont(LARGE, 255, 255, 255, 0, 0, 0);
06571
myGLCD.printNumI(Min1, min1X, 75);
06572
}
06573
if ((x>=175) && (x<=200)) //Pump 1 Second Minus
06574
{
06575
waitForIt(175, 70, 200, 95);
06576
Sec1 -= 1;
06577
if ((sec1X>=10) && (Sec1<=59)) {sec1X=221;}
06578
if ((Sec1<=9) && (Sec1>0)) {sec1X=237; myGLCD.print("0", 221, 75);}
06579
if (Sec1<=0) {Sec1=0; myGLCD.print("0", 237, 75);}
06580
setFont(LARGE, 255, 255, 255, 0, 0, 0);
06581
myGLCD.printNumI(Sec1, sec1X, 75);
06582
}
06583
if ((x>=274) && (x<=299)) //Pump 1 Second Plus
06584
{
06585
waitForIt(274, 70, 299, 95);
06586
Sec1 += 1;
06587
if ((Sec1>=0) && (Sec1<=9)) {sec1X=237;}
06588
if (Sec1>9) {sec1X=221;}
06589
if (Sec1>=59) {Sec1=59;}
06590
setFont(LARGE, 255, 255, 255, 0, 0, 0);
06591
myGLCD.printNumI(Sec1, sec1X, 75);
06592
}
06593
}
06594
06595
if ((y>=147) && (y<=172)) //Second Row
06596
{
06597
if ((x>=21) && (x<=46)) //Pump 2 Minute Minus
06598
{
06599
waitForIt(21, 147, 46, 172);
06600
Min2 -= 1;
06601
if ((min2X>=10) && (Min2<=99)) {min2X=75; myGLCD.print("0", 59, 152);}
06602
if ((Min2<=9) && (Min2>0)) {min2X=91; myGLCD.print("00", 59, 152);}
06603
if (Min2<=0) {Min2=0; myGLCD.print("0", 91, 152);}
06604
setFont(LARGE, 255, 255, 255, 0, 0, 0);
06605
myGLCD.printNumI(Min2, min2X, 152);
06606
}
06607
if ((x>=120) && (x<=145)) //Pump 2 Minute Plus
06608
{
06609
waitForIt(120, 147, 145, 172);
06610
Min2 += 1;
06611
if ((Min2>=0) && (Min2<=9)) {min2X=91;}
06612
if (Min2>9) {min2X=75;}
06613
if (Min2>99) {min2X=59;}
06614
if (Min2>=999) {Min2=999;}
06615
setFont(LARGE, 255, 255, 255, 0, 0, 0);
06616
myGLCD.printNumI(Min2, min2X, 152);
06617
}
06618
if ((x>=175) && (x<=200)) //Pump 2 Second Minus
06619
{
06620
waitForIt(175, 147, 200, 172);
06621
Sec2 -= 1;
06622
if ((sec2X>=10) && (Sec2<=59)) {sec2X=221;}
06623
if ((Sec2<=9) && (Sec2>0)) {sec2X=237; myGLCD.print("0", 221, 152);}
06624
if (Sec2<=0) {Sec2=0; myGLCD.print("0", 237, 152);}
06625
setFont(LARGE, 255, 255, 255, 0, 0, 0);
06626
myGLCD.printNumI(Sec2, sec2X, 152);
06627
}
06628
if ((x>=274) && (x<=299)) //Pump 2 Second Plus
06629
{
06630
waitForIt(274, 147, 299, 172);
06631
Sec2 += 1;
06632
if ((Sec2>=0) && (Sec2<=9)) {sec2X=237;}
06633
if (Sec2>9) {sec2X=221;}
06634
if (Sec2>=59) {Sec2=59;}
06635
setFont(LARGE, 255, 255, 255, 0, 0, 0);
06636
myGLCD.printNumI(Sec2, sec2X, 152);
06637
}
06638
}
06639
}
06640
*/
06641
/************************** END OF WAVEMAKER SETTINGS SCREEN **************************/
06642
06643
06644
/******** AUTOMATIC FEEDER SCREEN ************* dispScreen = 12 ***********************/
06645
/*
06646
void autoFeederScreen()
06647
{
06648
// printHeader("Automatic Fish Feeder Page");
06649
PrintStringIndex=25;
06650
printHeader ();
06651
06652
myGLCD.setColor(64, 64, 64);
06653
myGLCD.drawRect(0, 196, 319, 194);
06654
printButton("<< BACK", back[0], back[1], back[2], back[3], SMALL);
06655
printButton("CANCEL", canC[0], canC[1], canC[2], canC[3], SMALL);
06656
myGLCD.setColor(64, 64, 64);
06657
myGLCD.drawRect(159, 194, 161, 121);
06658
myGLCD.drawRoundRect(78, 87, 242, 121);
06659
myGLCD.drawRoundRect(80, 89, 240, 119);
06660
myGLCD.drawRect(0, 103, 78, 105);
06661
myGLCD.drawRect(242, 103, 319, 105);
06662
myGLCD.drawLine(159, 87, 159, 14);
06663
myGLCD.drawLine(161, 87, 161, 14);
06664
myGLCD.setColor(0, 0, 0);
06665
myGLCD.drawLine(160, 195, 160, 193);
06666
myGLCD.drawLine(160, 122, 160, 120);
06667
myGLCD.drawLine(77, 104, 79, 104);
06668
myGLCD.drawLine(241, 104, 243, 104);
06669
myGLCD.drawLine(160, 88, 160, 86);
06670
06671
myGLCD.setColor(153, 0, 102);
06672
myGLCD.fillRoundRect(85, 94, 235, 114); //Feed Fish Now Button
06673
myGLCD.setColor(255, 255, 255);
06674
myGLCD.drawRoundRect(85, 94, 235, 114);
06675
setFont(SMALL, 255, 255, 255, 153, 0, 102);
06676
//myGLCD.print("Feed Fish Now!", 106, 98);
06677
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[33])));
06678
myGLCD.print(buffer, 106, 98);
06679
06680
if (FEEDTime1==0) //Feeding Time 1 Button
06681
{ myGLCD.setColor(255, 0, 0);
06682
myGLCD.fillRoundRect(5, 20, 155, 40);
06683
setFont(SMALL, 255, 255, 255, 255, 0, 0);
06684
// myGLCD.print("Feeding Time 1", 24, 24);
06685
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[25])));
06686
myGLCD.print(buffer, 24, 24);
06687
setFont(SMALL, 255, 0, 0, 0, 0, 0);
06688
// myGLCD.print("This time has not", 12, 52);
06689
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[31])));
06690
myGLCD.print(buffer, 12, 52);
06691
// myGLCD.print("been scheduled", 24, 65);}
06692
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[32])));
06693
myGLCD.print(buffer, 24, 65);}
06694
else
06695
{ myGLCD.setColor(0, 255, 0);
06696
myGLCD.fillRoundRect(5, 20, 155, 40);
06697
setFont(SMALL, 0, 0, 0, 0, 255, 0);
06698
// myGLCD.print("Feeding Time 1", 24, 24);
06699
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[25])));
06700
myGLCD.print(buffer, 24, 24);
06701
timeDispH=feedFish1H; timeDispM=feedFish1M;
06702
if (setTimeFormat==0) { xTimeH=40;}
06703
if (setTimeFormat==1) { xTimeH=16;}
06704
// ReadFromEEPROM();
06705
if ((timeDispH>=0) && (timeDispH<=11)) { AM_PM=1;}
06706
else { AM_PM=2;}
06707
yTime=56; xColon=xTimeH+32;
06708
xTimeM10=xTimeH+48; xTimeM1=xTimeH+64; xTimeAMPM=xTimeH+96;
06709
timeCorrectFormat();}
06710
if (FEEDTime2==0) //Feeding Time 2 Button
06711
{ myGLCD.setColor(255, 0, 0);
06712
myGLCD.fillRoundRect(165, 20, 315, 40);
06713
setFont(SMALL, 255, 255, 255, 255, 0, 0);
06714
// myGLCD.print("Feeding Time 2", 184, 24);
06715
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[26])));
06716
myGLCD.print(buffer, 184, 24);
06717
setFont(SMALL, 255, 0, 0, 0, 0, 0);
06718
// myGLCD.print("This time has not", 172, 52);
06719
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[31])));
06720
myGLCD.print(buffer, 172, 52);
06721
// myGLCD.print("been scheduled", 184, 65);}
06722
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[32])));
06723
myGLCD.print(buffer, 184, 65);}
06724
06725
else
06726
{ myGLCD.setColor(0, 255, 0);
06727
myGLCD.fillRoundRect(165, 20, 315, 40);
06728
setFont(SMALL, 0, 0, 0, 0, 255, 0);
06729
// myGLCD.print("Feeding Time 2", 184, 24);
06730
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[26])));
06731
myGLCD.print(buffer, 184, 24);
06732
06733
timeDispH=feedFish2H; timeDispM=feedFish2M;
06734
if (setTimeFormat==0) { xTimeH=200;}
06735
if (setTimeFormat==1) { xTimeH=176;}
06736
// ReadFromEEPROM();
06737
if ((timeDispH>=0) && (timeDispH<=11)) { AM_PM=1;}
06738
else { AM_PM=2;}
06739
yTime=56; xColon=xTimeH+32;
06740
xTimeM10=xTimeH+48; xTimeM1=xTimeH+64; xTimeAMPM=xTimeH+96;
06741
timeCorrectFormat();}
06742
if (FEEDTime3==0) //Feeding Time 3 Button
06743
{ myGLCD.setColor(255, 0, 0);
06744
myGLCD.fillRoundRect(5, 168, 155, 188);
06745
setFont(SMALL, 255, 255, 255, 255, 0, 0);
06746
// myGLCD.print("Feeding Time 3", 24, 172);
06747
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[27])));
06748
myGLCD.print(buffer, 24, 172);
06749
setFont(SMALL, 255, 0, 0, 0, 0, 0);
06750
// myGLCD.print("This time has not", 12, 133);
06751
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[31])));
06752
myGLCD.print(buffer, 12, 133);
06753
// myGLCD.print("been scheduled", 24, 146);}
06754
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[32])));
06755
myGLCD.print(buffer, 24, 146);}
06756
else
06757
{ myGLCD.setColor(0, 255, 0);
06758
myGLCD.fillRoundRect(5, 168, 155, 188);
06759
setFont(SMALL, 0, 0, 0, 0, 255, 0);
06760
// myGLCD.print("Feeding Time 3", 24, 172);
06761
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[27])));
06762
myGLCD.print(buffer, 24, 172);
06763
06764
timeDispH=feedFish3H; timeDispM=feedFish3M;
06765
if (setTimeFormat==0) { xTimeH=40;}
06766
if (setTimeFormat==1) { xTimeH=16;}
06767
// ReadFromEEPROM();
06768
if ((timeDispH>=0) && (timeDispH<=11)) { AM_PM=1;}
06769
else { AM_PM=2;}
06770
yTime=137; xColon=xTimeH+32;
06771
xTimeM10=xTimeH+48; xTimeM1=xTimeH+64; xTimeAMPM=xTimeH+96;
06772
timeCorrectFormat();}
06773
if (FEEDTime4==0) //Feeding Time 4 Button
06774
{ myGLCD.setColor(255, 0, 0);
06775
myGLCD.fillRoundRect(165, 168, 315, 188);
06776
setFont(SMALL, 255, 255, 255, 255, 0, 0);
06777
// myGLCD.print("Feeding Time 4", 184, 172);
06778
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[28])));
06779
myGLCD.print(buffer, 184, 172);
06780
setFont(SMALL, 255, 0, 0, 0, 0, 0);
06781
// myGLCD.print("This time has not", 172, 133);
06782
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[31])));
06783
myGLCD.print(buffer, 172, 133);
06784
// myGLCD.print("been scheduled", 184, 146);}
06785
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[32])));
06786
myGLCD.print(buffer, 184, 146);}
06787
else
06788
{ myGLCD.setColor(0, 255, 0);
06789
myGLCD.fillRoundRect(165, 168, 315, 188);
06790
setFont(SMALL, 0, 0, 0, 0, 255, 0);
06791
// myGLCD.print("Feeding Time 4", 184, 172);
06792
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[28])));
06793
myGLCD.print(buffer, 184, 172);
06794
timeDispH=feedFish4H; timeDispM=feedFish4M;
06795
if (setTimeFormat==0) { xTimeH=200;}
06796
if (setTimeFormat==1) { xTimeH=176;}
06797
// ReadFromEEPROM();
06798
if ((timeDispH>=0) && (timeDispH<=11)) { AM_PM=1;}
06799
else { AM_PM=2;}
06800
yTime=137; xColon=xTimeH+32;
06801
xTimeM10=xTimeH+48; xTimeM1=xTimeH+64; xTimeAMPM=xTimeH+96;
06802
timeCorrectFormat();}
06803
06804
myGLCD.setColor(255, 255, 255);
06805
for (int x=0; x<2; x++)
06806
{ for (int y=0; y<2; y++)
06807
{ myGLCD.drawRoundRect((x*160)+5, (y*148)+20, (x*160)+155, (y*148)+40); }
06808
}
06809
}
06810
06811
06812
void feedingTimeOutput()
06813
{
06814
if ((FEEDTime1==1) && (feedFish1H==t.hour) && (feedFish1M==t.min)
06815
&& (t.sec>=0 || t.sec<5))
06816
{ if (setAutoStop==1)
06817
{ waveMakerOff=true;
06818
digitalWrite(WaveMakerTop, LOW);
06819
digitalWrite(WaveMakerBottom, LOW);
06820
fiveTillBackOn1=0;
06821
FeedWaveCtrl_1=true;}
06822
digitalWrite(autoFeeder, HIGH);
06823
delay(6000);
06824
t=rtc.getTime();
06825
digitalWrite(autoFeeder, LOW);
06826
}
06827
if (FeedWaveCtrl_1==true)
06828
{ fiveTillBackOn1++;
06829
if (fiveTillBackOn1>60) //60 is 5 minutes (60/12=5)
06830
{ waveMakerOff=false; FeedWaveCtrl_1=false;}
06831
}
06832
06833
if ((FEEDTime2==1) && (feedFish2H==t.hour) && (feedFish2M==t.min)
06834
&& (t.sec>=0 || t.sec<5))
06835
{ if (setAutoStop==1)
06836
{ waveMakerOff=true;
06837
digitalWrite(WaveMakerTop, LOW);
06838
digitalWrite(WaveMakerBottom, LOW);
06839
fiveTillBackOn2=0;
06840
FeedWaveCtrl_2=true;}
06841
digitalWrite(autoFeeder, HIGH);
06842
delay(6000);
06843
t=rtc.getTime();
06844
digitalWrite(autoFeeder, LOW);
06845
}
06846
if (FeedWaveCtrl_2==true)
06847
{ fiveTillBackOn2++;
06848
if (fiveTillBackOn2>60)
06849
{ waveMakerOff=false; FeedWaveCtrl_2=false;}
06850
}
06851
06852
if ((FEEDTime3==1) && (feedFish3H==t.hour) && (feedFish3M==t.min)
06853
&& (t.sec>=0 || t.sec<5))
06854
{ if (setAutoStop==1)
06855
{ waveMakerOff=true;
06856
digitalWrite(WaveMakerTop, LOW);
06857
digitalWrite(WaveMakerBottom, LOW);
06858
fiveTillBackOn3=0;
06859
FeedWaveCtrl_3=true;}
06860
digitalWrite(autoFeeder, HIGH);
06861
delay(6000);
06862
t=rtc.getTime();
06863
digitalWrite(autoFeeder, LOW);
06864
}
06865
if (FeedWaveCtrl_3==true)
06866
{ fiveTillBackOn3++;
06867
if (fiveTillBackOn3>60)
06868
{ waveMakerOff=false; FeedWaveCtrl_3=false;}
06869
}
06870
06871
if ((FEEDTime4==1) && (feedFish4H==t.hour) && (feedFish4M==t.min)
06872
&& (t.sec>=0 || t.sec<5))
06873
{ if (setAutoStop==1)
06874
{ waveMakerOff=true;
06875
digitalWrite(WaveMakerTop, LOW);
06876
digitalWrite(WaveMakerBottom, LOW);
06877
fiveTillBackOn4=0;
06878
FeedWaveCtrl_4=true;}
06879
digitalWrite(autoFeeder, HIGH);
06880
delay(6000);
06881
t=rtc.getTime();
06882
digitalWrite(autoFeeder, LOW);
06883
}
06884
if (FeedWaveCtrl_4==true)
06885
{ fiveTillBackOn4++;
06886
if (fiveTillBackOn4>60)
06887
{ waveMakerOff=false; FeedWaveCtrl_4=false;}
06888
}
06889
}
06890
*/
06891
/*********************** END OF AUTOMATIC FEEDER SETTINGS SCREEN **********************/
06892
06893
06894
/***** SET AUTOMATIC FEEDER TIMES SCREEN ********** dispScreen = 13 *******************/
06895
/*
06896
void setFeederTimesScreen(boolean refreshAll=true)
06897
{
06898
if (feedTime==1)
06899
{ //printHeader("Set Feeding Time 1"); }
06900
PrintStringIndex=26;
06901
printHeader ();}
06902
if (feedTime==2)
06903
{ //printHeader("Set Feeding Time 2");}
06904
PrintStringIndex=27;
06905
printHeader ();}
06906
if (feedTime==3)
06907
{ //printHeader("Set Feeding Time 3");}
06908
PrintStringIndex=28;
06909
printHeader ();}
06910
if (feedTime==4)
06911
{ //printHeader("Set Feeding Time 4");}
06912
PrintStringIndex=29;
06913
printHeader ();}
06914
06915
if (refreshAll)
06916
{
06917
rtcSetMin=t.min; rtcSetHr=t.hour;
06918
06919
myGLCD.setColor(64, 64, 64);
06920
myGLCD.drawRect(0, 196, 319, 194);
06921
printButton("<< BACK", back[0], back[1], back[2], back[3], SMALL);
06922
printButton("SAVE", prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3], SMALL);
06923
printButton("CANCEL", canC[0], canC[1], canC[2], canC[3], SMALL);
06924
06925
feedingTimeOnOff();
06926
06927
drawUpButton(houP[0], houP[1]); //hour up
06928
drawUpButton(minP[0], minP[1]); //min up
06929
drawDownButton(houM[0], houM[1]); //hour down
06930
drawDownButton(minM[0], minM[1]); //min down
06931
if (setTimeFormat==1)
06932
{ drawUpButton(ampmP[0], ampmP[1]); //AM/PM up
06933
drawDownButton(ampmM[0], ampmM[1]);} //AM/PM down
06934
}
06935
06936
timeDispH=rtcSetHr; timeDispM=rtcSetMin;
06937
xTimeH=107; yTime=68; xColon=xTimeH+42;
06938
xTimeM10=xTimeH+70; xTimeM1=xTimeH+86; xTimeAMPM=xTimeH+155;
06939
timeChange();
06940
}
06941
*/
06942
/********************** END OF SET AUTOMATIC FEEDER TIMES SCREEN **********************/
06943
06944
06945
/******* GENERAL SETTINGS PG1 SCREEN ************ dispScreen = 14 *********************/
06946
void
generalSettingsScreen_1()
06947
{
06948
// printHeader("View/Change General Settings: Page 1");
06949
PrintStringIndex=30;
06950
printHeader ();
06951
06952
myGLCD.setColor(64, 64, 64);
06953
myGLCD.drawRect(0, 196, 319, 194);
06954
for
(
byte
y=0; y<5; y++)
06955
{ myGLCD.drawLine(0, (y*30)+44, 319, (y*30)+44); }
06956
06957
printButton(
"<< BACK"
, backGS[0], backGS[1], backGS[2], backGS[3], SMALL);
06958
printButton(
"NEXT >>"
, nextGS[0], nextGS[1], nextGS[2], nextGS[3], SMALL);
06959
printButton(
"SAVE"
, prSAVEgs[0], prSAVEgs[1], prSAVEgs[2], prSAVEgs[3], SMALL);
06960
printButton(
"CANCEL"
, canCgs[0], canCgs[1], canCgs[2], canCgs[3], SMALL);
06961
06962
setFont(SMALL, 0, 255, 0, 0, 0, 0);
06963
myGLCD.print(
"Set Time and Date"
, 25, 23);
06964
myGLCD.print(
"Calendar Format"
, 25, 53);
06965
myGLCD.print(
"Show Day of Week"
, 25, 83);
06966
myGLCD.print(
"Time Format"
, 25, 113);
06967
myGLCD.print(
"Temperature Scale"
, 25, 143);
06968
myGLCD.print(
"Fan Startup Temps"
, 25, 173);
06969
06970
genSetSelect_1();
06971
}
06972
/************************ END OF GENERAL SETTINGS PAGE 1 SCREEN ***********************/
06973
06974
06975
/******* GENERAL SETTINGS PG2 SCREEN ************ dispScreen = 15 *********************/
06976
void
generalSettingsScreen_2()
06977
{
06978
// printHeader("View/Change General Settings: Page 2");
06979
PrintStringIndex=31;
06980
printHeader ();
06981
06982
myGLCD.setColor(64, 64, 64);
06983
myGLCD.drawRect(0, 196, 319, 194);
06984
for
(
byte
y=0; y<5; y++)
06985
{ myGLCD.drawLine(0, (y*30)+44, 319, (y*30)+44); }
06986
06987
// printButton("<< BACK", backGS[0], backGS[1], backGS[2], backGS[3], SMALL);
06988
// printButton("NEXT >>", nextGS[0], nextGS[1], nextGS[2], nextGS[3], SMALL);
06989
// printButton("SAVE", prSAVEgs[0], prSAVEgs[1], prSAVEgs[2], prSAVEgs[3], SMALL);
06990
// printButton("CANCEL", canCgs[0], canCgs[1], canCgs[2], canCgs[3], SMALL);
06991
06992
printButton(print_text[0], backGS[0], backGS[1], backGS[2], backGS[3], SMALL);
06993
printButton(print_text[1], nextGS[0], nextGS[1], nextGS[2], nextGS[3], SMALL);
06994
printButton(print_text[2], prSAVEgs[0], prSAVEgs[1], prSAVEgs[2], prSAVEgs[3], SMALL);
06995
printButton(print_text[3], canCgs[0], canCgs[1], canCgs[2], canCgs[3], SMALL);
06996
06997
setFont(SMALL, 0, 255, 0, 0, 0, 0);
06998
myGLCD.print(print_text[4], 15, 23);
06999
myGLCD.print(print_text[5], 15, 53);
07000
myGLCD.print(print_text[6], 15, 83);
07001
myGLCD.print(print_text[7], 15, 113);
07002
myGLCD.print(print_text[12], 15, 143);
07003
07004
genSetSelect_2();
07005
}
07006
/************************ END OF GENERAL SETTINGS PAGE 2 SCREEN ***********************/
07007
07008
/******* GENERAL SETTINGS PG3 SCREEN ************ dispScreen = 20 *********************/
07009
void
generalSettingsScreen_3()
07010
{
07011
// printHeader("View/Change General Settings: Page 3");
07012
PrintStringIndex=36;
07013
printHeader ();
07014
07015
setFont(SMALL, 0, 255, 0, 0, 0, 0);
07016
// myGLCD.print("Detect Dallas Sensors", 25, 24);
07017
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[6])));
07018
myGLCD.print(buffer, 24, 23);
07019
// myGLCD.print("Backup setting to SD Card", 5, 58);
07020
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[7])));
07021
myGLCD.print(buffer, 5, 53);
07022
// myGLCD.print("Reset setting to DEFAULT", 5, 92);
07023
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[8])));
07024
myGLCD.print(buffer, 5, 83);
07025
07026
myGLCD.setColor(64, 64, 64);
07027
myGLCD.drawRect(0, 196, 319, 194);
07028
for
(
byte
y=0; y<3; y++)
07029
{ myGLCD.drawLine(0, (y*30)+44, 319, (y*30)+44); }
07030
07031
07032
myGLCD.setColor(0, 0, 255);
07033
myGLCD.fillRoundRect(205, 19, 305, 39);
// detect
07034
myGLCD.fillRoundRect(205, 49, 305, 69);
// backup
07035
myGLCD.fillRoundRect(205, 79, 305, 99);
// reset
07036
07037
myGLCD.setColor(255, 255, 255);
07038
myGLCD.drawRoundRect(205, 19, 305, 39);
// detect
07039
myGLCD.drawRoundRect(205, 49, 305, 69);
// backup
07040
myGLCD.drawRoundRect(205, 79, 305, 99);
// reset
07041
07042
setFont(SMALL, 255, 255, 255, 0, 0, 255);
07043
myGLCD.print(
"DETECT"
, 231, 23);
07044
myGLCD.print(
"BACKUP"
, 231, 53);
07045
myGLCD.print(
"RESET"
, 235, 83);
07046
07047
bitClear(GlobalStatus1Byte,0);
// reset bit for Y/N button
07048
07049
printButton(
"<< BACK"
, backGS[0], backGS[1], backGS[2], backGS[3], SMALL);
07050
printButton(
"CANCEL"
, canCgs[0], canCgs[1], canCgs[2], canCgs[3], SMALL);
07051
}
07052
07053
/******** CHANGE FAN TEMPS SCREEN ************* dispScreen = 16 ***********************/
07054
void
ChangeFanTempsScreen(boolean refreshAll=
false
)
07055
{
07056
String deg;
07057
if
(refreshAll)
07058
{
07059
if
((setTempToBeginHeatsink1FanC==0) && (setTempScale==0))
07060
{ setTempToBeginHeatsink1FanC = 29.0;}
//change to 29 deg C
07061
if
((setTempToBeginHeatsink2FanC==0) && (setTempScale==0))
07062
{ setTempToBeginHeatsink2FanC = 29.0;}
//change to 29 deg C
07063
if
(((setTempToBeginHeatsink1FanF==0) || (setTempToBeginHeatsink1FanF==setTempToBeginHeatsink1FanC))
07064
&& (setTempScale==1))
07065
{ setTempToBeginHeatsink1FanF = 84.2;}
//change to 84 deg F
07066
if
(((setTempToBeginHeatsink2FanF==0) || (setTempToBeginHeatsink2FanF==setTempToBeginHeatsink2FanC))
07067
&& (setTempScale==1))
07068
{ setTempToBeginHeatsink2FanF = 84.2;}
//change to 84 deg F
07069
07070
if
(setTempScale==1)
07071
{ temp2beHFan=setTempToBeginHeatsink1FanF;
07072
temp2beSFan=setTempToBeginHeatsink2FanF; }
07073
else
07074
{ temp2beHFan=setTempToBeginHeatsink1FanC;
07075
temp2beSFan=setTempToBeginHeatsink2FanC;}
07076
07077
// printHeader("View/Change Fans Startup Temperatures");
07078
PrintStringIndex=32;
07079
printHeader ();
07080
myGLCD.setColor(64, 64, 64);
07081
myGLCD.drawRect(0, 73, 319, 75);
07082
myGLCD.drawRect(0, 73+60, 319, 75+60);
07083
07084
setFont(SMALL, 0, 255, 0, 0, 0, 0);
07085
// myGLCD.print("Heatsink N1 FAN", CENTER, 20);
07086
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[13])));
07087
myGLCD.print(buffer, CENTER, 20);
07088
// myGLCD.print("Heatsink N2 FAN", CENTER, 111);
07089
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[14])));
07090
myGLCD.print(buffer, CENTER, 81);
07091
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[17])));
// sound alarm temp
07092
myGLCD.print(buffer, CENTER, 140);
07093
07094
if
(setTempScale==1)
07095
{ strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[16])));
07096
myGLCD.print(buffer, 231, 46);
07097
myGLCD.print(buffer, 231, 105);
07098
// myGLCD.print("(68.0--120.0)", CENTER, 177);
07099
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[19])));
07100
myGLCD.print(buffer, 231, 164);
07101
}
07102
else
07103
{ strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[15])));
07104
myGLCD.print(buffer, 235, 46);
07105
myGLCD.print(buffer, 235, 105);
07106
// myGLCD.print("(20.0--50.0)", CENTER, 177);
07107
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[18])));
07108
myGLCD.print(buffer, 235, 164);
07109
}
07110
07111
printButton(
"-"
, HoodFanTm[0], HoodFanTm[1], HoodFanTm[2], HoodFanTm[3], LARGE);
07112
printButton(
"+"
, HoodFanTp[0], HoodFanTp[1], HoodFanTp[2], HoodFanTp[3], LARGE);
07113
printButton(
"-"
, SumpFanTm[0], SumpFanTm[1], SumpFanTm[2], SumpFanTm[3], LARGE);
07114
printButton(
"+"
, SumpFanTp[0], SumpFanTp[1], SumpFanTp[2], SumpFanTp[3], LARGE);
07115
printButton(
"-"
, SoundAlarmTm[0], SoundAlarmTm[1], SoundAlarmTm[2], SoundAlarmTm[3], LARGE);
07116
printButton(
"+"
, SoundAlarmTp[0], SoundAlarmTp[1], SoundAlarmTp[2], SoundAlarmTp[3], LARGE);
07117
07118
myGLCD.setColor(64, 64, 64);
07119
myGLCD.drawRect(0, 196, 319, 194);
07120
printButton(
"<< BACK"
, back[0], back[1], back[2], back[3], SMALL);
07121
printButton(
"SAVE"
, prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3], SMALL);
07122
printButton(
"CANCEL"
, canC[0], canC[1], canC[2], canC[3], SMALL);
07123
}
07124
07125
setFont(LARGE, 255, 255, 255, 0, 0, 0);
07126
myGLCD.printNumF(temp2beHFan, 1, 112, 45);
07127
if
(setTempScale==1 && temp2beHFan <100 ) {myGLCD.print(
" "
,176, 45);}
// Fan 1
07128
myGLCD.printNumF(temp2beSFan, 1, 112, 103);
07129
if
(setTempScale==1 && temp2beSFan <100 ) {myGLCD.print(
" "
,176, 103);}
// Fan 2
07130
if
(setTempScale==0) {myGLCD.printNumF(setTempToSoundAlarmC, 1, 112, 162);}
// display sound alarm temp
07131
if
(setTempScale==1) { myGLCD.printNumF(setTempToSoundAlarmF, 1, 112, 162);}
07132
// }
07133
}
07134
/*************************** END OF CHANGE FAN TEMPS SCREEN ***************************/
07135
07136
07137
/******** DIM LEDs AT TEMP SCREEN ************* dispScreen = 17 ***********************/
07138
void
DimLEDsAtTempScreen()
07139
{
07140
// printHeader("View/Change LEDs' Dimming Temperature");
07141
PrintStringIndex=33;
07142
printHeader ();
07143
07144
setFont(SMALL, 0, 255, 0, 0, 0, 0);
07145
myGLCD.print(
"If temp reaches:"
, 39, 59);
07146
if
(setTempScale==1) {myGLCD.print(
"F"
, 278, 59);}
//Print deg C or deg F
07147
else
{myGLCD.print(
"C"
, 278, 59);}
07148
/*
07149
String deg;
07150
if (setTempScale==1) {deg ="F";} //Print deg C or deg F
07151
else {deg = "C";}
07152
degC_F=deg;
07153
char bufferDeg[3];
07154
degC_F.toCharArray(bufferDeg,3);
07155
*/
07156
myGLCD.drawCircle(273, 61, 1);
07157
// myGLCD.print(bufferDeg, 278, 59);
07158
07159
myGLCD.print(
"Dim the LEDs to:"
, 39, 140);
07160
myGLCD.print(
"%."
, 273, 140);
07161
07162
myGLCD.setColor(64, 64, 64);
07163
myGLCD.drawRoundRect(175, 31, 265, 96);
07164
drawUpButton(235, 36);
07165
drawDownButton(235, 66);
07166
myGLCD.setColor(64, 64, 64);
07167
myGLCD.drawRoundRect(175, 112, 265, 177);
07168
drawUpButton(235, 117);
07169
drawDownButton(235, 147);
07170
07171
if
(setTempScale==1)
07172
{ TempLEDsDimTemp=setLEDsDimTempF;}
07173
else
{TempLEDsDimTemp=setLEDsDimTempC;}
07174
TempLEDsDimPercent=setLEDsDimPercent;
07175
setFont(LARGE, 0, 255, 0, 0, 0, 0);
07176
myGLCD.printNumI(TempLEDsDimTemp, 181, 55);
07177
07178
myGLCD.printNumI(TempLEDsDimPercent, 181, 136);
07179
07180
myGLCD.setColor(64, 64, 64);
07181
myGLCD.drawRect(0, 196, 319, 194);
07182
printButton(
"<< BACK"
, back[0], back[1], back[2], back[3], SMALL);
07183
printButton(
"SAVE"
, prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3], SMALL);
07184
printButton(
"CANCEL"
, canC[0], canC[1], canC[2], canC[3], SMALL);
07185
}
07186
/*************************** END OF DIM LEDs AT TEMP SCREEN ***************************/
07187
07188
07189
/***** SET SCREENSAVER WAIT TIME SCREEN ********** dispScreen = 18 ********************/
07190
void
ScreensaverSettingsScreen()
07191
{
07192
// printHeader("View/Change Screensaver Settings");
07193
PrintStringIndex=34;
07194
printHeader ();
07195
07196
myGLCD.setColor(64, 64, 64);
07197
myGLCD.drawLine(0, 45, 319, 45);
07198
myGLCD.drawLine(0, 76, 319, 76);
07199
myGLCD.drawLine(0, 107, 319, 107);
07200
myGLCD.drawRoundRect(115, 102+10, 205, 167+10);
07201
myGLCD.drawRect(0, 196, 319, 194);
07202
07203
setFont(SMALL, 0, 255, 0, 0, 0, 0);
07204
07205
myGLCD.print(print_text[13], 10, 24);
07206
myGLCD.print(print_text[14], 10, 55);
07207
myGLCD.print(print_text[17], 10, 86);
07208
myGLCD.print(print_text[15], 67, 130+10);
07209
myGLCD.print(print_text[16], 213, 130+10);
07210
// myGLCD.print("Choose ScreenSaver type", 10, 24);
07211
// myGLCD.print("Screen Lock ON/OFF", 10, 55);
07212
// myGLCD.print("Wait:", 67, 130);
07213
// myGLCD.print("minutes", 213, 130);
07214
drawUpButton(175, 107+10);
07215
drawDownButton(175, 137+10);
07216
07217
if
(setLockScreen==1)
// ON/OFF Screensaver lock function
07218
{printButton(
" ON "
, 206, 51, 260, 71, SMALL); }
07219
else
07220
{ printButton(
" OFF"
, 206, 51, 260, 71, SMALL); }
07221
07222
setFont(LARGE, 0, 255, 0, 0, 0, 0);
07223
TempSSminutes=setSSmintues;
07224
if
(TempSSminutes>=10)
07225
{ myGLCD.printNumI(TempSSminutes, 129, 126+10);}
// prins screen saver time
07226
else
{ myGLCD.printNumI(TempSSminutes, 137, 126+10);}
07227
07228
printButton(
"<< BACK"
, back[0], back[1], back[2], back[3], SMALL);
07229
printButton(
"SAVE"
, prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3], SMALL);
07230
printButton(
"CANCEL"
, canC[0], canC[1], canC[2], canC[3], SMALL);
07231
07232
ScreensaverSelect();
07233
}
07234
/********************** END OF SET SCREENSAVER WAIT TIME SCREEN ***********************/
07235
07236
int
PlusMinusCount ( boolean refreshAll,
int
XShift,
int
YShift,
int
Min,
int
Max,
int
Step,
int
PlsMnsCount=0 )
// increase/decrease all values counter
07237
{
07238
/*
07239
int XShift - X fist left "-" button coordinate
07240
int YShift Y fist left "-" button coordinate
07241
byte ButDist - distence between "-" and "+" buttons
07242
int Min - minimum value of counter
07243
int Max - maximum counter
07244
int Step - step
07245
int PlsMnsCount - input/output value
07246
*/
07247
byte
ButDist = 90;
// distanse beetween +/- buttons
07248
if
(refreshAll ==
true
){
07249
myGLCD.setColor(255, 255, 255);
07250
myGLCD.drawRoundRect (ButMns[0]+XShift-2, ButMns[1]+YShift-2, ButMns[2]+XShift+ButDist+2, ButMns[3]+YShift+2);
07251
07252
printButton(
"-"
, (ButMns[0]+XShift), (ButMns[1]+YShift), (ButMns[2]+XShift), (ButMns[3]+YShift), SMALL);
07253
printButton(
"+"
, (ButMns[0]+XShift+ButDist), (ButMns[1]+YShift), (ButMns[2]+XShift+ButDist), (ButMns[3]+YShift), SMALL);
07254
}
07255
07256
if
(x>=(ButMns[0]+XShift) && x<=(ButMns[2]+XShift) && y>=(ButMns[1]+YShift) && y<=(ButMns[3]+YShift))
//press "-"
07257
{ waitForIt_Wo_Touch(ButMns[0]+XShift, ButMns[1]+YShift, ButMns[2]+XShift, ButMns[3]+YShift);
07258
PlsMnsCount -= Step;
07259
if
(PlsMnsCount > Max) {PlsMnsCount = Min;}
07260
if
(PlsMnsCount < Min) {PlsMnsCount = Max;}
07261
}
07262
07263
if
(x>=(ButMns[0]+XShift+ButDist) && x<=(ButMns[2]+XShift+ButDist) && y>=(ButMns[1]+YShift) && y<=(ButMns[3]+YShift))
//press "+"
07264
{ waitForIt_Wo_Touch(ButMns[0]+XShift+ButDist, ButMns[1]+YShift, ButMns[2]+XShift+ButDist, ButMns[3]+YShift);
07265
PlsMnsCount += Step;
07266
if
(PlsMnsCount > Max) {PlsMnsCount = Min;}
07267
if
(PlsMnsCount < Min) {PlsMnsCount = Max;}
07268
}
07269
07270
setFont(LARGE, 255, 255, 255, 0, 0, 0);
07271
myGLCD.print(
" "
, (((ButMns[2]+XShift)+(ButMns[0]+XShift+ButDist))/2-24),ButMns[1]+YShift+3);
07272
if
(PlsMnsCount >=0 && PlsMnsCount <10 ) {myGLCD.printNumI(PlsMnsCount,(((ButMns[2]+XShift)+(ButMns[0]+XShift+ButDist))/2-8),ButMns[1]+YShift+3);}
07273
if
(PlsMnsCount >=10 && PlsMnsCount <100) {myGLCD.printNumI(PlsMnsCount, (((ButMns[2]+XShift)+(ButMns[0]+XShift+ButDist))/2-16),ButMns[1]+YShift+3);}
07274
if
(PlsMnsCount >=100) {myGLCD.printNumI(PlsMnsCount, (((ButMns[2]+XShift)+(ButMns[0]+XShift+ButDist))/2-24),ButMns[1]+YShift+3);}
07275
return
PlsMnsCount;
07276
07277
}
07278
07279
//************************ Weather Function start *********************
07280
void
wthScreen (boolean refreshAll=
false
) {
// control weather main csreen
07281
07282
if
(refreshAll){
07283
PrintStringIndex=37;
// config clouds.... header
07284
printHeader ();
07285
07286
myGLCD.setColor(64, 64, 64);
07287
myGLCD.drawRect(0, 196, 319, 194);
07288
for
(
byte
y=0; y<3; y++)
07289
{ myGLCD.drawLine(0, (y*30)+44, 319, (y*30)+44); }
07290
07291
printButton(print_text[0], backGS[0], backGS[1], backGS[2], backGS[3], SMALL);
// "Back"
07292
printButton(print_text[3], canCgs[0], canCgs[1], canCgs[2], canCgs[3], SMALL);
// "Cancel"
07293
07294
setFont(SMALL, 0, 255, 0, 0, 0, 0);
07295
myGLCD.print(print_text[18], 15, 23);
// Clouds
07296
myGLCD.print(print_text[19], 15, 53);
// ThuderStorm
07297
myGLCD.print(print_text[20], 15, 83);
// Test Weather
07298
07299
}
07300
07301
if
(clouDonOff == 0)
07302
{ printButton(print_text[23], CloudCtrlON[0], CloudCtrlON[1], CloudCtrlON[2], CloudCtrlON[3], SMALL);
//"OFF"
07303
printButton(print_text[21], CloudCtrl[0], CloudCtrl[1], CloudCtrl[2], CloudCtrl[3], SMALL, GREY_BAC);
//"Setting"
07304
printButton(print_text[23], StormCtrlON[0], StormCtrlON[1], StormCtrlON[2], StormCtrlON[3], SMALL, GREY_BAC);
//"OFF"
07305
printButton(print_text[21], StormCtrl[0], StormCtrl[1], StormCtrl[2], StormCtrl[3], SMALL, GREY_BAC);
//"Setting"
07306
}
07307
else
{
07308
printButton(print_text[22], CloudCtrlON[0], CloudCtrlON[1], CloudCtrlON[2], CloudCtrlON[3], SMALL);
//"ON"
07309
printButton(print_text[21], CloudCtrl[0], CloudCtrl[1], CloudCtrl[2], CloudCtrl[3], SMALL);
//"Setting" (BLUE_BAC)
07310
}
07311
07312
if
(storMonOff==0 & clouDonOff == 1)
07313
{
07314
printButton(print_text[23], StormCtrlON[0], StormCtrlON[1], StormCtrlON[2], StormCtrlON[3], SMALL);
//"OFF"
07315
printButton(print_text[21], StormCtrl[0], StormCtrl[1], StormCtrl[2], StormCtrl[3], SMALL, GREY_BAC);
//"Setting"
07316
}
07317
if
(storMonOff==1 & clouDonOff == 1)
07318
{
07319
printButton(print_text[22], StormCtrlON[0], StormCtrlON[1], StormCtrlON[2], StormCtrlON[3], SMALL);
//"ON"
07320
printButton(print_text[21], StormCtrl[0], StormCtrl[1], StormCtrl[2], StormCtrl[3], SMALL);
//"Setting" (BLUE_BAC)
07321
}
07322
07323
07324
if
(bitRead(GlobalStatus3Byte,0) == 1){
07325
printButton(print_text[39], StormCtrl[0], StormCtrl[1]+30, StormCtrl[2], StormCtrl[3]+30, SMALL, GREEN_BAC);}
//"Start" (BLUE_BAC)
07326
else
{ printButton(print_text[40], StormCtrl[0], StormCtrl[1]+30, StormCtrl[2], StormCtrl[3]+30, SMALL);}
//"Stop" (BLUE_BAC)
07327
07328
}
07329
07330
//******************** Cloud setting **************************** dispScreen = 26 */
07331
void
clouDScreen(boolean refreshAll=
false
) {
07332
if
(refreshAll){
07333
PrintStringIndex=38;
07334
printHeader ();
07335
07336
myGLCD.setColor(64, 64, 64);
//Draw Dividers in Grey
07337
myGLCD.drawRect(0, 80, 319, 74);
07338
myGLCD.drawRect(0, 114, 319, 114);
07339
myGLCD.drawRect(0, 154, 319, 154);
07340
myGLCD.drawRect(0, 194, 319, 194);
07341
myGLCD.drawRect(0, 196, 319, 196);
07342
07343
setFont(SMALL, 0, 255, 0, 0, 0, 0);
07344
myGLCD.print(print_text[24], 8, 20);
07345
myGLCD.print(print_text[25], 8, 32);
07346
myGLCD.print(print_text[26], 8, 44);
07347
07348
myGLCD.print(print_text[27], 8, 83);
//cloud/day
07349
myGLCD.print(print_text[28], 8, 98);
07350
07351
myGLCD.print(print_text[29], 8, 116);
//duration
07352
myGLCD.print(print_text[30], 8, 128);
07353
myGLCD.print(print_text[31], 8, 141);
07354
07355
myGLCD.print(print_text[32], 8, 160);
// quantity day in week
07356
myGLCD.print(print_text[33], 8, 173);
07357
07358
// ----------------------- display values ---------------------
07359
PlusMinusCount (
true
, 200, 88, 1, 5, 1, CloudDayQantity);
// quant Cloud/day
07360
PlusMinusCount (
true
, 200, 124, 15, 90, 1, CloudDuration);
//duration one cloud period
07361
PlusMinusCount (
true
, 200, 163, 1, 7, 1, CloudWeekQantity);
// week cloudy day
07362
07363
07364
printButton(print_text[0], backGS[0], backGS[1], backGS[2], backGS[3], SMALL);
// "Back"
07365
printButton(print_text[3], canCgs[0], canCgs[1], canCgs[2], canCgs[3], SMALL);
// "Cancel"
07366
printButton(print_text[2], prSAVEgs[0], prSAVEgs[1], prSAVEgs[2], prSAVEgs[3], SMALL);
// Save
07367
}
07368
}
07369
07370
//******************** Storm setting **************************** dispScreen = 27 */
07371
void
storMScreen(boolean refreshAll=
false
) {
07372
if
(refreshAll){
07373
PrintStringIndex=39;
07374
printHeader ();
07375
07376
myGLCD.setColor(64, 64, 64);
//Draw Dividers in Grey
07377
myGLCD.drawRect(0, 80, 319, 74);
07378
myGLCD.drawRect(0, 114, 319, 114);
07379
myGLCD.drawRect(0, 154, 319, 154);
07380
myGLCD.drawRect(0, 194, 319, 194);
07381
myGLCD.drawRect(0, 196, 319, 196);
07382
07383
setFont(SMALL, 0, 255, 0, 0, 0, 0);
07384
myGLCD.print(print_text[34], 8, 20);
07385
myGLCD.print(print_text[35], 8, 32);
07386
07387
myGLCD.print(print_text[36], 8, 74+9);
//maximum duration
07388
myGLCD.print(print_text[37], 8, 74+7+12+5);
07389
07390
myGLCD.print(print_text[38], 8, 128);
//storm at night
07391
07392
// ----------------------- display values ---------------------
07393
07394
PlusMinusCount (
true
, 200, 88, 1, 10, 1, timGROZtmp);
// storm duration
07395
07396
07397
if
(NightGR==1)
// Storm on/off
07398
{ printButton(print_text[22], StormCtrlONNight[0], StormCtrlONNight[1], StormCtrlONNight[2], StormCtrlONNight[3], SMALL); }
//"ON"
07399
07400
else
{ printButton(print_text[23], StormCtrlONNight[0], StormCtrlONNight[1], StormCtrlONNight[2], StormCtrlONNight[3], SMALL); }
//"OFF"
07401
07402
printButton(print_text[0], backGS[0], backGS[1], backGS[2], backGS[3], SMALL);
// "Back"
07403
printButton(print_text[3], canCgs[0], canCgs[1], canCgs[2], canCgs[3], SMALL);
// "Cancel"
07404
printButton(print_text[2], prSAVEgs[0], prSAVEgs[1], prSAVEgs[2], prSAVEgs[3], SMALL);
// Save
07405
}
07406
}
07407
07408
void
wheaterDim ()
07409
{
07410
if
((clouDonOff ==1) && (weeStart==1)) {
// start process, decrease brigthness to DimCloudMin (default 10%)
07411
DecreaseBrightness ();
07412
if
(DimCloud < DimCloudMin) { bitSet(GlobalStatus3Byte,1); weeStart= 0 ; DimCloudMax = random (50,100);
07413
//Serial.print("max1="); Serial.println(DimCloudMax);
07414
}
// end start, next mode - random
07415
}
07416
07417
if
((clouDonOff ==1) && (weeStart==0)) {
// random mode, increase/ decrease beetween DimCloudMax/DimCloudMin
07418
if
(bitRead(GlobalStatus3Byte,1) == 1) { IncreaseBrightness ();
07419
if
(DimCloud >= DimCloudMax) { bitClear(GlobalStatus3Byte,1); DimCloudMin = random (12,50);
07420
//Serial.print("min="); Serial.println(DimCloudMin);
07421
}
07422
}
else
{DecreaseBrightness ();
07423
if
(DimCloud < DimCloudMin) { bitSet(GlobalStatus3Byte,1); DimCloudMax = random (50,100);
07424
//Serial.print("max="); Serial.println(DimCloudMax);
07425
}
07426
}
07427
}
07428
if
((clouDonOff ==1) && (weeStart==2)) {
// end process encrease to DimCloudMax =100
07429
IncreaseBrightness ();
07430
if
(DimCloud >= 100) { clouDonOff=0 ;
07431
if
(dispScreen== 25) {
07432
printButton(print_text[40], StormCtrl[0], StormCtrl[1]+30, StormCtrl[2], StormCtrl[3]+30, SMALL);}
//"Stop" (BLUE_BAC)
07433
}
07434
}
07435
if
(clouDonOff ==1) {PercentDimLW = DimCloud*0.01;}
07436
}
07437
07438
void
DecreaseBrightness ()
07439
{
// 3min from 100% to 10%
07440
/*
07441
if ((w_out >=1500) && (w_out <=2200) ) {DimCloud = DimCloud -1.25 ; } // 2-0.5
07442
if ((w_out >=1000) && (w_out <1500) ) {DimCloud = DimCloud -0.75 ; }
07443
if ((w_out >=500) && (w_out <1000) ) {DimCloud = DimCloud -0.5 ; }
07444
if ((w_out >=250) && (w_out <500) ) {DimCloud = DimCloud -0.25 ; }
07445
if (w_out <250 ) {DimCloud = DimCloud -0.13 ; }
07446
07447
if ((w_out >=1750) && (w_out <2100) ) {RampRatio = 1;}
07448
if ((w_out >=1500) && (w_out <1750) ) {RampRatio = 1;}
07449
if ((w_out >=1250) && (w_out <1500) ) {RampRatio = 1.2;}
07450
if ((w_out >=1000) && (w_out <1250) ) {RampRatio = 1.5;}
07451
if ((w_out >=750) && (w_out <1000) ) {RampRatio = 2;}
07452
if ((w_out >=500) && (w_out <750) ) {RampRatio = 2.2;}
07453
if ((w_out >=250) && (w_out <500) ) {RampRatio = 2.5;}
07454
if (w_out <250 ) {RampRatio = 2.7;}
07455
*/
07456
// 2min 40sec 100% to 10% // delta100%->10% |70% ->10% |45% ->10% |25%->10%
07457
if
((wled_out >=1750) && (wled_out <2100) ) {DimCloud = DimCloud -1.60*RampRatio ; }
// d=32
07458
if
((wled_out >=1500) && (wled_out <1750) ) {DimCloud = DimCloud -1.30*RampRatio ; }
// d=26
07459
if
((wled_out >=1250) && (wled_out <1500) ) {DimCloud = DimCloud -1.00*RampRatio ; }
// d=20 d=17
07460
if
((wled_out >=1000) && (wled_out <1250) ) {DimCloud = DimCloud -0.75*RampRatio ; }
// d=15 d=12
07461
if
((wled_out >=750) && (wled_out <1000) ) {DimCloud = DimCloud -0.50*RampRatio ; }
// d=10 d=8 d=9
07462
if
((wled_out >=500) && (wled_out <750) ) {DimCloud = DimCloud -0.35*RampRatio ; }
// d=8 d=8 d=9
07463
if
((wled_out >=250) && (wled_out <500) ) {DimCloud = DimCloud -0.25*RampRatio ; }
// d=5 d=5 d=4 d=2
07464
if
(wled_out <250 ) {DimCloud = DimCloud -0.18*RampRatio ; }
// d=2 d=3 d=3 d=2
07465
07466
}
07467
07468
void
IncreaseBrightness ()
07469
{
07470
if
((wled_out >=1750) && (wled_out <2100) ) {DimCloud = DimCloud +1.60*RampRatio ; }
07471
if
((wled_out >=1500) && (wled_out <1750) ) {DimCloud = DimCloud +1.30*RampRatio ; }
07472
if
((wled_out >=1250) && (wled_out <1500) ) {DimCloud = DimCloud +1.00*RampRatio ; }
07473
if
((wled_out >=1000) && (wled_out <1250) ) {DimCloud = DimCloud +0.75*RampRatio ; }
07474
if
((wled_out >=750) && (wled_out <1000) ) {DimCloud = DimCloud +0.5*RampRatio ; }
07475
if
((wled_out >=500) && (wled_out <750) ) {DimCloud = DimCloud +0.35*RampRatio ; }
07476
if
((wled_out >=250) && (wled_out <500) ) {DimCloud = DimCloud +0.25*RampRatio ; }
07477
if
(wled_out <250 ) {DimCloud = DimCloud +0.18*RampRatio ; }
07478
}
07479
07480
void
RampRatioCalc()
07481
{
if
((wled_out >=1750) && (wled_out <2100) ) {RampRatio = 1;}
07482
if
((wled_out >=1500) && (wled_out <1750) ) {RampRatio = 1;}
07483
if
((wled_out >=1250) && (wled_out <1500) ) {RampRatio = 1.2;}
07484
if
((wled_out >=1000) && (wled_out <1250) ) {RampRatio = 1.5;}
07485
if
((wled_out >=750) && (wled_out <1000) ) {RampRatio = 2;}
07486
if
((wled_out >=500) && (wled_out <750) ) {RampRatio = 2.2;}
07487
if
((wled_out >=250) && (wled_out <500) ) {RampRatio = 2.5;}
07488
if
(wled_out <250 ) {RampRatio = 2.7;}
07489
}
07490
07491
void
timeStartOBL () {
// опрос таймеров на погоду
07492
if
(weezON==0) {kk1=0; kk2=0; kk3=0; kk4=0; kk5=0;}
07493
07494
if
(timOBL1 !=0) {
07495
if
((min_cnt >=timOBL1) && (min_cnt < timOBL1+deltaOBL1)) {kf1=0;
if
(kk1==0) {
if
(weezON==1) {DimCloud=dimmW;}
else
{DimCloud=100;} valHH=1; valueH1=8; weeStart=1; weezON=1; kk1=1;}}
07496
if
((min_cnt >= timOBL1+deltaOBL1)&&(kf1==0)) { weeStart=2; DimCloud=dimmW; kf1=1;
07497
if
(tew==1) { timOBL1 = timOBL1temp; deltaOBL1 = deltaOBL1temp;
07498
timerGR1 = timerGR1temp; deltaGR1 = deltaGR1temp; tew=0; } } }
07499
07500
//Serial.print ("timOBL1="); Serial.println (timOBL1);
07501
07502
/*
07503
if (timOBL2 !=0) {
07504
if ((timer >=timOBL2) && (timer < timOBL2+deltaOBL2)) {kf2=0; if (kk2==0) { if (weezON==1) {DimCloud=dimmW;} else {DimCloud=100;} valHH=1; valueH1=8; weeStart=1; weezON=1; kk2=1;}}
07505
if ((timer >= timOBL2+deltaOBL2)&&(kf2==0)) { weeStart=2; DimCloud=dimmW; kf2=1;} }
07506
07507
if (timOBL3 !=0) {
07508
if ((timer >=timOBL3) && (timer < timOBL3+deltaOBL3)) {kf3=0; if (kk3==0) { if (weezON==1) {DimCloud=dimmW;} else {DimCloud=100;} valHH=1; valueH1=8; weeStart=1; weezON=1; kk3=1;}}
07509
if ((timer >= timOBL3+deltaOBL3)&&(kf3==0)) { weeStart=2; DimCloud=dimmW; kf3=1;} }
07510
07511
if (timOBL4 !=0) {
07512
if ((timer >=timOBL4) && (timer < timOBL4+deltaOBL4)) {kf4=0; if (kk4==0) { if (weezON==1) {DimCloud=dimmW;} else {DimCloud=100;} valHH=1; valueH1=8; weeStart=1; weezON=1; kk4=1;}}
07513
if ((timer >= timOBL4+deltaOBL4)&&(kf4==0)) { weeStart=2; DimCloud=dimmW; kf4=1;} }
07514
07515
if (timOBL5 !=0) {
07516
if ((timer >=timOBL5) && (timer < timOBL5+deltaOBL5)) {kf5=0; if (kk5==0) { if (weezON==1) {DimCloud=dimmW;} else {DimCloud=100;} valHH=1; valueH1=8; weeStart=1; weezON=1; kk5=1;}}
07517
if ((timer >= timOBL5+deltaOBL5)&&(kf5==0)) { weeStart=2; DimCloud=dimmW; kf5=1;} }
07518
*/
07519
// Гроза (молнии)
07520
if
(timerGR1 !=0) {
07521
if
((timer >= timerGR1) && (timer < timerGR1+deltaGR1)) {
if
(kfg1==1) { GROZA=1; } kfg1=0; }
07522
if
((timer >= timerGR1+deltaGR1)&&(kfg1==0)) {GROZA=0; valHH=1; valueH1=8; kfg1=1; } }
07523
if
(timerGR2 !=0) {
07524
if
((timer >= timerGR2) && (timer < timerGR2+deltaGR2)) {
if
(kfg2==1) { GROZA=1; } kfg2=0; }
07525
if
((timer >= timerGR2+deltaGR2)&&(kfg2==0)) {GROZA=0; valHH=1; valueH1=8; kfg2=1; } }
07526
if
(timerGR3 !=0) {
07527
if
((timer >= timerGR3) && (timer < timerGR3+deltaGR3)) {
if
(kfg3==1) { GROZA=1; } kfg3=0; }
07528
if
((timer >= timerGR3+deltaGR3)&&(kfg3==0)) {GROZA=0; valHH=1; valueH1=8; kfg3=1; } }
07529
if
(timerGR4 !=0) {
07530
if
((timer >= timerGR4) && (timer < timerGR4+deltaGR4)) {
if
(kfg4==1) { GROZA=1; } kfg4=0; }
07531
if
((timer >= timerGR4+deltaGR4)&&(kfg4==0)) {GROZA=0; valHH=1; valueH1=8; kfg4=1; } }
07532
if
(timerGR5 !=0) {
07533
if
((timer >= timerGR5) && (timer < timerGR5+deltaGR5)) {
if
(kfg5==1) { GROZA=1; } kfg5=0; }
07534
if
((timer >= timerGR5+deltaGR5)&&(kfg5==0)) {GROZA=0; valHH=1; valueH1=8; kfg5=1; } }
07535
if
(timerGR6 !=0) {
07536
if
((timer >= timerGR6) && (timer < timerGR6+deltaGR6)) {
if
(kfg6==1) { GROZA=1; } kfg6=0; }
07537
if
((timer >= timerGR6+deltaGR6)&&(kfg6==0)) {GROZA=0; valHH=1; valueH1=8; kfg6=1; } }
07538
}
07539
07540
void
CalcCoud()
07541
{
07542
int
cloudDayFromTo;
07543
int
TempX;
07544
//byte TempY;
07545
07546
calculateStartTime();
// calculate SUNRISE Time
07547
calculateStopTime();
// calculate SUNSET Time
07548
cloudDayFromTo = (StopTime*15 - StartTime*15) - 60;
// -60min, end cloud 60min before sunset
07549
TempX = cloudDayFromTo/CloudDayQantity;
07550
07551
Serial
.println(StartTime*15);
07552
Serial
.println(StopTime*15);
07553
Serial
.println(TempX);
07554
07555
for
(
int
i=0; i<CloudDayQantity; i++)
07556
{
int
TempY;
07557
// TempY= ((StartTime*15)+ TempX*i);
07558
TempY= random(((StartTime*15)+ TempX*i), (((StartTime*15)+ TempX*i)+ TempX));
07559
07560
Serial
.println(TempY);
07561
}
07562
07563
//CloudDayQantity
07564
//CloudDuration
07565
//CloudWeekQantity
07566
07567
07568
}
07569
void
planPOG () {
// планирование погоды
07570
07571
OBLday = dayOBL[dayL];
07572
07573
timOBL1=0; timOBL2=0; timOBL3=0; timOBL4=0; timOBL5=0;
// планирование погоды на день
07574
int
tOBL_1=0;
07575
int
tOBL_2=0;
07576
int
tOBL_3=0;
07577
int
tOBL_4=0;
07578
OBLday = 7;
07579
dimmW = random(30,60);
07580
07581
if
((timOBL == 1)&&(OBLday !=0)) { tOBL_1 = random(1,6);}
07582
if
((timOBL == 2)&&(OBLday !=0)) { tOBL_1 = random(1,6); tOBL_2 = random(1,6); }
07583
if
((timOBL == 3)&&(OBLday !=0)) { tOBL_1 = random(1,6); tOBL_2 = random(1,6); tOBL_3 = random(1,6); }
07584
if
((timOBL == 4)&&(OBLday !=0)) { tOBL_1 = random(1,6); tOBL_2 = random(1,6); tOBL_3 = random(1,6); tOBL_4 = random(1,6);}
07585
07586
// cloud for one day
07587
// timOBL cloud counter 1..5
07588
// timOBL1....timOBL5 cloud start time
07589
// deltaOBL cloud duration
07590
07591
if
((tOBL_1 == 1)||(tOBL_2 == 1)||(tOBL_3 == 1)||(tOBL_4 == 1)) {timOBL1 = random(600,720); deltaOBL1 = random(5,deltaOBL); }
07592
if
((tOBL_1 == 2)||(tOBL_2 == 2)||(tOBL_3 == 2)||(tOBL_4 == 2)) {timOBL2 = random(720,840); deltaOBL2 = random(5,deltaOBL); }
07593
if
((tOBL_1 == 3)||(tOBL_2 == 3)||(tOBL_3 == 3)||(tOBL_4 == 3)) {timOBL3 = random(840,960); deltaOBL3 = random(5,deltaOBL); }
07594
if
((tOBL_1 == 4)||(tOBL_2 == 4)||(tOBL_3 == 4)||(tOBL_4 == 4)) {timOBL4 = random(960,1080); deltaOBL4 = random(5,deltaOBL); }
07595
if
((tOBL_1 == 5)||(tOBL_2 == 5)||(tOBL_3 == 5)||(tOBL_4 == 5)) {timOBL5 = random(1080,1200); deltaOBL5 = random(5,deltaOBL); }
07596
07597
if
(timOBL == 5) {
07598
timOBL1 = random(600,720); deltaOBL1 = random(5,deltaOBL);
// 10-12 hour
07599
timOBL2 = random(720,840); deltaOBL2 = random(5,deltaOBL);
// 12-14
07600
timOBL3 = random(840,960); deltaOBL3 = random(5,deltaOBL);
// 14-16
07601
timOBL4 = random(960,1080); deltaOBL4 = random(5,deltaOBL);
// 16-18
07602
timOBL5 = random(1080,1200); deltaOBL5 = random(5,deltaOBL);
// 18-20
07603
}
07604
07605
Serial
.print (
"timOBL="
);
Serial
.println (timOBL);
07606
Serial
.print (
"timOBL1="
);
Serial
.println (timOBL1);
07607
Serial
.print (
"timOBL2="
);
Serial
.println (timOBL2);
07608
Serial
.print (
"timOBL3="
);
Serial
.println (timOBL3);
07609
Serial
.print (
"timOBL4="
);
Serial
.println (timOBL4);
07610
Serial
.print (
"timOBL5="
);
Serial
.println (timOBL5);
07611
Serial
.print (
"tOBL_1="
);
Serial
.println (tOBL_1);
07612
07613
07614
07615
// Панирование грозы
07616
GR1=0; GR2=0; GR3=0; GR4=0; GR5=0; GR6=0;
07617
timerGR1=0; timerGR2=0; timerGR3=0; timerGR4=0; timerGR5=0; timerGR6=0;
07618
07619
if
(stormGR==1) {
07620
if
(random(0,2)==1) {GROZAday=1;}
else
{GROZAday=0;}
// решается, будет гроза сегодня или нет
07621
07622
if
((timOBL1 != 0)&&(GROZAday==1)) {
if
(random(0,3) !=1) {GR1=1; timerGR1=timOBL1+deltaOBL1/2;
// решается, будет гроза или нет (в облачночть 1)
07623
deltaGR1=random(1,timGROZ); }}
07624
if
((timOBL2 != 0)&&(GROZAday==1)) {
if
(random(0,3) !=1) {GR2=1; timerGR2=timOBL2+deltaOBL2/2;
07625
deltaGR2=random(1,timGROZ); }}
07626
if
((timOBL3 != 0)&&(GROZAday==1)) {
if
(random(0,3) !=1) {GR3=1; timerGR3=timOBL3+deltaOBL3/2;
07627
deltaGR3=random(1,timGROZ); }}
07628
if
((timOBL4 != 0)&&(GROZAday==1)) {
if
(random(0,3) !=1) {GR4=1; timerGR4=timOBL4+deltaOBL4/2;
07629
deltaGR4=random(1,timGROZ); }}
07630
if
((timOBL5 != 0)&&(GROZAday==1)) {
if
(random(0,3) !=1) {GR5=1; timerGR5=timOBL5+deltaOBL5/2;
07631
deltaGR5=random(1,timGROZ); }}
07632
07633
if
(GROZANight==1) {
if
(random(0,2)==1) { GR6=1;
07634
timerGR6=random(2, 600); deltaGR6=random(1,timGROZ);}}
// Гроза ночью
07635
}}
07636
07637
void
planPOG_ned() {
// планирование облаков на неделю
07638
07639
for
(
int
i=1; i<8; i++) {dayOBL[i]=0;}
// обнулеение массива дней облаков (недели) и планирование погоды (облаков) на неделю
07640
byte
po1=0, po2=0, po3=0, po4=0;
07641
if
(razOBL==1) { po1=random(1,8); dayOBL[po1]=1; }
07642
if
(razOBL==2) { po1=random(1,4); po2=random(4,8); dayOBL[po1]=1; dayOBL[po2]=1; }
07643
07644
if
(razOBL==3) { po1=random(1,4); po2=random(4,8); po3=random(1,8); dayOBL[po1]=1; dayOBL[po2]=1; dayOBL[po3]=1; }
07645
if
(razOBL==4) { po1=random(1,4); po2=random(4,8); po3=random(1,8); po4=random(1,8); dayOBL[po1]=1; dayOBL[po2]=1; dayOBL[po3]=1; dayOBL[po4]=1; }
07646
07647
if
((razOBL==5)||(razOBL==6)||(razOBL==7)) {
for
(
int
i=1; i<=7; i++) {dayOBL[i]=1; }
07648
if
(razOBL==5) {po1=random(1,4); po2=random(4,8); dayOBL[po1] =0; dayOBL[po2] =0; }
07649
if
(razOBL==6) {po1=random(1,8); dayOBL[po1] =0; } }
07650
}
07651
07652
07653
07654
/************************************ TOUCH SCREEN ************************************/
07655
void
processMyTouch()
07656
{
07657
myTouch.read();
07658
// x=myTouch.getX();
07659
// y=myTouch.getY();
07660
07661
#ifdef Mirror_X
07662
x=320-myTouch.getX();
07663
#else
07664
x=myTouch.getX();
07665
#endif
07666
07667
#ifdef Mirror_Y
07668
y=240-myTouch.getY();
07669
#else
07670
y=myTouch.getY();
07671
#endif
07672
07673
07674
returnTimer=0;
07675
screenSaverCounter=0;
07676
07677
if
((x>=canC[0]) && (x<=canC[2]) && (y>=canC[1]) && (y<=canC[3])
//press cancel
07678
&& (dispScreen!=0) && (dispScreen!=5) && (dispScreen!=6) && (dispScreen!=8)
07679
&& (dispScreen!=9) && (dispScreen!=11) && (dispScreen!=14) && (dispScreen!=15)
07680
&& (dispScreen!=20) && (dispScreen!=26) && (dispScreen!=27))
07681
{
07682
waitForIt(canC[0], canC[1], canC[2], canC[3]);
07683
// waveMakerOff = false;
07684
dispScreen=0;
07685
clearScreen();
07686
mainScreen(
true
);
07687
}
else
07688
if
((x>=back[0]) && (x<=back[2]) && (y>=back[1]) && (y<=back[3])
//press back
07689
&& (dispScreen!=0) && (dispScreen!=1) && (dispScreen!=2) && (dispScreen!=5) && (dispScreen!=6)
07690
&& (dispScreen!=8) && (dispScreen!=9) && (dispScreen!=11) && (dispScreen!=13)
07691
&& (dispScreen!=14) && (dispScreen!=15) && (dispScreen!=16) && (dispScreen!=17)
07692
&& (dispScreen!=18) && (dispScreen!=20) && (dispScreen!=21) && (dispScreen!=22) && (dispScreen!=23) && (dispScreen!=26) && (dispScreen!=27))
07693
{
07694
waitForIt(back[0], back[1], back[2], back[3]);
07695
// waveMakerOff = false;
07696
dispScreen=1;
07697
clearScreen();
07698
menuScreen();
07699
}
else
07700
07701
{
07702
switch
(dispScreen) {
07703
case
0:
//--------------- MAIN SCREEN (Press Any Key) ---------------
07704
dispScreen=1;
07705
clearScreen();
07706
menuScreen();
07707
break
;
07708
07709
case
1:
//--------------------- MENU SCREEN -------------------------
07710
07711
if
((x>=temC[0]) && (x<=temC[2]))
//first column
07712
{
07713
/*
07714
if ((x>=tanD[0]) && (x<=tanD[2])) //first column
07715
{
07716
07717
if ((y>=tanD[1]) && (y<=tanD[3])) //press Date & Clock Screen
07718
{
07719
waitForIt(tanD[0], tanD[1], tanD[2], tanD[3]);
07720
if ((timeDispH>=0) && (timeDispH<=11)) { AM_PM=1;}
07721
else { AM_PM=2;}
07722
dispScreen=2;
07723
clearScreen();
07724
clockScreen();
07725
t_temp = rtc.getTime();
07726
t_temp.dow=calcDOW(rtcSetDy, rtcSetMon, rtcSetYr);
07727
showDOW(t_temp.dow);
07728
}
07729
*/
07730
07731
if
((y>=temC[1]) && (y<=temC[3]))
//press H2O Temp Control
07732
{
07733
waitForIt(temC[0], temC[1], temC[2], temC[3]);
07734
dispScreen=3;
07735
clearScreen();
07736
tempScreen(
true
);
07737
}
07738
07739
if
((y>=WeatCtrl[1]) && (y<=WeatCtrl[3]))
//press Weather Control screen
07740
{
07741
waitForIt(WeatCtrl[0], WeatCtrl[1], WeatCtrl[2], WeatCtrl[3]);
07742
dispScreen=25;
07743
clearScreen();
07744
wthScreen(
true
);
07745
}
07746
07747
/*
07748
if ((y>=gSet[1]) && (y<=gSet[3])) //press General Settings
07749
{
07750
waitForIt(gSet[0], gSet[1], gSet[2], gSet[3]);
07751
dispScreen=14;
07752
clearScreen();
07753
generalSettingsScreen_1();
07754
}
07755
*/
07756
07757
if
((y>=prsM[1]) && (y<=prsM[3]))
//press PRESET XX button
07758
{
07759
waitForIt(prsM[0], prsM[1], prsM[2], prsM[3]);
07760
PresetSwitch();
07761
}
07762
}
07763
07764
if
((x>=tesT[0]) && (x<=tesT[2]))
//second column
07765
{
07766
if
((y>=tesT[1]) && (y<=tesT[3]))
//press LED Testing page
07767
{
07768
waitForIt(tesT[0], tesT[1], tesT[2], tesT[3]);
07769
dispScreen=4;
07770
clearScreen();
07771
ledTestOptionsScreen();
07772
}
07773
if
((y>=ledChM[1]) && (y<=ledChM[3]))
//press Change LED values
07774
{
07775
waitForIt(ledChM[0], ledChM[1], ledChM[2], ledChM[3]);
07776
dispScreen=7;
07777
clearScreen();
07778
ledColorViewScreen();
07779
}
07780
07781
if
((y>=gSet[1]) && (y<=gSet[3]))
//press General Settings
07782
{
07783
waitForIt(gSet[0], gSet[1], gSet[2], gSet[3]);
07784
dispScreen=14;
07785
clearScreen();
07786
generalSettingsScreen_1();
07787
}
07788
/*
07789
if ((y>=aFeed[1]) && (y<=aFeed[3])) //press Automatic Feeder screen
07790
{
07791
waitForIt(aFeed[0], aFeed[1], aFeed[2], aFeed[3]);
07792
dispScreen=12;
07793
clearScreen();
07794
autoFeederScreen();
07795
}
07796
if ((y>=about[1]) && (y<=about[3])) //press About sketch
07797
{
07798
waitForIt(about[0], about[1], about[2], about[3]);
07799
dispScreen=19;
07800
clearScreen();
07801
AboutScreen();
07802
}
07803
*/
07804
}
07805
break
;
07806
07807
case
2:
//--------------- SET TIME AND DATE -------------------------
07808
/*
07809
if ((x>=back[0]) && (x<=back[2]) && (y>=back[1]) && (y<=back[3])) //press back
07810
{
07811
waitForIt(back[0], back[1], back[2], back[3]);
07812
dispScreen=14;
07813
clearScreen();
07814
generalSettingsScreen_1();
07815
}
07816
*/
07817
// else
07818
if
((x>=prSAVE[0]) && (x<=prSAVE[2]) && (y>=prSAVE[1]) && (y<=prSAVE[3]))
//press SAVE
07819
{
07820
waitForIt(prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3]);
07821
if
(setTimeFormat==1)
07822
{
07823
if
((rtcSetHr==0) && (AM_PM==2))
07824
{ rtcSetHr+=12;}
07825
if
(((rtcSetHr>=1) && (rtcSetHr<=11)) && (AM_PM==2))
07826
{ rtcSetHr+=12;}
07827
if
(((rtcSetHr>=12) && (rtcSetHr<=23)) && (AM_PM==1))
07828
{ rtcSetHr-=12;}
07829
}
07830
07831
rtc.setTime(rtcSetHr, rtcSetMin, 0);
07832
rtc.setDate(rtcSetDy, rtcSetMon, rtcSetYr);
07833
dispScreen=14;
07834
clearScreen();
07835
generalSettingsScreen_1();
07836
}
07837
//-------------- change Hour/Min ----------------------
07838
else
07839
{
07840
if
((y>=houU[1]) && (y<=houU[3]))
//FIRST ROW (TIME UP)
07841
{
07842
if
((x>=houU[0]) && (x<=houU[2]))
//press hour up
07843
{
07844
// waitForIt(houU[0], houU[1], houU[2], houU[3]);
07845
waitForIt_Wo_Touch(houU[0], houU[1], houU[2], houU[3]);
07846
rtcSetHr++;
07847
if
(rtcSetHr>=24)
07848
{ rtcSetHr=0; }
07849
}
07850
if
((x>=minU[0]) && (x<=minU[2]))
//press min up
07851
{
07852
// waitForIt(minU[0], minU[1], minU[2], minU[3]);
07853
waitForIt_Wo_Touch(minU[0], minU[1], minU[2], minU[3]);
07854
rtcSetMin++;
07855
if
(rtcSetMin>=60) {rtcSetMin = 0; }
07856
}
07857
if
((x>=ampmU[0]) && (x<=ampmU[2]) && (setTimeFormat==1))
//press AMPM up
07858
{
07859
// waitForIt(ampmU[0], ampmU[1], ampmU[2], ampmU[3]);
07860
waitForIt_Wo_Touch(ampmU[0], ampmU[1], ampmU[2], ampmU[3]);
07861
if
(AM_PM==1) {AM_PM=2;}
07862
else
{AM_PM=1;}
07863
}
07864
clockScreen(
false
);
07865
}
07866
if
((y>=houD[1]) && (y<=houD[3]))
//SECOND ROW (TIME DOWN)
07867
{
07868
if
((x>=houD[0]) && (x<=houD[2]))
//press hour down
07869
{
07870
// waitForIt(houD[0], houD[1], houD[2], houD[3]);
07871
waitForIt_Wo_Touch(houD[0], houD[1], houD[2], houD[3]);
07872
rtcSetHr--;
07873
if
(rtcSetHr<0)
07874
{ rtcSetHr=23; }
07875
}
07876
if
((x>=minD[0]) && (x<=minD[2]))
//press min down
07877
{
07878
// waitForIt(minD[0], minD[1], minD[2], minD[3]);
07879
waitForIt_Wo_Touch(minD[0], minD[1], minD[2], minD[3]);
07880
rtcSetMin--;
07881
if
(rtcSetMin<0) {rtcSetMin = 59; }
07882
}
07883
if
((x>=ampmD[0]) && (x<=ampmD[2]) && (setTimeFormat==1))
//press AMPM down
07884
{
07885
// waitForIt(ampmD[0], ampmD[1], ampmD[2], ampmD[3]);
07886
waitForIt_Wo_Touch(ampmD[0], ampmD[1], ampmD[2], ampmD[3]);
07887
if
(AM_PM==1) {AM_PM=2;}
07888
else
{AM_PM=1;}
07889
}
07890
clockScreen(
false
);
07891
}
07892
07893
//-------------- change Day/Mouth/Year ----------------------
07894
07895
if
((y>=dayU[1]) && (y<=dayU[3]))
//THIRD ROW (DATE UP)
07896
{
07897
if
(setCalendarFormat==0)
//DD/MM/YYYY Format
07898
{
07899
if
((x>=dayU[0]) && (x<=dayU[2]))
//press day up
07900
{
07901
// waitForIt(dayU[0], dayU[1], dayU[2], dayU[3]);
07902
waitForIt_Wo_Touch(dayU[0], dayU[1], dayU[2], dayU[3]);
07903
rtcSetDy++;
07904
rtcSetDy=validateDate(rtcSetDy, rtcSetMon, rtcSetYr);
07905
t_temp = rtc.getTime();
07906
t_temp.dow=calcDOW(rtcSetDy, rtcSetMon, rtcSetYr);
07907
showDOW(t_temp.dow);
07908
}
07909
if
((x>=monU[0]) && (x<=monU[2]))
//press month up
07910
{
07911
// waitForIt(monU[0], monU[1], monU[2], monU[3]);
07912
waitForIt_Wo_Touch(monU[0], monU[1], monU[2], monU[3]);
07913
rtcSetMon++;
07914
if
(rtcSetMon>12) {rtcSetMon=1;}
//#oleg
07915
rtcSetDy=validateDateForMonth(rtcSetDy, rtcSetMon, rtcSetYr);
07916
t_temp = rtc.getTime();
07917
t_temp.dow=calcDOW(rtcSetDy, rtcSetMon, rtcSetYr);
07918
showDOW(t_temp.dow);
07919
}
07920
}
else
{
07921
if
(setCalendarFormat==1)
//MM/DD/YYYY Format
07922
{
07923
if
((x>=dayU[0]) && (x<=dayU[2]))
//press month up
07924
{
07925
// waitForIt(dayU[0], dayU[1], dayU[2], dayU[3]);
07926
waitForIt_Wo_Touch(dayU[0], dayU[1], dayU[2], dayU[3]);
07927
rtcSetMon++;
07928
if
(rtcSetMon>12) {rtcSetMon=1;}
//#oleg
07929
rtcSetDy=validateDateForMonth(rtcSetDy, rtcSetMon, rtcSetYr);
07930
t_temp = rtc.getTime();
07931
t_temp.dow=calcDOW(rtcSetDy, rtcSetMon, rtcSetYr);
07932
showDOW(t_temp.dow);
07933
}
07934
if
((x>=monU[0]) && (x<=monU[2]))
//press day up
07935
{
07936
// waitForIt(monU[0], monU[1], monU[2], monU[3]);
07937
waitForIt_Wo_Touch(monU[0], monU[1], monU[2], monU[3]);
07938
rtcSetDy++;
07939
rtcSetDy=validateDate(rtcSetDy, rtcSetMon, rtcSetYr);
07940
t_temp = rtc.getTime();
07941
t_temp.dow=calcDOW(rtcSetDy, rtcSetMon, rtcSetYr);
07942
showDOW(t_temp.dow);
07943
}
07944
} }
07945
if
((x>=yeaU[0]) && (x<=yeaU[2]))
//press year up
07946
{
07947
// waitForIt(yeaU[0], yeaU[1], yeaU[2], yeaU[3]);
07948
waitForIt_Wo_Touch(yeaU[0], yeaU[1], yeaU[2], yeaU[3]);
07949
rtcSetYr++;
07950
rtcSetDy=validateDateForMonth(rtcSetDy, rtcSetMon, rtcSetYr);
07951
t_temp = rtc.getTime();
07952
t_temp.dow=calcDOW(rtcSetDy, rtcSetMon, rtcSetYr);
07953
showDOW(t_temp.dow);
07954
}
07955
// t_temp = rtc.getTime();
07956
// t_temp.dow=calcDOW(rtcSetDy, rtcSetMon, rtcSetYr);
07957
// showDOW(t_temp.dow);
07958
clockScreen(
false
);
07959
}
07960
if
((y>=dayD[1]) && (y<=dayD[3]))
//FOURTH ROW (DATE DOWN)
07961
{
07962
if
(setCalendarFormat==0)
//DD/MM/YYYY Format
07963
{
07964
if
((x>=dayD[0]) && (x<=dayD[2]))
//press day down
07965
{
07966
// waitForIt(dayD[0], dayD[1], dayD[2], dayD[3]);
07967
waitForIt_Wo_Touch(dayD[0], dayD[1], dayD[2], dayD[3]);
07968
rtcSetDy--;
07969
rtcSetDy=validateDate(rtcSetDy, rtcSetMon, rtcSetYr);
07970
t_temp = rtc.getTime();
07971
t_temp.dow=calcDOW(rtcSetDy, rtcSetMon, rtcSetYr);
07972
showDOW(t_temp.dow);
07973
}
07974
if
((x>=monD[0]) && (x<=monD[2]))
//press month down
07975
{
07976
// waitForIt(monD[0], monD[1], monD[2], monD[3]);
07977
waitForIt_Wo_Touch(monD[0], monD[1], monD[2], monD[3]);
07978
rtcSetMon--;
07979
if
(rtcSetMon<1) {rtcSetMon=12;}
07980
rtcSetDy=validateDateForMonth(rtcSetDy, rtcSetMon, rtcSetYr);
07981
t_temp = rtc.getTime();
07982
t_temp.dow=calcDOW(rtcSetDy, rtcSetMon, rtcSetYr);
07983
showDOW(t_temp.dow);
07984
}
07985
}
else
{
07986
if
(setCalendarFormat==1)
//MM/DD/YYYY Format
07987
{
07988
if
((x>=dayD[0]) && (x<=dayD[2]))
//press day down
07989
{
07990
// waitForIt(dayD[0], dayD[1], dayD[2], dayD[3]);
07991
waitForIt_Wo_Touch(dayD[0], dayD[1], dayD[2], dayD[3]);
07992
rtcSetMon--;
07993
if
(rtcSetMon<1) {rtcSetMon=12;}
07994
rtcSetDy=validateDateForMonth(rtcSetDy, rtcSetMon, rtcSetYr);
07995
t_temp = rtc.getTime();
07996
t_temp.dow=calcDOW(rtcSetDy, rtcSetMon, rtcSetYr);
07997
showDOW(t_temp.dow);
07998
}
07999
if
((x>=monD[0]) && (x<=monD[2]))
//press month down
08000
{
08001
// waitForIt(monD[0], monD[1], monD[2], monD[3]);
08002
waitForIt_Wo_Touch(monD[0], monD[1], monD[2], monD[3]);
08003
rtcSetDy--;
08004
rtcSetDy=validateDate(rtcSetDy, rtcSetMon, rtcSetYr);
08005
t_temp = rtc.getTime();
08006
t_temp.dow=calcDOW(rtcSetDy, rtcSetMon, rtcSetYr);
08007
showDOW(t_temp.dow);
08008
}
08009
} }
08010
if
((x>=yeaD[0]) && (x<=yeaD[2]))
//press year down
08011
{
08012
// waitForIt(yeaD[0], yeaD[1], yeaD[2], yeaD[3]);
08013
waitForIt_Wo_Touch(yeaD[0], yeaD[1], yeaD[2], yeaD[3]);
08014
rtcSetYr--;
08015
rtcSetDy=validateDateForMonth(rtcSetDy, rtcSetMon, rtcSetYr);
08016
t_temp = rtc.getTime();
08017
t_temp.dow=calcDOW(rtcSetDy, rtcSetMon, rtcSetYr);
08018
showDOW(t_temp.dow);
08019
}
08020
// t_temp = rtc.getTime();
08021
// t_temp.dow=calcDOW(rtcSetDy, rtcSetMon, rtcSetYr);
08022
// showDOW(t_temp.dow);
08023
clockScreen(
false
);
08024
}
08025
// clockScreen(false);
08026
}
08027
08028
if
((x>=back[0]) && (x<=back[2]) && (y>=back[1]) && (y<=back[3]))
//press back
08029
{
08030
waitForIt(back[0], back[1], back[2], back[3]);
08031
dispScreen=14;
08032
clearScreen();
08033
generalSettingsScreen_1();
08034
}
08035
08036
break
;
08037
08038
case
3:
//------------------ H20 TEMPERATURE CONTROL ---------------
08039
if
((x>=prSAVE[0]) && (x<=prSAVE[2]) && (y>=prSAVE[1]) && (y<=prSAVE[3]))
//press SAVE
08040
{
08041
waitForIt(prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3]);
08042
setTempC = temp2beS;
08043
setTempF = temp2beS;
08044
offTempC = temp2beO;
08045
offTempF = temp2beO;
08046
alarmTempC = temp2beA;
08047
alarmTempF = temp2beA;
08048
if
(setTempScale==0)
//Celsius to Farenheit (Consistency Conversion)
08049
{
08050
setTempF=((1.8*setTempC)+32.05);
08051
offTempF=((1.8*offTempC)+0.05);
08052
alarmTempF=((1.8*alarmTempC)+0.05);
08053
}
08054
if
(setTempScale==1)
//Farenheit to Celsius (Consistency Conversion)
08055
{
08056
setTempC=((.55556*(setTempF-32))+.05);
08057
offTempC=(.55556)*offTempF+.05;
08058
alarmTempC=(.55556)*alarmTempF+.05;
08059
}
08060
dispScreen=0;
08061
SaveTempToEEPROM();
08062
clearScreen();
08063
mainScreen(
true
);
08064
}
else
08065
setFont(LARGE, 255, 255, 255, 0, 0, 0);
08066
{
08067
if
((x>=temM[0]) && (x<=temM[2]))
//first column
08068
{
08069
if
((y>=temM[1]) && (y<=temM[3]))
//press temp minus
08070
{
08071
temp2beS -= 0.1;
08072
if
((setTempScale==1) && (temp2beS <= 50)){
08073
temp2beS = 50; }
08074
if
((setTempScale==0) && (temp2beS <= 10)) {
08075
temp2beS = 10; }
08076
tempScreen();
08077
delay(150);
08078
}
08079
if
((y>=offM[1]) && (y<=offM[3]))
//press offset minus
08080
{
08081
temp2beO -= 0.1;
08082
if
(temp2beO <= 0.1) {temp2beO = 0.1; }
08083
tempScreen();
08084
delay(150);
08085
}
08086
if
((y>=almM[1]) && (y<=almM[3]))
//press alarm minus
08087
{
08088
temp2beA -= 0.1;
08089
if
(temp2beA <= 0.1) {temp2beA = 9.9;}
08090
tempScreen();
08091
delay(150);
08092
}
08093
}
08094
if
((x>=temP[0]) && (x<=temP[2]))
//second column
08095
{
08096
if
((y>=temP[1]) && (y<=temP[3]))
//press temp plus
08097
{
08098
temp2beS += 0.1;
08099
if
((setTempScale==1) && (temp2beS >= 104)){
08100
temp2beS = 104; }
08101
if
((setTempScale==0) && (temp2beS >= 40)) {
08102
temp2beS = 40; }
08103
tempScreen();
08104
delay(150);
08105
}
08106
if
((y>=offP[1]) && (y<=offP[3]))
//press offset plus
08107
{
08108
temp2beO += 0.1;
08109
if
(temp2beO >= 5) {temp2beO = 5; }
08110
tempScreen();
08111
delay(150);
08112
}
08113
if
((y>=almP[1]) && (y<=almP[3]))
//press alarm plus
08114
{
08115
temp2beA += 0.1;
08116
if
(temp2beA >=10.0) {temp2beA = 0.1;}
08117
tempScreen();
08118
delay(150);
08119
}
08120
}
08121
}
08122
break
;
08123
08124
case
4:
// -------------- LED TESTING OPTIONS SCREEN -----------------
08125
if
((x>=tstLA[0]) && (x<=tstLA[2]) && (y>=tstLA[1]) && (y<=tstLA[3]))
//Rapid Test LED Array Output
08126
{
08127
waitForIt(tstLA[0], tstLA[1], tstLA[2], tstLA[3]);
08128
dispScreen=5;
08129
clearScreen();
08130
LEDtestTick=
false
;
08131
// testArrayScreen(true); // rapid test led array, draw all test window
08132
AllColourGraph();
08133
08134
}
08135
if
((x>=cntIL[0]) && (x<=cntIL[2]) && (y>=cntIL[1]) && (y<=cntIL[3]))
//Control Individual LEDs
08136
{
08137
waitForIt(cntIL[0], cntIL[1], cntIL[2], cntIL[3]);
08138
dispScreen=6;
08139
clearScreen();
08140
testIndLedScreen(
true
);
// test and control individual led
08141
colorLEDtest =
true
;
08142
bitClear(GlobalStatus1Byte,3);
// clear bit for " Save changes before exit "
08143
bitClear(GlobalStatus1Byte,2);
// clear bit for " Save changes before exit "
08144
}
08145
08146
if
((x>=PrButL[0]) && (x<=PrButL[2]) && (y>=PrButL[1]) && (y<=PrButL[3]))
//preset button LEDs
08147
{
08148
waitForIt(PrButL[0], PrButL[1], PrButL[2], PrButL[3]);
08149
dispScreen=23;
08150
clearScreen();
08151
PresetLedScreen(
true
);
// preset led windows
08152
// colorLEDtest = true;
08153
}
08154
08155
break
;
08156
08157
case
5:
//---------------- Rapid LED TEST------------------------
08158
if
((x>=back[0]) && (x<=back[2]) && (y>=back[1]) && (y<=back[3])
//press back
08159
&& (LEDtestTick==
false
))
08160
{
08161
waitForIt(back[0], back[1], back[2], back[3]);
08162
// LEDtestTick = false;
08163
// ReadFromEEPROM();
08164
dispScreen=4;
08165
clearScreen();
08166
ledTestOptionsScreen();
// display buttons "Rapid test" and "Control Individual Leds"
08167
}
08168
if
((x>=canC[0]) && (x<=canC[2]) && (y>=canC[1]) && (y<=canC[3])
//press CANCEL
08169
&& (LEDtestTick==
false
))
08170
{
08171
waitForIt(canC[0], canC[1], canC[2], canC[3]);
08172
// LEDtestTick = false;
08173
// ReadFromEEPROM();
08174
dispScreen=0;
08175
clearScreen();
08176
mainScreen(
true
);
08177
}
08178
if
((x>=ledChV[0]) && (x<=ledChV[2]) && (y>=ledChV[1]) && (y<=ledChV[3]) && dispScreen==5)
//press start/stop test
08179
{
08180
waitForIt(ledChV[0], ledChV[1], ledChV[2], ledChV[3]);
08181
printButton(
"STOP"
, ledChV[0], ledChV[1], ledChV[2], ledChV[3], SMALL);
// buton start/stop test
08182
08183
if
(LEDtestTick ==
true
) {
08184
LEDtestTick =
false
;
// stop test
08185
}
08186
else
{
08187
LEDtestTick =
true
;
// start test
08188
myGLCD.setColor(0, 0, 0);
08189
myGLCD.fillRect(26, BotSldY+8, 319, BotSldY+3);
// clear test bar
08190
drawTestLedArrayScale();
08191
}
08192
}
08193
break
;
08194
08195
case
6:
// --------------- TEST INDIVIDUAL LED COLOR SCREEN ( dispScreen=6 )--------------
08196
08197
// DrawStaticElement == true;
08198
08199
if
((x>=back[0]) && (x<=back[2]) && (y>=back[1]) && (y<=back[3]) && (bitRead(GlobalStatus1Byte,2) ==
false
))
//press back, exit to "Test option screen"
08200
{
08201
waitForIt(back[0], back[1], back[2], back[3]);
08202
if
(bitRead(GlobalStatus1Byte,3) ==
false
)
// bit3 =0, no changes settings
08203
{
08204
dispScreen=4;
08205
clearScreen();
08206
ledTestOptionsScreen();
08207
colorLEDtest =
false
;
08208
LED_levels_output();
//return to current values led before exit to main
08209
}
08210
else
{colorLEDtest =
true
;
08211
bitSet(GlobalStatus1Byte,2);
// for detect button Yes/No in to "save and exit" windows
08212
SaveAndExit();
08213
}
08214
}
08215
if
((x>=No[0]) && (x<=No[2]) && (y>=No[1]) && (y<=No[3]) && (bitRead(GlobalStatus1Byte,2) ==
true
))
//press "NO", exit to menu without save,
08216
{
08217
waitForIt(No[0], No[1], No[2], No[3]);
08218
// LEDtestTick = false;
08219
dispScreen=4;
08220
clearScreen();
08221
ledTestOptionsScreen();
08222
COLOR = 0;
08223
ReadLedFromEEPROM();
08224
bitClear(GlobalStatus1Byte,3);
// bit 3 - changes setting (0 - no change, 1 -change )
08225
bitClear(GlobalStatus1Byte,2);
// clear bit for " Save changes before exit "
08226
colorLEDtest =
false
;
08227
LED_levels_output();
//return to current values led before exit to main
08228
}
08229
08230
if
((x>=Yes[0]) && (x<=Yes[2]) && (y>=Yes[1]) && (y<=Yes[3]) && (bitRead(GlobalStatus1Byte,2) ==
true
))
//press "Yes" for save all changes and exit
08231
{
08232
waitForIt(Yes[0], Yes[1], Yes[2], Yes[3]);
08233
// LEDtestTick = false;
08234
clearScreen();
08235
setFont(LARGE, 255, 0, 0, 0, 0, 0);
08236
myGLCD.print(
"PLEASE WAIT"
, 72, 80);
08237
COLOR=0 ;
// save all colour
08238
SaveLEDToEEPROM();
08239
bitClear(GlobalStatus1Byte,3);
// clear bit for " Save changes before exit "
08240
bitClear(GlobalStatus1Byte,2);
// clear bit for " Save changes before exit "
08241
dispScreen=4;
08242
colorLEDtest =
false
;
08243
ReadLedFromEEPROM();
08244
clearScreen();
08245
LED_levels_output();
//return to current values led before exit to main
08246
ledTestOptionsScreen();
08247
}
08248
08249
if
((x>=StopDay[0]) && (x<=StopDay[2]) && (y>=StopDay[1]) && (y<=StopDay[3]) && colorLEDtest==
true
08250
&& (bitRead(GlobalStatus1Byte,2) ==
false
))
//press SUNSET, jump to end "light day"
08251
{
08252
waitForIt(StopDay[0], StopDay[1], StopDay[2], StopDay[3]);
08253
08254
calculateStopTime();
// calculate SUNSET Time
08255
temp_sector = StopTime;
08256
testIndLedScreen(
false
);
08257
}
08258
08259
if
((x>=StartDay[0]) && (x<=StartDay[2]) && (y>=StartDay[1]) && (y<=StartDay[3]) && colorLEDtest==
true
08260
&& (bitRead(GlobalStatus1Byte,2) ==
false
))
//press SUNRISE, jump to start "light day"
08261
{
08262
waitForIt(StartDay[0], StartDay[1], StartDay[2], StartDay[3]);
08263
calculateStartTime();
// calculate SUNRISE Time
08264
temp_sector = StartTime;
08265
testIndLedScreen(
false
);
08266
}
08267
08268
if
((x>=canC[0]) && (x<=canC[2]) && (y>=canC[1]) && (y<=canC[3]) && colorLEDtest==
true
08269
&& (bitRead(GlobalStatus1Byte,2) ==
false
))
//press NEXT SECTOR, without exit from screen
08270
{
08271
waitForIt(canC[0], canC[1], canC[2], canC[3]);
08272
temp_sector+=1;
// insrease time sector
08273
// if (temp_sector>95) {temp_sector=95;}
08274
if
(temp_sector > 95) {temp_sector=0;}
08275
testIndLedScreen(
false
);
08276
}
08277
if
((x>=ledChV[0]) && (x<=ledChV[2]) && (y>=ledChV[1]) && (y<=ledChV[3]) && colorLEDtest==
true
08278
&& (bitRead(GlobalStatus1Byte,2) ==
false
))
//press PREV SECTOR, without exit from screen
08279
{
08280
waitForIt(ledChV[0], ledChV[1], ledChV[2], ledChV[3]);
08281
temp_sector-=1;
// desrease time sector
08282
// if (temp_sector<=0) {temp_sector=0;}
08283
if
(temp_sector == 255) {temp_sector=95;}
08284
testIndLedScreen(
false
);
08285
}
08286
08287
//*************************************************************************************
08288
08289
if
((y>=TopSldY)&&(y<=BotSldY) && (colorLEDtest==
true
) && (bitRead(GlobalStatus1Byte,2) ==
false
) )
//change value with Slider Bars touch
08290
{
08291
// waitForTouchRelease(); //#oleg this line prevent "parasitic" slider jump
08292
08293
for
(
byte
i=0; i<9; i++)
08294
{
08295
if
((x>=(i*35)+4+5) && (x<=(i*35)+34-5))
// desrease slider touchable area (5pix)
08296
{
// WHITE=1, BLUE=2, ROYAL=3, RED=4,
08297
// ULTRA=5, TV=6, MOON=7;
08298
// CYAN=8, YELLOW=9
08299
sbX1=(i*35)+4; sbX2=(i*35)+34;
// slider width 30 pix, clearens between sliders 5pix
08300
TopSldY=53, BotSldY=TopSldY+100;
08301
SliderSwitch =
false
;
08302
08303
if
(i==0 && bitRead(LedShannelStatusByte,5) ==
true
)
08304
{ sbR= rgbCh6[0]; sbG= rgbCh6[1]; sbB= rgbCh6[2];
// TV colour
08305
tvcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
08306
if
(i==1 && bitRead(LedShannelStatusByte,3) ==
true
)
08307
{ sbR= rgbCh5[0]; sbG= rgbCh5[1]; sbB= rgbCh5[2];
// DR colour
08308
rcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2); }
08309
if
(i==2 && bitRead(LedShannelStatusByte,0) ==
true
)
08310
{ sbR= rgbCh2[0]; sbG= rgbCh2[1]; sbB= rgbCh2[2];
// CW colour
08311
wcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
08312
if
(i==3 && bitRead(LedShannelStatusByte,1) ==
true
)
08313
{ sbR= rgbCh4[0]; sbG= rgbCh4[1]; sbB= rgbCh4[2];
// BL colour
08314
bcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
08315
if
(i==4 && bitRead(LedShannelStatusByte,2) ==
true
)
08316
{ sbR= rgbCh3[0]; sbG= rgbCh3[1]; sbB= rgbCh3[2];
// RBL colour
08317
rbcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
08318
if
(i==5 && bitRead(LedShannelStatusByte,4) ==
true
)
08319
{ sbR= rgbCh1[0]; sbG= rgbCh1[1]; sbB= rgbCh1[2];
// UV colour
08320
uvcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
08321
if
(i==6 && bitRead(LedShannelStatusByte,6) ==
true
)
08322
{ sbR= rgbCh0[0]; sbG= rgbCh0[1]; sbB= rgbCh0[2];
// CY colour
08323
cycol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
08324
if
(i==7 && bitRead(LedShannelStatusByte,7) ==
true
)
08325
{ sbR= rgbCh7[0]; sbG= rgbCh7[1]; sbB= rgbCh7[2];
// Yellow colour
08326
yelcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
08327
if
(i==8) { sbR= rgbCh8[0]; sbG= rgbCh8[1]; sbB= rgbCh8[2];
// MOON colour
08328
mooncol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
08329
08330
tvled[temp_sector] = tvcol_out;
// save to buffer before store to eeprom
08331
bled[temp_sector] = bcol_out;
08332
wled[temp_sector] = wcol_out;
08333
rbled[temp_sector] = rbcol_out;
08334
rled[temp_sector] = rcol_out;
08335
uvled[temp_sector] = uvcol_out;
08336
cyled[temp_sector] = cycol_out;
08337
yeled[temp_sector] = yelcol_out;
08338
bitSet(GlobalStatus1Byte,3);
// set bit3=1 if setting changed, for " Save changes before exit "
08339
LED_levels_output();
// send calculated value to PWM
08340
}
08341
}
08342
}
else
08343
08344
if
((y>=29+2) && (y<=44-2) && (colorLEDtest==
true
) && (bitRead(GlobalStatus1Byte,2) ==
false
))
//UP Buttons were touched, desrease button touchable area (2pix)
08345
{
08346
for
(
byte
i=0; i<9; i++)
08347
{
08348
if
((x>=(i*35)+4) && (x<=(i*35)+34))
// slider width 30 pix, clearens 5pix
08349
{
// WHITE=1, BLUE=2, ROYAL=3, RED=4,
08350
// ULTRA=5, TV=6, MOON=7;
08351
// CYAN=8, YELLOW=9
08352
sbX1=(i*35)+4; sbX2=(i*35)+34;
08353
TopSldY=53, BotSldY=TopSldY+100;
08354
SliderSwitch =
true
;
08355
08356
if
(i==0 && bitRead(LedShannelStatusByte,5) ==
true
)
08357
{ sbR= rgbCh6[0]; sbG= rgbCh6[1]; sbB= rgbCh6[2]; tSlide = tvcol_out; tSlide+=1;
// TV colour
08358
tvcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08359
tSlide= tvcol_out; }
08360
if
(i==1 && bitRead(LedShannelStatusByte,3) ==
true
)
08361
{ sbR= rgbCh5[0]; sbG= rgbCh5[1]; sbB= rgbCh5[2]; tSlide= rcol_out; tSlide+=1;
// DR colour
08362
rcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08363
tSlide= rcol_out; }
08364
if
(i==2 && bitRead(LedShannelStatusByte,0) ==
true
)
08365
{ sbR= rgbCh2[0]; sbG= rgbCh2[1]; sbB= rgbCh2[2]; tSlide= wcol_out; tSlide+=1;
// CW colour
08366
wcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08367
tSlide= wcol_out; }
08368
if
(i==3 && bitRead(LedShannelStatusByte,1) ==
true
)
08369
{ sbR= rgbCh4[0]; sbG= rgbCh4[1]; sbB= rgbCh4[2]; tSlide= bcol_out; tSlide+=1;
// BL colour
08370
bcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08371
tSlide= bcol_out;}
08372
if
(i==4 && bitRead(LedShannelStatusByte,2) ==
true
)
08373
{ sbR= rgbCh3[0]; sbG= rgbCh3[1]; sbB= rgbCh3[2]; tSlide= rbcol_out; tSlide+=1;
// RBL colour
08374
rbcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08375
tSlide= rbcol_out;}
08376
if
(i==5 && bitRead(LedShannelStatusByte,4) ==
true
)
08377
{ sbR= rgbCh1[0]; sbG= rgbCh1[1]; sbB= rgbCh1[2]; tSlide= uvcol_out; tSlide+=1;
// UV colour
08378
uvcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08379
tSlide= uvcol_out;}
08380
if
(i==6 && bitRead(LedShannelStatusByte,6) ==
true
)
08381
{ sbR= rgbCh0[0]; sbG= rgbCh0[1]; sbB= rgbCh0[2]; tSlide= cycol_out; tSlide+=1;
// CY colour
08382
cycol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08383
tSlide= cycol_out; }
08384
if
(i==7 && bitRead(LedShannelStatusByte,7) ==
true
)
08385
{ sbR= rgbCh7[0]; sbG= rgbCh7[1]; sbB= rgbCh7[2]; tSlide= yelcol_out; tSlide+=1;
// Yellow colour
08386
yelcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08387
tSlide= yelcol_out; }
08388
if
(i==8)
08389
{ sbR= rgbCh8[0]; sbG= rgbCh8[1]; sbB= rgbCh8[2]; tSlide= mooncol_out; tSlide+=1;
// MOON colour
08390
mooncol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08391
tSlide= mooncol_out; }
08392
08393
tvled[temp_sector] = tvcol_out;
// save to buffer before store to eeprom
08394
bled[temp_sector] = bcol_out;
08395
wled[temp_sector] = wcol_out;
08396
rbled[temp_sector] = rbcol_out;
08397
rled[temp_sector] = rcol_out;
08398
uvled[temp_sector] = uvcol_out;
08399
cyled[temp_sector] = cycol_out;
08400
yeled[temp_sector] = yelcol_out;
08401
LED_levels_output();
// send calculated value to PWM
08402
bitSet(GlobalStatus1Byte,3);
// set bit3=1 if setting changed, for " Save changes before exit "
08403
delay(100);
//delay 50msec after touch UP/DOWN button
08404
}
08405
}
08406
SliderSwitch =
false
;
08407
}
else
08408
if
((y>=174+2) && (y<=187-2) && (colorLEDtest==
true
) && (bitRead(GlobalStatus1Byte,2) ==
false
))
//DOWN Buttons were touched,desrease button touchable area (2pix)
08409
{
08410
for
(
byte
i=0; i<9; i++)
08411
{
08412
if
((x>=(i*35)+4) && (x<=(i*35)+34))
// slider width 30 pix, clearens 5pix
08413
{
// WHITE=1, BLUE=2, ROYAL=3, RED=4,
08414
// ULTRA=5, TV=6, MOON=7;
08415
// CYAN=8, YELLOW=9
08416
sbX1=(i*35)+4; sbX2=(i*35)+34;
08417
TopSldY=53, BotSldY=TopSldY+100;
08418
SliderSwitch =
true
;
08419
if
(i==0 && bitRead(LedShannelStatusByte,5) ==
true
)
08420
{ sbR= rgbCh6[0]; sbG= rgbCh6[1]; sbB= rgbCh6[2]; tSlide = tvcol_out; tSlide-=1;
// TV colour
08421
tvcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08422
tSlide = tvcol_out; }
08423
if
(i==1 && bitRead(LedShannelStatusByte,3) ==
true
)
08424
{ sbR= rgbCh5[0]; sbG= rgbCh5[1]; sbB= rgbCh5[2]; tSlide = rcol_out; tSlide-=1;
// DR colour
08425
rcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08426
tSlide = rcol_out ; }
08427
if
(i==2 && bitRead(LedShannelStatusByte,0) ==
true
)
08428
{ sbR= rgbCh2[0]; sbG= rgbCh2[1]; sbB= rgbCh2[2]; tSlide = wcol_out; tSlide-=1;
// CW colour
08429
wcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08430
tSlide= wcol_out; }
08431
if
(i==3 && bitRead(LedShannelStatusByte,1) ==
true
)
08432
{ sbR= rgbCh4[0]; sbG= rgbCh4[1]; sbB= rgbCh4[2]; tSlide = bcol_out; tSlide-=1;
// BL colour
08433
bcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08434
tSlide= bcol_out; }
08435
if
(i==4 && bitRead(LedShannelStatusByte,2) ==
true
)
08436
{ sbR= rgbCh3[0]; sbG= rgbCh3[1]; sbB= rgbCh3[2]; tSlide = rbcol_out; tSlide-=1;
// RBL colour
08437
rbcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08438
tSlide= rbcol_out; }
08439
if
(i==5 && bitRead(LedShannelStatusByte,4) ==
true
)
08440
{ sbR= rgbCh1[0]; sbG= rgbCh1[1]; sbB= rgbCh1[2]; tSlide = uvcol_out; tSlide-=1;
// UV colour
08441
uvcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08442
tSlide= uvcol_out; }
08443
if
(i==6 && bitRead(LedShannelStatusByte,6) ==
true
)
08444
{ sbR= rgbCh0[0]; sbG= rgbCh0[1]; sbB= rgbCh0[2]; tSlide = cycol_out; tSlide-=1;
// CY colour
08445
cycol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08446
tSlide= cycol_out; }
08447
if
(i==7 && bitRead(LedShannelStatusByte,7) ==
true
)
08448
{ sbR= rgbCh7[0]; sbG= rgbCh7[1]; sbB= rgbCh7[2]; tSlide = yelcol_out; tSlide-=1;
// Yellow colour
08449
yelcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08450
tSlide= yelcol_out; }
08451
if
(i==8) { sbR= rgbCh8[0]; sbG= rgbCh8[1]; sbB= rgbCh8[2]; tSlide = mooncol_out; tSlide-=1;
// MOON colour
08452
mooncol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08453
tSlide= mooncol_out; }
08454
08455
tvled[temp_sector] = tvcol_out;
// save to buffer before store to eeprom
08456
bled[temp_sector] = bcol_out;
08457
wled[temp_sector] = wcol_out;
08458
rbled[temp_sector] = rbcol_out;
08459
rled[temp_sector] = rcol_out;
08460
uvled[temp_sector] = uvcol_out;
08461
cyled[temp_sector] = cycol_out;
08462
yeled[temp_sector] = yelcol_out;
08463
LED_levels_output();
// send calculated value to PWM
08464
bitSet(GlobalStatus1Byte,3);
// set bit3=1 if setting changed for, " Save changes before exit "
08465
delay(100);
//delay 50msec after touch UP/DOWN button
08466
}
08467
}
08468
}
08469
SliderSwitch =
false
;
08470
break
;
08471
08472
case
7:
// ----------- INDIVIDUAL LED OUTPUT COLORS Choices -----------
08473
if
((x>=10) && (x<=150))
//first button column
08474
{
08475
if
((y>=20) && (y<=45))
//View TV LEDs Array
08476
{ waitForIt(10, 20, 150, 45); COLOR = TV;}
// COLOR=6
08477
08478
if
((y>=55) && (y<=80))
//View DRed LEDs Array
08479
{ waitForIt(10, 55, 150, 80); COLOR = RED;}
// COLOR=4
08480
08481
if
((y>=90) && (y<=115))
//View White LEDs Array
08482
{ waitForIt(10, 90, 150, 115); COLOR = WHITE;}
// COLOR=1
08483
08484
if
((y>=125) && (y<=150))
//View BLUE LEDs Array
08485
{ waitForIt(10, 125, 150, 150); COLOR = BLUE;}
// COLOR=2
08486
08487
if
((y>=160) && (y<=185))
//View Lunar LEDs Array
08488
{ waitForIt(10, 160, 150, 185); COLOR = MOON;}
// COLOR=7
08489
08490
dispScreen=8;
08491
clearScreen();
08492
// ReadLedFromEEPROM();
08493
if
(COLOR == MOON)
08494
{MoonPictureScreen();}
08495
else
08496
{ledValuesScreen();}
//print TOP NAME bar & horisontal buttons with timetable 12x8
08497
}
08498
08499
if
((x>=170) && (x<=310))
//second column
08500
{
08501
if
((y>=20) && (y<=45))
//View Royal Blue LEDs Array
08502
{ waitForIt(170, 20, 310, 45); COLOR = ROYAL;}
// COLOR=3
08503
08504
if
((y>=55) && (y<=80))
//View UV LEDs Array
08505
{ waitForIt(170, 55, 310, 80); COLOR = ULTRA;}
// COLOR=6
08506
08507
if
((y>=90) && (y<=115))
//View Cyan LEDs Array
08508
{ waitForIt(170, 90, 310, 115); COLOR = CYAN; }
// COLOR=8
08509
08510
if
((y>=125) && (y<=150))
//View Yellow LEDs Array
08511
{ waitForIt(170, 125, 310, 150); COLOR = YELLOW; }
// COLOR=9
08512
08513
if
((y>=160) && (y<=185))
//View All colour LEDs Array
08514
{ waitForIt(170, 160, 310, 185); COLOR = 0; }
// COLOR=0
08515
08516
dispScreen=8;
// draw for second column
08517
clearScreen();
08518
// ReadLedFromEEPROM();
08519
if
(COLOR == 0)
08520
{
08521
AllColourGraph();
08522
// testArrayScreen();
08523
COLOR = 0;
08524
}
08525
else
08526
{ledValuesScreen();}
//print TOP NAME bar & horisontal buttons with timetable 12x8
08527
08528
}
08529
08530
break
;
08531
08532
case
8:
// -----SHOW LED OUTPUT VALUES CURVE SCREEN and wait for button "<<BACK", "CHANGE", "SAVE"-------------//
08533
08534
if
((x>=110) && (x<=201) && (y>=0) && (y<=17) && (COLOR!=0))
//press ON/OFF button
08535
{
08536
waitForIt(110, 0, 201, 17);
08537
myGLCD.setColor(0, 0, 255);
08538
myGLCD.fillRoundRect(111, 1, 200, 16);
08539
setFont(SMALL, 255, 255, 255, 0, 0, 255 );
08540
08541
if
(LedShannelFlag_on_off ==
true
) {
08542
myGLCD.print(
"LED OFF"
, 129, 3);
08543
LedShannelFlag_on_off =
false
;
08544
SaveOnOffLedStatus(
false
);
08545
}
08546
else
{
08547
myGLCD.print(
"LED ON"
, 129, 3);
08548
LedShannelFlag_on_off =
true
;
08549
SaveOnOffLedStatus(
true
);}
08550
}
08551
08552
if
((x>=back[0]) && (x<=back[2]) && (y>=back[1]) && (y<=back[3]))
//press BACK for EXIT to other COLORS
08553
{
08554
waitForIt(back[0], back[1], back[2], back[3]);
08555
COLOR = 0;
08556
ReadLedFromEEPROM();
08557
// ReadFromEEPROM();
08558
dispScreen=7;
08559
clearScreen();
08560
ledColorViewScreen();
// print led & Moon colour buttons
08561
}
else
08562
if
((x>=ledChV[0]) && (x<=ledChV[2]) && (y>=ledChV[1]) && (y<=ledChV[3]) && (COLOR!=7) && (COLOR!=0))
//press CHANGE
08563
{
08564
waitForIt(ledChV[0], ledChV[1], ledChV[2], ledChV[3]);
08565
// ReadFromEEPROM();
08566
dispScreen=9;
08567
clearScreen();
08568
ledChangeScreen();
//print TOP timetable & Vertical buttons, w/o slider
08569
}
else
08570
if
((x>=eeprom[0]) && (x<=eeprom[2]) && (y>=eeprom[1]) && (y<=eeprom[3]) && (COLOR!=7) && (COLOR!=0))
//press SAVE
08571
{
08572
waitForIt(eeprom[0], eeprom[1], eeprom[2], eeprom[3]);
08573
SaveLEDToEEPROM();
08574
dispScreen=7;
08575
clearScreen();
08576
ledColorViewScreen();
// print led & Moon colour buttons
08577
}
else
08578
if
((x>=canC[0]) && (x<=canC[2]) && (y>=canC[1]) && (y<=canC[3]) && (COLOR==0))
//press CANCEL - exit from ALL COLOR GPRAPH
08579
{ waitForIt(canC[0], canC[1], canC[2], canC[3]);
08580
// LEDtestTick = false;
08581
dispScreen=0;
08582
clearScreen();
08583
mainScreen(
true
);
08584
}
08585
08586
//************* Moon section button ***********************************
08587
else
08588
if
((x>=prSAVE[0]) && (x<=prSAVE[2]) && (y>=prSAVE[1]) && (y<=prSAVE[3]) && (COLOR==7))
//press SAVE and exit from MOON section
08589
{ waitForIt(prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3]);
08590
SaveMoonLEDToEEPROM();
08591
dispScreen=7;
08592
clearScreen();
08593
ledColorViewScreen();
// print led & Moon colour buttons
08594
}
else
08595
if
((x>=canC[0]) && (x<=canC[2]) && (y>=canC[1]) && (y<=canC[3]) && (COLOR==7))
//press CANCEL from Moon
08596
{ waitForIt(canC[0], canC[1], canC[2], canC[3]);
08597
// ReadFromEEPROM();
08598
COLOR =7;
08599
ReadLedFromEEPROM();
//#oleg read led values only
08600
// LEDtestTick = false;
08601
dispScreen=0;
08602
clearScreen();
08603
mainScreen(
true
);
08604
}
else
08605
08606
if
(COLOR==7) {MoonChangeScreen();}
//change moon value brightness
08607
08608
break
;
08609
08610
case
9:
//---------------- CHANGE Selected LED VALUES SCREEN ---------------
08611
08612
if
((x>=8) && (x<=26) && (y>=66) && (y<=140))
//press OK, exit from "chande led output value" to "LED output table" menu
08613
{
08614
waitForIt(8, 66, 26, 140);
08615
dispScreen=8;
08616
08617
if
(COLOR==1) {
08618
for
(
byte
i=0; i<96; i++)
08619
{wled[i] = tled[i]; sbR= rgbCh2[0]; sbG= rgbCh2[1]; sbB= rgbCh2[2]; }}
08620
if
(COLOR==2) {
08621
for
(
byte
i=0; i<96; i++)
08622
{bled[i]=tled[i]; sbR= rgbCh4[0]; sbG= rgbCh4[1]; sbB= rgbCh4[2];}}
08623
if
(COLOR==3) {
08624
for
(
byte
i=0; i<96; i++)
08625
{rbled[i] = tled[i]; sbR= rgbCh3[0]; sbG= rgbCh3[1]; sbB= rgbCh3[2];}}
08626
if
(COLOR==4) {
08627
for
(
byte
i=0; i<96; i++)
08628
{rled[i] = tled[i]; sbR= rgbCh5[0]; sbG= rgbCh5[1]; sbB= rgbCh5[2];}}
08629
if
(COLOR==5) {
08630
for
(
byte
i=0; i<96; i++)
08631
{uvled[i] = tled[i]; sbR= rgbCh1[0]; sbG= rgbCh1[1]; sbB= rgbCh1[2];}}
08632
if
(COLOR==6) {
08633
for
(
byte
i=0; i<96; i++)
08634
{tvled[i] = tled[i]; sbR= rgbCh6[0]; sbG= rgbCh6[1]; sbB= rgbCh6[2];}}
08635
if
(COLOR==8) {
08636
for
(
byte
i; i<96; i++)
08637
{cyled[i] = tled[i]; sbR= rgbCh0[0]; sbG= rgbCh0[1]; sbB= rgbCh0[2];}}
08638
if
(COLOR==9) {
08639
for
(
byte
i=0; i<96; i++)
08640
{yeled[i] = tled[i]; sbR= rgbCh7[0]; sbG= rgbCh7[1]; sbB= rgbCh7[2];}}
08641
08642
DrawStaticElement =
false
;
08643
oldLCT = 0;
08644
myGLCD.setColor(64, 64, 64);
// fill with background bottom time|date bar
08645
myGLCD.fillRect(1, 226, 318, 240);
08646
clearScreen();
08647
ledValuesScreen();
//print TOP NAME bar & horisontal buttons, with LED GRAPH
08648
TimeDateBar(
true
);
08649
08650
}
else
08651
if
((x>=8) && (x<=26) && (y>=145) && (y<=219))
//press CANCEL, exit to "main display"
08652
{
08653
waitForIt(8, 145, 26, 219);
08654
waveMakerOff =
false
;
08655
DrawStaticElement =
false
;
08656
oldLCT = 0;
08657
COLOR = 0;
08658
ReadLedFromEEPROM();
//#oleg read led values only
08659
dispScreen=0;
08660
myGLCD.setColor(64, 64, 64);
// fill with background bottom time|date bar
08661
myGLCD.fillRect(1, 226, 318, 240);
08662
clearScreen();
08663
TimeDateBar(
true
);
08664
mainScreen(
true
);
08665
}
else
08666
if
((y>=15) && (y<=41))
//top row with times was touched
08667
{
08668
if
((x>=4) && (x<=316))
08669
{
08670
if
(DrawStaticElement==
false
)
08671
{
08672
myGLCD.setColor(0, 0, 0);
08673
myGLCD.fillRect(50, 110, 318, 146);
08674
for
(
byte
b=0; b<8; b++)
//draw UP Buttons
08675
{ drawUpButtonSlide((b*36)+34, 45);}
08676
for
(
byte
b=0; b<8; b++)
//draw DOWN Buttons
08677
{ drawDownButtonSlide((b*36)+34, 200);}
08678
TopSldY=71; BotSldY=185;
08679
/*
08680
setFont(SMALL, sbR, sbG, sbB, 0, 0, 0);
08681
for
(
int
i=0; i<8; i++)
//draw color Slider Bar Outlines
08682
{ myGLCD.drawRect((i*36)+34, TopSldY, (i*36)+64, BotSldY);}
08683
*/
08684
for
(
byte
i=0; i<8; i++)
// draw white bar outline rectangle
08685
{ sbX1=(i*36)+34; sbX2=(i*36)+64;
08686
setFont(SMALL, 255, 255, 255, 0, 0, 0);
08687
myGLCD.drawRect(sbX1, TopSldY-1, sbX2, BotSldY);}
08688
08689
myGLCD.setColor(140, 140, 140);
// print vertical divider
08690
myGLCD.fillRect(174, 42, 176, 240);
08691
08692
}
08693
08694
// # oleg change function 00 time ( LedChangTime shifted +1 )
08695
DrawStaticElement=
true
;
08696
LedChangTime = map(x, 3, 320, 1, 13);
08697
if
( oldLCT != LedChangTime)
//highlight and refresh touched time only first touch current time
08698
{
08699
if
(oldLCT !=0)
08700
{
08701
myGLCD.setColor(0, 0, 0);
08702
myGLCD.fillRect((oldLCT-1)*26+5, 17, (oldLCT-1)*26+29, 41);
08703
myGLCD.setColor(100, 100, 100);
08704
myGLCD.drawRect((oldLCT-1)*26+4, 16 , (oldLCT-1)*26+30, 41);
08705
setFont(SMALL, 0, 255, 255, 0, 0, 0);
08706
08707
if
((oldLCT-1)<5) {
08708
myGLCD.printNumI(((oldLCT-1)*2), ((oldLCT-1)*26)+15, 17);
08709
myGLCD.printNumI((((oldLCT-1)*2)+1), ((oldLCT-1)*26)+15, 28);}
08710
else
{
08711
myGLCD.printNumI(((oldLCT-1)*2), ((oldLCT-1)*26)+11, 17);
08712
myGLCD.printNumI((((oldLCT-1)*2)+1), ((oldLCT-1)*26)+11, 28);}
08713
}
08714
08715
myGLCD.setColor(255, 0, 0);
08716
if
((LedChangTime-1)<5) {
08717
myGLCD.fillRect(((LedChangTime-1)*26)+5, 17, ((LedChangTime-1)*26)+29, 41);
08718
setFont(SMALL, 255, 255, 255, 255, 0, 0);
08719
myGLCD.printNumI(((LedChangTime-1)*2), ((LedChangTime-1)*26)+15, 17);
08720
myGLCD.printNumI((((LedChangTime-1)*2)+1), ((LedChangTime-1)*26)+15, 28);}
08721
else
{
08722
myGLCD.fillRect(((LedChangTime-1)*26)+5, 17, ((LedChangTime-1)*26)+29, 41);
08723
setFont(SMALL, 255, 255, 255, 255, 0, 0);
08724
myGLCD.printNumI(((LedChangTime-1)*2), ((LedChangTime-1)*26)+11, 17);
08725
myGLCD.printNumI((((LedChangTime-1)*2)+1), ((LedChangTime-1)*26)+11, 28);}
08726
oldLCT= LedChangTime;
08727
08728
for
(
byte
i=0; i<=3; i++)
// print botttom additional time bar 0/15/30/45min
08729
{ setFont(SMALL, 255, 255, 255, 0, 0, 0);
08730
myGLCD.printNumI(i*15, (i*36+40), 225, 2,
'00'
);
08731
myGLCD.print(
"m"
,i*36+55 , 225);
08732
myGLCD.printNumI(i*15, (i*36+40+144), 225, 2,
'00'
);
08733
myGLCD.print(
"m"
,i*36+55+144 , 225);
08734
}
08735
08736
for
(
int
i=0; i<8; i++)
//print led values & slider value bars for highlighted time
08737
{
08738
int
k=((LedChangTime-1)*8)+i;
08739
// waitForTouchRelease(); //#oleg this line prevent "parasitic" slider jump
08740
sbX1=(i*36)+34; sbX2=(i*36)+64;
08741
TopSldY=71; BotSldY=185;
08742
SliderSwitch =
true
;
08743
tSlide=tled[k];
08744
SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08745
}
08746
}
08747
}
08748
08749
}
else
08750
if
((y>=TopSldY)&&(y<=BotSldY) && (DrawStaticElement==
true
))
//Slider Bars touch
08751
{
08752
// waitForTouchRelease(); //#oleg this line prevent "parasitic" slider jump
08753
08754
for
(
int
i=0; i<8; i++)
08755
{
08756
if
((x>=(i*36)+34+5) && (x<=(i*36)+64-5))
// decrease on 5pix slider touch area
08757
{
08758
int
k=((LedChangTime-1)*8)+i;
08759
sbX1=(i*36)+34; sbX2=(i*36)+64;
08760
TopSldY=71; BotSldY=185;
08761
SliderSwitch =
false
;
08762
tled[k]= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08763
}
08764
}
08765
}
else
08766
if
((y>=45) && (y<=67) && (DrawStaticElement==
true
))
//UP Buttons were touched
08767
{
08768
for
(
int
i=0; i<8; i++)
08769
{
08770
if
((x>=(i*36)+34) && (x<=(i*36)+64))
08771
{
08772
int
k= ((LedChangTime-1)*8)+i;
08773
TopSldY=71; BotSldY=185;
08774
sbX1=(i*36)+34; sbX2=(i*36)+64;
08775
SliderSwitch =
true
;
08776
tSlide = tled[k];
08777
tSlide+=1;
08778
tled[k] = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08779
08780
delay(100);
//delay 50msec after touch UP/DOWN button
08781
08782
}
08783
}
08784
}
else
08785
if
((y>=200) && (y<=222) && (DrawStaticElement==
true
))
//DOWN Buttons were touched
08786
{
08787
for
(
int
i=0; i<8; i++)
08788
{
08789
if
((x>=(i*36)+34) && (x<=(i*36)+64))
08790
{
08791
int
k= ((LedChangTime-1)*8)+i;
08792
08793
TopSldY=71; BotSldY=185;
08794
sbX1=(i*36)+34; sbX2=(i*36)+64;
08795
SliderSwitch =
true
;
08796
tSlide = tled[k];
08797
tSlide-=1;
08798
tled[k] = SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
08799
08800
delay(100);
//delay 50msec after touch UP/DOWN button
08801
}
08802
}
08803
}
08804
break
;
08805
08806
case
10:
//-------------------- WAVEMAKER SCREEN -------------------
08807
/*
08808
if ((x>=5) && (x<=155) && (y>=20) && (y<=40)) //press Alternating Mode
08809
{
08810
waitForIt(5, 20, 155, 40);
08811
Synch=0;
08812
WAVE=1;
08813
dispScreen=11;
08814
clearScreen();
08815
WaveMakerSettingsScreen();
08816
waveMakerOff=true;
08817
digitalWrite(WaveMakerTop, LOW);
08818
digitalWrite(WaveMakerBottom, LOW);
08819
} else
08820
if ((x>=165) && (x<=315) && (y>=20) && (y<=40)) //press Synchronous Mode
08821
{
08822
waitForIt(165, 20, 315, 40);
08823
WAVE=2;
08824
dispScreen=11;
08825
clearScreen();
08826
WaveMakerSettingsScreen();
08827
synchronousSynch();
08828
waveMakerOff=true;
08829
digitalWrite(WaveMakerTop, LOW);
08830
digitalWrite(WaveMakerBottom, LOW);
08831
} else
08832
if ((x>=165) && (x<=315) && (y>=46) && (y<=66)) //press Turn Pumps OFF/ON
08833
{
08834
waitForIt(165, 46, 315, 66);
08835
if (WAVE==3) {
08836
// ReadFromEEPROM();
08837
waveMakerOff=false;
08838
WaveMakerStatusScreen();
08839
}
08840
else {
08841
MODE=WAVE;
08842
WAVE=3;
08843
WaveMakerStatusScreen();
08844
}
08845
} else
08846
if ((x>=5) && (x<=155) && (y>=46) && (y<=66)) //press Feeding Mode
08847
{
08848
waitForIt(5, 46, 155, 66);
08849
if (WAVE==4) {
08850
// ReadFromEEPROM();
08851
waveMakerOff=false;
08852
WaveMakerStatusScreen();
08853
}
08854
else {
08855
// ReadFromEEPROM();
08856
MODE=WAVE;
08857
WAVE=4;
08858
countDown = 5*60 + 0; //Reset countdown for 5 minutes and zero seconds
08859
MIN_O = 5; //Reset start time at 5 Minutes
08860
SEC_T = 0;
08861
SEC_O = 0;
08862
WaveMakerStatusScreen();
08863
}
08864
}
08865
*/
08866
break
;
08867
08868
case
11:
08869
/*
08870
//---------------- WAVEMAKER SETTINGS SCREEN --------------
08871
if ((y>=200) && (y<=220)) //Bottom Row
08872
{
08873
if ((x>=5) && (x<=105)) //press BACK
08874
{
08875
waitForIt(5, 200, 105, 220);
08876
// ReadFromEEPROM();
08877
waveMakerTest=false;
08878
waveMakerOff=false;
08879
dispScreen=10;
08880
clearScreen();
08881
WaveMakerScreen();
08882
WaveMakerStatusScreen();
08883
} else
08884
if ((x>=110) && (x<=210)) //press TEST
08885
{
08886
waitForIt(110, 200, 210, 220);
08887
myGLCD.setColor(0, 255, 0);
08888
myGLCD.fillRoundRect(110, 200, 210, 220); //TEST Button in Green
08889
setFont(SMALL, 0, 0, 0, 0, 255, 0);
08890
myGLCD.print("TESTING", 132, 204);
08891
myGLCD.setColor(255, 255, 255);
08892
myGLCD.drawRoundRect(110, 200, 210, 220);
08893
waveMakerOff=false;
08894
waveMakerTest=true;
08895
} else
08896
if ((x>=210) && (x<=315)) //press SAVE
08897
{
08898
waitForIt(215, 200, 315, 220);
08899
if (WAVE==1) { Pump1m=Min1; Pump1s=Sec1; Pump2m=Min2; Pump2s=Sec2;}
08900
if (WAVE==2) { OnForTm=Min1; OnForTs=Sec1; OffForTm=Min2; OffForTs=Sec2;}
08901
SaveWaveToEEPROM();
08902
waveMakerTest=false;
08903
waveMakerOff=false;
08904
dispScreen=10;
08905
clearScreen();
08906
WaveMakerScreen();
08907
WaveMakerStatusScreen();
08908
}
08909
}
08910
else
08911
{
08912
if (WAVE==1) //Alternating Mode Settings
08913
{
08914
waveModePlusMinus();
08915
}
08916
08917
if (WAVE==2) //Synchronous Mode Settings
08918
{
08919
if ((x>=5) && (x<=155) && (y>=20) && (y<=40)) //Constantly ON
08920
{
08921
waitForIt(5, 20, 155, 40);
08922
Synch=1;
08923
synchronousSynch();
08924
} else
08925
if ((x>=165) && (x<=315) && (y>=20) && (y<=40)) //Pulsating Mode
08926
{
08927
waitForIt(165, 20, 315, 40);
08928
Synch=2;
08929
synchronousSynch();
08930
}
08931
if (Synch==2) //Synchronous-Pulsating Settings
08932
{
08933
waveModePlusMinus();
08934
}
08935
}
08936
}
08937
*/
08938
break
;
08939
08940
case
12:
08941
/*
08942
//--------------- AUTOMATIC FISH FEEDER PAGE --------------
08943
if ((x>=5) && (x<=155) && (y>=20) && (y<=40)) //press Feeding Time 1
08944
{
08945
waitForIt(5, 20, 155, 40);
08946
feedTime=1;
08947
dispScreen=13;
08948
clearScreen();
08949
setFeederTimesScreen();
08950
} else
08951
if ((x>=165) && (x<=315) && (y>=20) && (y<=40)) //press Feeding Time 2
08952
{
08953
waitForIt(165, 20, 315, 40);
08954
feedTime=2;
08955
dispScreen=13;
08956
clearScreen();
08957
setFeederTimesScreen();
08958
} else
08959
if ((x>=5) && (x<=155) && (y>=168) && (y<=188)) //press Feeding Time 3
08960
{
08961
waitForIt(5, 168, 155, 188);
08962
feedTime=3;
08963
dispScreen=13;
08964
clearScreen();
08965
setFeederTimesScreen();
08966
} else
08967
if ((x>=165) && (x<=315) && (y>=168) && (y<=188)) //press Feeding Time 4
08968
{
08969
waitForIt(165, 168, 315, 188);
08970
feedTime=4;
08971
dispScreen=13;
08972
clearScreen();
08973
setFeederTimesScreen();
08974
} else
08975
if ((x>=85) && (x<=235) && (y>=94) && (y<=114)) //press Feeding Fish Now!
08976
{
08977
waitForIt(85, 94, 235, 114);
08978
myGLCD.setColor(0, 255, 0);
08979
myGLCD.fillRoundRect(85, 94, 235, 114);
08980
myGLCD.setColor(255, 255, 255);
08981
myGLCD.drawRoundRect(85, 94, 235, 114);
08982
setFont(SMALL, 0, 0, 0, 0, 255, 0);
08983
// myGLCD.print("Now Feeding", 118, 98);
08984
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[34])));
08985
myGLCD.print(buffer, 118, 98);
08986
digitalWrite(autoFeeder, HIGH);
08987
delay(5000);
08988
myGLCD.setColor(153, 0, 102);
08989
myGLCD.fillRoundRect(85, 94, 235, 114);
08990
myGLCD.setColor(255, 255, 255);
08991
myGLCD.drawRoundRect(85, 94, 235, 114);
08992
setFont(SMALL, 255, 255, 255, 153, 0, 102);
08993
// myGLCD.print("Feed Fish Now!", 106, 98);
08994
strcpy_P(buffer, (char*)pgm_read_word_near(&(Text_table[33])));
08995
myGLCD.print(buffer, 106, 98);
08996
digitalWrite(autoFeeder, LOW);
08997
}
08998
*/
08999
break
;
09000
09001
case
13:
09002
/*
09003
//------------ SET AUTOMATIC FISH FEEDER TIMES ------------
09004
if ((x>=back[0]) && (x<=back[2]) && (y>back[1]) && (y<=back[3])) //press back
09005
{
09006
waitForIt(back[0], back[1], back[2], back[3]);
09007
// ReadFromEEPROM();
09008
if ((timeDispH>=0) && (timeDispH<=11)) { AM_PM=1;}
09009
else { AM_PM=2;}
09010
dispScreen=12;
09011
clearScreen();
09012
autoFeederScreen();
09013
} else
09014
if ((x>=prSAVE[0]) && (x<=prSAVE[2]) && (y>=prSAVE[1]) && (y<=prSAVE[3])) //press SAVE
09015
{
09016
waitForIt(prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3]);
09017
if (setTimeFormat==1)
09018
{
09019
if ((rtcSetHr==0) && (AM_PM==2))
09020
{ rtcSetHr+=12;}
09021
if (((rtcSetHr>=1) && (rtcSetHr<=11)) && (AM_PM==2))
09022
{ rtcSetHr+=12;}
09023
if (((rtcSetHr>=12) && (rtcSetHr<=23)) && (AM_PM==1))
09024
{ rtcSetHr-=12;}
09025
}
09026
if (feedTime==1)
09027
{ feedFish1H=rtcSetHr; feedFish1M=rtcSetMin;}
09028
if (feedTime==2)
09029
{ feedFish2H=rtcSetHr; feedFish2M=rtcSetMin;}
09030
if (feedTime==3)
09031
{ feedFish3H=rtcSetHr; feedFish3M=rtcSetMin;}
09032
if (feedTime==4)
09033
{ feedFish4H=rtcSetHr; feedFish4M=rtcSetMin;}
09034
SaveFeedTimesToEEPROM();
09035
dispScreen=12;
09036
clearScreen();
09037
autoFeederScreen();
09038
} else
09039
if ((x>=70) && (x<=250) && (y>=150) && (y<=170)) //Feeding ON/OFF
09040
{
09041
waitForIt(70, 150, 250, 170);
09042
if (feedTime==1)
09043
{ if (FEEDTime1==1) { FEEDTime1=0;}
09044
else { FEEDTime1=1;}}
09045
if (feedTime==2)
09046
{ if (FEEDTime2==1) { FEEDTime2=0;}
09047
else { FEEDTime2=1;}}
09048
if (feedTime==3)
09049
{ if (FEEDTime3==1) { FEEDTime3=0;}
09050
else { FEEDTime3=1;}}
09051
if (feedTime==4)
09052
{ if (FEEDTime4==1) { FEEDTime4=0;}
09053
else { FEEDTime4=1;}}
09054
feedingTimeOnOff();
09055
}
09056
else
09057
{
09058
if ((y>=houP[1]) && (y<=houP[3])) //FIRST ROW
09059
{
09060
if ((x>=houP[0]) && (x<=houP[2])) //press hour up
09061
{
09062
waitForIt(houP[0], houP[1], houP[2], houP[3]);
09063
rtcSetHr++;
09064
if (rtcSetHr>=24)
09065
{ rtcSetHr=0; }
09066
}
09067
if ((x>=minP[0]) && (x<=minP[2])) //press min up
09068
{
09069
waitForIt(minP[0], minP[1], minP[2], minP[3]);
09070
rtcSetMin++;
09071
if (rtcSetMin>=60) {rtcSetMin=0; }
09072
}
09073
if ((x>=ampmP[0]) && (x<=ampmP[2]) //press AMPM up
09074
&& (setTimeFormat==1))
09075
{
09076
waitForIt(ampmP[0], ampmP[1], ampmP[2], ampmP[3]);
09077
if (AM_PM==1) {AM_PM=2;}
09078
else {AM_PM=1;}
09079
}
09080
}
09081
if ((y>=houM[1]) && (y<=houM[3])) //SECOND ROW
09082
{
09083
if ((x>=houM[0]) && (x<=houM[2])) //press hour down
09084
{
09085
waitForIt(houM[0], houM[1], houM[2], houM[3]);
09086
rtcSetHr--;
09087
if (rtcSetHr<0)
09088
{ rtcSetHr=23; }
09089
}
09090
if ((x>=minM[0]) && (x<=minM[2])) //press min down
09091
{
09092
waitForIt(minM[0], minM[1], minM[2], minM[3]);
09093
rtcSetMin--;
09094
if (rtcSetMin<0) {rtcSetMin=59; }
09095
}
09096
if ((x>=ampmM[0]) && (x<=ampmM[2]) //press AMPM down
09097
&& (setTimeFormat==1))
09098
{
09099
waitForIt(ampmM[0], ampmM[1], ampmM[2], ampmM[3]);
09100
if (AM_PM==1) {AM_PM=2;}
09101
else {AM_PM=1;}
09102
}
09103
}
09104
setFeederTimesScreen(false);
09105
}
09106
*/
09107
break
;
09108
09109
case
14:
//------------- GENERAL SETTINGS (PAGE 1) -----------------
09110
if
((x>=backGS[0]) && (x<=backGS[2]) && (y>=backGS[1]) && (y<=backGS[3]))
//press back
09111
{
09112
waitForIt(backGS[0], backGS[1], backGS[2], backGS[3]);
09113
// LEDtestTick = false;
09114
waveMakerOff =
false
;
09115
// ReadFromEEPROM();
09116
dispScreen=1;
09117
clearScreen();
09118
menuScreen();
09119
}
else
09120
if
((x>=nextGS[0]) && (x<=nextGS[2]) && (y>=nextGS[1]) && (y<=nextGS[3]))
//press next
09121
{
09122
waitForIt(nextGS[0], nextGS[1], nextGS[2], nextGS[3]);
09123
dispScreen=15;
09124
clearScreen();
09125
generalSettingsScreen_2();
09126
}
else
09127
if
((x>=prSAVEgs[0]) && (x<=prSAVEgs[2]) && (y>=prSAVEgs[1]) && (y<=prSAVEgs[3]))
//press SAVE
09128
{
09129
waitForIt(prSAVEgs[0], prSAVEgs[1], prSAVEgs[2], prSAVEgs[3]);
09130
SaveGenSetsToEEPROM();
09131
SaveLEDsFailsafeToEEPROM();
09132
// dispScreen=1;
09133
// clearScreen();
09134
// menuScreen();
09135
}
09136
if
((x>=canCgs[0]) && (x<=canCgs[2]) && (y>=canCgs[1]) && (y<=canCgs[3]))
//press cancel
09137
{
09138
waitForIt(canCgs[0], canCgs[1], canCgs[2], canCgs[3]);
09139
waveMakerOff =
false
;
09140
dispScreen=0;
09141
clearScreen();
09142
mainScreen(
true
);
09143
}
else
09144
09145
if
((x>=185) && (x<=305) && (y>=19) && (y<=39))
//press Time/Date Button
09146
{
09147
waitForIt(185, 19, 305, 39);
09148
if
((timeDispH>=0) && (timeDispH<=11)) { AM_PM=1;}
09149
else
{ AM_PM=2;}
09150
dispScreen=2;
09151
clearScreen();
09152
clockScreen();
09153
t_temp = rtc.getTime();
09154
t_temp.dow=calcDOW(rtcSetDy, rtcSetMon, rtcSetYr);
09155
showDOW(t_temp.dow);
09156
}
09157
09158
if
((x>=185) && (x<=305) && (y>=45) && (y<=65))
//change "Month DD, YYYY" or "DD/MM/YYYY" format
09159
{
09160
waitForIt(185, 49, 305, 69);
09161
myGLCD.setColor(255, 255, 255);
09162
myGLCD.drawRoundRect(185, 49, 305, 69);
// calendar
09163
if
(setCalendarFormat ==1)
09164
{ setCalendarFormat=0;
09165
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09166
myGLCD.print(
" DD/MM/YYYY "
, 199, 53);
09167
}
09168
else
{
09169
setCalendarFormat = 1;
09170
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09171
myGLCD.print(
"MTH DD, YYYY"
, 199, 53);
09172
}
09173
}
09174
09175
if
((x>=185) && (x<=229) && (y>=79) && (y<=99))
09176
{
09177
waitForIt(185, 79, 229, 99);
09178
myGLCD.setColor(255, 255, 255);
09179
myGLCD.drawRoundRect(185, 79, 229, 99);
09180
09181
if
(displayDOW == 1)
09182
{ displayDOW =0;
09183
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09184
myGLCD.print(
"OFF"
, 199, 83);
09185
}
09186
else
{
09187
displayDOW = 1;
09188
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09189
myGLCD.print(
" ON "
, 193, 83);
09190
}
09191
}
09192
09193
if
((x>=185) && (x<=229) && (y>=109) && (y<=129))
09194
{
09195
waitForIt(185, 109, 229, 129);
09196
myGLCD.setColor(255, 255, 255);
09197
myGLCD.drawRoundRect(185, 109, 229, 129);
09198
09199
if
(setTimeFormat == 1)
09200
{ setTimeFormat =0;
09201
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09202
myGLCD.print(
"24HR"
, 191, 113);
09203
}
09204
else
{
09205
setTimeFormat = 1;
09206
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09207
myGLCD.print(
"12HR"
, 191, 113);
09208
}
09209
}
09210
09211
if
((x>=185) && (x<=229) && (y>=139) && (y<=159))
09212
{
09213
waitForIt(185, 139, 229, 159);
09214
myGLCD.setColor(255, 255, 255);
09215
myGLCD.drawRoundRect(185, 139, 229, 159);
09216
09217
if
(setTempScale == 1)
09218
{ setTempScale = 0;
09219
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09220
myGLCD.print(
"C"
, 205, 142);
09221
myGLCD.drawCircle(200, 144, 1);
09222
}
09223
else
{
09224
setTempScale = 1;
09225
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09226
myGLCD.print(
"F"
, 205, 142);
09227
myGLCD.drawCircle(200, 144, 1);
09228
}
09229
}
09230
09231
if
((x>=185) && (x<=305) && (y>=169) && (y<=189))
//press CHANGE TEMPS
09232
{
09233
waitForIt(185, 169, 305, 189);
09234
dispScreen=16;
09235
clearScreen();
09236
ChangeFanTempsScreen(
true
);
09237
}
09238
break
;
09239
09240
case
15:
//------------- GENERAL SETTINGS (PAGE 2) -----------------
09241
09242
if
((x>=backGS[0]) && (x<=backGS[2]) && (y>=backGS[1]) && (y<=backGS[3]))
//press back
09243
{
09244
waitForIt(backGS[0], backGS[1], backGS[2], backGS[3]);
09245
dispScreen=14;
09246
clearScreen();
09247
generalSettingsScreen_1();
09248
}
else
09249
09250
if
((x>=nextGS[0]) && (x<=nextGS[2]) && (y>=nextGS[1]) && (y<=nextGS[3]))
//press next
09251
{
09252
waitForIt(nextGS[0], nextGS[1], nextGS[2], nextGS[3]);
09253
dispScreen=20;
09254
clearScreen();
09255
generalSettingsScreen_3();
09256
}
else
09257
09258
if
((x>=prSAVEgs[0]) && (x<=prSAVEgs[2]) && (y>=prSAVEgs[1]) && (y<=prSAVEgs[3]))
//press SAVE
09259
{
09260
waitForIt(prSAVEgs[0], prSAVEgs[1], prSAVEgs[2], prSAVEgs[3]);
09261
SaveGenSetsToEEPROM();
09262
SaveLEDsFailsafeToEEPROM();
09263
// dispScreen=1;
09264
// clearScreen();
09265
// menuScreen();
09266
}
09267
if
((x>=canCgs[0]) && (x<=canCgs[2]) && (y>=canCgs[1]) && (y<=canCgs[3]))
//press cancel
09268
{
09269
waitForIt(canCgs[0], canCgs[1], canCgs[2], canCgs[3]);
09270
waveMakerOff =
false
;
09271
dispScreen=0;
09272
clearScreen();
09273
mainScreen(
true
);
09274
}
else
09275
09276
if
(((x>=185) && (x<=305) && (y>=19) && (y<=39)) && setDimLEDsOnOff ==1 )
//press CHANGE TEMP (Dim LEDs), if ON pressed
09277
{
09278
waitForIt(185, 19, 305, 39);
09279
dispScreen=17;
09280
clearScreen();
09281
DimLEDsAtTempScreen();
09282
}
09283
09284
if
((x>=130) && (x<=174) && (y>=19) && (y<=39))
//press ON/OFF led DIM setting
09285
{
09286
waitForIt(130, 19, 174, 39);
09287
myGLCD.setColor(255, 255, 255);
09288
myGLCD.drawRoundRect(130, 19, 174, 39);
09289
myGLCD.drawRoundRect(185, 19, 305, 39);
09290
09291
if
(setDimLEDsOnOff == 1)
09292
{ setDimLEDsOnOff =0;
09293
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09294
myGLCD.print(
"OFF"
, 144, 23);
09295
myGLCD.setColor(64, 64, 64);
09296
myGLCD.fillRoundRect(185, 19, 305, 39);
09297
setFont(SMALL, 255, 255, 255, 64, 64, 64);
09298
myGLCD.print(
"Change Temp"
, 203, 23);
09299
myGLCD.setColor(255, 255, 255);
09300
myGLCD.drawRoundRect(185, 19, 305, 39);
// dim led
09301
09302
}
09303
else
{
09304
setDimLEDsOnOff = 1;
09305
myGLCD.setColor(0, 0, 255);
09306
myGLCD.fillRoundRect(185, 19, 305, 39);
09307
myGLCD.setColor(255, 255, 255);
09308
myGLCD.drawRoundRect(185, 19, 305, 39);
09309
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09310
myGLCD.print(
" ON "
, 138, 23);
09311
myGLCD.print(
"Change Temp"
, 203, 23);
09312
09313
}
09314
}
09315
09316
if
(((x>=185) && (x<=305) && (y>=49) && (y<=69)) && setScreensaverOnOff==1)
//press SETTINGS (Screensaver)
09317
{
09318
waitForIt(185, 49, 305, 69);
09319
dispScreen=18;
09320
clearScreen();
09321
ScreensaverSettingsScreen();
09322
}
09323
09324
if
((x>=130) && (x<=174) && (y>=49) && (y<=69))
//press ON/OFF screensaver
09325
{
09326
waitForIt(130, 49, 174, 69);
09327
myGLCD.setColor(255, 255, 255);
09328
myGLCD.drawRoundRect(130, 49, 174, 69);
09329
myGLCD.drawRoundRect(185, 49, 305, 69);
09330
09331
if
(setScreensaverOnOff == 1)
09332
{ setScreensaverOnOff = 0;
09333
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09334
myGLCD.print(
"OFF"
, 144, 53);
09335
myGLCD.setColor(64, 64, 64);
09336
myGLCD.fillRoundRect(185, 49, 305, 69);
09337
setFont(SMALL, 255, 255, 255, 64, 64, 64);
09338
// myGLCD.print("Setting", 217, 53);
09339
myGLCD.print(print_text[21], 217, 53);
09340
myGLCD.setColor(255, 255, 255);
09341
myGLCD.drawRoundRect(185, 49, 305, 69);
// screen saver
09342
}
09343
else
{
09344
setScreensaverOnOff = 1;
09345
myGLCD.setColor(0, 0, 255);
09346
myGLCD.fillRoundRect(185, 49, 305, 69);
09347
myGLCD.setColor(255, 255, 255);
09348
myGLCD.drawRoundRect(185, 49, 305, 69);
09349
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09350
myGLCD.print(
" ON "
, 138, 53);
09351
// myGLCD.print("Setting", 217, 53);
09352
myGLCD.print(print_text[21], 217, 53);
09353
}
09354
}
09355
09356
if
((x>=185) && (x<=229) && (y>=79) && (y<=99))
//display MAX temp ON/OFF
09357
{
09358
waitForIt(185, 79, 229, 99);
09359
myGLCD.setColor(255, 255, 255);
09360
myGLCD.drawRoundRect(185, 79, 229, 99);
09361
if
(MAX_Temp_on_off == 1)
09362
{ MAX_Temp_on_off =0;
09363
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09364
myGLCD.print(
"OFF"
, 199, 83);
09365
}
09366
else
{MAX_Temp_on_off = 1;
09367
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09368
myGLCD.print(
" ON "
, 193, 83);
09369
}
09370
}
09371
09372
if
((x>=185) && (x<=229) && (y>=109) && (y<=129))
//Led Soft start on_off
09373
{
09374
waitForIt(185, 109, 229, 129);
09375
PercentSoftStart = 1;
09376
myGLCD.setColor(255, 255, 255);
09377
myGLCD.drawRoundRect(185, 109, 229, 129);
09378
if
(SoftStartON ==1)
09379
{ SoftStartON = 0;
09380
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09381
myGLCD.print(
"OFF"
, 199, 113);
09382
}
09383
else
{SoftStartON =1;
09384
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09385
myGLCD.print(
" ON "
, 193, 113);
09386
}
09387
}
09388
09389
if
((x>=185) && (x<=305) && (y>=139) && (y<=159))
//Buzzer ON/OFF
09390
{
09391
waitForIt(185, 139, 305, 159);
09392
myGLCD.setColor(255, 255, 255);
09393
myGLCD.drawRoundRect(185, 139, 305, 159);
09394
AlarmLevel+=1;
09395
if
(AlarmLevel >=3) {AlarmLevel =0 ;}
09396
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09397
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[56+AlarmLevel])));
//
09398
myGLCD.print(buffer, 193, 143);
09399
if
(AlarmLevel==0) {
09400
digitalWrite(tempAlarmPin, LOW);
// OFF alarm
09401
tempAlarmflagW =
false
;
// clear all error flag
09402
tempAlarmflagH1 =
false
;
09403
tempAlarmflagH2 =
false
;}
09404
09405
}
09406
09407
break
;
09408
09409
case
16:
//------------------ CHANGE Heatsink FAN TEMP ---------------------
09410
if
((x>=back[0]) && (x<=back[2]) && (y>=back[1]) && (y<=back[3]))
//press back
09411
{
09412
waitForIt(back[0], back[1], back[2], back[3]);
09413
dispScreen=14;
09414
clearScreen();
09415
generalSettingsScreen_1();
09416
}
else
09417
if
((x>=prSAVE[0]) && (x<=prSAVE[2]) && (y>=prSAVE[1]) && (y<=prSAVE[3]))
//press SAVE
09418
{
09419
waitForIt(prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3]);
09420
setTempToBeginHeatsink1FanC=temp2beHFan;
09421
setTempToBeginHeatsink1FanF=temp2beHFan;
09422
setTempToBeginHeatsink2FanC=temp2beSFan;
09423
setTempToBeginHeatsink2FanF=temp2beSFan;
09424
if
(setTempScale==0)
09425
{ setTempToBeginHeatsink1FanF=((1.8*setTempToBeginHeatsink1FanC)+32.05);
09426
setTempToBeginHeatsink2FanF=((1.8*setTempToBeginHeatsink2FanC)+32.05);}
09427
if
(setTempScale==1)
09428
{ setTempToBeginHeatsink1FanC=((.55556*(setTempToBeginHeatsink1FanF-32))+.05);
09429
setTempToBeginHeatsink2FanC=((.55556*(setTempToBeginHeatsink2FanF-32))+.05);}
09430
dispScreen=14;
09431
SaveGenSetsToEEPROM();
09432
SaveTempToEEPROM();
09433
clearScreen();
09434
generalSettingsScreen_1();
09435
}
else
09436
if
((x>=canC[0]) && (x<=canC[2]) && (y>=canC[1]) && (y<=canC[3]))
//press cancel
09437
{
09438
waitForIt(canC[0], canC[1], canC[2], canC[3]);
09439
// LEDtestTick = false;
09440
waveMakerOff =
false
;
09441
// ReadFromEEPROM();
09442
dispScreen=0;
09443
clearScreen();
09444
mainScreen(
true
);
09445
}
else
09446
setFont(LARGE, 255, 255, 255, 0, 0, 0);
09447
if
((x>=HoodFanTm[0]) && (x<=HoodFanTm[2]))
//first column
09448
{
09449
if
((y>=HoodFanTm[1]) && (y<=HoodFanTm[3]))
//press Heatsink1 Fan Temp -0.1
09450
{
09451
temp2beHFan -= 0.1;
09452
if
((setTempScale==1) && (temp2beHFan <= 68.0)){
09453
temp2beHFan = 68.0; }
09454
if
((setTempScale==0) && (temp2beHFan <= 20.0)) {
09455
temp2beHFan = 20.0; }
09456
ChangeFanTempsScreen();
09457
delay(150);
09458
}
09459
if
((y>=SumpFanTm[1]) && (y<=SumpFanTm[3]))
//press Heatsink2 Fan Temp -0.1
09460
{
09461
temp2beSFan -= 0.1;
09462
if
((setTempScale==1) && (temp2beSFan <= 68.0)){
09463
temp2beSFan = 68.0; }
09464
if
((setTempScale==0) && (temp2beSFan <= 20.0)) {
09465
temp2beSFan = 20.0; }
09466
ChangeFanTempsScreen();
09467
delay(150);
09468
}
09469
if
((y>=SoundAlarmTm[1]) && (y<=SoundAlarmTm[3]))
// press Sound Alarm -
09470
{
09471
if
(setTempScale==1) { setTempToSoundAlarmF -= 1;
09472
if
(setTempToSoundAlarmF > 210) {setTempToSoundAlarmF = 104;}
09473
if
(setTempToSoundAlarmF < 104.0) { setTempToSoundAlarmF = 210; }
09474
}
09475
if
(setTempScale==0) { setTempToSoundAlarmC -= 1;
09476
if
(setTempToSoundAlarmC > 99) {setTempToSoundAlarmC = 40;}
09477
if
( setTempToSoundAlarmC < 40.0) { setTempToSoundAlarmC = 99;}
09478
}
09479
ChangeFanTempsScreen();
09480
delay(150);
09481
}
09482
}
09483
if
((x>=HoodFanTp[0]) && (x<=HoodFanTp[2]))
//second column
09484
{
09485
if
((y>=HoodFanTp[1]) && (y<=HoodFanTp[3]))
//press Heatsink1 Fan Temp +0.1
09486
{
09487
temp2beHFan += 0.1;
09488
if
((setTempScale==1) && (temp2beHFan >= 122.0)){
09489
temp2beHFan = 122.0; }
09490
if
((setTempScale==0) && (temp2beHFan >= 50.0)) {
09491
temp2beHFan = 50.0; }
09492
ChangeFanTempsScreen();
09493
delay(150);
09494
}
09495
if
((y>=SumpFanTp[1]) && (y<=SumpFanTp[3]))
//press Heatsink2 Fan Temp +0.1
09496
{
09497
temp2beSFan += 0.1;
09498
if
((setTempScale==1) && (temp2beSFan >= 122.0)){
09499
temp2beSFan = 122.0; }
09500
if
((setTempScale==0) && (temp2beSFan >= 50.0)) {
09501
temp2beSFan = 50.0; }
09502
ChangeFanTempsScreen();
09503
delay(150);
09504
}
09505
if
((y>=SoundAlarmTp[1]) && (y<=SoundAlarmTp[3]))
// press Sound Alarm +
09506
{
09507
if
(setTempScale==1) { setTempToSoundAlarmF += 1;
09508
if
(setTempToSoundAlarmF > 210) {setTempToSoundAlarmF = 104;}
09509
if
(setTempToSoundAlarmF < 104.0) { setTempToSoundAlarmF = 210; }
09510
09511
}
09512
if
(setTempScale==0) { setTempToSoundAlarmC += 1;
09513
if
(setTempToSoundAlarmC > 99) { setTempToSoundAlarmC = 40; }
// OFF alarm
09514
if
(setTempToSoundAlarmC < 40.0) { setTempToSoundAlarmC = 99;}
09515
}
09516
ChangeFanTempsScreen();
09517
delay(150);
09518
}
09519
}
09520
break
;
09521
case
17:
//------------------ DIM LEDs AT TEMP ---------------------
09522
if
((x>=back[0]) && (x<=back[2]) && (y>=back[1]) && (y<=back[3]))
//press back
09523
{
09524
waitForIt(back[0], back[1], back[2], back[3]);
09525
dispScreen=15;
09526
clearScreen();
09527
generalSettingsScreen_2();
09528
}
else
09529
if
((x>=prSAVE[0]) && (x<=prSAVE[2]) && (y>=prSAVE[1]) && (y<=prSAVE[3]))
//press SAVE
09530
{
09531
waitForIt(prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3]);
09532
setLEDsDimTempC=TempLEDsDimTemp;
09533
setLEDsDimTempF=TempLEDsDimTemp;
09534
if
(setTempScale==0)
09535
{ setLEDsDimTempF=((1.8*setLEDsDimTempC)+32.5);}
09536
if
(setTempScale==1)
09537
{ setLEDsDimTempC=((.55556*(setLEDsDimTempF-32))+.5);}
09538
setLEDsDimPercent=TempLEDsDimPercent;
09539
SaveLEDsFailsafeToEEPROM();
09540
dispScreen=15;
09541
clearScreen();
09542
generalSettingsScreen_2();
09543
}
else
09544
if
((x>=canC[0]) && (x<=canC[2]) && (y>=canC[1]) && (y<=canC[3]))
//press cancel
09545
{
09546
waitForIt(canC[0], canC[1], canC[2], canC[3]);
09547
// LEDtestTick = false;
09548
waveMakerOff =
false
;
09549
// ReadFromEEPROM();
09550
dispScreen=0;
09551
clearScreen();
09552
mainScreen(
true
);
09553
}
else
09554
09555
if
((x>=235) && (x<=260) && (y>=36) && (y<=61))
//press TEMP UP button
09556
{
09557
TempLEDsDimTemp++;
09558
setFont(LARGE, 0, 255, 0, 0, 0, 0);
09559
if
(setTempScale ==0 && TempLEDsDimTemp>=99)
09560
{ TempLEDsDimTemp=99;}
09561
else
09562
if
(setTempScale ==1 && TempLEDsDimTemp>=210)
09563
{ TempLEDsDimTemp=210;}
09564
myGLCD.printNumI(TempLEDsDimTemp, 181, 55);
//189
09565
delay(200);
09566
}
else
09567
if
((x>=235) && (x<=260) && (y>=66) && (y<=91))
//press TEMP DOWN button
09568
{
09569
TempLEDsDimTemp--;
09570
setFont(LARGE, 0, 255, 0, 0, 0, 0);
09571
if
(setTempScale ==0 && TempLEDsDimTemp<=40)
09572
{ TempLEDsDimTemp=40;}
09573
else
09574
if
(setTempScale ==1 && TempLEDsDimTemp<=104)
09575
{ TempLEDsDimTemp=104;}
09576
myGLCD.printNumI(TempLEDsDimTemp, 181, 55);
09577
delay(200);
09578
}
else
09579
09580
if
((x>=235) && (x<=260) && (y>=117) && (y<=142))
//press % UP button
09581
{
09582
TempLEDsDimPercent++;
09583
setFont(LARGE, 0, 255, 0, 0, 0, 0);
09584
if
(TempLEDsDimPercent>=80)
09585
{ TempLEDsDimPercent=80;}
09586
myGLCD.printNumI(TempLEDsDimPercent, 181, 136);
09587
delay(200);
09588
}
else
09589
if
((x>=235) && (x<=260) && (y>=147) && (y<=172))
//press % DOWN button
09590
{
09591
TempLEDsDimPercent--;
09592
setFont(LARGE, 0, 255, 0, 0, 0, 0);
09593
if
(TempLEDsDimPercent<=10)
09594
{ TempLEDsDimPercent=10;}
09595
myGLCD.printNumI(TempLEDsDimPercent, 181, 136);
09596
delay(200);
09597
}
09598
break
;
09599
09600
case
18:
//-------------- SET SCREENSAVER WAIT TIME ----------------
09601
if
((x>=back[0]) && (x<=back[2]) && (y>=back[1]) && (y<=back[3]))
//press back
09602
{
09603
waitForIt(back[0], back[1], back[2], back[3]);
09604
dispScreen=15;
09605
clearScreen();
09606
generalSettingsScreen_2();
09607
}
else
09608
if
((x>=prSAVE[0]) && (x<=prSAVE[2]) && (y>=prSAVE[1]) && (y<=prSAVE[3]))
//press SAVE
09609
{
09610
waitForIt(prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3]);
09611
setSSmintues=TempSSminutes;
09612
SaveGenSetsToEEPROM();
09613
dispScreen=15;
09614
clearScreen();
09615
generalSettingsScreen_2();
09616
}
else
09617
if
((x>=canC[0]) && (x<=canC[2]) && (y>=canC[1]) && (y<=canC[3]))
//press cancel
09618
{
09619
waitForIt(canC[0], canC[1], canC[2], canC[3]);
09620
// LEDtestTick = false;
09621
waveMakerOff =
false
;
09622
// ReadFromEEPROM();
09623
dispScreen=0;
09624
clearScreen();
09625
mainScreen(
true
);
09626
}
else
09627
09628
if
((x>=206) && (x<=310) && (y>=20) && (y<=40))
//press "Choose type of screensaver"
09629
{
09630
waitForIt(206, 20, 310, 40);
09631
ClockType +=1;
09632
if
(ClockType >3) {ClockType = 0;}
09633
ScreensaverSelect();
09634
}
09635
09636
if
((x>=206) && (x<=260) && (y>=51) && (y<=71))
//press "ON/OFF Screensaver lock"
09637
{
09638
waitForIt(206, 51, 260, 71);
09639
if
(setLockScreen==1) { setLockScreen =0;
09640
printButton(
" OFF"
, 206, 51, 260, 71, SMALL); }
09641
else
09642
{setLockScreen =1;
09643
printButton(
" ON "
, 206, 51, 260, 71, SMALL); }
09644
}
09645
09646
if
((x>=206) && (x<=260) && (y>=82) && (y<=102))
//press Brightness button
09647
{
09648
waitForIt(206, 82, 260, 102);
09649
BrigthnessCount +=1;
09650
if
(BrigthnessCount >4) {BrigthnessCount = 0;}
09651
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09652
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[59+BrigthnessCount])));
// counter = 0/1/2/3/4 -> 0%-25%-50%-75%-100%
09653
myGLCD.print(buffer, 217, 86);
09654
}
09655
09656
if
((x>=175) && (x<=200) && (y>=107+10) && (y<=132+10))
//press Minute UP button
09657
{
09658
TempSSminutes++;
09659
setFont(LARGE, 0, 255, 0, 0, 0, 0);
09660
if
(TempSSminutes>=99)
09661
{ TempSSminutes=99;}
09662
if
(TempSSminutes>=10)
09663
{ myGLCD.printNumI(TempSSminutes, 129, 126+10);}
09664
else
{ myGLCD.printNumI(TempSSminutes, 137, 126+10);}
09665
delay(200);
09666
}
else
09667
if
((x>=175) && (x<=200) && (y>=137+10) && (y<=162+10))
//press Minute DOWN button
09668
{
09669
TempSSminutes--;
09670
setFont(LARGE, 0, 255, 0, 0, 0, 0);
09671
if
(TempSSminutes<=1)
09672
{ TempSSminutes=1;}
09673
if
(TempSSminutes>=10)
09674
{ myGLCD.printNumI(TempSSminutes, 129, 126+10);}
09675
else
{ myGLCD.printNumI(TempSSminutes, 137, 126+10);
09676
myGLCD.setColor(0, 0, 0);
09677
myGLCD.fillRect(129, 126+10, 136, 142+10);
09678
myGLCD.fillRect(153, 126+10, 161, 142+10);}
09679
delay(200);
09680
}
09681
break
;
09682
09683
case
19:
// ************* not used ******************
09684
09685
09686
09687
break
;
09688
09689
case
20:
//---------------General setting PAGE 3 ------------------------
09690
if
((x>=backGS[0]) && (x<=backGS[2]) && (y>=backGS[1]) && (y<=backGS[3]))
//press back
09691
{
09692
waitForIt(backGS[0], backGS[1], backGS[2], backGS[3]);
09693
dispScreen=15;
09694
clearScreen();
09695
generalSettingsScreen_2();
09696
}
else
09697
09698
if
((x>=canCgs[0]) && (x<=canCgs[2]) && (y>=canCgs[1]) && (y<=canCgs[3]))
//press cancel
09699
{
09700
waitForIt(canCgs[0], canCgs[1], canCgs[2], canCgs[3]);
09701
waveMakerOff =
false
;
09702
dispScreen=0;
09703
clearScreen();
09704
mainScreen(
true
);
09705
}
else
09706
09707
if
(x>=205 && x<=305 && y>=19 && y<=39)
//press DETECT button
09708
{
09709
waitForIt(205, 19, 305, 39);
09710
clearScreen();
09711
dispScreen=21;
09712
DetectDallalsSensors(
true
);
09713
}
09714
09715
if
(x>=205 && x<=305 && y>=49 && y<=69)
//press BACKUP button
09716
{
09717
waitForIt(205, 49, 305, 69);
09718
clearScreen();
09719
dispScreen=22;
09720
Backup();}
09721
09722
if
(x>=205 && x<=305 && y>=79 && y<=99 && bitRead(GlobalStatus1Byte,0) ==
false
)
//press RESET button
09723
{
09724
waitForIt(205, 79, 305, 99);
09725
myGLCD.setColor(0, 0, 0);
09726
myGLCD.fillRoundRect(205, 79, 305, 99);
// clear button position
09727
bitSet(GlobalStatus1Byte,0);
// set bit for check Y/N button
09728
09729
myGLCD.setColor(0, 0, 255);
09730
myGLCD.fillRoundRect(205, 79, 245, 99);
// YES
09731
myGLCD.fillRoundRect(265, 79, 305, 99);
// NO
09732
myGLCD.setColor(255, 255, 255);
09733
myGLCD.drawRoundRect(205, 79, 245, 99);
// YES
09734
myGLCD.drawRoundRect(265, 79, 305, 99);
// NO
09735
09736
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09737
myGLCD.print(
"YES"
, 205+8, 83);
09738
myGLCD.print(
"NO"
, 265+16, 83);
09739
myGLCD.print(
"Are You Sure Y/N? "
, 5, 83);
09740
}
else
09741
09742
if
(x>=205 && x<=245 && y>=88 && y<=108 && bitRead(GlobalStatus1Byte,0) ==
true
)
//press Yes button
09743
{ waitForIt(205, 79, 245, 99);
09744
09745
EEPROM.write(0, 0);
// clear fisrs eeprom byte
09746
setFont(SMALL, 255, 0, 0, 0, 0, 0);
09747
myGLCD.print(print_text[8], CENTER, 120);
// "Please press on the shield Reset Button"
09748
myGLCD.print(print_text[9], CENTER, 135);
// "or turn off
09749
myGLCD.print(print_text[10],CENTER, 150);
// and then turn on the controller"
09750
bitClear(GlobalStatus1Byte,0);
// clear bit for check Y/N button
09751
}
else
09752
09753
if
(x>=265 && x<=305 && y>=79 && y<=99 && bitRead(GlobalStatus1Byte,0) ==
true
)
//press NO button
09754
{ waitForIt(265, 79, 305, 99);
09755
dispScreen=20;
09756
clearScreen();
09757
generalSettingsScreen_3();
09758
bitClear(GlobalStatus1Byte,0);
// clear bit for check Y/N button
09759
}
09760
09761
break
;
09762
09763
case
21:
// ----------- autodetect Dallas sensor page -----------------
09764
09765
if
((x>=back[0]) && (x<=back[2]) && (y>=back[1]) && (y<=back[3]) && dispScreen==21 )
//press back
09766
{
09767
waitForIt(back[0], back[1], back[2], back[3]);
09768
dispScreen=20;
09769
clearScreen();
09770
generalSettingsScreen_3();
09771
09772
}
else
09773
if
((x>=prSAVE[0]) && (x<=prSAVE[2]) && (y>=prSAVE[1]) && (y<=prSAVE[3]))
//press SAVE
09774
{
09775
waitForIt(prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3]);
09776
DetectDallalsSensors(
false
);
09777
SaveDallasAddress ();
09778
dispScreen=0;
09779
clearScreen();
09780
mainScreen(
true
);
09781
}
else
09782
if
(x>=200 && x<=300 && y>=20 && y<=40)
// Refresh button
09783
{
09784
waitForIt(200, 20, 300, 40);
// re-read all sensor data
09785
DetectDallalsSensors(
false
);
09786
}
09787
09788
if
((x>=165) && (x<=225) && (y>=83+20) && (y<=83+40) && numberOfDevices >=1)
// sensor N1 button
09789
{
09790
waitForIt(165, 83+20, 225, 83+40);
09791
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09792
counterB1 +=1;
09793
if
(counterB1 > 3) {counterB1 = 0;}
09794
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[2+counterB1])));
// counterBX = 0/1/2/3 -> NC/Water/H.Sink1/H.Sink2
09795
myGLCD.print(buffer, 169, 83+24);
09796
}
else
09797
09798
if
((x>=165) && (x<=225) && (y>=83+50) && (y<=83+70) && numberOfDevices >=2)
// sensor N2 button
09799
{
09800
waitForIt(165, 83+50, 225, 83+70);
09801
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09802
counterB2 +=1;
09803
if
(counterB2 > 3) {counterB2 = 0;}
09804
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[2+counterB2])));
// counterBX = 0/1/2/3 -> NC/Water/H.Sink1/H.Sink2
09805
myGLCD.print(buffer, 169, 83+54);
09806
}
else
09807
09808
if
((x>=165) && (x<=225) && (y>=83+80) && (y<=83+100) && numberOfDevices ==3)
// sensor N3 button
09809
{
09810
waitForIt(165, 83+80, 225, 83+100);
09811
setFont(SMALL, 255, 255, 255, 0, 0, 255);
09812
counterB3 +=1;
09813
if
(counterB3 > 3) {counterB3 = 0;}
09814
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[2+counterB3])));
// counterBX = 0/1/2/3 -> NC/Water/H.Sink1/H.Sink2
09815
myGLCD.print(buffer, 169, 83+84);
09816
}
09817
break
;
09818
09819
case
22:
// ----------- BACKUP ALL EEPROM SETTING -----------------
09820
if
((x>=back[0]) && (x<=back[2]) && (y>=back[1]) && (y<=back[3]) && dispScreen==22 )
//press back
09821
{
09822
waitForIt(back[0], back[1], back[2], back[3]);
09823
dispScreen=20;
09824
09825
clearScreen();
09826
generalSettingsScreen_3();
09827
}
else
09828
//-----------------------------------------
09829
if
((x>=205 && x<=305 && y>=74 && y<=94) && dispScreen==22)
//press BACKUP button
09830
{ waitForIt(205, 74, 305, 94);
09831
09832
myGLCD.setColor(0, 0, 0);
// clear text area
09833
myGLCD.fillRoundRect(2, 14, 318, 55);
09834
09835
sd.remove(
"Backup.txt"
);
// remove old file from card
09836
myFile.open(
"Backup.txt"
, O_CREAT | O_EXCL | O_WRITE) ;
09837
09838
if
(myFile.isOpen()) {
09839
setFont(SMALL, 0, 255, 0, 0, 0, 0);
09840
// myGLCD.print("Writing to file Backup.txt", 5, 24);
09841
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[0])));
09842
myGLCD.print(buffer, 5, 24);
09843
09844
for
(
int
i=0; i<=4095; i++)
09845
{
byte
TEMP = EEPROM.read(i);
// readed data in DEC format
09846
myFile.print(TEMP, DEC);
// store to file in DEC
09847
myFile.print(
','
); }
// store separator "," between bytes
09848
09849
myFile.close();
09850
setFont(SMALL, 0, 255, 0, 0, 0, 0);
09851
// myGLCD.print("Backup done. ", 5, 41);
09852
strcpy_P(buffer, (
char
*)pgm_read_word_near(&(Text_table[1])));
09853
myGLCD.print(buffer, 5, 41);
09854
09855
}
else
09856
{ setFont(SMALL, 255, 0, 0, 0, 0, 0);
09857
myGLCD.print(
"error opening file Backup.txt"
, 5, 41); }
09858
}
else
09859
09860
//------------------------------------------------------------------------------
09861
if
((x>=15 && x<=115 && y>=74 && y<=94) && dispScreen==22)
//press RESTORE button
09862
{ waitForIt(15, 74, 115, 94);
09863
09864
myGLCD.setColor(0, 0, 0);
// clear text area
09865
myGLCD.fillRoundRect(2, 14, 318, 55);
09866
09867
// re-open the file for reading:
09868
09869
if
(myFile.open(
"Backup.txt"
, O_READ)) {
09870
setFont(SMALL, 0, 255, 0, 0, 0, 0);
09871
myGLCD.print(
"Open file Backup.txt "
, 5, 24);
09872
myGLCD.print(
"Please Wait..... "
, 5, 41);
09873
09874
int
TEMP;
09875
int
i=0;
09876
byte
SD_buff[3];
09877
byte
k=0;
09878
// read from the file until there's nothing else in it:
09879
while
((TEMP = myFile.read()) > 0)
// readed data in ASCII only, need convert ASCII to DEC
09880
{
09881
// Serial.write((char)TEMP); // output to serial port
09882
if
(TEMP != 44 && k<=2) {
09883
TEMP= TEMP -
'0'
;
//convert ASCII to DEC
09884
SD_buff[k]= TEMP;
09885
k++;
09886
}
else
09887
{
09888
int
Result = SD_buff[0]*100 + SD_buff[1]*10 + SD_buff[2];
// convert three consecutive bytes to one decimal
09889
if
(k ==2 ) {Result = Result/10;}
// before save to eeprom
09890
if
(k ==1 ) {Result = Result/100;}
09891
09892
EEPROM.write(i, Result);
// store data to EEPROM
09893
09894
i +=1; k=0;
09895
SD_buff[0]=0;
// clean buffer before new read
09896
SD_buff[1]=0;
09897
SD_buff[2]=0;
09898
}
09899
}
09900
myFile.close();
09901
ReadDallasAddress ();
// read temp sensor address from eeprom
09902
ReadLedFromEEPROM();
// read led setting from EEPROM
09903
ReadFromEEPROM();
// read other setting from eeprom
09904
09905
setFont(SMALL, 0, 255, 0, 0, 0, 0);
09906
myGLCD.print(
"Restore done. "
, 5, 41);
09907
}
else
{
09908
setFont(SMALL, 255, 0, 0, 0, 0, 0);
09909
myGLCD.print(
"error opening file Backup.txt"
, 5, 41);}
09910
}
09911
break
;
09912
09913
//---------------- LED Preset -----------------------------------
09914
case
23:
09915
if
((x>=back[0]) && (x<=back[2]) && (y>=back[1]) && (y<=back[3]))
//press back
09916
{
09917
waitForIt(back[0], back[1], back[2], back[3]);
09918
dispScreen=4;
09919
clearScreen();
09920
ledTestOptionsScreen();
// display buttons "Rapid test"/"Control Individual Leds"/"Preset"
09921
}
09922
/*
09923
if ((x>=canC[0]) && (x<=canC[2]) && (y>=canC[1]) && (y<=canC[3])) //press CANCEL
09924
{
09925
waitForIt(canC[0], canC[1], canC[2], canC[3]);
09926
dispScreen=0;
09927
clearScreen();
09928
mainScreen(true);
09929
}
09930
*/
09931
if
((x>=prSAVE[0]) && (x<=prSAVE[2]) && (y>=prSAVE[1]) && (y<=prSAVE[3]))
//press SAVE
09932
{
09933
waitForIt(prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3]);
09934
if
(bitRead(GlobalStatus2Byte,0)== 1) {AddressShift=0;}
09935
if
(bitRead(GlobalStatus2Byte,1)== 1) {AddressShift=9;}
09936
if
(bitRead(GlobalStatus2Byte,2)== 1) {AddressShift=18;}
09937
if
(bitRead(GlobalStatus2Byte,3)== 1) {AddressShift=27;}
09938
// if ((GlobalStatus2Byte & 0x0F) !=0 ) {SaveLEDPresetToEEPROM();}
09939
SaveLEDPresetToEEPROM();
09940
}
09941
09942
if
((x>=LedPres1[0]) && (x<=LedPres1[2]) && (y>=LedPres1[1]) && (y<=LedPres1[3]))
//press Preset N1
09943
{
09944
waitForIt(LedPres1[0], LedPres1[1], LedPres1[2], LedPres1[3]);
09945
if
(bitRead(GlobalStatus2Byte,0)== 0){
09946
printButton(
"Preset 1"
, LedPres1[0], LedPres1[1], LedPres1[2], LedPres1[3], SMALL, GREEN_BAC);
// ON preset 1
09947
printButton(
"Preset 2"
, LedPres2[0], LedPres2[1], LedPres2[2], LedPres2[3], SMALL);
09948
printButton(
"Preset 3"
, LedPres3[0], LedPres3[1], LedPres3[2], LedPres3[3], SMALL);
09949
printButton(
"Preset 4"
, LedPres4[0], LedPres4[1], LedPres4[2], LedPres4[3], SMALL);
09950
GlobalStatus2Byte = (GlobalStatus2Byte & 0xF0 | 0x1);
//set flag Preset1, clear 2..4
09951
colorLEDtest =
true
;
09952
}
09953
else
{printButton(
"Preset 1"
, LedPres1[0], LedPres1[1], LedPres1[2], LedPres1[3], SMALL);
// OFF preset
09954
colorLEDtest =
false
;
09955
bitClear(GlobalStatus2Byte,0);}
// clear flag Preset1
09956
AddressShift = 0;
09957
ReadLEDPresetFromEEPROM();
09958
PresetLedScreen(
false
);
// preset led windows
09959
}
09960
09961
if
((x>=LedPres2[0]) && (x<=LedPres2[2]) && (y>=LedPres2[1]) && (y<=LedPres2[3]))
//press Preset N2
09962
{
09963
waitForIt(LedPres2[0], LedPres2[1], LedPres2[2], LedPres2[3]);
09964
if
(bitRead(GlobalStatus2Byte,1)== 0){
09965
printButton(
"Preset 1"
, LedPres1[0], LedPres1[1], LedPres1[2], LedPres1[3], SMALL);
09966
printButton(
"Preset 2"
, LedPres2[0], LedPres2[1], LedPres2[2], LedPres2[3], SMALL, GREEN_BAC);
// ON preset 2
09967
printButton(
"Preset 3"
, LedPres3[0], LedPres3[1], LedPres3[2], LedPres3[3], SMALL);
09968
printButton(
"Preset 4"
, LedPres4[0], LedPres4[1], LedPres4[2], LedPres4[3], SMALL);
09969
GlobalStatus2Byte = (GlobalStatus2Byte & 0xF0 | 0x2);
//set flag Preset2, clear 1,3,4
09970
colorLEDtest =
true
;
09971
}
09972
else
{printButton(
"Preset 2"
, LedPres2[0], LedPres2[1], LedPres2[2], LedPres2[3], SMALL);
// OFF preset
09973
colorLEDtest =
false
;
09974
bitClear(GlobalStatus2Byte,1);}
// clear flag Preset2
09975
AddressShift = 9;
09976
ReadLEDPresetFromEEPROM();
09977
PresetLedScreen(
false
);
// preset led windows
09978
}
09979
09980
if
((x>=LedPres3[0]) && (x<=LedPres3[2]) && (y>=LedPres3[1]) && (y<=LedPres3[3]))
//press Preset N3
09981
{
09982
waitForIt(LedPres3[0], LedPres3[1], LedPres3[2], LedPres3[3]);
09983
if
(bitRead(GlobalStatus2Byte,2)== 0){
09984
printButton(
"Preset 1"
, LedPres1[0], LedPres1[1], LedPres1[2], LedPres1[3], SMALL);
09985
printButton(
"Preset 2"
, LedPres2[0], LedPres2[1], LedPres2[2], LedPres2[3], SMALL);
09986
printButton(
"Preset 3"
, LedPres3[0], LedPres3[1], LedPres3[2], LedPres3[3], SMALL, GREEN_BAC);
// ON preset 3
09987
printButton(
"Preset 4"
, LedPres4[0], LedPres4[1], LedPres4[2], LedPres4[3], SMALL);
09988
GlobalStatus2Byte = (GlobalStatus2Byte & 0xF0| 0x4);
//set flag Preset3, clear 1,2,4
09989
colorLEDtest =
true
;
09990
}
09991
else
{printButton(
"Preset 3"
, LedPres3[0], LedPres3[1], LedPres3[2], LedPres3[3], SMALL);
// OFF preset
09992
colorLEDtest =
false
;
09993
bitClear(GlobalStatus2Byte,2);}
// clear flag Preset3
09994
AddressShift = 18;
09995
ReadLEDPresetFromEEPROM();
09996
PresetLedScreen(
false
);
// preset led windows
09997
}
09998
09999
if
((x>=LedPres4[0]) && (x<=LedPres4[2]) && (y>=LedPres4[1]) && (y<=LedPres4[3]))
//press Preset N4
10000
{
10001
waitForIt(LedPres4[0], LedPres4[1], LedPres4[2], LedPres4[3]);
10002
if
(bitRead(GlobalStatus2Byte,3)== 0){
10003
printButton(
"Preset 1"
, LedPres1[0], LedPres1[1], LedPres1[2], LedPres1[3], SMALL);
10004
printButton(
"Preset 2"
, LedPres2[0], LedPres2[1], LedPres2[2], LedPres2[3], SMALL);
10005
printButton(
"Preset 3"
, LedPres3[0], LedPres3[1], LedPres3[2], LedPres3[3], SMALL);
10006
printButton(
"Preset 4"
, LedPres4[0], LedPres4[1], LedPres4[2], LedPres4[3], SMALL, GREEN_BAC);
// ON preset 4
10007
GlobalStatus2Byte = (GlobalStatus2Byte & 0xF0 | 0x8);
//set flag Preset4, clear 1..3
10008
colorLEDtest =
true
;
10009
}
10010
else
{printButton(
"Preset 4"
, LedPres4[0], LedPres4[1], LedPres4[2], LedPres4[3], SMALL);
// OFF preset
10011
colorLEDtest =
false
;
10012
bitClear(GlobalStatus2Byte,3);}
// clear flag Preset4
10013
AddressShift = 27;
10014
ReadLEDPresetFromEEPROM();
10015
PresetLedScreen(
false
);
// preset led windows
10016
}
10017
10018
if
((y>=TopSldY)&&(y<=BotSldY) && (colorLEDtest==
true
))
//change value with Slider Bars touch
10019
{
10020
TopSldY=53, BotSldY=TopSldY+100;
10021
SliderSwitch =
false
;
10022
for
(
byte
i=0; i<8; i++)
10023
{ sbX1=(i*35)+4+18; sbX2=(i*35)+34+18;
10024
if
(x>=sbX1+5 && x<=sbX2-5)
// desrease slider touchable area (-5pix)
10025
{
// WHITE=1, BLUE=2, ROYAL=3, RED=4,
10026
// ULTRA=5, TV=6, MOON=7;
10027
// CYAN=8, YELLOW=9
10028
// slider width 30 pix, clearens between sliders 5pix
10029
10030
if
(i==0 && bitRead(LedShannelStatusByte,5) ==
true
)
10031
{ sbR= rgbCh6[0]; sbG= rgbCh6[1]; sbB= rgbCh6[2];
// TV colour
10032
tvcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
10033
if
(i==1 && bitRead(LedShannelStatusByte,3) ==
true
)
10034
{ sbR= rgbCh5[0]; sbG= rgbCh5[1]; sbB= rgbCh5[2];
// DR colour
10035
rcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2); }
10036
if
(i==2 && bitRead(LedShannelStatusByte,0) ==
true
)
10037
{ sbR= rgbCh2[0]; sbG= rgbCh2[1]; sbB= rgbCh2[2];
// CW colour
10038
wcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
10039
if
(i==3 && bitRead(LedShannelStatusByte,1) ==
true
)
10040
{ sbR= rgbCh4[0]; sbG= rgbCh4[1]; sbB= rgbCh4[2];
// BL colour
10041
bcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
10042
if
(i==4 && bitRead(LedShannelStatusByte,2) ==
true
)
10043
{ sbR= rgbCh3[0]; sbG= rgbCh3[1]; sbB= rgbCh3[2];
// RBL colour
10044
rbcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
10045
if
(i==5 && bitRead(LedShannelStatusByte,4) ==
true
)
10046
{ sbR= rgbCh1[0]; sbG= rgbCh1[1]; sbB= rgbCh1[2];
// UV colour
10047
uvcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
10048
if
(i==6 && bitRead(LedShannelStatusByte,6) ==
true
)
10049
{ sbR= rgbCh0[0]; sbG= rgbCh0[1]; sbB= rgbCh0[2];
// CY colour
10050
cycol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
10051
if
(i==7 && bitRead(LedShannelStatusByte,7) ==
true
)
10052
{ sbR= rgbCh7[0]; sbG= rgbCh7[1]; sbB= rgbCh7[2];
// Yellow colour
10053
yelcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);}
10054
10055
LED_levels_output();
10056
}
10057
}
10058
}
else
10059
10060
if
((y>=29+2) && (y<=44-2) && (colorLEDtest==
true
))
//UP Buttons were touched, desrease button touchable area (2pix)
10061
{
10062
TopSldY=53, BotSldY=TopSldY+100;
10063
SliderSwitch =
true
;
10064
10065
for
(
byte
i=0; i<8; i++)
10066
{ sbX1=(i*35)+4+18; sbX2=(i*35)+34+18;
10067
if
(x>=sbX1 && x<=sbX2)
// slider width 30 pix, clearens 5pix
10068
{
// WHITE=1, BLUE=2, ROYAL=3, RED=4,
10069
// ULTRA=5, TV=6, MOON=7;
10070
// CYAN=8, YELLOW=9
10071
if
(i==0 && bitRead(LedShannelStatusByte,5) ==
true
)
10072
{ sbR= rgbCh6[0]; sbG= rgbCh6[1]; sbB= rgbCh6[2]; tSlide = tvcol_out; tSlide+=1;
// TV colour
10073
tvcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10074
tSlide= tvcol_out; }
10075
if
(i==1 && bitRead(LedShannelStatusByte,3) ==
true
)
10076
{ sbR= rgbCh5[0]; sbG= rgbCh5[1]; sbB= rgbCh5[2]; tSlide= rcol_out; tSlide+=1;
// DR colour
10077
rcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10078
tSlide= rcol_out; }
10079
if
(i==2 && bitRead(LedShannelStatusByte,0) ==
true
)
10080
{ sbR= rgbCh2[0]; sbG= rgbCh2[1]; sbB= rgbCh2[2]; tSlide= wcol_out; tSlide+=1;
// CW colour
10081
wcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10082
tSlide= wcol_out; }
10083
if
(i==3 && bitRead(LedShannelStatusByte,1) ==
true
)
10084
{ sbR= rgbCh4[0]; sbG= rgbCh4[1]; sbB= rgbCh4[2]; tSlide= bcol_out; tSlide+=1;
// BL colour
10085
bcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10086
tSlide= bcol_out;}
10087
if
(i==4 && bitRead(LedShannelStatusByte,2) ==
true
)
10088
{ sbR= rgbCh3[0]; sbG= rgbCh3[1]; sbB= rgbCh3[2]; tSlide= rbcol_out; tSlide+=1;
// RBL colour
10089
rbcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10090
tSlide= rbcol_out;}
10091
if
(i==5 && bitRead(LedShannelStatusByte,4) ==
true
)
10092
{ sbR= rgbCh1[0]; sbG= rgbCh1[1]; sbB= rgbCh1[2]; tSlide= uvcol_out; tSlide+=1;
// UV colour
10093
uvcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10094
tSlide= uvcol_out;}
10095
if
(i==6 && bitRead(LedShannelStatusByte,6) ==
true
)
10096
{ sbR= rgbCh0[0]; sbG= rgbCh0[1]; sbB= rgbCh0[2]; tSlide= cycol_out; tSlide+=1;
// CY colour
10097
cycol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10098
tSlide= cycol_out; }
10099
if
(i==7 && bitRead(LedShannelStatusByte,7) ==
true
)
10100
{ sbR= rgbCh7[0]; sbG= rgbCh7[1]; sbB= rgbCh7[2]; tSlide= yelcol_out; tSlide+=1;
// Yellow colour
10101
yelcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10102
tSlide= yelcol_out; }
10103
delay(100);
//delay 50msec after touch UP/DOWN button
10104
LED_levels_output();
10105
}
10106
}
10107
SliderSwitch =
false
;
10108
10109
}
else
10110
if
((y>=174+2) && (y<=187-2) && (colorLEDtest==
true
))
//DOWN Buttons were touched,desrease button touchable area (2pix)
10111
{
10112
TopSldY=53, BotSldY=TopSldY+100;
10113
SliderSwitch =
true
;
10114
for
(
byte
i=0; i<8; i++)
10115
{ sbX1=(i*35)+4+18; sbX2=(i*35)+34+18;
10116
if
(x>=sbX1 && x<=sbX2)
// slider width 30 pix, clearens 5pix
10117
{
// WHITE=1, BLUE=2, ROYAL=3, RED=4,
10118
// ULTRA=5, TV=6, MOON=7;
10119
// CYAN=8, YELLOW=9
10120
if
(i==0 && bitRead(LedShannelStatusByte,5) ==
true
)
10121
{ sbR= rgbCh6[0]; sbG= rgbCh6[1]; sbB= rgbCh6[2]; tSlide = tvcol_out; tSlide-=1;
// TV colour
10122
tvcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10123
tSlide = tvcol_out; }
10124
if
(i==1 && bitRead(LedShannelStatusByte,3) ==
true
)
10125
{ sbR= rgbCh5[0]; sbG= rgbCh5[1]; sbB= rgbCh5[2]; tSlide = rcol_out; tSlide-=1;
// DR colour
10126
rcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10127
tSlide = rcol_out ; }
10128
if
(i==2 && bitRead(LedShannelStatusByte,0) ==
true
)
10129
{ sbR= rgbCh2[0]; sbG= rgbCh2[1]; sbB= rgbCh2[2]; tSlide = wcol_out; tSlide-=1;
// CW colour
10130
wcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10131
tSlide= wcol_out; }
10132
if
(i==3 && bitRead(LedShannelStatusByte,1) ==
true
)
10133
{ sbR= rgbCh4[0]; sbG= rgbCh4[1]; sbB= rgbCh4[2]; tSlide = bcol_out; tSlide-=1;
// BL colour
10134
bcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10135
tSlide= bcol_out; }
10136
if
(i==4 && bitRead(LedShannelStatusByte,2) ==
true
)
10137
{ sbR= rgbCh3[0]; sbG= rgbCh3[1]; sbB= rgbCh3[2]; tSlide = rbcol_out; tSlide-=1;
// RBL colour
10138
rbcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10139
tSlide= rbcol_out; }
10140
if
(i==5 && bitRead(LedShannelStatusByte,4) ==
true
)
10141
{ sbR= rgbCh1[0]; sbG= rgbCh1[1]; sbB= rgbCh1[2]; tSlide = uvcol_out; tSlide-=1;
// UV colour
10142
uvcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10143
tSlide= uvcol_out; }
10144
if
(i==6 && bitRead(LedShannelStatusByte,6) ==
true
)
10145
{ sbR= rgbCh0[0]; sbG= rgbCh0[1]; sbB= rgbCh0[2]; tSlide = cycol_out; tSlide-=1;
// CY colour
10146
cycol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10147
tSlide= cycol_out; }
10148
if
(i==7 && bitRead(LedShannelStatusByte,7) ==
true
)
10149
{ sbR= rgbCh7[0]; sbG= rgbCh7[1]; sbB= rgbCh7[2]; tSlide = yelcol_out; tSlide-=1;
// Yellow colour
10150
yelcol_out= SliderBarsForChange( TopSldY, BotSldY, y, sbR, sbG, sbB, sbX1, sbX2);
10151
tSlide= yelcol_out; }
10152
delay(100);
//delay 50msec after touch UP/DOWN button
10153
LED_levels_output();
10154
}
10155
}
10156
}
10157
SliderSwitch =
false
;
10158
10159
break
;
10160
10161
case
24:
// ************* not used ******************
10162
break
;
10163
10164
case
25:
// ************* Weather control ******************
10165
10166
10167
if
((x>=CloudCtrl[0]) && (x<=CloudCtrl[2]) && (y>=CloudCtrl[1]) && (y<=CloudCtrl[3]) && clouDonOff== 1)
//press Cloud setting
10168
{ waitForIt(CloudCtrl[0], CloudCtrl[1], CloudCtrl[2], CloudCtrl[3]);
10169
dispScreen=26;
10170
// timOBLtmp = timOBL;
10171
// deltaOBLtmp = deltaOBL;
10172
// razOBLtmp = razOBL;
10173
clearScreen();
10174
clouDScreen(
true
); }
10175
10176
if
((x>=CloudCtrlON[0]) && (x<=CloudCtrlON[2]) && (y>=CloudCtrlON[1]) && (y<=CloudCtrlON[3]))
//press Cloud on/off
10177
{ waitForIt(CloudCtrlON[0], CloudCtrlON[1], CloudCtrlON[2], CloudCtrlON[3]);
10178
10179
if
(clouDonOff== 1 )
10180
{clouDonOff=0;
// cloud off
10181
storMonOff=0;
// Storm off
10182
weeStart = 2;
10183
OBLoNoff=0;
10184
DimCloud = dimmW;}
10185
else
{clouDonOff=1;
// cloud on
10186
weezleONoff=1;
10187
OBLoNoff=1;
10188
DimCloud = 100;}
10189
wthScreen ();
10190
}
10191
10192
if
((x>=StormCtrl[0]) && (x<=StormCtrl[2]) && (y>=StormCtrl[1]+30) && (y<=StormCtrl[3]+30))
//press Start/Stop test
10193
{ waitForIt(StormCtrl[0], StormCtrl[1]+30, StormCtrl[2], StormCtrl[3]+30);
10194
if
(bitRead(GlobalStatus3Byte,0) == 0){
10195
bitSet(GlobalStatus3Byte,0);
10196
printButton(print_text[39], StormCtrl[0], StormCtrl[1]+30, StormCtrl[2], StormCtrl[3]+30, SMALL, GREEN_BAC);
//"Start" (BLUE_BAC)
10197
weeStart=1;
10198
clouDonOff =1;
10199
DimCloud = 100;
10200
RampRatioCalc();
10201
10202
}
10203
else
{ bitClear(GlobalStatus3Byte,0);
10204
// printButton(print_text[40], StormCtrl[0], StormCtrl[1]+30, StormCtrl[2], StormCtrl[3]+30, SMALL); //"Stop" (BLUE_BAC)
10205
printButton(print_text[40], StormCtrl[0], StormCtrl[1]+30, StormCtrl[2], StormCtrl[3]+30, SMALL, GREEN_BAC);
//"Stop" (BLUE_BAC)
10206
weeStart=2;
10207
// clouDonOff =0;
10208
}
10209
}
10210
10211
10212
if
((x>=StormCtrl[0]) && (x<=StormCtrl[2]) && (y>=StormCtrl[1]) && (y<=StormCtrl[3]) && clouDonOff== 1 && storMonOff== 1)
//press Storm setting
10213
{ waitForIt(StormCtrl[0], StormCtrl[1], StormCtrl[2], StormCtrl[3]);
10214
dispScreen=27;
10215
timGROZtmp=timGROZ;
10216
clearScreen();
10217
storMScreen(
true
); }
10218
10219
if
((x>=StormCtrlON[0]) && (x<=StormCtrlON[2]) && (y>=StormCtrlON[1]) && (y<=StormCtrlON[3])&& clouDonOff== 1)
//press Storm on/off
10220
{ waitForIt(StormCtrlON[0], StormCtrlON[1], StormCtrlON[2], StormCtrlON[3]);
10221
10222
if
(storMonOff== 1 )
10223
{storMonOff=0;
// Storm off
10224
// weeStart = 2;
10225
// DimCloud = dimmW;
10226
stormGR = 0; }
10227
else
{storMonOff=1;
// Storm on
10228
stormGR = 1;}
10229
wthScreen ();
10230
}
10231
10232
break
;
10233
10234
case
26:
// ************* Cloud Control ******************
10235
10236
// ---------------- increase/decrease values -------------
10237
CloudDayQantity = PlusMinusCount (
false
, 200, 88, 1, 5, 1, CloudDayQantity);
// quant Cloud/day
10238
CloudDuration = PlusMinusCount (
false
, 200, 124, 15, 90, 1, CloudDuration);
//duration cloud
10239
CloudWeekQantity = PlusMinusCount (
false
, 200, 163, 1, 7, 1, CloudWeekQantity);
// cloudy day
10240
10241
//CalcCoud();
10242
10243
if
((x>=canCgs[0]) && (x<=canCgs[2]) && (y>=canCgs[1]) && (y<=canCgs[3]))
//press CANCEL
10244
{
10245
waitForIt(canCgs[0], canCgs[1], canCgs[2], canCgs[3]);
10246
dispScreen=0;
10247
clearScreen();
10248
mainScreen(
true
); }
10249
10250
if
((x>=backGS[0]) && (x<=backGS[2]) && (y>=backGS[1]) && (y<=backGS[3]))
//press back
10251
{ waitForIt(backGS[0], backGS[1], backGS[2], backGS[3]);
10252
dispScreen=25;
10253
clearScreen();
10254
wthScreen (
true
); }
10255
10256
if
((x>=prSAVEgs[0]) && (x<=prSAVEgs[2]) && (y>=prSAVEgs[1]) && (y<=prSAVEgs[3]))
//press SAVE
10257
{ waitForIt(prSAVEgs[0], prSAVEgs[1], prSAVEgs[2], prSAVEgs[3]);
10258
timOBL = timOBLtmp;
10259
deltaOBL = deltaOBLtmp;
10260
razOBL = razOBLtmp;
10261
planPOG ();
10262
// dispScreen=1;
10263
// clearScreen();
10264
// menuScreen();
10265
}
10266
10267
break
;
10268
10269
case
27:
// ************* Storm Control ******************
10270
10271
// ---------------- increase/decrease values -------------
10272
timGROZtmp = PlusMinusCount (
true
, 200, 88, 1, 10, 1, timGROZtmp);
// storm duration
10273
10274
if
((x>=backGS[0]) && (x<=backGS[2]) && (y>=backGS[1]) && (y<=backGS[3]))
//press back
10275
{ waitForIt(backGS[0], backGS[1], backGS[2], backGS[3]);
10276
dispScreen=25;
10277
clearScreen();
10278
wthScreen (
true
); }
10279
10280
if
((x>=canCgs[0]) && (x<=canCgs[2]) && (y>=canCgs[1]) && (y<=canCgs[3]))
//press CANCEL
10281
{
10282
waitForIt(canCgs[0], canCgs[1], canCgs[2], canCgs[3]);
10283
dispScreen=0;
10284
clearScreen();
10285
mainScreen(
true
); }
10286
10287
if
((x>=prSAVE[0]) && (x<=prSAVE[2]) && (y>=prSAVE[1]) && (y<=prSAVE[3]))
//press SAVE
10288
{ waitForIt(prSAVE[0], prSAVE[1], prSAVE[2], prSAVE[3]);
10289
timGROZ = timGROZtmp;
10290
// SaveLEDsFailsafeToEEPROM();
10291
// dispScreen=1;
10292
// clearScreen();
10293
// menuScreen();
10294
}
10295
10296
if
((StormCtrlONNight[0]) && (StormCtrlONNight[2]) && (StormCtrlONNight[1]) && (StormCtrlONNight[3]))
10297
{ waitForIt(StormCtrlONNight[0], StormCtrlONNight[1], StormCtrlONNight[2], StormCtrlONNight[3]);
//press ON
10298
10299
if
(NightGR==1)
// Storm on/off
10300
{ printButton(print_text[23], StormCtrlONNight[0], StormCtrlONNight[1], StormCtrlONNight[2], StormCtrlONNight[3], SMALL);
//"OFF"
10301
GROZANight=0;
10302
NightGR=0; }
10303
else
{ printButton(print_text[22], StormCtrlONNight[0], StormCtrlONNight[1], StormCtrlONNight[2], StormCtrlONNight[3], SMALL);
//"ON"
10304
GROZANight=1;
10305
NightGR=1; }
10306
}
10307
10308
break
;
10309
10310
case
28:
// ************* Weather test ******************
10311
10312
break
;
10313
}
10314
}
10315
}
10316
/********************************* END of TOUCH SCREEN loop ****************************/
10317
10318
10319
/**************************************** SETUP **************************************/
10320
void
setup
()
10321
{
10322
//wdt_disable();
10323
10324
Serial
.begin(9600);
10325
10326
/* --------timer setting for change frequency--------
10327
Timer 0
10328
13 OC0A
10329
4 OC0B //Caution: this one directly effects major timing {i.e delay and millis} DO NOT CHANGE
10330
Timer 1
10331
11 OC1A
10332
12 OC1B
10333
Timer 2
10334
10 OC2A
10335
9 OC2B
10336
Timer 3
10337
5 OC3A
10338
2 OC3B
10339
3 OC3C
10340
Timer 4
10341
6 OC4A
10342
7 OC4B
10343
8 OC4C
10344
Timer 5
10345
46 OC5A
10346
45 OC5B
10347
44 OC5C
10348
10349
// Timers 0-5 clock for PWM via analogWrite(PIN, Value);
10350
TIMER 0 CLKt=Fosc256 = 62500, Phase Correct PWM Mode
10351
Value Divisor Frequency
10352
0×01 1 62500 hz
10353
0×02 8 7812.5 hz
10354
0×03 64 976.5625 hz // default
10355
0×04 256 244.140625 hz
10356
0×05 1024 61.03515625 hz
10357
Code: TCCR0B = (TCCR0B & 0xF8) | value ;
10358
10359
TIMER 1, 3, 4, 5 CLKt=Fosc/512 = 31250, Phase Correct PWM Mode
10360
Value Divisor Frequency
10361
0×01 1 31250 hz
10362
0×02 8 3906.25 hz
10363
0×03 64 488.28125 hz
10364
0×04 256 122.0703125 hz
10365
0×05 1024 30.517578125 hz
10366
Code: TCCR1B = (TCCR1B & 0xF8) | value ;
10367
Code: TCCR3B = (TCCR3B & 0xF8) | value ;
10368
Code: TCCR4B = (TCCR4B & 0xF8) | value ;
10369
Code: TCCR5B = (TCCR5B & 0xF8) | value ;
10370
10371
TIMER 2 CLKt=Fosc/512 = 31250, Phase Correct PWM Mode
10372
Value Divisor Frequency
10373
0×01 1 31250 hz
10374
0×02 8 3906.25 hz
10375
0×03 32 976.5625 hz
10376
0×04 64 488.28125 hz
10377
0×05 128 244.140625 hz
10378
0×06 256 122.0703125 hz
10379
0×07 1024 30.517578125 hz
10380
Code: TCCR2B = (TCCR2B & 0xF8) | value ;
10381
*/
10382
10383
10384
#ifdef Timers_8bit
10385
TCCR1B = (TCCR1B & 0xF8) | PWM_FRQ_Value;
// pin 12, 13
10386
TCCR2B = (TCCR2B & 0xF8) | PWM_FRQ_ValueT2;
// pin 10
10387
TCCR3B = (TCCR3B & 0xF8) | PWM_FRQ_Value;
// pin 2,3,5
10388
TCCR4B = (TCCR4B & 0xF8) | PWM_FRQ_Value;
// pin 6,7,8
10389
TCCR5B = (TCCR5B & 0xF8) | PWM_FRQ_Value_Fan;
// 30hz pin 44, 45, 46 for FANs
10390
#endif
10391
10392
#ifdef Timers_8_11bit
10393
//**************** 8 and 11 bit timer setting **********************************
10394
10395
#ifdef Standard_shield
10396
TCCR2B = (TCCR2B & 0xF8) | PWM_FRQ_ValueT2;
// pin 10 8bit
10397
TCCR5B = (TCCR5B & 0xF8) | PWM_FRQ_Value_Fan;
// 30hz pin 44, 45, 46 for FANs 8bit
10398
10399
// set 11 bit timer setting
10400
TCCR1A = B00000010;
// mode 14Fast PWM timer 1
10401
TCCR4A = B00000010;
// mode 14Fast PWM timer4
10402
// TCCR1B = B00011010; // clk/8 prescalering
10403
// TCCR4B = B00011010; // clk/8 prescalering
10404
// set timer mode
10405
TCCR4B = B00011000;
10406
TCCR1B = B00011000;
10407
// set prescaler value
10408
TCCR1B = TCCR1B | PWM_FRQ_Value;
// pin 11, 12
10409
TCCR4B = TCCR4B | PWM_FRQ_Value;
// pin 6, 7, 8
10410
10411
OCR1A = 0;
10412
OCR1B = 0;
10413
OCR4B = 0;
10414
OCR4C = 0;
10415
10416
ICR1 = 2005;
10417
ICR4 = 2005;
10418
10419
cbi_mix( PORTB, 5 );
//Timer1, port 11
10420
sbi_mix( DDRB , 5 );
10421
cbi_mix( PORTB, 6 );
//Timer1, port 12
10422
sbi_mix( DDRB , 6 );
//
10423
cbi_mix( PORTH, 4 );
//Timer4, port 7
10424
sbi_mix( DDRH , 4 );
//
10425
cbi_mix( PORTH, 5 );
//Timer4, port 8
10426
sbi_mix( DDRH , 5 );
//
10427
10428
#else // For Aquashield V2 and V3
10429
// 8 bit timer setting
10430
TCCR2B = (TCCR2B & 0xF8) | PWM_FRQ_ValueT2;
// pin 9, 10 8bit
10431
TCCR5B = (TCCR5B & 0xF8) | PWM_FRQ_Value_Fan;
// 30hz pin 44, 45, 46 for FANs 8bit
10432
10433
// 11bit timer setting
10434
// set timer mode 14 - fast PWM
10435
TCCR4A = B00000010;
// mode 14Fast PWM timer4
10436
TCCR3A = B00000010;
// mode 14Fast PWM timer3
10437
TCCR1A = B00000010;
// mode 14Fast PWM timer1
10438
TCCR4B = B00011000;
10439
TCCR3B = B00011000;
10440
TCCR1B = B00011000;
10441
// set prescaler value
10442
TCCR1B = TCCR1B | PWM_FRQ_Value;
// pin 11, 12
10443
TCCR3B = TCCR3B | PWM_FRQ_Value;
// pin 2, 3,
10444
TCCR4B = TCCR4B | PWM_FRQ_Value;
// pin 6,
10445
10446
OCR1A = 0;
10447
OCR1B = 0;
10448
OCR3A = 0;
10449
OCR3B = 0;
10450
OCR3C = 0;
10451
OCR4A = 0;
10452
10453
ICR1 = 2005;
10454
ICR3 = 2005;
10455
ICR4 = 2005;
10456
10457
cbi_mix( PORTB, 5 );
//Timer1, port 11
10458
sbi_mix( DDRB , 5 );
10459
cbi_mix( PORTB, 6 );
//Timer1, port 12
10460
sbi_mix( DDRB , 6 );
//
10461
10462
cbi_mix( PORTE, 3 );
//Timer3, port 5
10463
sbi_mix( DDRE , 3 );
//
10464
cbi_mix( PORTE, 4 );
//Timer3, port 2
10465
sbi_mix( DDRE , 4 );
//
10466
cbi_mix( PORTE, 5 );
//Timer3, port 3
10467
sbi_mix( DDRE , 5 );
//
10468
cbi_mix( PORTH, 3 );
//Timer4, port 6
10469
sbi_mix( DDRH , 3 );
//
10470
#endif
10471
#endif
10472
10473
#ifdef Timers_11bit
10474
//**************** 11 bit timer setting **********************************
10475
10476
TCCR2B = (TCCR2B & 0xF8) | PWM_FRQ_Value_Fan+2 ;
// 30Hz pin 10, 9 8bit
10477
TCCR5B = (TCCR5B & 0xF8) | PWM_FRQ_Value_Fan;
// 30hz pin 44, 45, 46 for FANs 8bit
10478
10479
/* B00011001 - 8khz TCCRXB register, no prescaling
10480
B00011010 - 1khz TCCRXB register, clkI/O/8
10481
B00011011 - 125hz TCCRXB register, clkI/O/64
10482
B00011100 - 31hz TCCRXB register, clkI/O/256
10483
10484
TCCR4A = B00000010;
// mode 14 Fast PWM timer4 WGM41=1, WGM40=0
10485
TCCR4B = B00011010;
// clkI/O/8 WGM43=1, WGM42=1 + CS42..CS40 =10
10486
TCCR3A = B00000010;
// mode 14 Fast PWM timer3
10487
TCCR3B = B00011010;
// clkI/O/8
10488
TCCR1A = B00000010;
// mode 14 Fast PWM timer 1
10489
TCCR1B = B00011010;
// clkI/O/8
10490
*/
10491
// set timer mode 14 - fast PWM
10492
TCCR4A = B00000010;
// mode 14Fast PWM timer4
10493
TCCR3A = B00000010;
// mode 14Fast PWM timer3
10494
TCCR1A = B00000010;
// mode 14Fast PWM timer1
10495
TCCR4B = B00011000;
10496
TCCR3B = B00011000;
10497
TCCR1B = B00011000;
10498
// set prescaler value
10499
TCCR1B = TCCR1B | PWM_FRQ_Value;
// pin 11, 12
10500
TCCR3B = TCCR3B | PWM_FRQ_Value;
// pin 2, 3,
10501
TCCR4B = TCCR4B | PWM_FRQ_Value;
// pin 6, 7, 8
10502
10503
OCR1A = 0;
10504
OCR1B = 0;
10505
OCR3A = 0;
10506
OCR3B = 0;
10507
OCR3C = 0;
10508
OCR4A = 0;
10509
OCR4B = 0;
10510
OCR4C = 0;
10511
10512
ICR1 = 2005;
10513
ICR3 = 2005;
10514
ICR4 = 2005;
10515
10516
cbi_mix( PORTB, 5 );
//Timer1, port 11
10517
sbi_mix( DDRB , 5 );
10518
cbi_mix( PORTB, 6 );
//Timer1, port 12
10519
sbi_mix( DDRB , 6 );
//
10520
cbi_mix( PORTE, 3 );
//Timer3, port 5
10521
sbi_mix( DDRE , 3 );
//
10522
cbi_mix( PORTE, 4 );
//Timer3, port 2
10523
sbi_mix( DDRE , 4 );
//
10524
cbi_mix( PORTE, 5 );
//Timer3, port 3
10525
sbi_mix( DDRE , 5 );
//
10526
cbi_mix( PORTH, 3 );
//Timer4, port 6
10527
sbi_mix( DDRH , 3 );
//
10528
cbi_mix( PORTH, 4 );
//Timer4, port 7
10529
sbi_mix( DDRH , 4 );
//
10530
cbi_mix( PORTH, 5 );
//Timer4, port 8
10531
sbi_mix( DDRH , 5 );
//
10532
#endif
10533
10534
pinMode(ledPinTV, OUTPUT);
10535
pinMode(ledPinRed, OUTPUT);
10536
pinMode(ledPinWhite, OUTPUT);
10537
pinMode(ledPinBlue, OUTPUT);
10538
pinMode(ledPinRoyBlue, OUTPUT);
10539
pinMode(ledPinUV, OUTPUT);
10540
pinMode(ledPinCyan, OUTPUT);
10541
pinMode(ledPinYellow, OUTPUT);
10542
pinMode(ledPinMoon, OUTPUT);
10543
10544
pinMode(Heatsink1_FansPWM, OUTPUT);
10545
pinMode(Heatsink2_FansPWM, OUTPUT);
10546
pinMode(Heatsink3_FansPWM, OUTPUT);
10547
pinMode(PowerSwitch2, OUTPUT);
10548
pinMode(tempHeatPin, OUTPUT);
10549
pinMode(tempChillPin, OUTPUT);
10550
pinMode(tempAlarmPin, OUTPUT);
10551
pinMode(SDchipSelect, OUTPUT);
10552
10553
#ifdef Aqua_shield_v2
10554
pinMode(WirelessSPI_CS, OUTPUT);
10555
pinMode(WirelessW_CE, OUTPUT);
10556
pinMode(WirelessW_IRQ, INPUT);
10557
pinMode(AnalogIN, INPUT);
10558
#endif
10559
10560
#ifdef Aqua_shield_v3
10561
pinMode(WirelessSPI_CS, OUTPUT);
10562
pinMode(WirelessW_CE, OUTPUT);
10563
pinMode(WirelessW_IRQ, INPUT);
10564
pinMode(PowerSwitch3, OUTPUT);
10565
pinMode(Temp_SensorBus1, OUTPUT);
10566
pinMode(BackLite, OUTPUT);
10567
#endif
10568
10569
//digitalWrite(BackLite,HIGH);
10570
analogWrite(BackLite, 255);
10571
10572
10573
ReadDallasAddress ();
10574
sensors.begin();
//start up temperature library
10575
sensors.setResolution(waterThermometer, resolution);
// set the resolution to 11 bit
10576
sensors.setResolution(Heatsink1Thermometer, resolution);
10577
sensors.setResolution(Heatsink2Thermometer, resolution);
10578
sensors.setWaitForConversion(
false
);
10579
sensors.requestTemperatures();
10580
delayInMillis = 750 / (1 << (12 - resolution));
10581
lastTempRequest = millis();
10582
10583
myGLCD.InitLCD(LANDSCAPE);
10584
myGLCD.clrScr();
10585
10586
EraseAllEEPROM_SaveDefault();
// check and erase eeprom for my format, save all default
10587
myGLCD.clrScr();
10588
10589
myTouch.InitTouch(LANDSCAPE);
10590
myTouch.setPrecision(PREC_MEDIUM);
10591
myTouch.read();
//dummy read, enale IRQ
10592
10593
myGLCD.setColor(64, 64, 64);
10594
myGLCD.fillRect(0, 226, 319, 239);
//Bottom Bar
10595
rtc.halt(
false
);
//Set the clock to run-mode
10596
10597
COLOR=0;
// read all colors
10598
ReadLedFromEEPROM();
// read led setting from EEPROM
10599
ReadFromEEPROM();
// read other setting
10600
t = rtc.getTime();
10601
min_cnt= (t.hour*60)+t.min;
10602
10603
calculateStartTime();
// calculate SUNRISE time
10604
calculateStopTime();
// calculate SUNSET time
10605
10606
//--------ON OFF LED Analog Driver ----------
10607
if
((min_cnt/15 >= StartTime-1) && (min_cnt/15 <= StopTime))
10608
{digitalWrite(PowerSwitch2, LOW);}
//ON driver before StartTime - 15min
10609
else
{digitalWrite(PowerSwitch2, HIGH);}
//OFF driver before StartTime
10610
10611
LED_levels_output();
10612
delay(1000);
// wait before first reading temperature data
10613
checkTempC();
10614
mainScreen(
true
);
10615
setScreenSaverTimer = setSSmintues * 12;
// 5sec*12=1 min, convert minutes to 5sec stepping
10616
10617
}
10618
/*********************************** END of SETUP ************************************/
10619
10620
10621
/********************************** BEGIN MAIN LOOP **********************************/
10622
10623
void
loop
()
10624
{
10625
10626
if
((myTouch.dataAvailable()) && (screenSaverCounter>=setScreenSaverTimer))
//exit from screen saver
10627
{
if
(setLockScreen ==1) { analogWrite(BackLite, 255);}
// set normal brightness
10628
Exit_From_ScreenSaver();}
10629
else
10630
{
if
(myTouch.dataAvailable() && (screenSaverCounter < setScreenSaverTimer))
10631
{ processMyTouch();} }
10632
10633
Alarm();
// ON/OFF alarm signal and Fan starup process
10634
10635
unsigned
long
currentMillis = millis();
10636
10637
#ifdef Timers_8bit
10638
10639
#else
10640
//----------check LED levels every 1s for 8/11 & 11 bit version ---------------------------
10641
// unsigned long currentMillis = millis();
10642
if
(currentMillis - previousMillisOne > 1000)
//check LED levels every 1s
10643
{ previousMillisOne = currentMillis;
10644
min_cnt= (t.hour*60)+t.min;
10645
10646
//if (clouDonOff ==1) { weezleLED(); } // Wheater calculation
10647
10648
LED_levels_output();
10649
}
10650
#endif
10651
10652
if
(currentMillis - previousMillisFive > 5000)
//check time, temp and LED levels every 5s
10653
10654
{ previousMillisFive = currentMillis;
10655
10656
checkTempC();
// read current temperature
10657
10658
10659
if
(clouDonOff ==1) { timeStartOBL(); }
// опрос таймера на погоду
10660
10661
10662
if
((screenSaverCounter<setScreenSaverTimer) && (dispScreen == 0))
10663
{ mainScreen(); }
// display MAIN Screen include TimeDateBar()
10664
10665
if
((screenSaverCounter<setScreenSaverTimer) && dispScreen!=9 && dispScreen !=0)
10666
{ TimeDateBar(); }
// display time and data in all windows exept dispScreen=9 and MAIN windows
10667
10668
if
(screenSaverCounter>=setScreenSaverTimer || dispScreen ==9)
// check current time in Screen saver mode or dispScreen=9
10669
{ t = rtc.getTime();
10670
WaterTempCheckFunction();
// ON/OFF chiller, heater and display TEMP value and messages
10671
FanTempCheckFunction();
10672
10673
if
(tempAlarmflagW ==
true
|| tempAlarmflagH1 ==
true
|| tempAlarmflagH2 ==
true
)
// exit from screensaver in case of alarm
10674
{
10675
firstTouch =
false
;
10676
screenSaverCounter=0;
10677
dispScreen=0;
10678
clearScreen();
10679
myGLCD.setColor(64, 64, 64);
10680
myGLCD.fillRect(0, 226, 319, 239);
10681
mainScreen(
true
);
10682
}
10683
}
10684
min_cnt= (t.hour*60)+t.min;
10685
//Serial.print("min_cnt="); Serial.println(min_cnt);
10686
10687
#ifdef Timers_8bit
10688
LED_levels_output();
10689
#endif
10690
10691
//--------------ON OFF LED Analog Driver --------------------------
10692
if
((GlobalStatus2Byte & 0x0F) == 0) {
10693
if
((min_cnt/15 >= StartTime-1) && (min_cnt/15 <= StopTime))
10694
{digitalWrite(PowerSwitch2, LOW);}
//ON driver before StartTime - 15min
10695
else
{digitalWrite(PowerSwitch2, HIGH);}}
//OFF driver before StartTime
10696
10697
// feedingTimeOutput();
10698
10699
//-------------- Off PRESET 45min before the end of light day ------------------------------
10700
if
(((GlobalStatus2Byte & 0x0F) !=0) && (min_cnt/15 == StopTime-3 ))
// !=0 if preset is ON
10701
{GlobalStatus2Byte = (GlobalStatus2Byte & 0xF0);
//clear flags Preset1..Preset4
10702
colorLEDtest =
false
;}
10703
screenReturn();
// return to Main window after preset is OFF or after 2min timeout
10704
screenSaver();
// check screen time and display saver
10705
10706
}
10707
}
10708
10709
/********************************** END OF MAIN LOOP *********************************/
Прилаживаю ссылку на весь архив. http://reefcentral.ru/forum/topic/2016-akva-kontroller-ot-olega/page-36#...
Эта ветка _платных_ испонителей
Код вставлять научитесь, никто вашу простынь читать не будет
Вы правда считаете что у кого-то появиться желание проананлизировать просто так 10 ТЫСЯЧ строк кода?
"Есть код для Ардуино мега 2560 с сенсорным экраном, но он дороговат..."
Цену хоть бы озвучили.
подозреваю под "дороговат" имеется ввиду 2560+сенсорный экран :)
Хмм, спойлера я не нашел... Дороговат - 3 рубля нашими.
Вам надо провести поиск по готовым проектам, которые вас удовлетворят. Либо самостоятельно разбираться. Подкинуть совет, что-то подсказать, ответить на вопрос - это одно дело. А что-то лопатить по вашему тз, да еще имитировать фазы луну - навряд ли кто-то бесплатно загорится желанием. И да, это ветка поиска работы. Любая работа это время и имхо должна быть оплачена так или иначе.
Спасибо всем за ответы. Раз уж можете подсказать, то подсказывайте :)
Вроде бы нашел проект: http://forum.arduino.cc/index.php?topic=63503.0 .
Только не понятно кое-что.
1. Нужен контроллер Ардуино Мега, только какой? 2560? 1280? Там вроде как не указано. В качестве дисплея - ЛСД 20:4 символа. Так же нужны часики.
2. Он приводит полный код, т.е. мне нужно просто купить контроллер, скопировать код и прошить? Или как?
3. Я так понял, контроллер управляет тремя каналами: лунным светом, синим (заменю на теплый белый) и белым, так?
Всем заранее огромное спасибо
Да, еще вопросик. Светодиоды плавно включаются, или сразу на полную мощь (т.е. рассвет-закат присутствует?) СПС