/**
Arduino Electronic Safe
Copyright (C) 2020, Uri Shaked.
Released under the MIT License.
*/
#include <LiquidCrystal.h>
/* Locking mechanism definitions */
#define BUTTONS A7
#define FlowSensor_PIN 3
#define A5_Val A5
#define A4_Val A4
#define A3_Val A3
#define PumpA 10
#define PumpB 6
#define WaterPump 11
#define WaterLevelPin A2
#define NutrientStir A0
#define OzonePump A1
#define LCD_Light 13
int iVoltageA5 = 0;
int iVoltageA4 = 0;
int iVoltageA3 = 0;
//////////////////////
/// BUTTONS & MENU ///
//////////////////////
// B1, B2, B3, B4//
// byte bSet = 0;
// byte bUp = 511;
// byte bDown = 683;
// byte bEnter = 773;
const byte bMainMenu = 7;
const byte bSetMenu = 11;
byte bSec = 1; //set the timer to count in seconds rather than 0.5 sec
byte bWait = 0;
byte bPauseMenu = 0;
byte bPauseEnter = 0;
int A7_VAL = 0; // BUTTON INPUT
int bMenuTimerMax = 300; //250ms
int bMenuTimer = bMenuTimerMax;
int iMenuSelectMin = 1000;
int iMenuSelectMax = 8000;
int iMenuSelect = iMenuSelectMin;
int iMenuSelectStep = iMenuSelectMin;
int iDebounce = 300;
int iDebounceCnt = iDebounce;
//////////////////
// 1Khz Counter //
//////////////////
byte i1Kmax = 2;
byte i1Kcnt = i1Kmax;
/////////////////////////////////
// Nutrient Controller Setting //
/////////////////////////////////
byte bCnt = 0;
int iWaterVolMax = 10;
int iWaterVolSetting[4] = {10, 20, 30, 40};
int iNutrient_to_Water = 4;
int iNutrient_Stir_Timer_Max = 10;
int iOzone_Timer_Max = 30;
String sPumpACalState5ml = "-";
String sPumpACalState25ml = "-";
String sPumpACalState50ml = "-";
String sPumpACalState100ml = "-";
String sPumpACalState200ml = "-";
long iPumpACalibrationTime5ml = 0;
long iPumpACalibrationTime25ml = 0;
long iPumpACalibrationTime50ml = 0;
long iPumpACalibrationTime100ml = 0;
long iPumpACalibrationTime200ml = 0;
String sPumpBCalState5ml = "-";
String sPumpBCalState25ml = "-";
String sPumpBCalState50ml = "-";
String sPumpBCalState100ml = "-";
String sPumpBCalState200ml = "-";
long iPumpBCalibrationTime5ml = 0;
long iPumpBCalibrationTime25ml = 0;
long iPumpBCalibrationTime50ml = 0;
long iPumpBCalibrationTime100ml = 0;
long iPumpBCalibrationTime200ml = 0;
String sFlowCalState1ltr = "-";
String sFlowCalState5ltr = "-";
String sFlowCalState10ltr = "-";
String sFlowCalState20ltr = "-";
String sFlowCalState40ltr = "-";
long iFlowCalibrationCnt1ltr = 0;
long iFlowCalibrationCnt5ltr = 0;
long iFlowCalibrationCnt10ltr = 0;
long iFlowCalibrationCnt20ltr = 0;
long iFlowCalibrationCnt40ltr = 0;
byte bWaterPump = 0;
byte bOff = 0;
byte bOn = 1;
byte bStandby = 3;
byte bActive = 3;
byte bPumpA = bOff;
byte bPumpB = bOff;
long FlowSensorCnt = 0;
byte WaterLevelTimerMax = 1; //Seconds
byte WaterLevelTimer = WaterLevelTimerMax;
byte bWaterLevelState = 0;
byte bFull = 1;
byte bEmpty = 0;
byte bFilling = 3;
byte bWaterReservourState = bFull;
double dWaterVolume = 0;
double dWaterFlowRate = 0;
int iFillTimer = 0;
byte bNutrientStirMotor = bOff;
int iNutrient_Stir_Timer = 0;
byte bOzonePump = bOff;
int iOzone_Timer = 0;
int iNutrientPumpTime = 0;
byte bNutrientDoseA = bOff;
byte bNutrientDoseB = bOff;
////////////////////
// LCD Back Light //
////////////////////
byte bLCD_Backlight_State = bOn;
byte bLCD_Light_Timer_Max = 12;
byte bLCD_Light_Timer = bLCD_Light_Timer_Max;
///////////////
// pH Sensor //
///////////////
byte bpHDisplayUpdate = 1;
int iPrevMenuSelect = 0;
int iBasePumpTimerCnt = 0;
int iBasePumpTimer = 3;
int iAcidPumpTimerCnt = 0;
int iAcidPumpTimer = 3;
byte bBasePumpPower = 200;
byte bAcidPumpPower = 200;
byte bBasePumpState = 3;
byte bAcidPumpState = 3;
int iPumpWaitTimerMax = 60; //Wait 60 minutes before enabling the base pump
int iBasePumpWaitTimer = iPumpWaitTimerMax * 60;
int iAcidPumpWaitTimer = iPumpWaitTimerMax * 60;
int iPrevMenu = 0;
byte bPumpMenuCnt = 200;
/* Display */
const int rs = 12, en = 8, d4 = 7, d5 = 4, d6 = 9, d7 = 5;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
attachInterrupt(digitalPinToInterrupt(FlowSensor_PIN), FlowSensorDetect, FALLING);
//LCD
lcd.begin(16, 2);
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("* Hydroponics *");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("* Menu System *");
pinMode(PumpA, OUTPUT);
pinMode(PumpB, OUTPUT);
pinMode(WaterPump, OUTPUT);
pinMode(NutrientStir, OUTPUT);
pinMode(OzonePump, OUTPUT);
pinMode(LCD_Light, OUTPUT);
cli();//stop interrupts
//set timer0 interrupt at 2kHz
TCCR0A = 0;// set entire TCCR0A register to 0
TCCR0B = 0;// same for TCCR0B
TCNT0 = 0;//initialize counter value to 0
// set compare match register for 2khz increments
OCR0A = 124;// = (16*10^6) / (2000*64) - 1 (must be <256)
// turn on CTC mode
TCCR0A |= (1 << WGM01);
// Set CS01 and CS00 bits for 64 prescaler
TCCR0B |= (1 << CS01) | (1 << CS00);
// enable timer compare interrupt
TIMSK0 |= (1 << OCIE0A);
//set timer1 interrupt at 1Hz
TCCR1A = 0;// set entire TCCR1A register to 0
TCCR1B = 0;// same for TCCR1B
TCNT1 = 0;//initialize counter value to 0
// set compare match register for 1hz increments
OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536)
// turn on CTC mode
TCCR1B |= (1 << WGM12);
// Set CS12 and CS10 bits for 1024 prescaler
TCCR1B |= (1 << CS12) | (1 << CS10);
// enable timer compare interrupt
TIMSK1 |= (1 << OCIE1A);
//set timer2 interrupt at 8kHz
// TCCR2A = 0;// set entire TCCR2A register to 0
// TCCR2B = 0;// same for TCCR2B
// TCNT2 = 0;//initialize counter value to 0
// // set compare match register for 8khz increments
// OCR2A = 249;// = (16*10^6) / (8000*8) - 1 (must be <256)
// // turn on CTC mode
// TCCR2A |= (1 << WGM21);
// // Set CS21 bit for 8 prescaler
// TCCR2B |= (1 << CS21);
// // enable timer compare interrupt
// TIMSK2 |= (1 << OCIE2A);
sei();//allow interrupts
}
void loop() {
if (bMenuTimer==0) {
pMenu();
}
if ((bLCD_Backlight_State == bOn) && (bLCD_Light_Timer > 0)) {
bLCD_Backlight_State = bStandby;
digitalWrite(LCD_Light, HIGH);
}
if ((bLCD_Backlight_State == bStandby) && (bLCD_Light_Timer == 0)) {
bLCD_Backlight_State = bOff;
digitalWrite(LCD_Light, LOW);
}
if (bPumpA==bOn) {
digitalWrite(PumpA, HIGH); //ON
bPumpA = bStandby;
}
if (bPumpA==bOff) {
digitalWrite(PumpA, LOW); //OFF
bPumpA = bStandby;
}
if (bPumpB==bOn) {
digitalWrite(PumpB, HIGH); //ON
bPumpB = bStandby;
}
if (bPumpB==bOff) {
digitalWrite(PumpB, LOW); //OFF
bPumpB = bStandby;
}
if (bWaterPump==bOff) {
digitalWrite(WaterPump, LOW); //OFF
bWaterPump = bStandby;
}
if (bWaterPump==bOn) {
digitalWrite(WaterPump, HIGH); //ON
bWaterPump = bStandby;
}
if (WaterLevelTimer==0) {
WaterLevelTimer = WaterLevelTimerMax;
bWaterLevelState = analogRead(WaterLevelPin);
}
if ((bWaterLevelState > 200) && (bWaterReservourState == bFull)) {
bWaterPump=bOn;
bNutrientStirMotor = bOn;
dWaterVolume = 0;
dWaterFlowRate = 0;
FlowSensorCnt = 0;
iMenuSelect = 0;
bWaterReservourState = bFilling;
}
else if ((bWaterReservourState == bFilling) && (dWaterVolume <= iWaterVolMax)) {
pWaterReservourFill();
}
else if ((bWaterReservourState == bFilling) && (dWaterVolume >= iWaterVolMax)) {
bWaterPump=bOff;
iMenuSelect = 1000;
bWaterReservourState = bFull;
bOzonePump = bOn;
}
if (bNutrientStirMotor == bOn) {
iNutrient_Stir_Timer = 0;
digitalWrite(NutrientStir, HIGH); //ON
bNutrientStirMotor = bActive;
}
else if ((bNutrientStirMotor == bActive) && (iNutrient_Stir_Timer >= iNutrient_Stir_Timer_Max)) {
digitalWrite(NutrientStir, LOW); //OFF
bNutrientStirMotor = bOff;
bNutrientDoseA = bOn;
}
if (bOzonePump == bOn) {
iOzone_Timer = 0;
digitalWrite(OzonePump, HIGH); //ON
bOzonePump = bActive;
}
else if ((bOzonePump == bActive) && (iOzone_Timer >= iOzone_Timer_Max)) {
digitalWrite(OzonePump, LOW); //OFF
bOzonePump = bOff;
}
if (bNutrientDoseA == bOn) {
bPumpA = bOn;
bNutrientDoseA = bActive;
iNutrientPumpTime = 0;
}
if ((bNutrientDoseA == bActive) && (iNutrientPumpTime >= iPumpACalibrationTime50ml)) {
bPumpA = bOff;
bNutrientDoseA = bOff;
bNutrientDoseB = bOn;
}
if (bNutrientDoseB == bOn) {
bPumpB = bOn;
bNutrientDoseB = bActive;
iNutrientPumpTime = 0;
}
if ((bNutrientDoseB == bActive) && (iNutrientPumpTime >= iPumpBCalibrationTime50ml)) {
bPumpB = bOff;
bNutrientDoseB = bOff;
}
}
void pWaterReservourFill() {
dWaterVolume = dWaterVolume + FlowSensorCnt * 0.0005;
dWaterFlowRate = dWaterVolume / (iFillTimer);
lcd.setCursor ( 0, 0 );
lcd.print("Filling:"+String(dWaterVolume)+" ");
lcd.setCursor ( 0, 1 );
lcd.print("Flow Rate:"+String(FlowSensorCnt * 0.5)+" ");
}
void pMenu(){
bMenuTimer = bMenuTimerMax;
//A7_VAL = analogRead(BUTTONS);
iVoltageA5 = analogRead(A5_Val);
iVoltageA4 = analogRead(A4_Val);
iVoltageA3 = analogRead(A3_Val);
A7_VAL = 1024;
if (iVoltageA5 == 0) {
A7_VAL = 683;
}
if (iVoltageA4 == 0) {
A7_VAL = 511;
}
if (iVoltageA3 == 0) {
A7_VAL = 10;
}
//Serial.println(A7_VAL);
// byte bUp = 511;
// byte bDown = 683;
// byte bEnter = 773;
if (A7_VAL < 1000) {
bLCD_Backlight_State = bOn;
bLCD_Light_Timer = bLCD_Light_Timer_Max;
}
//MENU NAVIGATION
if ((A7_VAL > 500) && (A7_VAL < 550) && (iMenuSelect < iMenuSelectMax) && (bPauseMenu == 0 && iDebounceCnt == 0)) { //DOWN
iMenuSelect = iMenuSelect + iMenuSelectStep;
//Serial.println("Menu Select:"+String(iMenuSelect)+", MenuStep:"+String(iMenuSelectStep) );
iDebounceCnt = iDebounce;
}
else if ((A7_VAL > 630) && (A7_VAL < 730) && (iMenuSelect > iMenuSelectMin) && bPauseMenu == 0 && iDebounceCnt == 0) { //UP
iMenuSelect = iMenuSelect - iMenuSelectStep;
//Serial.println("Menu Select:"+String(iMenuSelect)+", MenuStep:"+String(iMenuSelectStep) );
iDebounceCnt = iDebounce;
}
else if ((A7_VAL >= 0) && (A7_VAL < 50) && (bPauseEnter == 0) && bPauseMenu == 0 && iDebounceCnt == 0) { //ENTER
iMenuSelectStep = iMenuSelectStep / 10;
iMenuSelect = iMenuSelect + iMenuSelectStep;
//Serial.println("Menu Select:"+String(iMenuSelect)+", MenuStep:"+String(iMenuSelectStep) );
iDebounceCnt = iDebounce;
}
//Serial.println("Menu Select:"+String(iMenuSelect)+", MenuStep:"+String(iMenuSelectStep)+", PauseMenu:"+String(bPauseMenu) );
if (iMenuSelect == 1000) {
pMainMenu1000();
}
if ((iMenuSelect == 2000) && (bpHDisplayUpdate==0)) { //Display Current pH
pMainMenu2000();
}
if (iMenuSelect == 2100) {
pMainMenu2100();
//Serial.println("Menu Select:"+String(iMenuSelect)+", MenuStep:"+String(iMenuSelectStep) );
}
if (iMenuSelect == 2110) {
//pMainMenu2110();
//Serial.println("Menu Select:"+String(iMenuSelect)+", MenuStep:"+String(iMenuSelectStep) );
}
if (iMenuSelect == 3000) {
pMainMenu3000();
}
if (iMenuSelect == 3100) {
pMainMenu3100();
}
if (iMenuSelect == 4000) { // Base Pump
pMainMenu4000();
}
if (iMenuSelect == 4100) { // Base Pump
pMainMenu4100();
}
if (iMenuSelect == 5000) { //Acid Pump
pMainMenu5000();
}
if (iMenuSelect == 5100) { //Acid Pump
pMainMenu5100();
}
if (iMenuSelect == 6000) { //Prime Base Line
pMainMenu6000();
}
if (iMenuSelect == 6100) { //Prime Base Line
pMainMenu6100();
}
if (iMenuSelect == 6110) { //Prime Base Line
pMainMenu6110();
}
if (iMenuSelect == 6111) { //Prime Base Line
pMainMenu6111();
}
if (iMenuSelect == 6200) { //Prime Base Line
pMainMenu6200();
}
if (iMenuSelect == 6210) { //Prime Base Line
pMainMenu6210();
}
if (iMenuSelect == 6211) { //Prime Base Line
pMainMenu6211();
}
if (iMenuSelect == 6300) { //Prime Base Line
pMainMenu6300();
}
if (iMenuSelect == 6310) { //Prime Base Line
pMainMenu6310();
}
if (iMenuSelect == 6311) { //Prime Base Line
pMainMenu6311();
}
if (iMenuSelect == 6400) { //Prime Base Line
pMainMenu6400();
}
if (iMenuSelect == 6410) { //Prime Base Line
pMainMenu6410();
}
if (iMenuSelect == 6411) { //Prime Base Line
pMainMenu6411();
}
if (iMenuSelect == 6500) { //Prime Base Line
pMainMenu6500();
}
if (iMenuSelect == 6510) { //Prime Base Line
pMainMenu6510();
}
if (iMenuSelect == 6511) { //Prime Base Line
pMainMenu6511();
}
if (iMenuSelect == 6600) { //Prime Base Line
pMainMenu6600();
}
if (iMenuSelect == 6610) { //Prime Base Line
pMainMenu6610();
}
if (iMenuSelect == 6611) { //Prime Base Line
pMainMenu6611();
}
if (iMenuSelect == 6700) { //Prime Base Line
pMainMenu6700();
}
if (iMenuSelect == 6710) { //Prime Base Line
pMainMenu6710();
}
if (iMenuSelect == 7000) { //Prime Base Line
pMainMenu7000();
}
if (iMenuSelect == 7100) { //Prime Base Line
pMainMenu7100();
}
if (iMenuSelect == 7110) { //Prime Base Line
pMainMenu7110();
}
if (iMenuSelect == 7111) { //Prime Base Line
pMainMenu7111();
}
if (iMenuSelect == 7200) { //Prime Base Line
pMainMenu7200();
}
if (iMenuSelect == 7210) { //Prime Base Line
pMainMenu7210();
}
if (iMenuSelect == 7211) { //Prime Base Line
pMainMenu7211();
}
if (iMenuSelect == 7300) { //Prime Base Line
pMainMenu7300();
}
if (iMenuSelect == 7310) { //Prime Base Line
pMainMenu7310();
}
if (iMenuSelect == 7311) { //Prime Base Line
pMainMenu7311();
}
if (iMenuSelect == 7400) { //Prime Base Line
pMainMenu7400();
}
if (iMenuSelect == 7410) { //Prime Base Line
pMainMenu7410();
}
if (iMenuSelect == 7411) { //Prime Base Line
pMainMenu7411();
}
if (iMenuSelect == 7500) { //Prime Base Line
pMainMenu7500();
}
if (iMenuSelect == 7510) { //Prime Base Line
pMainMenu7510();
}
if (iMenuSelect == 7511) { //Prime Base Line
pMainMenu7511();
}
if (iMenuSelect == 7600) { //Prime Base Line
pMainMenu7600();
}
if (iMenuSelect == 7610) { //Prime Base Line
pMainMenu7610();
}
if (iMenuSelect == 7611) { //Prime Base Line
pMainMenu7611();
}
if (iMenuSelect == 7700) { //Prime Base Line
pMainMenu7700();
}
if (iMenuSelect == 7710) { //Prime Base Line
pMainMenu7710();
}
if (iMenuSelect == 8000) { //Prime Base Line
pMainMenu8000();
}
if (iMenuSelect == 8100) { //Prime Base Line
pMainMenu8100();
}
if (iMenuSelect == 8110) { //Prime Base Line
pMainMenu8110();
}
if (iMenuSelect == 8111) { //Prime Base Line
pMainMenu8111();
}
if (iMenuSelect == 8200) { //Prime Base Line
pMainMenu8200();
}
if (iMenuSelect == 8210) { //Prime Base Line
pMainMenu8210();
}
if (iMenuSelect == 8211) { //Prime Base Line
pMainMenu8211();
}
if (iMenuSelect == 8300) { //Prime Base Line
pMainMenu8300();
}
if (iMenuSelect == 8310) { //Prime Base Line
pMainMenu8310();
}
if (iMenuSelect == 8311) { //Prime Base Line
pMainMenu8311();
}
if (iMenuSelect == 8400) { //Prime Base Line
pMainMenu8400();
}
if (iMenuSelect == 8410) { //Prime Base Line
pMainMenu8410();
}
if (iMenuSelect == 8411) { //Prime Base Line
pMainMenu8411();
}
if (iMenuSelect == 8500) { //Prime Base Line
pMainMenu8500();
}
if (iMenuSelect == 8510) { //Prime Base Line
pMainMenu8510();
}
if (iMenuSelect == 8511) { //Prime Base Line
pMainMenu8511();
}
if (iMenuSelect == 8600) { //Prime Base Line
pMainMenu8600();
}
if (iMenuSelect == 8610) { //Prime Base Line
pMainMenu8610();
}
if (iMenuSelect == 8611) { //Prime Base Line
pMainMenu8611();
}
if (iMenuSelect == 8700) { //Prime Base Line
pMainMenu8700();
}
if (iMenuSelect == 8710) { //Prime Base Line
pMainMenu8710();
}
iPrevMenuSelect = iMenuSelect;
}
void pMainMenu1000() {
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Water Vol:"+String(iWaterVolMax)+" "+String(bWaterLevelState));
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Nutr Ratio:"+String(iNutrient_to_Water)+" ");
lcd.setCursor ( 12, 1 ); // go to the next line
lcd.print("ml/l");
bpHDisplayUpdate = 1;
//Serial.println("Current PH:"+String(dCurrentpH));
iMenuSelectStep = 1000;
}
void pMainMenu1100() {
iMenuSelect = 1000;
iMenuSelectStep = 1000;
}
void pMainMenu2000() { // Set pH Limits
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Water Vol Limit ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Vol:"+String(iWaterVolMax)+" ");
}
void pMainMenu2100() { // Set pH Limits
if (bPauseMenu == 0) {
bPauseMenu = 1;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Set Water Qty: ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(String(iWaterVolMax)+" ");
}
else {
if ((A7_VAL > 500) && (A7_VAL < 550)) { //UP
if (bCnt > 0) {
bCnt--;
iWaterVolMax = iWaterVolSetting[bCnt];
}
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(String(iWaterVolMax)+" ");
//Serial.println("Menu Select:"+String(iMenuSelect)+", MenuStep:"+String(iMenuSelectStep) );
}
else if ((A7_VAL > 630) && (A7_VAL < 730)) { //DOWN
if (bCnt < 3) {
bCnt++;
iWaterVolMax = iWaterVolSetting[bCnt];
}
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(String(iWaterVolMax)+" ");
//Serial.println("Menu Select:"+String(iMenuSelect)+", MenuStep:"+String(iMenuSelectStep) );
}
else if ((A7_VAL >= 0) && (A7_VAL < 50)) { //ENTER
iMenuSelectStep = 1000;
iMenuSelect = 2000;
iMenuSelectMin = 1000;
iMenuSelectMax = 8000;
bPauseMenu = 0;
//Serial.println("Menu Select:"+String(iMenuSelect)+", MenuStep:"+String(iMenuSelectStep)+", PauseMenu:"+String(bPauseMenu) );
}
}
}
void pMainMenu3000() { // Set pH Limits
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Nutrient Ratio ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(String(iNutrient_to_Water)+" ml/l ");
}
void pMainMenu3100() { // Set pH Limits
if (bPauseMenu == 0) {
bPauseMenu = 1;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Set Nutrient R: ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(String(iNutrient_to_Water)+" ");
}
else {
if ((A7_VAL > 500) && (A7_VAL < 550)) { //UP
if (iNutrient_to_Water>0){
iNutrient_to_Water = iNutrient_to_Water - 1;
}
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(String(iNutrient_to_Water)+" ");
//Serial.println("Menu Select:"+String(iMenuSelect)+", MenuStep:"+String(iMenuSelectStep) );
}
else if ((A7_VAL > 630) && (A7_VAL < 730)) { //DOWN
iNutrient_to_Water = iNutrient_to_Water + 1;
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(String(iNutrient_to_Water)+" ");
//Serial.println("Menu Select:"+String(iMenuSelect)+", MenuStep:"+String(iMenuSelectStep) );
}
else if ((A7_VAL >= 0) && (A7_VAL < 50)) { //ENTER
iMenuSelectStep = 1000;
iMenuSelect = 3000;
iMenuSelectMin = 1000;
iMenuSelectMax = 8000;
bPauseMenu = 0;
//Serial.println("Menu Select:"+String(iMenuSelect)+", MenuStep:"+String(iMenuSelectStep)+", PauseMenu:"+String(bPauseMenu) );
}
}
}
void pMainMenu4000() {
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Nutr Stir Timer ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(String(iNutrient_Stir_Timer_Max)+" Seconds ");
}
void pMainMenu4100() { //
if (bPauseMenu == 0) {
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Set Stir Timer: ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(iNutrient_Stir_Timer_Max);
bPauseMenu = 1;
}
else if ((A7_VAL > 500) && (A7_VAL < 550)) { //UP
if (iNutrient_Stir_Timer_Max > 0) {
iNutrient_Stir_Timer_Max = iNutrient_Stir_Timer_Max - 1;
}
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(iNutrient_Stir_Timer_Max);
}
else if ((A7_VAL > 630) && (A7_VAL < 730)) { //DOWN
if (iNutrient_Stir_Timer_Max < 1000) {
iNutrient_Stir_Timer_Max = iNutrient_Stir_Timer_Max + 1;
}
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(iNutrient_Stir_Timer_Max);
}
else if ((A7_VAL >= 0) && (A7_VAL < 50)) { //ENTER
iMenuSelectStep = 1000;
iMenuSelect = 4000;
iMenuSelectMin = 1000;
iMenuSelectMax = 8000;
bPauseMenu = 0;
}
}
void pMainMenu5000() {
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Ozone Pump Timer");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(String(iOzone_Timer_Max)+" minutes ");
}
void pMainMenu5100() { //
if (bPauseMenu == 0) {
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Ozone Timer: ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(iOzone_Timer_Max);
bPauseMenu = 1;
}
else if ((A7_VAL > 500) && (A7_VAL < 550)) { //UP
if (iOzone_Timer_Max > 0) {
iOzone_Timer_Max = iOzone_Timer_Max - 1;
}
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(iOzone_Timer_Max);
}
else if ((A7_VAL > 630) && (A7_VAL < 730)) { //DOWN
if (iOzone_Timer_Max < 60) {
iOzone_Timer_Max = iOzone_Timer_Max + 1;
}
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print(iOzone_Timer_Max);
}
else if ((A7_VAL >= 0) && (A7_VAL < 50)) { //ENTER
iMenuSelectStep = 1000;
iMenuSelect = 5000;
iMenuSelectMin = 1000;
iMenuSelectMax = 8000;
bPauseMenu = 0;
}
}
void pMainMenu6000() {
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Calibrate Pump A");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("5,25,50,100,200");
}
void pMainMenu6100() { //
iMenuSelectMin = 6100;
iMenuSelectMax = 6700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("5ml "+sPumpACalState5ml+" "+String(iPumpACalibrationTime5ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu6110() { //
iMenuSelectMin = 6110;
iMenuSelectMax = 6110;
if (sPumpBCalState5ml == "*") {
iPumpBCalibrationTime5ml = 0;
sPumpBCalState5ml = "-";
}
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("5ml - "+String(iPumpACalibrationTime5ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bPumpA = 1; //ON
iMenuSelect = 6110;
iMenuSelectStep = 10;
}
void pMainMenu6111() { //
iMenuSelectMin = 6111;
iMenuSelectMax = 6111;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("5ml ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sPumpACalState5ml = "*";
bPumpA = 0; //OFF
iMenuSelect = 6100;
iMenuSelectStep = 100;
}
void pMainMenu6200() { //
iMenuSelectMin = 6100;
iMenuSelectMax = 6700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("25ml "+sPumpACalState25ml+" "+String(iPumpACalibrationTime25ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu6210() { //
iMenuSelectMin = 6210;
iMenuSelectMax = 6210;
if (sPumpACalState25ml == "*") {
iPumpACalibrationTime25ml = 0;
sPumpACalState25ml = "-";
}
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("25ml - "+String(iPumpACalibrationTime25ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bPumpA = 1; //ON
iMenuSelect = 6210;
iMenuSelectStep = 10;
}
void pMainMenu6211() { //
iMenuSelectMin = 6211;
iMenuSelectMax = 6211;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("25ml ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sPumpACalState25ml = "*";
bPumpA = 0; //OFF
iMenuSelect = 6200;
iMenuSelectStep = 100;
}
void pMainMenu6300() { //
iMenuSelectMin = 6100;
iMenuSelectMax = 6700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("50ml "+sPumpACalState50ml+" "+String(iPumpACalibrationTime50ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu6310() { //
iMenuSelectMin = 6310;
iMenuSelectMax = 6310;
if (sPumpACalState50ml == "*") {
iPumpACalibrationTime50ml = 0;
sPumpACalState50ml = "-";
}
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("50ml - "+String(iPumpACalibrationTime50ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bPumpA = 1; //ON
iMenuSelect = 6310;
iMenuSelectStep = 10;
}
void pMainMenu6311() { //
iMenuSelectMin = 6311;
iMenuSelectMax = 6311;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("50ml ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sPumpACalState50ml = "*";
bPumpA = 0; //OFF
iMenuSelect = 6300;
iMenuSelectStep = 100;
}
void pMainMenu6400() { //
iMenuSelectMin = 6100;
iMenuSelectMax = 6700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("100ml "+sPumpACalState100ml+" "+String(iPumpACalibrationTime100ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu6410() { //
iMenuSelectMin = 6410;
iMenuSelectMax = 6410;
if (sPumpACalState100ml == "*") {
iPumpACalibrationTime100ml = 0;
sPumpACalState100ml = "-";
}
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("100ml - "+String(iPumpACalibrationTime100ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bPumpA = 1; //ON
iMenuSelect = 6410;
iMenuSelectStep = 10;
}
void pMainMenu6411() { //
iMenuSelectMin = 6411;
iMenuSelectMax = 6411;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("100ml ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sPumpACalState100ml = "*";
bPumpA = 0; //OFF
iMenuSelect = 6400;
iMenuSelectStep = 100;
}
void pMainMenu6500() { //
iMenuSelectMin = 6100;
iMenuSelectMax = 6700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("200ml "+sPumpACalState200ml+" "+String(iPumpACalibrationTime200ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu6510() { //
iMenuSelectMin = 6510;
iMenuSelectMax = 6510;
if (sPumpACalState200ml == "*") {
iPumpACalibrationTime200ml = 0;
sPumpACalState200ml = "-";
}
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("200ml - "+String(iPumpACalibrationTime200ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bPumpA = 1; //ON
iMenuSelect = 6510;
iMenuSelectStep = 10;
}
void pMainMenu6511() { //
iMenuSelectMin = 6511;
iMenuSelectMax = 6511;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("200ml ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sPumpACalState200ml = "*";
bPumpA = 0; //OFF
iMenuSelect = 6500;
iMenuSelectStep = 100;
}
void pMainMenu6600() { //
iMenuSelectMin = 6100;
iMenuSelectMax = 6700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Calibrate Now ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Press Enter ");
}
void pMainMenu6610() { //
iMenuSelectMin = 6610;
iMenuSelectMax = 6610;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Calibration Done");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Exit ");
}
void pMainMenu6611() { //
iMenuSelect = 6600;
iMenuSelectStep = 100;
}
void pMainMenu6700() { //
iMenuSelectMin = 6100;
iMenuSelectMax = 6700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Return To Main ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Exit ");
}
void pMainMenu6710() {
iMenuSelect = 6000;
iMenuSelectStep = 1000;
iMenuSelectMin = 1000;
iMenuSelectMax = 8000;
}
void pMainMenu7000() {
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Calibrate Pump B");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("5,25,50,100,200");
}
void pMainMenu7100() { //
iMenuSelectMin = 7100;
iMenuSelectMax = 7700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("5ml "+sPumpBCalState5ml+" "+String(iPumpBCalibrationTime5ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu7110() { //
iMenuSelectMin = 7110;
iMenuSelectMax = 7110;
if (sPumpBCalState5ml == "*") {
iPumpBCalibrationTime5ml = 0;
sPumpBCalState5ml = "-";
}
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("5ml - "+String(iPumpBCalibrationTime5ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bPumpB = 1; //ON
iMenuSelect = 7110;
iMenuSelectStep = 10;
}
void pMainMenu7111() { //
iMenuSelectMin = 7111;
iMenuSelectMax = 7111;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("5ml ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sPumpBCalState5ml = "*";
bPumpB = 0; //OFF
iMenuSelect = 7100;
iMenuSelectStep = 100;
}
void pMainMenu7200() { //
iMenuSelectMin = 7100;
iMenuSelectMax = 7700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("25ml "+sPumpBCalState25ml+" "+String(iPumpBCalibrationTime25ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu7210() { //
iMenuSelectMin = 7210;
iMenuSelectMax = 7210;
if (sPumpBCalState25ml == "*") {
iPumpBCalibrationTime25ml = 0;
sPumpBCalState25ml = "-";
}
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("25ml - "+String(iPumpBCalibrationTime25ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bPumpB = 1; //ON
iMenuSelect = 7210;
iMenuSelectStep = 10;
}
void pMainMenu7211() { //
iMenuSelectMin = 7211;
iMenuSelectMax = 7211;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("25ml ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sPumpBCalState25ml = "*";
bPumpB = 0; //OFF
iMenuSelect = 7200;
iMenuSelectStep = 100;
}
void pMainMenu7300() { //
iMenuSelectMin = 7100;
iMenuSelectMax = 7700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("50ml "+sPumpBCalState50ml+" "+String(iPumpBCalibrationTime50ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu7310() { //
iMenuSelectMin = 7310;
iMenuSelectMax = 7310;
if (sPumpBCalState50ml == "*") {
iPumpBCalibrationTime50ml = 0;
sPumpBCalState50ml = "-";
}
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("50ml - "+String(iPumpBCalibrationTime50ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bPumpB = 1; //ON
iMenuSelect = 7310;
iMenuSelectStep = 10;
}
void pMainMenu7311() { //
iMenuSelectMin = 7311;
iMenuSelectMax = 7311;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("50ml ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sPumpBCalState50ml = "*";
bPumpB = 0; //OFF
iMenuSelect = 7300;
iMenuSelectStep = 100;
}
void pMainMenu7400() { //
iMenuSelectMin = 7100;
iMenuSelectMax = 7700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("100ml "+sPumpBCalState100ml+" "+String(iPumpBCalibrationTime100ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu7410() { //
iMenuSelectMin = 7410;
iMenuSelectMax = 7410;
if (sPumpBCalState100ml == "*") {
iPumpBCalibrationTime100ml = 0;
sPumpBCalState100ml = "-";
}
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("100ml - "+String(iPumpBCalibrationTime100ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bPumpB = 1; //ON
iMenuSelect = 7410;
iMenuSelectStep = 10;
}
void pMainMenu7411() { //
iMenuSelectMin = 7411;
iMenuSelectMax = 7411;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("100ml ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sPumpBCalState100ml = "*";
bPumpB = 0; //OFF
iMenuSelect = 7400;
iMenuSelectStep = 100;
}
void pMainMenu7500() { //
iMenuSelectMin = 7100;
iMenuSelectMax = 7700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("200ml "+sPumpBCalState200ml+" "+String(iPumpBCalibrationTime200ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu7510() { //
iMenuSelectMin = 7510;
iMenuSelectMax = 7510;
if (sPumpBCalState200ml == "*") {
iPumpBCalibrationTime200ml = 0;
sPumpBCalState200ml = "-";
}
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("200ml - "+String(iPumpBCalibrationTime200ml)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bPumpB = 1; //ON
iMenuSelect = 7510;
iMenuSelectStep = 10;
}
void pMainMenu7511() { //
iMenuSelectMin = 7511;
iMenuSelectMax = 7511;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("200ml ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sPumpBCalState200ml = "*";
bPumpB = 0; //OFF
iMenuSelect = 7500;
iMenuSelectStep = 100;
}
void pMainMenu7600() { //
iMenuSelectMin = 7100;
iMenuSelectMax = 7700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Calibrate Now ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Press Enter ");
}
void pMainMenu7610() { //
iMenuSelectMin = 7610;
iMenuSelectMax = 7610;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Calibration Done");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Exit ");
}
void pMainMenu7611() { //
iMenuSelect = 7600;
iMenuSelectStep = 100;
}
void pMainMenu7700() { //
iMenuSelectMin = 7100;
iMenuSelectMax = 7700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Return To Main ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Exit ");
}
void pMainMenu7710() {
iMenuSelect = 7000;
iMenuSelectStep = 1000;
iMenuSelectMin = 1000;
iMenuSelectMax = 8000;
}
void pMainMenu8000() {
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Calibrate Flow S");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("1,5,10,20,40 ");
}
void pMainMenu8100() { //
iMenuSelectMin = 8100;
iMenuSelectMax = 8700;
FlowSensorCnt = 0;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("1ltr "+sFlowCalState1ltr+" "+String(iFlowCalibrationCnt1ltr)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu8110() { //
iMenuSelectMin = 8110;
iMenuSelectMax = 8110;
if (sFlowCalState1ltr == "*") {
iFlowCalibrationCnt1ltr = 0;
sFlowCalState1ltr = "-";
}
iFlowCalibrationCnt1ltr = FlowSensorCnt;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("1ltr - "+String(iFlowCalibrationCnt1ltr)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bWaterPump = 1; //ON
iMenuSelect = 8110;
iMenuSelectStep = 10;
}
void pMainMenu8111() { //
iMenuSelectMin = 8111;
iMenuSelectMax = 8111;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("1ltr ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sFlowCalState1ltr = "*";
bWaterPump = 0; //OFF
iMenuSelect = 8100;
iMenuSelectStep = 100;
}
void pMainMenu8200() { //
iMenuSelectMin = 8100;
iMenuSelectMax = 8700;
FlowSensorCnt = 0;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("5ltr "+sFlowCalState5ltr+" "+String(iFlowCalibrationCnt5ltr)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu8210() { //
iMenuSelectMin = 8210;
iMenuSelectMax = 8210;
if (sFlowCalState5ltr == "*") {
iFlowCalibrationCnt5ltr = 0;
sFlowCalState5ltr = "-";
}
iFlowCalibrationCnt5ltr = FlowSensorCnt;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("5ltr - "+String(iFlowCalibrationCnt5ltr)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bWaterPump = bOn; //ON
iMenuSelect = 8210;
iMenuSelectStep = 10;
}
void pMainMenu8211() { //
iMenuSelectMin = 8211;
iMenuSelectMax = 8211;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("5ltr ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sFlowCalState5ltr = "*";
bWaterPump = bOff; //OFF
iMenuSelect = 8200;
iMenuSelectStep = 100;
}
void pMainMenu8300() { //
iMenuSelectMin = 8100;
iMenuSelectMax = 8700;
FlowSensorCnt = 0;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("10ltr "+sFlowCalState10ltr+" "+String(iFlowCalibrationCnt10ltr)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu8310() { //
iMenuSelectMin = 8310;
iMenuSelectMax = 8310;
if (sFlowCalState10ltr == "*") {
iFlowCalibrationCnt10ltr = 0;
sFlowCalState10ltr = "-";
}
iFlowCalibrationCnt10ltr = FlowSensorCnt;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("10ltr - "+String(iFlowCalibrationCnt10ltr)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bWaterPump = 1; //ON
iMenuSelect = 8310;
iMenuSelectStep = 10;
}
void pMainMenu8311() { //
iMenuSelectMin = 8311;
iMenuSelectMax = 8311;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("10ltr ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sFlowCalState10ltr = "*";
bWaterPump = 0; //OFF
iMenuSelect = 8300;
iMenuSelectStep = 100;
}
void pMainMenu8400() { //
iMenuSelectMin = 8100;
iMenuSelectMax = 8700;
FlowSensorCnt = 0;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("20ltr "+sFlowCalState20ltr+" "+String(iFlowCalibrationCnt20ltr)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu8410() { //
iMenuSelectMin = 8410;
iMenuSelectMax = 8410;
if (sFlowCalState20ltr == "*") {
iFlowCalibrationCnt20ltr = 0;
sFlowCalState20ltr = "-";
}
lcd.setCursor ( 0, 0 ); // go to the next line
iFlowCalibrationCnt20ltr = FlowSensorCnt;
lcd.print("20ltr - "+String(iFlowCalibrationCnt20ltr)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bWaterPump = 1; //ON
iMenuSelect = 8410;
iMenuSelectStep = 10;
}
void pMainMenu8411() { //
iMenuSelectMin = 8411;
iMenuSelectMax = 8411;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("20ltr ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sFlowCalState20ltr = "*";
bWaterPump = 0; //OFF
iMenuSelect = 8400;
iMenuSelectStep = 100;
}
void pMainMenu8500() { //
iMenuSelectMin = 8100;
iMenuSelectMax = 8700;
FlowSensorCnt = 0;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("40ltr "+sFlowCalState40ltr+" "+String(iFlowCalibrationCnt40ltr)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to start ");
}
void pMainMenu8510() { //
iMenuSelectMin = 8510;
iMenuSelectMax = 8510;
if (sFlowCalState40ltr == "*") {
iFlowCalibrationCnt40ltr = 0;
sFlowCalState40ltr = "-";
}
iFlowCalibrationCnt40ltr = FlowSensorCnt;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("40ltr - "+String(iFlowCalibrationCnt40ltr)+" ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Stop ");
bWaterPump = 1; //ON
iMenuSelect = 8510;
iMenuSelectStep = 10;
}
void pMainMenu8511() { //
iMenuSelectMin = 8511;
iMenuSelectMax = 8511;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("40ltr ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Done ");
sFlowCalState40ltr = "*";
bWaterPump = 0; //OFF
iMenuSelect = 8500;
iMenuSelectStep = 100;
}
void pMainMenu8600() { //
iMenuSelectMin = 8100;
iMenuSelectMax = 8700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Calibrate Now ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Press Enter ");
}
void pMainMenu8610() { //
iMenuSelectMin = 8610;
iMenuSelectMax = 8610;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Calibration Done");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Exit ");
}
void pMainMenu8611() { //
iMenuSelect = 8600;
iMenuSelectStep = 100;
}
void pMainMenu8700() { //
iMenuSelectMin = 8100;
iMenuSelectMax = 8700;
lcd.setCursor ( 0, 0 ); // go to the next line
lcd.print("Return To Main ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Enter to Exit ");
}
void pMainMenu8710() {
iMenuSelect = 8000;
iMenuSelectStep = 1000;
iMenuSelectMin = 1000;
iMenuSelectMax = 8000;
}
ISR(TIMER0_COMPA_vect){//timer0 interrupt 2kHz toggles pin 8
//generates pulse wave of frequency 2kHz/2 = 1kHz (takes two cycles for full wave- toggle high then toggle low)
if (iDebounceCnt>0) {
iDebounceCnt--;
}
i1Kcnt--;
if (i1Kcnt <= 0) {
if ((iMenuSelect > 6100) && (iMenuSelect < 7000)){
if (iMenuSelect == 6110) {
iPumpACalibrationTime5ml++;
}
if (iMenuSelect == 6210) {
iPumpACalibrationTime25ml++;
}
if (iMenuSelect == 6310) {
iPumpACalibrationTime50ml++;
}
if (iMenuSelect == 6410) {
iPumpACalibrationTime100ml++;
}
if (iMenuSelect == 6510) {
iPumpACalibrationTime200ml++;
}
}
else if ((iMenuSelect > 7100) && (iMenuSelect < 8000)){
if (iMenuSelect == 7110) {
iPumpBCalibrationTime5ml++;
}
if (iMenuSelect == 7210) {
iPumpBCalibrationTime25ml++;
}
if (iMenuSelect == 7310) {
iPumpBCalibrationTime50ml++;
}
if (iMenuSelect == 7410) {
iPumpBCalibrationTime100ml++;
}
if (iMenuSelect == 7510) {
iPumpBCalibrationTime200ml++;
}
}
if (bMenuTimer > 0) {
bMenuTimer--;
}
if (bWaterReservourState == bFilling){
iFillTimer++;
}
if ((bNutrientDoseA == bActive) | (bNutrientDoseB == bActive)) {
iNutrientPumpTime++;
}
i1Kcnt = i1Kmax;
}
}
ISR(TIMER1_COMPA_vect){//timer1 interrupt 1Hz toggles pin 13 (LED)
//generates pulse wave of frequency 1Hz/2 = 0.5Hz (takes two cycles for full wave- toggle high then toggle low)
if (bSec == 0) {
bSec = 1;
if (bLCD_Light_Timer > 0) {
bLCD_Light_Timer--;
}
if (bWait > 0) {
bWait--;
}
if (bpHDisplayUpdate > 0){
bpHDisplayUpdate--;
}
if(WaterLevelTimer > 0) {
WaterLevelTimer--;
}
}
else {
bSec--;
}
iNutrient_Stir_Timer++;
iOzone_Timer++;
}
ISR(TIMER2_COMPA_vect){//timer1 interrupt 8kHz toggles pin 9
//generates pulse wave of frequency 8kHz/2 = 4kHz (takes two cycles for full wave- toggle high then toggle low)
}
void FlowSensorDetect() {
FlowSensorCnt++;
}