ok so i am having a little issue with trying to make the case smaller due to its repeating it self for timer 1-4...
i know that in normal functions you can use the "for loop" to reprint things that are repeating but what about the touch portion on a utft?
here is my sketch that i want to make smaller...
i have tryed doing it like this and it doesnt seem to work....
any one with arduino knowledge that can help would be great...
i know that in normal functions you can use the "for loop" to reprint things that are repeating but what about the touch portion on a utft?
here is my sketch that i want to make smaller...
Code:
case 10: //--------------------- Display Set Timer SCREEN -------------------------
if ((x>=1) && (y>=31) && (x<=318) && (y<=55) // Set Misting Timer 1
&& (mistingT1OnH==0) && (mistingT1OnM==0) && (mistingT1OnS==0)
&& (mistingT1OffH==0) && (mistingT1OffM==0) && (mistingT1OffS==0)
|| (x>=1) && (y>=32) && (x<=220) && (y<=55))
{
timerPage=1;
timerHoursOn=timeHour; timerMinsOn=t.min; timerSecsOn=t.sec;
timerHoursOff=timeHour; timerMinsOff=t.min; timerSecsOff=t.sec;
timerAmPmOn=AM_PM; timerAmPmOff=AM_PM;
timerSetSu=0; timerSetMo=0; timerSetTu=0; timerSetWe=0;
timerSetTh=0; timerSetFr=0; timerSetSa=0;
dispScreen=9;
clearScreen();
setTimerScreen();
}
if ((mistingT1OnH>0) || (mistingT1OnM>0) || (mistingT1OnS>0) || (mistingT1OffH>0) || (mistingT1OffM>0) || (mistingT1OffS>0))
{
if ((x>=onOffTimerButton1[0]) && (y>=onOffTimerButton1[1]) && (x<=onOffTimerButton1[2]) && (y<=onOffTimerButton1[3])) //Pushing On/Off Button
{
if (mistingSwitch1OnOff==false)
{
mistingSwitch1OnOff=true;
} else {
mistingSwitch1OnOff=false;}
waitForIt(onOffTimerButton1[0], onOffTimerButton1[1], onOffTimerButton1[2], onOffTimerButton1[3]);
SaveMistingSwitch1OnOffToEEPROM();
dispScreen=10;
clearScreen();
displayTimerScreen();
}
if ((x>=resetTimerButton1[0]) && (y>=resetTimerButton1[1]) && (x<=resetTimerButton1[2]) && (y<=resetTimerButton1[3])) //Pushing Reset Button
{
waitForIt(resetTimerButton1[0], resetTimerButton1[1], resetTimerButton1[2], resetTimerButton1[3]);
mistingT1OnH=0; mistingT1OnM=0; mistingT1OnS=0;
mistingT1OffH=0; mistingT1OffM=0; mistingT1OffS=0;
timerAmPm1On=1; timerAmPm1Off=1;
timerSetSu1=0; timerSetMo1=0; timerSetTu1=0; timerSetWe1=0;
timerSetTh1=0; timerSetFr1=0; timerSetSa1=0;
mistingSwitch1OnOff=false;
SaveMistingSwitch1OnOffToEEPROM();
SaveMisting1ToEEPROM();
dispScreen=10;
clearScreen();
displayTimerScreen();
}
}
if ((x>=1) && (y>=59) && (x<=318) && (y<=83) // Set Misting Timer 2
&&(mistingT2OnH==0) && (mistingT2OnM==0) && (mistingT2OnS==0)
&& (mistingT2OffH==0) && (mistingT2OffM==0) && (mistingT2OffS==0)
|| (x>=1) && (y>=59) && (x<=220) && (y<=83))
{
timerPage=2;
timerHoursOn=timeHour; timerMinsOn=t.min; timerSecsOn=t.sec;
timerHoursOff=timeHour; timerMinsOff=t.min; timerSecsOff=t.sec;
timerAmPmOn=AM_PM; timerAmPmOff=AM_PM;
timerSetSu=0; timerSetMo=0; timerSetTu=0; timerSetWe=0;
timerSetTh=0; timerSetFr=0; timerSetSa=0;
dispScreen=9;
clearScreen();
setTimerScreen();
}
if ((mistingT2OnH>0) || (mistingT2OnM>0) || (mistingT2OnS>0) || (mistingT2OffH>0) || (mistingT2OffM>0) || (mistingT2OffS>0))
{
if ((x>=onOffTimerButton2[0]) && (y>=onOffTimerButton2[1]) && (x<=onOffTimerButton2[2]) && (y<=onOffTimerButton2[3])) //Pushing On/Off Button
{
if (mistingSwitch2OnOff==false)
{
mistingSwitch2OnOff=true;
} else {
mistingSwitch2OnOff=false;}
waitForIt(onOffTimerButton2[0], onOffTimerButton2[1], onOffTimerButton2[2], onOffTimerButton2[3]);
SaveMistingSwitch2OnOffToEEPROM();
dispScreen=10;
clearScreen();
displayTimerScreen();
}
if ((x>=resetTimerButton2[0]) && (y>=resetTimerButton2[1]) && (x<=resetTimerButton2[2]) && (y<=resetTimerButton2[3])) //Pushing Reset Button
{
waitForIt(resetTimerButton2[0], resetTimerButton2[1], resetTimerButton2[2], resetTimerButton2[3]);
mistingT2OnH=0; mistingT2OnM=0; mistingT2OnS=0;
mistingT2OffH=0; mistingT2OffM=0; mistingT2OffS=0;
timerAmPm2On=1; timerAmPm2Off=1;
timerSetSu2=0; timerSetMo2=0; timerSetTu2=0; timerSetWe2=0;
timerSetTh2=0; timerSetFr2=0; timerSetSa2=0;
mistingSwitch2OnOff=false;
SaveMistingSwitch2OnOffToEEPROM();
SaveMisting2ToEEPROM();
dispScreen=10;
clearScreen();
displayTimerScreen();
}
}
if ((x>=1) && (y>=87) && (x<=318) && (y<=111) // Set Misting Timer 3
&&(mistingT3OnH==0) && (mistingT3OnM==0) && (mistingT3OnS==0)
&& (mistingT3OffH==0) && (mistingT3OffM==0) && (mistingT3OffS==0)
|| (x>=1) && (y>=87) && (x<=220) && (y<=111))
{
timerPage=3;
timerHoursOn=timeHour; timerMinsOn=t.min; timerSecsOn=t.sec;
timerHoursOff=timeHour; timerMinsOff=t.min; timerSecsOff=t.sec;
timerAmPmOn=AM_PM; timerAmPmOff=AM_PM;
timerSetSu=0; timerSetMo=0; timerSetTu=0; timerSetWe=0;
timerSetTh=0; timerSetFr=0; timerSetSa=0;
dispScreen=9;
clearScreen();
setTimerScreen();
}
if ((mistingT3OnH>0) || (mistingT3OnM>0) || (mistingT3OnS>0) || (mistingT3OffH>0) || (mistingT3OffM>0) || (mistingT3OffS>0))
{
if ((x>=onOffTimerButton3[0]) && (y>=onOffTimerButton3[1]) && (x<=onOffTimerButton3[2]) && (y<=onOffTimerButton3[3])) //Pushing On/Off Button
{
if (mistingSwitch3OnOff==false)
{
mistingSwitch3OnOff=true;
} else {
mistingSwitch3OnOff=false;}
waitForIt(onOffTimerButton3[0], onOffTimerButton3[1], onOffTimerButton3[2], onOffTimerButton3[3]);
SaveMistingSwitch3OnOffToEEPROM();
dispScreen=10;
clearScreen();
displayTimerScreen();
}
if ((x>=resetTimerButton3[0]) && (y>=resetTimerButton3[1]) && (x<=resetTimerButton3[2]) && (y<=resetTimerButton3[3])) //Pushing Reset Button
{
waitForIt(resetTimerButton3[0], resetTimerButton3[1], resetTimerButton3[2], resetTimerButton3[3]);
mistingT3OnH=0; mistingT3OnM=0; mistingT3OnS=0;
mistingT3OffH=0; mistingT3OffM=0; mistingT3OffS=0;
timerAmPm3On=1; timerAmPm3Off=1;
timerSetSu3=0; timerSetMo3=0; timerSetTu3=0; timerSetWe3=0;
timerSetTh3=0; timerSetFr3=0; timerSetSa3=0;
mistingSwitch3OnOff=false;
SaveMistingSwitch3OnOffToEEPROM();
SaveMisting3ToEEPROM();
dispScreen=10;
clearScreen();
displayTimerScreen();
}
}
if ((x>=1) && (y>=115) && (x<=318) && (y<=139) // Set Misting Timer 4
&&(mistingT4OnH==0) && (mistingT4OnM==0) && (mistingT4OnS==0)
&& (mistingT4OffH==0) && (mistingT4OffM==0) && (mistingT4OffS==0)
|| (x>=1) && (y>=115) && (x<=220) && (y<=139))
{
timerPage=4;
timerHoursOn=timeHour; timerMinsOn=t.min; timerSecsOn=t.sec;
timerHoursOff=timeHour; timerMinsOff=t.min; timerSecsOff=t.sec;
timerAmPmOn=AM_PM; timerAmPmOff=AM_PM;
timerSetSu=0; timerSetMo=0; timerSetTu=0; timerSetWe=0;
timerSetTh=0; timerSetFr=0; timerSetSa=0;
dispScreen=9;
clearScreen();
setTimerScreen();
}
if ((mistingT4OnH>0) || (mistingT4OnM>0) || (mistingT4OnS>0) || (mistingT4OffH>0) || (mistingT4OffM>0) || (mistingT4OffS>0))
{
if ((x>=onOffTimerButton4[0]) && (y>=onOffTimerButton4[1]) && (x<=onOffTimerButton4[2]) && (y<=onOffTimerButton4[3])) //Pushing On/Off Button
{
if (mistingSwitch4OnOff==false)
{
mistingSwitch4OnOff=true;
} else {
mistingSwitch4OnOff=false;}
waitForIt(onOffTimerButton4[0], onOffTimerButton4[1], onOffTimerButton4[2], onOffTimerButton4[3]);
SaveMistingSwitch4OnOffToEEPROM();
dispScreen=10;
clearScreen();
displayTimerScreen();
}
if ((x>=resetTimerButton4[0]) && (y>=resetTimerButton4[1]) && (x<=resetTimerButton4[2]) && (y<=resetTimerButton4[3])) //Pushing Reset Button
{
waitForIt(resetTimerButton4[0], resetTimerButton4[1], resetTimerButton4[2], resetTimerButton4[3]);
mistingT4OnH=0; mistingT4OnM=0; mistingT4OnS=0;
mistingT4OffH=0; mistingT4OffM=0; mistingT4OffS=0;
timerAmPm4On=1; timerAmPm4Off=1;
timerSetSu4=0; timerSetMo4=0; timerSetTu4=0; timerSetWe4=0;
timerSetTh4=0; timerSetFr4=0; timerSetSa4=0;
mistingSwitch4OnOff=false;
SaveMistingSwitch4OnOffToEEPROM();
SaveMisting4ToEEPROM();
dispScreen=10;
clearScreen();
displayTimerScreen();
}
}
break;
i have tryed doing it like this and it doesnt seem to work....
Code:
case 10: //--------------------- Display Set Timer SCREEN -------------------------
byte timerOnH[]={0, mistingT1OnH, mistingT2OnH, mistingT3OnH, mistingT4OnH},
timerOnM[]={0, mistingT1OnM, mistingT2OnM, mistingT3OnM, mistingT4OnM},
timerOnS[]={0, mistingT1OnS, mistingT2OnS, mistingT3OnS, mistingT4OnS},
timerOffH[]={0, mistingT1OffH, mistingT2OffH, mistingT3OffH, mistingT4OffH},
timerOffM[]={0, mistingT1OffM, mistingT2OffM, mistingT3OffM, mistingT4OffM},
timerOffS[]={0, mistingT1OffS, mistingT2OffS, mistingT3OffS, mistingT4OffS};
byte timerAmPmOnx[]={0, timerAmPm1On, timerAmPm2On, timerAmPm3On, timerAmPm4On},
timerAmPmOffx[]={0, timerAmPm1Off, timerAmPm2Off, timerAmPm3Off, timerAmPm4Off};
byte timerSetSux[]={0, timerSetSu1, timerSetSu2, timerSetSu3, timerSetSu4},
timerSetMox[]={0, timerSetMo1, timerSetMo2, timerSetMo3, timerSetMo4},
timerSetTux[]={0, timerSetTu1, timerSetTu2, timerSetTu3, timerSetTu4},
timerSetWex[]={0, timerSetWe1, timerSetWe2, timerSetWe3, timerSetWe4},
timerSetThx[]={0, timerSetTh1, timerSetTh2, timerSetTh3, timerSetTh4},
timerSetFrx[]={0, timerSetFr1, timerSetFr2, timerSetFr3, timerSetFr4},
timerSetSax[]={0, timerSetSa1, timerSetSa2, timerSetSa3, timerSetSa4};
boolean SwitchOnOff[]={0, mistingSwitch1OnOff, mistingSwitch2OnOff, mistingSwitch3OnOff, mistingSwitch4OnOff};
if (offMisting2RH>0)
{
// do nothing
} else {
for (byte xx= 1; xx< 5; xx++)
{
if ((x>=1) && (y>=4 + xx * 28) && (x<=318) && (y<=27 + xx * 28) // Set Misting Timer 1
&& (timerOnH[xx]==0) && (timerOnM[xx]==0) && (timerOnS[xx]==0)
&& (timerOffH[xx]==0) && (timerOffM[xx]==0) && (timerOffS[xx]==0)
|| (x>=1) && (y>=4 + xx * 28) && (x<=220) && (y<=27 + xx * 28))
{
timerPage=xx;
timerHoursOn=timeHour; timerMinsOn=t.min; timerSecsOn=t.sec;
timerHoursOff=timeHour; timerMinsOff=t.min; timerSecsOff=t.sec;
timerAmPmOn=AM_PM; timerAmPmOff=AM_PM;
timerSetSu=0; timerSetMo=0; timerSetTu=0; timerSetWe=0;
timerSetTh=0; timerSetFr=0; timerSetSa=0;
dispScreen=9;
clearScreen();
setTimerScreen();
}
if ((timerOnH[xx]>0) || (timerOnM[xx]>0) || (timerOnS[xx]>0) || (timerOffH[xx]>0) || (timerOffM[xx]>0) || (timerOffS[xx]>0))
{
if ((x>=onOffTimerButton1[0]) && (y>=5 + xx * 28) && (x<=onOffTimerButton1[2]) && (y<=25 + xx * 28)) //Pushing On/Off Button
{
if (SwitchOnOff[xx]==false)
{
SwitchOnOff[xx]=true;
} else {
SwitchOnOff[xx]=false;}
waitForIt(onOffTimerButton1[0], (5 + xx * 28), onOffTimerButton1[2], (25 + xx * 28));
if (xx=1){
SaveMistingSwitch1OnOffToEEPROM();}
if (xx=2){
SaveMistingSwitch2OnOffToEEPROM();}
if (xx=3){
SaveMistingSwitch3OnOffToEEPROM();}
if (xx=4){
SaveMistingSwitch4OnOffToEEPROM();}
dispScreen=10;
clearScreen();
displayTimerScreen();
}
if ((x>=resetTimerButton1[0]) && (y>=5 + xx * 28) && (x<=resetTimerButton1[2]) && (y<=25 + xx * 28)) //Pushing Reset Button
{
waitForIt(resetTimerButton1[0], (y>=5 + xx * 28), resetTimerButton1[2], (25 + xx * 28));
timerOnH[xx]=0; timerOnM[xx]=0; timerOnS[xx]=0;
timerOffH[xx]=0; timerOffM[xx]=0; timerOffS[xx]=0;
timerAmPmOnx[xx]=1; timerAmPmOffx[xx]=1;
timerSetSux[xx]=0; timerSetMox[xx]=0; timerSetTux[xx]=0; timerSetWex[xx]=0;
timerSetThx[xx]=0; timerSetFrx[xx]=0; timerSetSax[xx]=0;
SwitchOnOff[xx]=false;
if (xx=1){
SaveMistingSwitch1OnOffToEEPROM();
SaveMisting1ToEEPROM();}
if (xx=2){
SaveMistingSwitch2OnOffToEEPROM();
SaveMisting2ToEEPROM();}
if (xx=3){
SaveMistingSwitch3OnOffToEEPROM();
SaveMisting3ToEEPROM();}
if (xx=4){
SaveMistingSwitch4OnOffToEEPROM();
SaveMisting4ToEEPROM();}
dispScreen=10;
clearScreen();
displayTimerScreen();
}
}
}
break;
any one with arduino knowledge that can help would be great...