void processMyTouch() // this is a huge block dedicated to processing all touch screen events { //Serial.print("Touch Detected...\n"); myTouch.read(); x=myTouch.getX(); y=myTouch.getY(); // initiate char vars for converting numbers to char for display char char3[3]; char char3t[3]; char char4[4]; char char5[5]; char char6[6]; // we evaluate touch based on which screen we are in switch (dispScreen) { case 1: // home screen if ((x>=175)&&(x<=235)&&(y>=44)&&(y<=95)) // Stisknout prutokomer pro vymazani varovani { flowWarningCleared=true; // Vymazani varovani screenHome(); } if ((x>=127)&&(x<=175)&&(y>=60)&&(y<=108)) // Zapni chlazeni { if (schedcirc.active==0) { if (globalPower.pwrCirc==0) AlarmPwrCirc_On(); else if (globalPower.pwrCirc==1) AlarmPwrCirc_Off(); screenHome(); } } if ((x>=10)&&(x<=58)&&(y>=266)&&(y<=314)) // Dopln vodu { screenWater(); } if ((x>=67)&&(x<=115)&&(y>=266)&&(y<=314)) // feeding dock icon { screenFeeding(); } // coordinates of the power putton if ((x>=124)&&(x<=172)&&(y>=266)&&(y<=314)) // power dock icon { screenPower(); } // coordinates of the exras button if ((x>=181)&&(x<=229)&&(y>=266)&&(y<=314)) // settings dock icon { screenSettings(); } break; case 2: // feeding screen if ((x>=67)&&(x<=115)&&(y>=223)&&(y<=271)) // stop button { feedingStop(); screenHome(); } if ((x>=124)&&(x<=172)&&(y>=223)&&(y<=271)) // play button { // start feeding cycle if not already active if (feedingActive==false) { // capture current power status so we can return to it preFeedPower.pwrLight1=globalPower.pwrLight1; preFeedPower.pwrLight2=globalPower.pwrLight2; preFeedPower.pwrFilter=globalPower.pwrFilter; preFeedPower.pwrHeat=globalPower.pwrHeat; // there is a catch to make sure CO2 isn't turned back on if the schedule turns it off during feeding preFeedPower.pwrCO2=globalPower.pwrCO2; preFeedPower.pwrAux1=globalPower.pwrAux1; preFeedPower.pwrAux2=globalPower.pwrAux2; preFeedPower.pwrCable=globalPower.pwrCable; // fire power relays as configured if (feedPower.pwrLight1==1) AlarmPwrLight1_On(); else if (feedPower.pwrLight1==0) AlarmPwrLight1_Off(); if (feedPower.pwrLight2==1) AlarmPwrLight2_On(); else if (feedPower.pwrLight2==0) AlarmPwrLight2_Off(); if (feedPower.pwrFilter==1) AlarmPwrFilter_On(); else if (feedPower.pwrFilter==0) AlarmPwrFilter_Off(); if (feedPower.pwrHeat==1) AlarmPwrHeat_On(); else if (feedPower.pwrHeat==0) AlarmPwrHeat_Off(); if (feedPower.pwrCO2==1) AlarmPwrCO2_On(); else if (feedPower.pwrCO2==0) AlarmPwrCO2_Off(); if (feedPower.pwrAux1==1) AlarmPwrAux1_On(); else if (feedPower.pwrAux1==0) AlarmPwrAux1_Off(); if (feedPower.pwrAux2==1) AlarmPwrAux2_On(); else if (feedPower.pwrAux2==0) AlarmPwrAux2_Off(); if (feedPower.pwrCable==1) AlarmPwrCable_On(); else if (feedPower.pwrCable==0) AlarmPwrCable_Off(); feedingActive=true; startFeedingTime = now(); // mark when feeding started checkFeeding(); screenHome(); } } if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // home button { screenHome(); } break; case 3: // power screen if ((x>=69)&&(x<=118)&&(y>=77)&&(y<=125)) // all on { // turn on all power outputs AlarmPwrLight1_On(); AlarmPwrLight2_On(); AlarmPwrFilter_On(); AlarmPwrHeat_On(); AlarmPwrCO2_On(); AlarmPwrAux1_On(); AlarmPwrAux2_On(); AlarmPwrCable_On(); screenPower(); // redraw screen } else if ((x>=125)&&(x<=174)&&(y>=77)&&(y<=125)) // all off { // turn off all power outputs AlarmPwrLight1_Off(); AlarmPwrLight2_Off(); AlarmPwrFilter_Off(); AlarmPwrHeat_Off(); AlarmPwrCO2_Off(); AlarmPwrAux1_Off(); AlarmPwrAux2_Off(); AlarmPwrCable_Off(); screenPower(); // redraw screen } else if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // home button { screenHome(); } else if ((x>=15)&&(x<=64)&&(y>=139)&&(y<=187)) // Front lights power { //toggle power if (globalPower.pwrLight1==0) AlarmPwrLight1_On(); else if (globalPower.pwrLight1==1) AlarmPwrLight1_Off(); // draw icons myFiles.load(15, 139, 48, 48, pwrLightIcon[globalPower.pwrLight1]); myFiles.load(34, 192, 10, 11, pwrDot[globalPower.pwrLight1]); } else if ((x>=69)&&(x<=118)&&(y>=139)&&(y<=187)) // Back lights power { // toggle power if (globalPower.pwrLight2==0) AlarmPwrLight2_On(); else if (globalPower.pwrLight2==1) AlarmPwrLight2_Off(); // draw icons myFiles.load(69, 139, 48, 48, pwrLightIcon[globalPower.pwrLight2]); myFiles.load(88, 192, 10, 11, pwrDot[globalPower.pwrLight2]); } else if ((x>=124)&&(x<=173)&&(y>=139)&&(y<=187)) // Filter power { // toggle power if (globalPower.pwrFilter==0) AlarmPwrFilter_On(); else if (globalPower.pwrFilter==1)AlarmPwrFilter_Off(); // draw icons myFiles.load(124, 139, 48, 48, pwrFilterIcon[globalPower.pwrFilter]); myFiles.load(143, 192, 10, 11, pwrDot[globalPower.pwrFilter]); } else if ((x>=178)&&(x<=227)&&(y>=139)&&(y<=187)) // CO2 power { // toggle power if (globalPower.pwrCO2==0) AlarmPwrCO2_On(); else if (globalPower.pwrCO2==1) AlarmPwrCO2_Off(); // draw icons myFiles.load(178, 139, 48, 48, pwrCO2Icon[globalPower.pwrCO2] ); myFiles.load(197, 192, 10, 11, pwrDot[globalPower.pwrCO2]); } else if ((x>=15)&&(x<=64)&&(y>=198)&&(y<=246)) // Heat power { // toggle power if (globalPower.pwrHeat==0) AlarmPwrHeat_On(); else if (globalPower.pwrHeat==1)AlarmPwrHeat_Off(); // draw icons myFiles.load(15, 212, 48, 48, pwrHeatIcon[globalPower.pwrHeat] ); myFiles.load(34, 264, 10, 11, pwrDot[globalPower.pwrHeat]); } else if ((x>=69)&&(x<=118)&&(y>=198)&&(y<=246)) // Cable power { // toggle power if (globalPower.pwrCable==0) AlarmPwrCable_On(); else if (globalPower.pwrCable==1) AlarmPwrCable_Off(); // draw icons myFiles.load(69, 212, 48, 48, pwrCableIcon[globalPower.pwrCable] ); myFiles.load(88, 264, 10, 11, pwrDot[globalPower.pwrCable]); } else if ((x>=124)&&(x<=173)&&(y>=198)&&(y<=246)) // aux 1 power { // toggle power if (globalPower.pwrAux1==0) AlarmPwrAux1_On(); else if (globalPower.pwrAux1==1) AlarmPwrAux1_Off(); // draw icons myFiles.load(124, 212, 48, 48, pwrAux1Icon[globalPower.pwrAux1] ); myFiles.load(143, 264, 10, 11, pwrDot[globalPower.pwrAux1]); } else if ((x>=178)&&(x<=227)&&(y>=198)&&(y<=246)) // aux 2 power { // toggle power if (globalPower.pwrAux2==0) AlarmPwrAux2_On(); else if (globalPower.pwrAux2==1) AlarmPwrAux2_Off(); // draw icons myFiles.load(178, 212, 48, 48, pwrAux2Icon[globalPower.pwrAux2] ); myFiles.load(197, 264, 10, 11, pwrDot[globalPower.pwrAux2]); } break; case 4: // settings screen if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // home button { screenHome(); } if ((x>=10)&&(x<=58)&&(y>=50)&&(y<=113)) { if ((globalPower.pwrLight1==1) || (globalPower.pwrLight2==1)) screenLights(); // only respond to the lights button if they are turned on } else if ((x>=67)&&(x<=115)&&(y>=50)&&(y<=113)) { screenClock(); } else if ((x>=124)&&(x<=172)&&(y>=50)&&(y<=113)) { screenFeedSettings(); } else if ((x>=181)&&(x<=229)&&(y>=50)&&(y<=113)) { screenSchedule(); } else if ((x>=10)&&(x<=58)&&(y>=118)&&(y<=181)) { screenPh(); } else if ((x>=67)&&(x<=115)&&(y>=118)&&(y<=181)) { screenDosing(); } else if ((x>=124)&&(x<=172)&&(y>=118)&&(y<=181)) { screenScreen(); } else if ((x>=181)&&(x<=229)&&(y>=118)&&(y<=181)) { screenoffset(); } else if ((x>=10)&&(x<=58)&&(y>=186)&&(y<=249)) { screenHeater(); } else if ((x>=67)&&(x<=115)&&(y>=186)&&(y<=249)) { screenCable(); } else if ((x>=124)&&(x<=172)&&(y>=186)&&(y<=249)) { screenCirc(); } else if ((x>=181)&&(x<=229)&&(y>=186)&&(y<=249)) { screenWaterSettings(); } break; case 5: // lights screen if (lightEditing==0) // actions for buttons that are active when editing is not active { boolean updateLightValues=false; // track if we need to update the light values at the end due to mode change if ((x>=10)&&(x<=58)&&(y>=39)&&(y<=87)) // full sun mode button { clearSelectedLight(1); // deselect the previously selected light currentLightMode=0; currentColor = lightHighSun; // update current color values myFiles.load(10, 101, 48, 63, lightEdit[1]); // activate the edit button myFiles.load(10, 39, 48, 48, lightModeS[currentLightMode]); // draw the button selected updateLightValues=true; // update the light values } else if ((x>=67)&&(x<=115)&&(y>=39)&&(y<=87)) // mid sun mode button { clearSelectedLight(1); // deselect the previously selected light currentLightMode=1; currentColor = lightMidSun; myFiles.load(10, 101, 48, 63, lightEdit[1]); // activate the edit button myFiles.load(67, 39, 48, 48, lightModeS[currentLightMode]); // draw the button selected updateLightValues=true; // update the light values } else if ((x>=124)&&(x<=172)&&(y>=39)&&(y<=87)) // low sun mode button { clearSelectedLight(1); // deselect the previously selected light currentLightMode=2; currentColor = lightLowSun; myFiles.load(10, 101, 48, 63, lightEdit[1]); // activate the edit button myFiles.load(124, 39, 48, 48, lightModeS[currentLightMode]); // draw the button selected updateLightValues=true; // update the light values } else if ((x>=181)&&(x<=229)&&(y>=39)&&(y<=87)) // moon mode button { clearSelectedLight(1); // deselect the previously selected light currentLightMode=3; currentColor = lightMoon; myFiles.load(10, 101, 48, 63, lightEdit[1]); // activate the edit button myFiles.load(181, 39, 48, 48, lightModeS[currentLightMode]); // draw the button selected updateLightValues=true; // update the light values } else if ((x>=10)&&(x<=58)&&(y>=101)&&(y<=149)) // edit button { clearSelectedLight(2); // turn off light modes that are inactive lightEditing=1; // activate editing mode myFiles.load(181, 101, 48, 63, lightResync[0]); // disable resync myFiles.load(10, 101, 48, 63, lightEdit[0]); // disable edit myFiles.load(67, 101, 48, 63, lightSave[1]); // enable save myFiles.load(124, 101, 48, 63, lightCancel[1]); // enable cancel } else if ((x>=181)&&(x<=229)&&(y>=101)&&(y<=149)) // resync button { screenResyncLights(); // display that we are resyncing resyncLights(); // actually resync the lights screenLights(); // redraw the lights screen } // if modes were switched, we need to update the lighting values by the RGBW up/down buttons if (updateLightValues==1) { // make sure values are in range currentColor.chan1 = constrain(currentColor.chan1,0,maxRGBW); currentColor.chan2 = constrain(currentColor.chan2,0,maxRGBW); currentColor.chan3 = constrain(currentColor.chan3,0,maxRGBW); currentColor.chan4 = constrain(currentColor.chan4,0,maxRGBW); //update bargraphs to currentColor drawLEDBarGraph(1,currentColor.chan1); drawLEDBarGraph(2,currentColor.chan2); drawLEDBarGraph(3,currentColor.chan3); drawLEDBarGraph(4,currentColor.chan4); writeToLED(1,currentColor.chan1); writeToLED(2,currentColor.chan2); writeToLED(3,currentColor.chan3); writeToLED(4,currentColor.chan4); } } else if (lightEditing==1) // actions for buttons that are active when editing is active { int dy; if ((x>=67)&&(x<=115)&&(y>=101)&&(y<=149)) // save button { screenResyncLights(); // show that we are working /// setup eeprom rgbw variables int e1, e2, e3, e4; // holding bytes to rescale 0-4095 values to bytes for saving byte v1, v2, v3, v4; // save current light mode if (currentLightMode==0) { e1=400; // eeprom location to save M1 red e2=401; // eeprom location to save M1 green e3=402; // eeprom location to save M1 blue e4=403; // eeprom location to save M1 white } else if (currentLightMode==1) { e1=410; // eeprom location to save M2 red e2=411; // eeprom location to save M2 green e3=412; // eeprom location to save M2 blue e4=413; // eeprom location to save M2 white } else if (currentLightMode==2) { e1=420; // eeprom location to save M3 red e2=421; // eeprom location to save M3 green e3=422; // eeprom location to save M3 blue e4=423; // eeprom location to save M3 white } else if (currentLightMode==3) { e1=430; // eeprom location to save M4 red e2=431; // eeprom location to save M4 green e3=432; // eeprom location to save M4 blue e4=433; // eeprom location to save M4 white } v1 = map(currentColor.chan1,0,maxRGBW,0,255); v2 = map(currentColor.chan2,0,maxRGBW,0,255); v3 = map(currentColor.chan3,0,maxRGBW,0,255); v4 = map(currentColor.chan4,0,maxRGBW,0,255); // save new values to eeprom locations EEPROM.write(e1,v1); EEPROM.write(e2,v2); EEPROM.write(e3,v3); EEPROM.write(e4,v4); lightEditing=0; // disable editing int prevMode=currentLightMode; // keep track of what mode we are in resyncLights(); // we resync the lights after saving currentLightMode=prevMode; // return to the saved mode setStartupPWMLighting(); screenLights(); // redraw the screen } else if ((x>=124)&&(x<=172)&&(y>=101)&&(y<=149)) // cancel button { lightEditing=0; // switch back to current light mode if (currentLightMode==0) { currentColor=lightHighSun; } else if (currentLightMode==1) { currentColor=lightMidSun; } else if (currentLightMode==2) { currentColor=lightLowSun; } else if (currentLightMode==3) { currentColor=lightMoon; } writeToLED(1,currentColor.chan1); writeToLED(2,currentColor.chan2); writeToLED(3,currentColor.chan3); writeToLED(4,currentColor.chan4); screenLights(); // redraw screen } else if ((x>=10)&&(x<=57)&&(y>=185)&&(y<=285)) // red bargraph { dy = 285-y; currentColor.chan1 = map(dy, 0, 100, 0, maxRGBW); drawLEDBarGraph(1,currentColor.chan1); writeToLED(1,currentColor.chan1); } else if ((x>=67)&&(x<=114)&&(y>=185)&&(y<=285)) // Green bargraph { dy = 285-y; currentColor.chan2 = map(dy, 0, 100, 0, maxRGBW); drawLEDBarGraph(2,currentColor.chan2); writeToLED(2,currentColor.chan2); } else if ((x>=124)&&(x<=171)&&(y>=185)&&(y<=285)) // blue bargraph { dy = 285-y; currentColor.chan3 = map(dy, 0, 100, 0, maxRGBW); drawLEDBarGraph(3,currentColor.chan3); writeToLED(3,currentColor.chan3); } else if ((x>=181)&&(x<=228)&&(y>=185)&&(y<=285)) // cool white bargraph { dy = 285-y; //dy will be between 0 and 100 currentColor.chan4 = map(dy, 0, 100, 0, maxRGBW); drawLEDBarGraph(4,currentColor.chan4); //update bargraph with new value writeToLED(4,currentColor.chan4); } } if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // settings button { //smartStartupRamp(); screenSettings(); } break; case 6: // clock screen for setting time itoa(0, char3t, 10); //make char3t 0 myGLCD.setFont(arial_bold); myGLCD.setColor(255, 77, 0); touchWaitTime = MEDIUM_WAIT; if ((x>=12)&&(x<=96)&&(y>=286)&&(y<=312)) // cancel button { screenSettings(); } else if ((x>=144)&&(x<=228)&&(y>=286)&&(y<=312)) // save button { SaveTime(); screenSettings(); } else if ((x>=12)&&(x<=36)&&(y>=89)&&(y<=113)) // hour up button { saveRTC.Hour=(saveRTC.Hour+1); if (saveRTC.Hour>23) saveRTC.Hour=0; itoa(saveRTC.Hour, char3, 10); if (saveRTC.Hour>=0 && saveRTC.Hour<=9) // add a zero { strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 45, 108); } else if ((x>=12)&&(x<=36)&&(y>=119)&&(y<=143)) // hour down button { saveRTC.Hour=(saveRTC.Hour-1); if (saveRTC.Hour>23) saveRTC.Hour=23; itoa(saveRTC.Hour, char3, 10); if (saveRTC.Hour>=0 && saveRTC.Hour<=9) // add a zero { strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 45, 108); } else if ((x>=83)&&(x<=107)&&(y>=89)&&(y<=113)) // min up button { saveRTC.Minute=(saveRTC.Minute+1); if (saveRTC.Minute>59) saveRTC.Minute=0; itoa(saveRTC.Minute, char3, 10); if (saveRTC.Minute>=0 && saveRTC.Minute<=9) // add a zero { strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 123, 108); } else if ((x>=83)&&(x<=107)&&(y>=119)&&(y<=143)) // min down button { saveRTC.Minute=(saveRTC.Minute-1); if (saveRTC.Minute>59) saveRTC.Minute=59; itoa(saveRTC.Minute, char3, 10); if (saveRTC.Minute>=0 && saveRTC.Minute<=9) // add a zero { strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 123, 108); } else if ((x>=164)&&(x<=188)&&(y>=89)&&(y<=113)) // sec up button { saveRTC.Second=(saveRTC.Second+1); if (saveRTC.Second>59) saveRTC.Second=0; itoa(saveRTC.Second, char3, 10); if (saveRTC.Second>=0 && saveRTC.Second<=9) // add a zero { strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 201, 108); } else if ((x>=164)&&(x<=188)&&(y>=119)&&(y<=143)) // sec down button { saveRTC.Second=(saveRTC.Second-1); if (saveRTC.Second>59) saveRTC.Second=59; itoa(saveRTC.Second, char3, 10); if (saveRTC.Second>=0 && saveRTC.Second<=9) // add a zero { strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 201, 108); } else if ((x>=12)&&(x<=36)&&(y>=211)&&(y<=235)) // month up button { saveRTC.Month=(saveRTC.Month+1); if (saveRTC.Month>12) saveRTC.Month=1; itoa(saveRTC.Month, char3, 10); if (saveRTC.Month>=0 && saveRTC.Month<=9) // add a zero { strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 45, 230); } else if ((x>=12)&&(x<=36)&&(y>=241)&&(y<=265)) // month down button { saveRTC.Month=(saveRTC.Month-1); if (saveRTC.Month<1) saveRTC.Month=12; itoa(saveRTC.Month, char3, 10); if (saveRTC.Month>=0 && saveRTC.Month<=9) // add a zero { strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 45, 230); } else if ((x>=83)&&(x<=107)&&(y>=211)&&(y<=235)) // day up button { saveRTC.Day=(saveRTC.Day+1); if (saveRTC.Day>31) saveRTC.Day=1; itoa(saveRTC.Day, char3, 10); if (saveRTC.Day>=0 && saveRTC.Day<=9) // add a zero { strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 123, 230); } else if ((x>=83)&&(x<=107)&&(y>=241)&&(y<=265)) // day down button { saveRTC.Day=(saveRTC.Day-1); if (saveRTC.Day<1) saveRTC.Day=31; itoa(saveRTC.Day, char3, 10); if (saveRTC.Day>=0 && saveRTC.Day<=9) // add a zero { strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 123, 230); } else if ((x>=164)&&(x<=188)&&(y>=211)&&(y<=235)) // year up button { saveRTC.Year=(saveRTC.Year+1); if (saveRTC.Year>129) saveRTC.Year=30; // 30 == 2000, 130 == 2100 itoa((saveRTC.Year-30), char3, 10); if (saveRTC.Year>=30 && saveRTC.Year<=39) // add a zero { strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 201, 230); } else if ((x>=164)&&(x<=188)&&(y>=241)&&(y<=265)) // year down button { saveRTC.Year=(saveRTC.Year-1); if (saveRTC.Year<30) saveRTC.Year=129; itoa((saveRTC.Year-30), char3, 10); if (saveRTC.Year>=30 && saveRTC.Year<=39) // add a zero { strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 201, 230); } break; case 7: // feeding schedule screen if ((x>=158)&&(x<=182)&&(y>=46)&&(y<=70)) // minutes up button { feedingMins=feedingMins+1; itoa(feedingMins, char3, 10); if (feedingMins>=0 && feedingMins<=9) // add a zero { char char3t[3]; itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.setFont(arial_bold); myGLCD.setColor(255, 77, 0); myGLCD.print(char3, 195, 65); } else if ((x>=158)&&(x<=182)&&(y>=76)&&(y<=100)) // minutes down { if (feedingMins>1) // don't increment lower than 1 minute { feedingMins=feedingMins-1; itoa(feedingMins, char3, 10); if (feedingMins>=0 && feedingMins<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.setFont(arial_bold); myGLCD.setColor(255, 77, 0); myGLCD.print(char3, 195, 65); } } else if ((x>=15)&&(x<=63)&&(y>=151)&&(y<=199)) // pwrLight1Icon { // toggle to opposite power setting if (feedPower.pwrLight1==0) feedPower.pwrLight1=1; else if (feedPower.pwrLight1==1) feedPower.pwrLight1=0; // save to memory EEPROM.write(8, feedPower.pwrLight1); // update icons myFiles.load(15, 151, 48, 48, pwrLightIcon[feedPower.pwrLight1]); myFiles.load(34, 204, 10, 11, pwrDot[feedPower.pwrLight1]); } else if ((x>=69)&&(x<=117)&&(y>=151)&&(y<=199)) // pwrLight2Icon { // toggle to opposite power setting if (feedPower.pwrLight2==0) feedPower.pwrLight2=1; else if (feedPower.pwrLight2==1) feedPower.pwrLight2=0; // save to memory EEPROM.write(9, feedPower.pwrLight2); // update icons myFiles.load(69, 151, 48, 48, pwrLightIcon[feedPower.pwrLight2]); myFiles.load(88, 204, 10, 11, pwrDot[feedPower.pwrLight2]); } else if ((x>=124)&&(x<=172)&&(y>=151)&&(y<=199)) // pwrFilterIcon { // toggle to opposite power setting if (feedPower.pwrFilter==0) feedPower.pwrFilter=1; else if (feedPower.pwrFilter==1) feedPower.pwrFilter=0; // save to memory EEPROM.write(10, feedPower.pwrFilter); // update icons myFiles.load(124, 151, 48, 48, pwrFilterIcon[feedPower.pwrFilter]); myFiles.load(143, 204, 10, 11, pwrDot[feedPower.pwrFilter]); } else if ((x>=178)&&(x<=226)&&(y>=151)&&(y<=199)) // pwrCO2Icon { // toggle to opposite power setting if (feedPower.pwrCO2==0) feedPower.pwrCO2=1; else if (feedPower.pwrCO2==1) feedPower.pwrCO2=0; // save to memory EEPROM.write(13, feedPower.pwrCO2); // update icons myFiles.load(178, 151, 48, 48, pwrCO2Icon[feedPower.pwrCO2] ); myFiles.load(197, 204, 10, 11, pwrDot[feedPower.pwrCO2]); } else if ((x>=15)&&(x<=63)&&(y>=224)&&(y<=272)) // pwrHeatIcon { // toggle to opposite power setting if (feedPower.pwrHeat==0) feedPower.pwrHeat=1; else if (feedPower.pwrHeat==1) feedPower.pwrHeat=0; // save to memory EEPROM.write(12, feedPower.pwrHeat); // update icons myFiles.load(15, 224, 48, 48, pwrHeatIcon[feedPower.pwrHeat] ); myFiles.load(34, 276, 10, 11, pwrDot[feedPower.pwrHeat]); } else if ((x>=69)&&(x<=118)&&(y>=224)&&(y<=272)) // pwrCableIcon { // toggle to opposite power setting if (feedPower.pwrCable==0) feedPower.pwrCable=1; else if (feedPower.pwrCable==1) feedPower.pwrCable=0; // save to memory EEPROM.write(441, feedPower.pwrCable); // update icons myFiles.load(69, 224, 48, 48, pwrCableIcon[feedPower.pwrCable] ); myFiles.load(88, 276, 10, 11, pwrDot[feedPower.pwrCable]); } else if ((x>=124)&&(x<=172)&&(y>=224)&&(y<=272)) // pwrAux1Icon { // toggle to opposite power setting if (feedPower.pwrAux1==0) feedPower.pwrAux1=1; else if (feedPower.pwrAux1==1) feedPower.pwrAux1=0; // save to memory EEPROM.write(14, feedPower.pwrAux1); // update icons myFiles.load(124, 224, 48, 48, pwrAux1Icon[feedPower.pwrAux1] ); myFiles.load(143, 276, 10, 11, pwrDot[feedPower.pwrAux1]); } else if ((x>=178)&&(x<=226)&&(y>=224)&&(y<=272)) // pwrAux2Icon { // toggle to opposite power setting if (feedPower.pwrAux2==0) feedPower.pwrAux2=1; else if (feedPower.pwrAux2==1) feedPower.pwrAux2=0; // save to memory EEPROM.write(15, feedPower.pwrAux2); // update icons myFiles.load(178, 224, 48, 48, pwrAux2Icon[feedPower.pwrAux2] ); myFiles.load(197, 276, 10, 11, pwrDot[feedPower.pwrAux2]); } else if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // settings button { // save minutes on exit EEPROM.write(6,1); EEPROM.write(7,feedingMins); // exit screen screenSettings(); } break; case 8: // heater settings screen myGLCD.setColor(255, 77, 0); myGLCD.setFont(arial_bold); if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // settings button { screenSettings(); } else if ((x>=155)&&(x<=179)&&(y>=59)&&(y<=83)) // off up button { int theSettingOff=EEPROM.read(17); // read existing setting if (theSettingOff < 40) { theSettingOff=theSettingOff+1; // increment itoa(theSettingOff, char3, 10); myGLCD.print(char3, 184, 76); EEPROM.write(17,theSettingOff); // save setting heatOffTemp=theSettingOff; } } else if ((x>=155)&&(x<=179)&&(y>=89)&&(y<=113)) // off down button { int theSettingOff=EEPROM.read(17); // read existing setting int theSettingOn=EEPROM.read(18); // read existing setting if (theSettingOff > theSettingOn+1) { theSettingOff=theSettingOff-1; // increment itoa(theSettingOff, char3, 10); myGLCD.print(char3, 184, 76); EEPROM.write(17,theSettingOff); // save setting heatOffTemp=theSettingOff; } } else if ((x>=155)&&(x<=179)&&(y>=141)&&(y<=165)) // on up button { int theSettingOn=EEPROM.read(18); // read existing setting int theSettingOff=EEPROM.read(17); // read existing setting if (theSettingOn < theSettingOff-1) { theSettingOn=theSettingOn+1; // increment itoa(theSettingOn, char3, 10); myGLCD.print(char3, 184, 158); EEPROM.write(18,theSettingOn); // save setting heatOnTemp=theSettingOn; } } else if ((x>=155)&&(x<=179)&&(y>=171)&&(y<=195)) // on down button { int theSettingOn=EEPROM.read(18); // read existing setting if (theSettingOn > 10) { theSettingOn=theSettingOn-1; // increment itoa(theSettingOn, char3, 10); myGLCD.print(char3, 184, 158); EEPROM.write(18,theSettingOn); // save setting heatOnTemp=theSettingOn; } } else if ((x>=155)&&(x<=179)&&(y>=224)&&(y<=248)) // warn up button { int theSetting=EEPROM.read(19); // read existing setting if(theSetting < 5) { theSetting=theSetting+1; // increment itoa(theSetting, char3, 10); myGLCD.print(char3, 190, 241); EEPROM.write(19,theSetting); // save setting coldWarnTemp=theSetting; } } else if ((x>=155)&&(x<=179)&&(y>=254)&&(y<=278)) // warn down button { int theSetting=EEPROM.read(19); // read existing setting if(theSetting > 0) { theSetting=theSetting-1; // increment itoa(theSetting, char3, 10); myGLCD.print(char3, 190, 241); EEPROM.write(19,theSetting); // save setting coldWarnTemp=theSetting; } } break; case 9: // schedule screen if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // home button { updateAlarms(); // this will rebuild all of the schedules screenSettings(); } else if ((x>=10)&&(x<=58)&&(y>=50)&&(y<=113)) { screenPwrSchedule(); } else if ((x>=67)&&(x<=115)&&(y>=50)&&(y<=113)) { screenDosingSched(1); // send 1 to start with Macro pump } else if ((x>=124)&&(x<=172)&&(y>=50)&&(y<=113)) { screenLightRamps(); } break; case 10: // dosing configuration screen if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // settings button { screenSettings(); } else if ((x>=145)&&(x<=169)&&(y>=42)&&(y<=66)) // dose up { byte doseAmt=EEPROM.read(21); // 21 // read dose in mL if ( doseAmt < 20 ) { doseAmt=doseAmt+1; // increment up by one itoa(doseAmt, char3, 10); myGLCD.setColor(255, 77, 0); myGLCD.setFont(arial_bold); int px=196; if (doseAmt>9) px=188; myGLCD.print(char3, px, 59); // display dose size int doseCap=EEPROM.read(22); // 22 // read dosing reseviors capacity in ^10 mL; doseCap=doseCap*10; // multiply by 10 to get acutal mL int doses=(doseCap/doseAmt); // calcuate number of doses in a full resevoir itoa(doses, char3, 10); if (doses>=0 && doses<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.setColor(0, 0, 0); myGLCD.fillRect(108,152,140,160); // clear previous value myGLCD.setFont(Sinclair_S); myGLCD.setColor(255, 77, 0); myGLCD.print(char3, 111, 152); // draw total doses to screen EEPROM.write(21,doseAmt); // save to memory } } else if ((x>=145)&&(x<=169)&&(y>=72)&&(y<=96)) // dose down { byte doseAmt=EEPROM.read(21); // 21 // read dose in mL if (doseAmt > 1) { doseAmt=doseAmt-1; // increment down by one myGLCD.setColor(0, 0, 0); myGLCD.fillRect(191,60,220,80); // clear previous value itoa(doseAmt, char3, 10); myGLCD.setColor(255, 77, 0); myGLCD.setFont(arial_bold); int px=196; if (doseAmt>9) px=188; myGLCD.print(char3, px, 59); int doseCap=EEPROM.read(22); // 22 // read dosing reseviors capacity in ^10 mL; doseCap=doseCap*10; // multiply by 10 to get acutal mL int doses=(doseCap/doseAmt); // calcuate number of doses in a full resevoir itoa(doses, char3, 10); if (doses>=0 && doses<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.setFont(Sinclair_S); myGLCD.print(char3, 111, 152); // draw total doses to screen EEPROM.write(21,doseAmt); // save to memory } } else if ((x>=145)&&(x<=169)&&(y>=110)&&(y<=134)) // resevoir volume up by 10 { int doseCap=EEPROM.read(22); // 22 // dosing reseviors capacity in mL; if (doseCap < 200) { doseCap=(doseCap+1); // increment up by 1 EEPROM.write(22,doseCap); // save new value doseCap=(doseCap*10); // convert to power of 10 to get actual mL itoa(doseCap, char4, 10); myGLCD.setColor(255, 77, 0); myGLCD.setFont(arial_bold); int px=187; if (doseCap>99) px=180; if (doseCap>999) px=173; myGLCD.print(char4, px, 127); byte doseAmt=EEPROM.read(21); // 21 // read dose in mL int doses=(doseCap/doseAmt); // calcuate number of doses in a full resevoir itoa(doses, char3, 10); if (doses>=0 && doses<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.setFont(Sinclair_S); myGLCD.print(char3, 111, 152); // draw total doses to screen } } else if ((x>=145)&&(x<=169)&&(y>=140)&&(y<=164)) // resevoir volume down by 10 { int doseCap=EEPROM.read(22); // 22 // dosing reseviors capacity in mL; if (doseCap > 10) { doseCap=(doseCap-1); // increment up by 1 EEPROM.write(22,doseCap); // save new value doseCap=(doseCap*10); // convert to power of 10 to get actual mL itoa(doseCap, char4, 10); myGLCD.setColor(0, 0, 0); myGLCD.fillRect(175,127,235,143); // clear previous value myGLCD.fillRect(108,152,140,160); // clear previous value myGLCD.setColor(255, 77, 0); myGLCD.setFont(arial_bold); int px=187; if (doseCap>99) px=180; if (doseCap>999) px=173; myGLCD.print(char4, px, 127); byte doseAmt=EEPROM.read(21); // 21 // read dose in mL int doses=(doseCap/doseAmt); // calcuate number of doses in a full resevoir itoa(doses, char3, 10); if (doses>=0 && doses<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.setFont(Sinclair_S); myGLCD.print(char3, 111, 152); // draw total doses to screen } } else if ((x>=145)&&(x<=169)&&(y>=178)&&(y<=202)) // pump1 sec increased by .1 (technically 10 since it's 10th power) { int pumpSpeed=EEPROM.read(23); // 22 // read saved motor ms/mL; if (pumpSpeed < 200) { pumpSpeed=(pumpSpeed+1); // increment up by 1 EEPROM.write(23,pumpSpeed); // save new value pumpSpeed=(pumpSpeed*10); // convert to power of 10 to get actual ms itoa(pumpSpeed, char5, 10); int px=187; if (pumpSpeed>99) px=180; if (pumpSpeed>999) px=173; myGLCD.setColor(255, 77, 0); myGLCD.setFont(arial_bold); myGLCD.print(char5, px, 197); } } else if ((x>=145)&&(x<=169)&&(y>=178)&&(y<=232)) // pump1 sec decreased by .1 (technically 10 since it's 10th power) { int pumpSpeed=EEPROM.read(23); // 22 // read saved motor ms/mL; if (pumpSpeed > 1) { pumpSpeed=(pumpSpeed-1); // increment up by 1 EEPROM.write(23,pumpSpeed); // save new value pumpSpeed=(pumpSpeed*10); // convert to power of 10 to get actual ms itoa(pumpSpeed, char5, 10); int px=187; if (pumpSpeed>99) px=180; if (pumpSpeed>999) px=173; myGLCD.setColor(0,0,0); myGLCD.fillRect(175,197,239,213); // clear previous value myGLCD.setColor(255, 77, 0); myGLCD.setFont(arial_bold); myGLCD.print(char5, px, 197); } } else if ((x>=4)&&(x<=52)&&(y>=112)&&(y<=160)) // resevoir fill button { byte doseCap=EEPROM.read(22); // read dosing resevoir capacity EEPROM.write(32,doseCap); // reset the number of doses left, high byte EEPROM.write(33,0); // reset the number of doses left, low byte EEPROM.write(34,doseCap); // reset the number of doses left, high byte EEPROM.write(35,0); // reset the number of doses left, low byte byte doseAmt=EEPROM.read(21); // 21 // read dose in mL int doses=(doseCap/doseAmt); // calcuate number of doses in a full resevoir myGLCD.setColor(255, 77, 0); myGLCD.setFont(arial_bold); myGLCD.print("PLNE ", 62, 112); } else if ((x>=145)&&(x<=169)&&(y>=245)&&(y<=269)) // pump 2 rate increase { int pumpSpeed=EEPROM.read(24); // 22 // read saved motor ms/mL; if (pumpSpeed < 200) { pumpSpeed=(pumpSpeed+1); // increment up by 1 EEPROM.write(24,pumpSpeed); // save new value pumpSpeed=(pumpSpeed*10); // convert to power of 10 to get actual ms itoa(pumpSpeed, char5, 10); int px=187; if (pumpSpeed>99) px=180; if (pumpSpeed>999) px=173; myGLCD.setColor(255, 77, 0); myGLCD.setFont(arial_bold); myGLCD.print(char5, px, 264); } } else if ((x>=145)&&(x<=169)&&(y>=275)&&(y<=299)) // pump 2 rate decrease { int pumpSpeed=EEPROM.read(24); // 22 // read saved motor ms/mL; if (pumpSpeed > 1) { pumpSpeed=(pumpSpeed-1); // increment up by 1 EEPROM.write(24,pumpSpeed); // save new value pumpSpeed=(pumpSpeed*10); // convert to power of 10 to get actual ms itoa(pumpSpeed, char5, 10); int px=187; if (pumpSpeed>99) px=180; if (pumpSpeed>999) px=173; myGLCD.setColor(0, 0, 0); myGLCD.fillRect(175,264,239,280); // clear previous value myGLCD.setColor(255, 77, 0); myGLCD.setFont(arial_bold); myGLCD.print(char5, px, 264); } } else if ((x>=4)&&(x<=52)&&(y>=181)&&(y<=229)) // pump1 test button { int pumpTime=EEPROM.read(23); // 23 // pump 1 sec/ml int doseAmt=EEPROM.read(21); // 21 // dose in mL pumpTime=((pumpTime*10)*doseAmt); // multiply ms/mL by number of mL to pump analogWrite(dosingPump1, 255); delay(pumpTime); // set how long you want the motor to run... 1000 = aprox 1ml, test your own pump analogWrite(dosingPump1, 0); } else if ((x>=4)&&(x<=52)&&(y>=249)&&(y<=297)) // pump2 test button { int pumpTime=EEPROM.read(24); // 23 // pump 2 sec/ml int doseAmt=EEPROM.read(21); // 21 // dose in mL pumpTime=((pumpTime*10)*doseAmt); // multiply ms/mL by number of mL to pump analogWrite(dosingPump2, 255); delay(pumpTime); // set how long you want the motor to run... 1000 = aprox 1ml, test your own pump analogWrite(dosingPump2, 0); } break; case 11: // power schedule screen if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // schedule button { screenSchedule(); } else if ((x>=0)&&(x<=185)&&(y>=100)&&(y<=125)) { screenPwrScheduleItem(1); } else if ((x>=0)&&(x<=185)&&(y>=126)&&(y<=151)) { screenPwrScheduleItem(2); } else if ((x>=0)&&(x<=185)&&(y>=152)&&(y<=177)) { screenPwrScheduleItem(3); } else if ((x>=0)&&(x<=185)&&(y>=178)&&(y<=203)) { screenPwrScheduleItem(4); } else if ((x>=0)&&(x<=185)&&(y>=204)&&(y<=229)) { screenPwrScheduleItem(5); } else if ((x>=0)&&(x<=185)&&(y>=230)&&(y<=255)) { screenPwrScheduleItem(6); } break; case 12: // power item schedule screen myGLCD.setFont(arial_bold); myGLCD.setColor(255, 77, 0); if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // schedule button { screenPwrSchedule(); } else if ((x>=83)&&(x<=107)&&(y>=94)&&(y<=118)) // on hour up { int onHour; if (scheduleItem==1) { if (schedLights1.onHour==23) schedLights1.onHour=0; else schedLights1.onHour=schedLights1.onHour+1; onHour=schedLights1.onHour; EEPROM.write(101,onHour); // save to memory } else if (scheduleItem==2) { if (schedLights2.onHour==23) schedLights2.onHour=0; else schedLights2.onHour=schedLights2.onHour+1; onHour=schedLights2.onHour; EEPROM.write(106,onHour); // save to memory } else if (scheduleItem==3) { if (schedCo2.onHour==23) schedCo2.onHour=0; else schedCo2.onHour=schedCo2.onHour+1; onHour=schedCo2.onHour; EEPROM.write(116,onHour); // save to memory } else if (scheduleItem==4) { if (schedAux1.onHour==23) schedAux1.onHour=0; else schedAux1.onHour=schedAux1.onHour+1; onHour=schedAux1.onHour; EEPROM.write(121,onHour); // save to memory } else if (scheduleItem==5) { if (schedAux2.onHour==23) schedAux2.onHour=0; else schedAux2.onHour=schedAux2.onHour+1; onHour=schedAux2.onHour; EEPROM.write(126,onHour); // save to memory } // print to screen itoa(onHour, char3, 10); if (onHour>=0 && onHour<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 123, 113); } else if ((x>=83)&&(x<=107)&&(y>=124)&&(y<=148)) // on hour down { int onHour; if (scheduleItem==1) { if (schedLights1.onHour==0) schedLights1.onHour=23; else schedLights1.onHour=schedLights1.onHour-1; onHour=schedLights1.onHour; EEPROM.write(101,onHour); // save to memory } else if (scheduleItem==2) { if (schedLights2.onHour==0) schedLights2.onHour=23; else schedLights2.onHour=schedLights2.onHour-1; onHour=schedLights2.onHour; EEPROM.write(106,onHour); // save to memory } else if (scheduleItem==3) { if (schedCo2.onHour==0) schedCo2.onHour=23; else schedCo2.onHour=schedCo2.onHour-1; onHour=schedCo2.onHour; EEPROM.write(116,onHour); // save to memory } else if (scheduleItem==4) { if (schedAux1.onHour==0) schedAux1.onHour=23; else schedAux1.onHour=schedAux1.onHour-1; onHour=schedAux1.onHour; EEPROM.write(121,onHour); // save to memory } else if (scheduleItem==5) { if (schedAux2.onHour==0) schedAux2.onHour=23; else schedAux2.onHour=schedAux2.onHour-1; onHour=schedAux2.onHour; EEPROM.write(126,onHour); // save to memory } // print to screen itoa(onHour, char3, 10); if (onHour>=0 && onHour<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 123, 113); } else if ((x>=164)&&(x<=188)&&(y>=94)&&(y<=118)) // on min up { int onMinute; if (scheduleItem==1) { if (schedLights1.onMinute==59) schedLights1.onMinute=0; else schedLights1.onMinute=schedLights1.onMinute+1; onMinute=schedLights1.onMinute; EEPROM.write(102,onMinute); // save to memory } else if (scheduleItem==2) { if (schedLights2.onMinute==59) schedLights2.onMinute=0; else schedLights2.onMinute=schedLights2.onMinute+1; onMinute=schedLights2.onMinute; EEPROM.write(107,onMinute); // save to memory } else if (scheduleItem==3) { if (schedCo2.onMinute==59) schedCo2.onMinute=0; else schedCo2.onMinute=schedCo2.onMinute+1; onMinute=schedCo2.onMinute; EEPROM.write(117,onMinute); // save to memory } else if (scheduleItem==4) { if (schedAux1.onMinute==59) schedAux1.onMinute=0; else schedAux1.onMinute=schedAux1.onMinute+1; onMinute=schedAux1.onMinute; EEPROM.write(122,onMinute); // save to memory } else if (scheduleItem==5) { if (schedAux2.onMinute==59) schedAux2.onMinute=0; else schedAux2.onMinute=schedAux2.onMinute+1; onMinute=schedAux2.onMinute; EEPROM.write(127,onMinute); // save to memory } // print to screen itoa(onMinute, char3, 10); if (onMinute>=0 && onMinute<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 201, 113); } else if ((x>=164)&&(x<=188)&&(y>=124)&&(y<=148)) // on min down { int onMinute; if (scheduleItem==1) { if (schedLights1.onMinute==0) schedLights1.onMinute=59; else schedLights1.onMinute=schedLights1.onMinute-1; onMinute=schedLights1.onMinute; EEPROM.write(102,onMinute); // save to memory } else if (scheduleItem==2) { if (schedLights2.onMinute==0) schedLights2.onMinute=59; else schedLights2.onMinute=schedLights2.onMinute-1; onMinute=schedLights2.onMinute; EEPROM.write(107,onMinute); // save to memory } else if (scheduleItem==3) { if (schedCo2.onMinute==0) schedCo2.onMinute=59; else schedCo2.onMinute=schedCo2.onMinute-1; onMinute=schedCo2.onMinute; EEPROM.write(117,onMinute); // save to memory } else if (scheduleItem==4) { if (schedAux1.onMinute==0) schedAux1.onMinute=59; else schedAux1.onMinute=schedAux1.onMinute-1; onMinute=schedAux1.onMinute; EEPROM.write(122,onMinute); // save to memory } else if (scheduleItem==5) { if (schedAux2.onMinute==0) schedAux2.onMinute=59; else schedAux2.onMinute=schedAux2.onMinute-1; onMinute=schedAux2.onMinute; EEPROM.write(127,onMinute); // save to memory } // print to screen itoa(onMinute, char3, 10); if (onMinute>=0 && onMinute<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 201, 113); } else if ((x>=83)&&(x<=107)&&(y>=175)&&(y<=199)) // off hour up { int offHour; if (scheduleItem==1) { if (schedLights1.offHour==23) schedLights1.offHour=0; else schedLights1.offHour=schedLights1.offHour+1; offHour=schedLights1.offHour; EEPROM.write(103,offHour); // save to memory } else if (scheduleItem==2) { if (schedLights2.offHour==23) schedLights2.offHour=0; else schedLights2.offHour=schedLights2.offHour+1; offHour=schedLights2.offHour; EEPROM.write(108,offHour); // save to memory } else if (scheduleItem==3) { if (schedCo2.offHour==23) schedCo2.offHour=0; else schedCo2.offHour=schedCo2.offHour+1; offHour=schedCo2.offHour; EEPROM.write(118,offHour); // save to memory } else if (scheduleItem==4) { if (schedAux1.offHour==23) schedAux1.offHour=0; else schedAux1.offHour=schedAux1.offHour+1; offHour=schedAux1.offHour; EEPROM.write(123,offHour); // save to memory } else if (scheduleItem==5) { if (schedAux2.offHour==23) schedAux2.offHour=0; else schedAux2.offHour=schedAux2.offHour+1; offHour=schedAux2.offHour; EEPROM.write(128,offHour); // save to memory } // print to screen itoa(offHour, char3, 10); if (offHour>=0 && offHour<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 123, 194); } else if ((x>=83)&&(x<=107)&&(y>=205)&&(y<=229)) // off hour down { int offHour; if (scheduleItem==1) { if (schedLights1.offHour==0) schedLights1.offHour=23; else schedLights1.offHour=schedLights1.offHour-1; offHour=schedLights1.offHour; EEPROM.write(103,offHour); // save to memory } else if (scheduleItem==2) { if (schedLights2.offHour==0) schedLights2.offHour=23; else schedLights2.offHour=schedLights2.offHour-1; offHour=schedLights2.offHour; EEPROM.write(108,offHour); // save to memory } else if (scheduleItem==3) { if (schedCo2.offHour==0) schedCo2.offHour=23; else schedCo2.offHour=schedCo2.offHour-1; offHour=schedCo2.offHour; EEPROM.write(118,offHour); // save to memory } else if (scheduleItem==4) { if (schedAux1.offHour==0) schedAux1.offHour=23; else schedAux1.offHour=schedAux1.offHour-1; offHour=schedAux1.offHour; EEPROM.write(123,offHour); // save to memory } else if (scheduleItem==5) { if (schedAux2.offHour==0) schedAux2.offHour=23; else schedAux2.offHour=schedAux2.offHour-1; offHour=schedAux2.offHour; EEPROM.write(128,offHour); // save to memory } // print to screen itoa(offHour, char3, 10); if (offHour>=0 && offHour<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 123, 194); } else if ((x>=164)&&(x<=188)&&(y>=175)&&(y<=199)) // off min up { int offMinute; if (scheduleItem==1) { if (schedLights1.offMinute==59) schedLights1.offMinute=0; else schedLights1.offMinute=schedLights1.offMinute+1; offMinute=schedLights1.offMinute; EEPROM.write(104,offMinute); // save to memory } else if (scheduleItem==2) { if (schedLights2.offMinute==59) schedLights2.offMinute=0; else schedLights2.offMinute=schedLights2.offMinute+1; offMinute=schedLights2.offMinute; EEPROM.write(109,offMinute); // save to memory } else if (scheduleItem==3) { if (schedCo2.offMinute==59) schedCo2.offMinute=0; else schedCo2.offMinute=schedCo2.offMinute+1; offMinute=schedCo2.offMinute; EEPROM.write(119,offMinute); // save to memory } else if (scheduleItem==4) { if (schedAux1.offMinute==59) schedAux1.offMinute=0; else schedAux1.offMinute=schedAux1.offMinute+1; offMinute=schedAux1.offMinute; EEPROM.write(124,offMinute); // save to memory } else if (scheduleItem==5) { if (schedAux2.offMinute==59) schedAux2.offMinute=0; else schedAux2.offMinute=schedAux2.offMinute+1; offMinute=schedAux2.offMinute; EEPROM.write(129,offMinute); // save to memory } // print to screen itoa(offMinute, char3, 10); if (offMinute>=0 && offMinute<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 201, 194); } else if ((x>=164)&&(x<=188)&&(y>=205)&&(y<=229)) // off min down { int offMinute; if (scheduleItem==1) { if (schedLights1.offMinute==0) schedLights1.offMinute=59; else schedLights1.offMinute=schedLights1.offMinute-1; offMinute=schedLights1.offMinute; EEPROM.write(104,offMinute); // save to memory } else if (scheduleItem==2) { if (schedLights2.offMinute==0) schedLights2.offMinute=59; else schedLights2.offMinute=schedLights2.offMinute-1; offMinute=schedLights2.offMinute; EEPROM.write(109,offMinute); // save to memory } else if (scheduleItem==3) { if (schedCo2.offMinute==0) schedCo2.offMinute=59; else schedCo2.offMinute=schedCo2.offMinute-1; offMinute=schedCo2.offMinute; EEPROM.write(119,offMinute); // save to memory } else if (scheduleItem==4) { if (schedAux1.offMinute==0) schedAux1.offMinute=59; else schedAux1.offMinute=schedAux1.offMinute-1; offMinute=schedAux1.offMinute; EEPROM.write(124,offMinute); // save to memory } else if (scheduleItem==5) { if (schedAux2.offMinute==0) schedAux2.offMinute=59; else schedAux2.offMinute=schedAux2.offMinute-1; offMinute=schedAux2.offMinute; EEPROM.write(129,offMinute); // save to memory } // print to screen itoa(offMinute, char3, 10); if (offMinute>=0 && offMinute<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 201, 194); } else if ((x>=161)&&(x<=191)&&(y>=249)&&(y<=279)) // active button { int isActive; if (scheduleItem==1) { if (schedLights1.active==1) schedLights1.active=0; else schedLights1.active=1; isActive=schedLights1.active; EEPROM.write(100,isActive); // save to memory } if (scheduleItem==2) { if (schedLights2.active==1) schedLights2.active=0; else schedLights2.active=1; isActive=schedLights2.active; EEPROM.write(105,isActive); // save to memory } if (scheduleItem==3) { if (schedCo2.active==1) schedCo2.active=0; else schedCo2.active=1; isActive=schedCo2.active; EEPROM.write(115,isActive); // save to memory } if (scheduleItem==4) { if (schedAux1.active==1) schedAux1.active=0; else schedAux1.active=1; isActive=schedAux1.active; EEPROM.write(120,isActive); // save to memory } if (scheduleItem==5) { if (schedAux2.active==1) schedAux2.active=0; else schedAux2.active=1; isActive=schedAux2.active; EEPROM.write(125,isActive); // save to memory } myFiles.load(161, 249, 30, 30, schedActiveB[isActive]); } break; case 13: // light ramp schedule screen if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // schedule button { screenSchedule(); } else if ((x>=0)&&(x<=185)&&(y>=100)&&(y<=125)) { screenLightRampItem(1); } else if ((x>=0)&&(x<=185)&&(y>=126)&&(y<=151)) { screenLightRampItem(2); } else if ((x>=0)&&(x<=185)&&(y>=152)&&(y<=177)) { screenLightRampItem(3); } else if ((x>=0)&&(x<=185)&&(y>=178)&&(y<=203)) { screenLightRampItem(4); } else if ((x>=0)&&(x<=185)&&(y>=204)&&(y<=229)) { screenLightRampItem(5); } else if ((x>=0)&&(x<=185)&&(y>=230)&&(y<=255)) { screenLightRampItem(6); } break; case 14: // power item schedule screen myGLCD.setFont(arial_bold); myGLCD.setColor(255, 77, 0); if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // schedule button { screenLightRamps(); } else if ((x>=75)&&(x<=99)&&(y>=120)&&(y<=144)) // on hour up { int onHour; if (scheduleItem==1) { if (ramp1.onHour==23) ramp1.onHour=0; else ramp1.onHour=ramp1.onHour+1; onHour=ramp1.onHour; EEPROM.write(220,onHour); // save to memory } else if (scheduleItem==2) { if (ramp2.onHour==23) ramp2.onHour=0; else ramp2.onHour=ramp2.onHour+1; onHour=ramp2.onHour; EEPROM.write(224,onHour); // save to memory } else if (scheduleItem==3) { if (ramp3.onHour==23) ramp3.onHour=0; else ramp3.onHour=ramp3.onHour+1; onHour=ramp3.onHour; EEPROM.write(228,onHour); // save to memory } else if (scheduleItem==4) { if (ramp4.onHour==23) ramp4.onHour=0; else ramp4.onHour=ramp4.onHour+1; onHour=ramp4.onHour; EEPROM.write(232,onHour); // save to memory } else if (scheduleItem==5) { if (ramp5.onHour==23) ramp5.onHour=0; else ramp5.onHour=ramp5.onHour+1; onHour=ramp5.onHour; EEPROM.write(236,onHour); // save to memory } else if (scheduleItem==6) { if (ramp6.onHour==23) ramp6.onHour=0; else ramp6.onHour=ramp6.onHour+1; onHour=ramp6.onHour; EEPROM.write(240,onHour); // save to memory } // print to screen itoa(onHour, char3, 10); if (onHour>=0 && onHour<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 110, 139); } else if ((x>=75)&&(x<=99)&&(y>=150)&&(y<=174)) // on hour down { int onHour; if (scheduleItem==1) { if (ramp1.onHour==0) ramp1.onHour=23; else ramp1.onHour=ramp1.onHour-1; onHour=ramp1.onHour; EEPROM.write(220,onHour); // save to memory } else if (scheduleItem==2) { if (ramp2.onHour==0) ramp2.onHour=23; else ramp2.onHour=ramp2.onHour-1; onHour=ramp2.onHour; EEPROM.write(224,onHour); // save to memory } else if (scheduleItem==3) { if (ramp3.onHour==0) ramp3.onHour=23; else ramp3.onHour=ramp3.onHour-1; onHour=ramp3.onHour; EEPROM.write(228,onHour); // save to memory } else if (scheduleItem==4) { if (ramp4.onHour==0) ramp4.onHour=23; else ramp4.onHour=ramp4.onHour-1; onHour=ramp4.onHour; EEPROM.write(232,onHour); // save to memory } else if (scheduleItem==5) { if (ramp5.onHour==0) ramp5.onHour=23; else ramp5.onHour=ramp5.onHour-1; onHour=ramp5.onHour; EEPROM.write(236,onHour); // save to memory } else if (scheduleItem==6) { if (ramp6.onHour==0) ramp6.onHour=23; else ramp6.onHour=ramp6.onHour-1; onHour=ramp6.onHour; EEPROM.write(240,onHour); // save to memory } // print to screen itoa(onHour, char3, 10); if (onHour>=0 && onHour<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 110, 139); } else if ((x>=154)&&(x<=178)&&(y>=120)&&(y<=144)) // on min up { int onMinute; if (scheduleItem==1) { if (ramp1.onMinute==59) ramp1.onMinute=0; else ramp1.onMinute=ramp1.onMinute+1; onMinute=ramp1.onMinute; EEPROM.write(221,onMinute); // save to memory } else if (scheduleItem==2) { if (ramp2.onMinute==59) ramp2.onMinute=0; else ramp2.onMinute=ramp2.onMinute+1; onMinute=ramp2.onMinute; EEPROM.write(225,onMinute); // save to memory } else if (scheduleItem==3) { if (ramp3.onMinute==59) ramp3.onMinute=0; else ramp3.onMinute=ramp3.onMinute+1; onMinute=ramp3.onMinute; EEPROM.write(229,onMinute); // save to memory } else if (scheduleItem==4) { if (ramp4.onMinute==59) ramp4.onMinute=0; else ramp4.onMinute=ramp4.onMinute+1; onMinute=ramp4.onMinute; EEPROM.write(233,onMinute); // save to memory } else if (scheduleItem==5) { if (ramp5.onMinute==59) ramp5.onMinute=0; else ramp5.onMinute=ramp5.onMinute+1; onMinute=ramp5.onMinute; EEPROM.write(237,onMinute); // save to memory } else if (scheduleItem==6) { if (ramp6.onMinute==59) ramp6.onMinute=0; else ramp6.onMinute=ramp6.onMinute+1; onMinute=ramp6.onMinute; EEPROM.write(241,onMinute); // save to memory } // print to screen itoa(onMinute, char3, 10); if (onMinute>=0 && onMinute<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 189, 139); } else if ((x>=154)&&(x<=178)&&(y>=150)&&(y<=174)) // on min down { int onMinute; if (scheduleItem==1) { if (ramp1.onMinute==0) ramp1.onMinute=59; else ramp1.onMinute=ramp1.onMinute-1; onMinute=ramp1.onMinute; EEPROM.write(221,onMinute); // save to memory } else if (scheduleItem==2) { if (ramp2.onMinute==0) ramp2.onMinute=59; else ramp2.onMinute=ramp2.onMinute-1; onMinute=ramp2.onMinute; EEPROM.write(225,onMinute); // save to memory } else if (scheduleItem==3) { if (ramp3.onMinute==0) ramp3.onMinute=59; else ramp3.onMinute=ramp3.onMinute-1; onMinute=ramp3.onMinute; EEPROM.write(229,onMinute); // save to memory } else if (scheduleItem==4) { if (ramp4.onMinute==0) ramp4.onMinute=59; else ramp4.onMinute=ramp4.onMinute-1; onMinute=ramp4.onMinute; EEPROM.write(233,onMinute); // save to memory } else if (scheduleItem==5) { if (ramp5.onMinute==0) ramp5.onMinute=59; else ramp5.onMinute=ramp5.onMinute-1; onMinute=ramp5.onMinute; EEPROM.write(237,onMinute); // save to memory } else if (scheduleItem==6) { if (ramp6.onMinute==0) ramp6.onMinute=59; else ramp6.onMinute=ramp6.onMinute-1; onMinute=ramp6.onMinute; EEPROM.write(241,onMinute); // save to memory } // print to screen itoa(onMinute, char3, 10); if (onMinute>=0 && onMinute<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 189, 139); } else if ((x>=75)&&(x<=99)&&(y>=231)&&(y<=255)) // off hour up { int offHour; if (scheduleItem==1) { if (ramp1.offHour==23) ramp1.offHour=0; else ramp1.offHour=ramp1.offHour+1; offHour=ramp1.offHour; EEPROM.write(222,offHour); // save to memory } else if (scheduleItem==2) { if (ramp2.offHour==23) ramp2.offHour=0; else ramp2.offHour=ramp2.offHour+1; offHour=ramp2.offHour; EEPROM.write(226,offHour); // save to memory } else if (scheduleItem==3) { if (ramp3.offHour==23) ramp3.offHour=0; else ramp3.offHour=ramp3.offHour+1; offHour=ramp3.offHour; EEPROM.write(230,offHour); // save to memory } else if (scheduleItem==4) { if (ramp4.offHour==23) ramp4.offHour=0; else ramp4.offHour=ramp4.offHour+1; offHour=ramp4.offHour; EEPROM.write(234,offHour); // save to memory } else if (scheduleItem==5) { if (ramp5.offHour==23) ramp5.offHour=0; else ramp5.offHour=ramp5.offHour+1; offHour=ramp5.offHour; EEPROM.write(238,offHour); // save to memory } else if (scheduleItem==6) { if (ramp6.offHour==23) ramp6.offHour=0; else ramp6.offHour=ramp6.offHour+1; offHour=ramp6.offHour; EEPROM.write(242,offHour); // save to memory } // print to screen itoa(offHour, char3, 10); if (offHour>=0 && offHour<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 110, 250); } else if ((x>=75)&&(x<=99)&&(y>=261)&&(y<=285)) // off hour down { int offHour; if (scheduleItem==1) { if (ramp1.offHour==0) ramp1.offHour=23; else ramp1.offHour=ramp1.offHour-1; offHour=ramp1.offHour; EEPROM.write(222,offHour); // save to memory } else if (scheduleItem==2) { if (ramp2.offHour==0) ramp2.offHour=23; else ramp2.offHour=ramp2.offHour-1; offHour=ramp2.offHour; EEPROM.write(226,offHour); // save to memory } else if (scheduleItem==3) { if (ramp3.offHour==0) ramp3.offHour=23; else ramp3.offHour=ramp3.offHour-1; offHour=ramp3.offHour; EEPROM.write(230,offHour); // save to memory } else if (scheduleItem==4) { if (ramp4.offHour==0) ramp4.offHour=23; else ramp4.offHour=ramp4.offHour-1; offHour=ramp4.offHour; EEPROM.write(234,offHour); // save to memory } else if (scheduleItem==5) { if (ramp5.offHour==0) ramp5.offHour=23; else ramp5.offHour=ramp5.offHour-1; offHour=ramp5.offHour; EEPROM.write(238,offHour); // save to memory } else if (scheduleItem==6) { if (ramp6.offHour==0) ramp6.offHour=23; else ramp6.offHour=ramp6.offHour-1; offHour=ramp6.offHour; EEPROM.write(242,offHour); // save to memory } // print to screen itoa(offHour, char3, 10); if (offHour>=0 && offHour<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 110, 250); } else if ((x>=154)&&(x<=178)&&(y>=231)&&(y<=255)) // off min up { int offMinute; if (scheduleItem==1) { if (ramp1.offMinute==59) ramp1.offMinute=0; else ramp1.offMinute=ramp1.offMinute+1; offMinute=ramp1.offMinute; EEPROM.write(223,offMinute); // save to memory } else if (scheduleItem==2) { if (ramp2.offMinute==59) ramp2.offMinute=0; else ramp2.offMinute=ramp2.offMinute+1; offMinute=ramp2.offMinute; EEPROM.write(227,offMinute); // save to memory } else if (scheduleItem==3) { if (ramp3.offMinute==59) ramp3.offMinute=0; else ramp3.offMinute=ramp3.offMinute+1; offMinute=ramp3.offMinute; EEPROM.write(231,offMinute); // save to memory } else if (scheduleItem==4) { if (ramp4.offMinute==59) ramp4.offMinute=0; else ramp4.offMinute=ramp4.offMinute+1; offMinute=ramp4.offMinute; EEPROM.write(235,offMinute); // save to memory } else if (scheduleItem==5) { if (ramp5.offMinute==59) ramp5.offMinute=0; else ramp5.offMinute=ramp5.offMinute+1; offMinute=ramp5.offMinute; EEPROM.write(239,offMinute); // save to memory } else if (scheduleItem==6) { if (ramp6.offMinute==59) ramp6.offMinute=0; else ramp6.offMinute=ramp6.offMinute+1; offMinute=ramp6.offMinute; EEPROM.write(243,offMinute); // save to memory } // print to screen itoa(offMinute, char3, 10); if (offMinute>=0 && offMinute<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 189, 250); } else if ((x>=154)&&(x<=178)&&(y>=261)&&(y<=285)) // off min down { int offMinute; if (scheduleItem==1) { if (ramp1.offMinute==0) ramp1.offMinute=59; else ramp1.offMinute=ramp1.offMinute-1; offMinute=ramp1.offMinute; EEPROM.write(223,offMinute); // save to memory } else if (scheduleItem==2) { if (ramp2.offMinute==0) ramp2.offMinute=59; else ramp2.offMinute=ramp2.offMinute-1; offMinute=ramp2.offMinute; EEPROM.write(227,offMinute); // save to memory } else if (scheduleItem==3) { if (ramp3.offMinute==0) ramp3.offMinute=59; else ramp3.offMinute=ramp3.offMinute-1; offMinute=ramp3.offMinute; EEPROM.write(231,offMinute); // save to memory } else if (scheduleItem==4) { if (ramp4.offMinute==0) ramp4.offMinute=59; else ramp4.offMinute=ramp4.offMinute-1; offMinute=ramp4.offMinute; EEPROM.write(235,offMinute); // save to memory } else if (scheduleItem==5) { if (ramp5.offMinute==0) ramp5.offMinute=59; else ramp5.offMinute=ramp5.offMinute-1; offMinute=ramp5.offMinute; EEPROM.write(239,offMinute); // save to memory } else if (scheduleItem==6) { if (ramp6.offMinute==0) ramp6.offMinute=59; else ramp6.offMinute=ramp6.offMinute-1; offMinute=ramp6.offMinute; EEPROM.write(243,offMinute); // save to memory } // print to screen itoa(offMinute, char3, 10); if (offMinute>=0 && offMinute<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 189, 250); } break; case 15: // macro and micro dosing schedule // scheduleItem 1 = macros // scheduleItem 2 = micros myGLCD.setFont(arial_bold); // set font color based on micros or macros if (scheduleItem==1) myGLCD.setColor(34, 81, 255); else myGLCD.setColor(255, 77, 0); if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // schedule button { screenSchedule(); } else if ((x>=12)&&(x<=58)&&(y>=71)&&(y<=119)) // macros button { if (scheduleItem==2) screenDosingSched(1); // switch to macros schedule } else if ((x>=12)&&(x<=58)&&(y>=120)&&(y<=168)) // micros button { if (scheduleItem==1) screenDosingSched(2); // switch to micros schedule } else if ((x>=85)&&(x<=109)&&(y>=110)&&(y<=134)) // on hour up { int onHour; if (scheduleItem==1) // for Macros { if (pump1.onHour==23) pump1.onHour=0; else pump1.onHour=pump1.onHour+1; onHour=pump1.onHour; EEPROM.write(300,onHour); // save to memory } else if (scheduleItem==2) // for Micros { if (pump2.onHour==23) pump2.onHour=0; else pump2.onHour=pump2.onHour+1; onHour=pump2.onHour; EEPROM.write(309,onHour); // save to memory } // print to screen itoa(onHour, char3, 10); if (onHour>=0 && onHour<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 120, 129); } else if ((x>=85)&&(x<=109)&&(y>=140)&&(y<=164)) // on hour down { int onHour; if (scheduleItem==1) // for Macros { if (pump1.onHour==0) pump1.onHour=23; else pump1.onHour=pump1.onHour-1; onHour=pump1.onHour; EEPROM.write(300,onHour); // save to memory } else if (scheduleItem==2) // for Micros { if (pump2.onHour==0) pump2.onHour=23; else pump2.onHour=pump2.onHour-1; onHour=pump2.onHour; EEPROM.write(309,onHour); // save to memory } // print to screen itoa(onHour, char3, 10); if (onHour>=0 && onHour<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 120, 129); } else if ((x>=164)&&(x<=188)&&(y>=110)&&(y<=134)) // on min up { int onMinute; if (scheduleItem==1) // for Macros { if (pump1.onMinute==59) pump1.onMinute=0; else pump1.onMinute=pump1.onMinute+1; onMinute=pump1.onMinute; EEPROM.write(301,onMinute); // save to memory } else if (scheduleItem==2) // for Micros { if (pump2.onMinute==59) pump2.onMinute=0; else pump2.onMinute=pump2.onMinute+1; onMinute=pump2.onMinute; EEPROM.write(310,onMinute); // save to memory } // print to screen itoa(onMinute, char3, 10); if (onMinute>=0 && onMinute<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 199, 129); } else if ((x>=164)&&(x<=188)&&(y>=140)&&(y<=164)) // on min down { int onMinute; if (scheduleItem==1) // for Macros { if (pump1.onMinute==0) pump1.onMinute=59; else pump1.onMinute=pump1.onMinute-1; onMinute=pump1.onMinute; EEPROM.write(301,onMinute); // save to memory } else if (scheduleItem==2) // for Micros { if (pump2.onMinute==0) pump2.onMinute=59; else pump2.onMinute=pump2.onMinute-1; onMinute=pump2.onMinute; EEPROM.write(310,onMinute); // save to memory } // print to screen itoa(onMinute, char3, 10); if (onMinute>=0 && onMinute<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.print(char3, 199, 129); } else if ((x>=51)&&(x<=81)&&(y>=203)&&(y<=233)) // dose on Sunday { if (scheduleItem==1) // for Macros { if (pump1.Sunday==1) pump1.Sunday=0; else pump1.Sunday=1; EEPROM.write(302,pump1.Sunday); // save to memory myFiles.load(51, 203, 30, 30, schedActiveB[pump1.Sunday]); } else if (scheduleItem==2) // for Micros { if (pump2.Sunday==1) pump2.Sunday=0; else pump2.Sunday=1; EEPROM.write(311,pump2.Sunday); // save to memory myFiles.load(51, 203, 30, 30, schedActiveB[pump2.Sunday]); } } else if ((x>=105)&&(x<=135)&&(y>=203)&&(y<=233)) // dose on Monday { if (scheduleItem==1) // for Macros { if (pump1.Monday==1) pump1.Monday=0; else pump1.Monday=1; EEPROM.write(303,pump1.Monday); // save to memory myFiles.load(105, 203, 30, 30, schedActiveB[pump1.Monday]); } else if (scheduleItem==2) // for Micros { if (pump2.Monday==1) pump2.Monday=0; else pump2.Monday=1; EEPROM.write(312,pump2.Monday); // save to memory myFiles.load(105, 203, 30, 30, schedActiveB[pump2.Monday]); } } else if ((x>=159)&&(x<=189)&&(y>=203)&&(y<=233)) // dose on Tuesday { if (scheduleItem==1) // for Macros { if (pump1.Tuesday==1) pump1.Tuesday=0; else pump1.Tuesday=1; EEPROM.write(304,pump1.Tuesday); // save to memory myFiles.load(159, 203, 30, 30, schedActiveB[pump1.Tuesday]); } else if (scheduleItem==2) // for Micros { if (pump2.Tuesday==1) pump2.Tuesday=0; else pump2.Tuesday=1; EEPROM.write(313,pump2.Tuesday); // save to memory myFiles.load(159, 203, 30, 30, schedActiveB[pump2.Tuesday]); } } else if ((x>=30)&&(x<=60)&&(y>=250)&&(y<=280)) // dose on Wednesday { if (scheduleItem==1) // for Macros { if (pump1.Wednesday==1) pump1.Wednesday=0; else pump1.Wednesday=1; EEPROM.write(305,pump1.Wednesday); // save to memory myFiles.load(30, 250, 30, 30, schedActiveB[pump1.Wednesday]); } else if (scheduleItem==2) // for Micros { if (pump2.Wednesday==1) pump2.Wednesday=0; else pump2.Wednesday=1; EEPROM.write(314,pump2.Wednesday); // save to memory myFiles.load(30, 250, 30, 30, schedActiveB[pump2.Wednesday]); } } else if ((x>=84)&&(x<=114)&&(y>=250)&&(y<=280)) // dose on Thursday { if (scheduleItem==1) // for Macros { if (pump1.Thursday==1) pump1.Thursday=0; else pump1.Thursday=1; EEPROM.write(306,pump1.Thursday); // save to memory myFiles.load(84, 250, 30, 30, schedActiveB[pump1.Thursday]); } else if (scheduleItem==2) // for Micros { if (pump2.Thursday==1) pump2.Thursday=0; else pump2.Thursday=1; EEPROM.write(315,pump2.Thursday); // save to memory myFiles.load(84, 250, 30, 30, schedActiveB[pump2.Thursday]); } } else if ((x>=132)&&(x<=162)&&(y>=250)&&(y<=280)) // dose on Friday { if (scheduleItem==1) // for Macros { if (pump1.Friday==1) pump1.Friday=0; else pump1.Friday=1; EEPROM.write(307,pump1.Friday); // save to memory myFiles.load(132, 250, 30, 30, schedActiveB[pump1.Friday]); } else if (scheduleItem==2) // for Micros { if (pump2.Friday==1) pump2.Friday=0; else pump2.Friday=1; EEPROM.write(316,pump2.Friday); // save to memory myFiles.load(132, 250, 30, 30, schedActiveB[pump2.Friday]); } } else if ((x>=186)&&(x<=216)&&(y>=250)&&(y<=280)) // dose on Saturday { if (scheduleItem==1) // for Macros { if (pump1.Saturday==1) pump1.Saturday=0; else pump1.Saturday=1; EEPROM.write(308,pump1.Saturday); // save to memory myFiles.load(186, 250, 30, 30, schedActiveB[pump1.Saturday]); } else if (scheduleItem==2); // for Micros { if (pump2.Saturday==1) pump2.Saturday=0; else pump2.Saturday=1; EEPROM.write(317,pump2.Saturday); // save to memory myFiles.load(186, 250, 30, 30, schedActiveB[pump2.Saturday]); } } break; case 16: // screen brightness settings myGLCD.setFont(arial_bold); // byte screenRetHome, screenDimLevel, screenDimSec, screenBrightMem; if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // settings button { screenSettings(); } else if ((x>=145)&&(x<=169)&&(y>=59)&&(y<=83)) // return home min up { if (screenRetHome<9) { screenRetHome=screenRetHome+1; // increment up by one itoa(screenRetHome, char3, 10); if (screenRetHome>=0 && screenRetHome<=9) // add a zero { myGLCD.setColor(0, 0, 0); myGLCD.fillRect(191,59,239,75); // clear previous value } myGLCD.setColor(255, 77, 0); myGLCD.print(char3, 191, 73); EEPROM.write(28,screenRetHome); // save to memory } } else if ((x>=145)&&(x<=169)&&(y>=89)&&(y<=113)) // return home min down { if (screenRetHome>0) { screenRetHome=screenRetHome-1; // increment down by one itoa(screenRetHome, char3, 10); myGLCD.setColor(255, 77, 0); if (screenRetHome>=0 && screenRetHome<=9) // add a zero { myGLCD.setColor(0, 0, 0); myGLCD.fillRect(191,59,239,75); // clear previous value } myGLCD.setColor(255, 77, 0); myGLCD.print(char3, 191, 73); EEPROM.write(28,screenRetHome); // save to memory } } else if ((x>=145)&&(x<=169)&&(y>=141)&&(y<=165)) // auto-dim level up by 1 { if (screenDimLevel<5) { screenDimLevel=(screenDimLevel+1); // increment up by 1 EEPROM.write(29,screenDimLevel); // save new value itoa(screenDimLevel, char3, 10); myGLCD.setColor(255, 77, 0); myGLCD.print(char3, 191, 155); } } else if ((x>=145)&&(x<=169)&&(y>=171)&&(y<=195)) // auto-dim level down by 1 { if (screenDimLevel>0) { screenDimLevel=(screenDimLevel-1); // increment up by 1 EEPROM.write(29,screenDimLevel); // save new value itoa(screenDimLevel, char3, 10); myGLCD.setColor(255, 77, 0); myGLCD.print(char3, 191, 155); } } else if ((x>=145)&&(x<=169)&&(y>=224)&&(y<=248)) // dim seconds up by 1 { if (screenDimSec<9) { screenDimSec=(screenDimSec+1); // increment up by 1 EEPROM.write(30,screenDimSec); // save new value itoa(screenDimSec, char4, 10); myGLCD.setColor(255, 77, 0); myGLCD.print(char4, 191, 238); } } else if ((x>=145)&&(x<=169)&&(y>=254)&&(y<=278)) // dim seconds down by one { if (screenDimSec>0) { screenDimSec=(screenDimSec-1); // increment up by 1 EEPROM.write(30,screenDimSec); // save new value itoa(screenDimSec, char4, 10); myGLCD.setColor(255, 77, 0); myGLCD.print(char4, 191, 238); } } break; case 17: // sensor offset myGLCD.setFont(arial_bold); if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // settings button { screenSettings(); } else if ((x>=140)&&(x<=164)&&(y>=42)&&(y<=66)) // offset teplota vody1 up { byte storedVal = EEPROM.read(58); byte dx = 186; if(storedVal < 227) { storedVal++; EEPROM.write(58,storedVal); if(storedVal < 128)dx = 170; sensor1Calibration = ((float)storedVal - 128) / 10; dtostrf(sensor1Calibration, 3, 1, char6); //convert to string myGLCD.setColor(255, 77, 0); myGLCD.print(char6, dx, 60); checkTemp(); if(storedVal == 128) { myGLCD.setColor(0, 0, 0); myGLCD.fillRect(172,65,180,72);//erase negative sign } } } else if ((x>=140)&&(x<=164)&&(y>=72)&&(y<=96)) // offset teplota vody1 down { byte storedVal = EEPROM.read(58); byte dx = 186; if(storedVal > 29) { storedVal--; EEPROM.write(58,storedVal); if(storedVal < 128)dx = 170; sensor1Calibration = ((float)storedVal - 128) / 10; dtostrf(sensor1Calibration, 3, 1, char6); //convert to string myGLCD.setColor(255, 77, 0); myGLCD.print(char6, dx, 60); checkTemp(); } } else if ((x>=140)&&(x<=164)&&(y>=110)&&(y<=134)) // offset teplota vody2 up { byte storedVal2 = EEPROM.read(59); byte dx2 = 186; if(storedVal2 < 227) { storedVal2++; EEPROM.write(59,storedVal2); if(storedVal2 < 128)dx2 = 170; sensor2Calibration = ((float)storedVal2 - 128) / 10; dtostrf(sensor2Calibration, 3, 1, char6); //convert to string myGLCD.setColor(255, 77, 0); myGLCD.print(char6, dx2, 128); checkTemp(); if(storedVal2 == 128) { myGLCD.setColor(0, 0, 0); myGLCD.fillRect(172,126,186,140);//erase negative sign } } } else if ((x>=140)&&(x<=164)&&(y>=140)&&(y<=164)) // offset teplota vody2 down { byte storedVal2 = EEPROM.read(59); byte dx2 = 186; if(storedVal2 > 29) { storedVal2--; EEPROM.write(59,storedVal2); if(storedVal2 < 128)dx2 = 170; sensor2Calibration = ((float)storedVal2 - 128) / 10; dtostrf(sensor2Calibration, 3, 1, char6); //convert to string myGLCD.setColor(255, 77, 0); myGLCD.print(char6, dx2, 128); checkTemp(); } } else if ((x>=140)&&(x<=164)&&(y>=178)&&(y<=202)) // offset teplota vzduchu up { byte storedVal3 = EEPROM.read(60); byte dx3 = 186; if(storedVal3 < 227) { storedVal3++; EEPROM.write(60,storedVal3); if(storedVal3 < 128)dx3 = 170; sensor3Calibration = ((float)storedVal3 - 128) / 10; dtostrf(sensor3Calibration, 3, 1, char6); //convert to string myGLCD.setColor(255, 77, 0); myGLCD.print(char6, dx3, 196); if(storedVal3 == 128) { myGLCD.setColor(0, 0, 0); myGLCD.fillRect(172,194,186,206);//erase negative sign } } } else if ((x>=140)&&(x<=164)&&(y>=178)&&(y<=232)) // teplota teplota vzduchu dovn { byte storedVal3 = EEPROM.read(60); byte dx3 = 186; if(storedVal3 > 29) { storedVal3--; EEPROM.write(60,storedVal3); if(storedVal3 < 128)dx3 = 170; sensor3Calibration = ((float)storedVal3 - 128) / 10; dtostrf(sensor3Calibration, 3, 1, char6); //convert to string myGLCD.setColor(255, 77, 0); myGLCD.print(char6, dx3, 196); } } else if ((x>=140)&&(x<=164)&&(y>=245)&&(y<=269)) // vlhkost vzduchu up { byte storedVal4 = EEPROM.read(61); byte dx4 = 186; if(storedVal4 < 227) { storedVal4++; EEPROM.write(61,storedVal4); if(storedVal4 < 128)dx4 = 170; sensor4Calibration = ((float)storedVal4 - 128) / 10; dtostrf(sensor4Calibration, 3, 1, char6); //convert to string myGLCD.setColor(255, 77, 0); myGLCD.print(char6, dx4, 264); if(storedVal4 == 128) { myGLCD.setColor(0, 0, 0); myGLCD.fillRect(172,262,186,274);//erase negative sign } } } else if ((x>=140)&&(x<=164)&&(y>=275)&&(y<=299)) // vlhkost vzduchu down { byte storedVal4 = EEPROM.read(61); byte dx4 = 186; if(storedVal4 > 29) { storedVal4--; EEPROM.write(61,storedVal4); if(storedVal4 < 128)dx4 = 170; sensor4Calibration = ((float)storedVal4 - 128) / 10; dtostrf(sensor4Calibration, 3, 1, char6); //convert to string myGLCD.setColor(255, 77, 0); myGLCD.print(char6, dx4, 264); } } break; case 18: // Water screen if ((x>=67)&&(x<=115)&&(y>=223)&&(y<=271)) // stop button { WaterStop(); screenHome(); } if ((x>=124)&&(x<=172)&&(y>=223)&&(y<=271)) // play button { // start feeding cycle if not already active if (waterActive==false) { // fire power relays as configured AlarmPwrWater_On(); waterActive=true; startWaterTime = now(); // mark when feeding started } checkWater(); screenHome(); } if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // home button { screenHome(); } break; case 19: // water schedule screen if ((x>=158)&&(x<=182)&&(y>=46)&&(y<=70)) // minutes up button { if (waterMins<15) // don't increment lower than 1 minute { waterMins=waterMins+1; itoa(waterMins, char3, 10); if (waterMins>=0 && waterMins<=9) // add a zero { char char3t[3]; itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.setFont(arial_bold); myGLCD.setColor(255, 77, 0); myGLCD.print(char3, 190, 65); } } else if ((x>=158)&&(x<=182)&&(y>=76)&&(y<=100)) // minutes down { if (waterMins>1) // don't increment lower than 1 minute { waterMins=waterMins-1; itoa(waterMins, char3, 10); if (waterMins>=0 && waterMins<=9) // add a zero { itoa(0, char3t, 10); //make char3t 0 strcat(char3t, char3); strcpy (char3,char3t); } myGLCD.setFont(arial_bold); myGLCD.setColor(255, 77, 0); myGLCD.print(char3, 190, 65); } } else if ((x>=158)&&(x<=182)&&(y>=128)&&(y<=152)) // minutes up button { if (waterSec<30) // don't increment lower than 1 minute { waterSec=waterSec+1; itoa(waterSec, char3, 10); myGLCD.setFont(arial_bold); myGLCD.setColor(255, 77, 0); myGLCD.print(char3, 195, 150); } } else if ((x>=158)&&(x<=182)&&(y>=158)&&(y<=182)) // minutes down { if (waterSec>0) // don't increment lower than 1 minute { waterSec=waterSec-1; itoa(waterSec, char3, 10); myGLCD.setFont(arial_bold); myGLCD.setColor(255, 77, 0); myGLCD.print(char3, 195, 150); } } else if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // settings button { // save minutes on exit EEPROM.write(446,waterMins); EEPROM.write(447,waterSec); // exit screen screenSettings(); } break; case 20: // heater settings screen myGLCD.setColor(255, 77, 0); myGLCD.setFont(arial_bold); if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // settings button { screenSettings(); } else if ((x>=155)&&(x<=179)&&(y>=59)&&(y<=83)) // off up button { int theSettingOff=EEPROM.read(442); // read existing setting if (theSettingOff < 442) { theSettingOff=theSettingOff+1; // increment itoa(theSettingOff, char3, 10); myGLCD.print(char3, 184, 76); EEPROM.write(442,theSettingOff); // save setting cableOffTemp=theSettingOff; } } else if ((x>=155)&&(x<=179)&&(y>=89)&&(y<=113)) // off down button { int theSettingOff=EEPROM.read(442); // read existing setting int theSettingOn=EEPROM.read(443); // read existing setting if (theSettingOff > theSettingOn+1) { theSettingOff=theSettingOff-1; // increment itoa(theSettingOff, char3, 10); myGLCD.print(char3, 184, 76); EEPROM.write(442,theSettingOff); // save setting cableOffTemp=theSettingOff; } } else if ((x>=155)&&(x<=179)&&(y>=141)&&(y<=165)) // on up button { int theSettingOn=EEPROM.read(443); // read existing setting int theSettingOff=EEPROM.read(442); // read existing setting if (theSettingOn < theSettingOff - 1) { theSettingOn=theSettingOn+1; // increment itoa(theSettingOn, char3, 10); myGLCD.print(char3, 184, 158); EEPROM.write(443,theSettingOn); // save setting cableOnTemp=theSettingOn; } } else if ((x>=155)&&(x<=179)&&(y>=171)&&(y<=195)) // on down button { int theSettingOn=EEPROM.read(443); // read existing setting if (theSettingOn > 10) { theSettingOn=theSettingOn-1; // increment itoa(theSettingOn, char3, 10); myGLCD.print(char3, 184, 158); EEPROM.write(443,theSettingOn); // save setting cableOnTemp=theSettingOn; } } else if ((x>=161)&&(x<=191)&&(y>=249)&&(y<=279)) // active button { int isActive; if (schedcable.active==1) schedcable.active=0; else schedcable.active=1; isActive=schedcable.active; EEPROM.write(42,isActive); // save to memory myFiles.load(175, 242, 30, 30, schedActiveB[schedcable.active]); } break; case 21: // obrazovka chlazeni myGLCD.setColor(255, 77, 0); myGLCD.setFont(arial_bold); if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // zpet na nastaveni { screenSettings(); } else if ((x>=155)&&(x<=179)&&(y>=37)&&(y<=61)) // nastaveni teploty zapnuti nahoru { int theSettingOn=EEPROM.read(445); // read existing setting if (theSettingOn < 50) { theSettingOn=theSettingOn+1; // increment itoa(theSettingOn, char3, 10); myGLCD.print(char3, 184, 56); EEPROM.write(445,theSettingOn); // save setting circOnTemp=theSettingOn; } } else if ((x>=155)&&(x<=179)&&(y>=67)&&(y<=91)) // nastaveni teploty zapnuti dolu { int theSettingOn=EEPROM.read(445); // read existing setting int theSettingOff=EEPROM.read(444); // read existing setting if (theSettingOn > theSettingOff + 1 ) { theSettingOn=theSettingOn-1; // increment itoa(theSettingOn, char3, 10); myGLCD.print(char3, 184, 56); EEPROM.write(445,theSettingOn); // save setting circOnTemp=theSettingOn; } } else if ((x>=155)&&(x<=179)&&(y>=103)&&(y<=127)) // nastaveni teploty vypnuti nahoru { int theSettingOff=EEPROM.read(444); // read existing setting int theSettingOn=EEPROM.read(445); // read existing setting if (theSettingOff < theSettingOn - 1) { theSettingOff=theSettingOff+1; // increment itoa(theSettingOff, char3, 10); myGLCD.print(char3, 184, 122); EEPROM.write(444,theSettingOff); // save setting circOffTemp=theSettingOff; } } else if ((x>=155)&&(x<=179)&&(y>=133)&&(y<=157)) // nastaveni teploty zapnuti dolu { int theSettingOff=EEPROM.read(444); // read existing setting if (theSettingOff > 20) { theSettingOff=theSettingOff-1; // increment itoa(theSettingOff, char3, 10); myGLCD.print(char3, 184, 122); EEPROM.write(444,theSettingOff); // save setting circOffTemp=theSettingOff; } } else if ((x>=155)&&(x<=179)&&(y>=169)&&(y<=193)) // nastaveni teploty vypnuti nahoru { int theSettingOn=EEPROM.read(448); // read existing setting if (theSettingOn < 90) { theSettingOn=theSettingOn+10; // increment itoa(theSettingOn, char3, 10); myGLCD.print(char3, 184, 188); EEPROM.write(448,theSettingOn); // save setting humiOn=theSettingOn; } } else if ((x>=155)&&(x<=179)&&(y>=199)&&(y<=223)) // nastaveni teploty zapnuti dolu { int theSettingOn=EEPROM.read(448); // read existing setting if (theSettingOn > 30) { theSettingOn=theSettingOn-10; // increment itoa(theSettingOn, char3, 10); myGLCD.print(char3, 184, 188); EEPROM.write(448,theSettingOn); // save setting humiOn=theSettingOn; } } else if ((x>=161)&&(x<=191)&&(y>=249)&&(y<=279)) // active button { int isActive; if (schedcirc.active==1) schedcirc.active=0; else schedcirc.active=1; isActive=schedcirc.active; EEPROM.write(47,isActive); // save to memory myFiles.load(175, 242, 30, 30, schedActiveB[schedcirc.active]); } break; case 22: // obrazovka pH myGLCD.setFont(arial_bold); myGLCD.setColor(255, 77, 0); touchWaitTime = MEDIUM_WAIT; if ((x>=107)&&(x<=129)&&(y>=294)&&(y<=318)) // settings button { screenSettings(); } else if ((x>=108)&&(x<=132)&&(y>=37)&&(y<=61)) // Fan off temp up arrow { CO2OffVal=EEPROM.read(96); // read existing setting CO2OnVal=EEPROM.read(97); // read existing setting if(CO2OffVal < CO2OnVal - 1 ) { CO2OffVal=CO2OffVal+1; // increment float cf=(((float)CO2OffVal-128)/10)+7; dtostrf(cf, 3, 1, char6); itoa(CO2OffVal, char3, 10); myGLCD.print(char6, 140, 56); EEPROM.write(96,CO2OffVal); // save setting } } else if ((x>=108)&&(x<=132)&&(y>=67)&&(y<=91)) // Fan off temp down arrow { CO2OffVal=EEPROM.read(96); // read existing setting if(CO2OffVal > 118) { CO2OffVal=CO2OffVal-1; // decrease float cf=(((float)CO2OffVal-128)/10)+7; dtostrf(cf, 3, 1, char6); itoa(CO2OffVal, char3, 10); myGLCD.print(char6, 140, 56); EEPROM.write(96,CO2OffVal); // save setting } } else if ((x>=108)&&(x<=132)&&(y>=103)&&(y<=127)) // Fan on temp up arrow { CO2OnVal=EEPROM.read(97); // read existing setting if(CO2OnVal < 138) { CO2OnVal=CO2OnVal+1; // increase float cn=(((float)CO2OnVal-128)/10)+7; dtostrf(cn, 3, 1, char6); itoa(CO2OnVal, char3, 10); myGLCD.print(char6, 140, 122); EEPROM.write(97,CO2OnVal); // save setting } } else if ((x>=108)&&(x<=132)&&(y>=133)&&(y<=157)) // Fan on temp down arrow { CO2OnVal=EEPROM.read(97); // read existing setting CO2OffVal=EEPROM.read(96); // read existing setting if(CO2OnVal > CO2OffVal + 1) { CO2OnVal=CO2OnVal-1; // decrease float cn=(((float)CO2OnVal-128)/10)+7; dtostrf(cn, 3, 1, char6); itoa(CO2OnVal, char3, 10); myGLCD.print(char6, 140, 122); EEPROM.write(97,CO2OnVal); // save setting } } else if ((x>=18)&&(x<=66)&&(y>=174)&&(y<=214)) // calibrate button { AlertPHCalibrate(); } else if ((x>=187)&&(x<=216)&&(y>=249)&&(y<=279)) // active button { int isActive; if (schedph.active==1) schedph.active=0; else schedph.active=1; isActive=schedph.active; EEPROM.write(48,isActive); // save to memory myFiles.load(187, 242, 30, 30, schedActiveB[schedph.active]); } break; case 23: //Upozorneni na kalibraci if ((x>=65)&&(x<=95)&&(y>=170)&&(y<=200)) // enable display PH Calibrate { myFiles.load(65, 170, 30, 30, schedActiveB[true],2); SolManage=7; AlertRinse("7"); } if ((x>=145)&&(x<=175)&&(y>=170)&&(y<=200)) // return screensettings { myFiles.load(145, 170, 30, 30, schedActiveB[true],2); screenPh(); } break; case 24: //AlertRinse if ((x>=105)&&(x<=135)&&(y>=170)&&(y<=200)&& SolManage==7) { myFiles.load(105, 170, 30, 30, schedActiveB[true],2); myGLCD.setColor(0, 0, 0); myGLCD.fillRect(16, 52, 224, 269);//erase negative sign myGLCD.setFont(arial_bold); myGLCD.setColor(255, 255, 255); myGLCD.print("STABILIZACE", 30, 130); waitForCal(); ReadPH(); //delay(100); ReadPH(); //SAVE NEW DATA mvReading_7=mvReading; value2= average/4; EEPROM.write(91,value2); //Resetting the days sinc calibration Day_Last_Calibration=0; CalibrationWarning=0; Slope_calc(); ProbeLife_Check_1(); EEPROM.write(95,Day_Last_Calibration); ///////////////////////////////////////**// SolManage=4; AlertRinse("4"); } else if ((x>=105)&&(x<=135)&&(y>=170)&&(y<=200)&&SolManage==4) { myFiles.load(105, 170, 30, 30, schedActiveB[true],2); //delay(100); myGLCD.setColor(0, 0, 0); myGLCD.fillRect(16, 52, 224, 269);//erase negative sign myGLCD.setFont(arial_bold); myGLCD.setColor(255, 255, 255); myGLCD.print("STABILIZACE", 30, 130); waitForCal(); ReadPH(); //delay(100); mvReading_4=mvReading; ///////////*************////////// AlertHealthCheckPH(); } break; } }