// Menu file for iSMART TFT module ///////// //Files// ///////// LIB(fntAscii24,"SDHC/asc_24.fnt"); //Load ASCII 24 Font File LIB(fntAscii32,"SDHC/asc_32.fnt"); //Load ASCII 32 Font File LIB(fntAscii72,"SDHC/asc_72.fnt"); //Load ASCII 72 Font File LIB(backg,"SDHC/back.bmp"); //Load background Image File LIB(button,"SDHC/button.bmp"); //Load Button Image File LIB(ybutton,"SDHC/ybutton.bmp"); //Load Year Button Image File LIB(Pkeys,"SDHC/Pkeys.bmp"); //Load Plus key Image File LIB(Mkeys,"SDHC/Mkeys.bmp"); //Load Minus key Image File /////////// //Styles// /////////// STYLE(MainPg,Page){image=backg;} //Style for page background STYLE(Htext,Text){font=fntAscii24;col=blue;maxLen=64;maxRows=1;curRel=CC;} //Text styel for Edit Page and titles STYLE(Btext,Text){font=fntAscii24;col=white;maxLen=64;maxRows=1;curRel=CC;} //Text style for the Confirm and Edit Button STYLE(Stext,Text){font=fntAscii32;col=red;maxLen=64;maxRows=1;curRel=CC;} //Text style for the seconds on TimePage STYLE(Dtext,Text){font=fntAscii32;col=blue;maxLen=64;maxRows=1;curRel=CC;} //Text style for Date on TimePage STYLE(HMtext,Text){font=fntAscii72;col=Red;maxLen=64;maxRows=1;curRel=CC;} //Text style for Hours and Mins on TimePage STYLE(BoxGreen,DRAW){type=B; col=white; width=1; back=lime; curRel=CC;} //Green Box for confirm and edit buttons STYLE(DayStyle,Data) {type=text; length=6; format="jS"; } //Day (no zeros) with suffix STYLE(MonthStyle2,Data) {type=text; length=4; format="m"; } //Month 1-12 STYLE(YearStyle,Data) {type=text; length=5; format="Y"; } //Full Year STYLE(HourStyle,Data) {type=text; length=3; format="H"; } //24 Hour with zero STYLE(MinuteStyle,Data) {type=text; length=3; format="i"; } //Minutes with zero STYLE(SecondStyle,Data) {type=text; length=3; format="s"; } //Seconds with zero STYLE(TimeStyle,Data) {type=text; length=8; format="H:i";} //Hours:Minutes as above STYLE(DateStyle,Data) {type=text; length=50; format="jS F Y"; } //Date as above STYLE(stGenImg,Image) {curRel=CC;} /////////////// //Variables// ////////////// VAR(years,2011,S16); //Initial Year Value VAR(months,08,S8); //Initial Month Value VAR(days,16,S8); //Initial Day Value VAR(hours,11,S8); //Initial Hour Value VAR(mins,28,S8); //Initial Minute Value VAR(secs,07,S8); //Initial second Value VAR(yearst,"",TXT); //Year text string VAR(monthst,"",TXT); //Month text string VAR(dayst,"",TXT); //Day text string VAR(hourst,"",TXT); //Hour text string VAR(minst,"",TXT); //Minute text string VAR(secst,"",TXT); //Second text string VAR(DayVar,"",DayStyle); //Create a variable to store the formatted Day string VAR(MonthVar,"",MonthStyle2); //Create a variable to store the formatted Month string VAR(YearVar,"",YearStyle); //Create a variable to store the formatted Year string VAR(HourVar,"",HourStyle); //Create a variable to store the formatted Hour string VAR(MinuteVar,"",MinuteStyle); //Create a variable to store the formatted Minute string VAR(SecondVar,"",SecondStyle); //Create a variable to store the formatted Second string VAR(DateVar,"",DateStyle); //Create a variable to store the formatted Date string VAR(TimeVar,"",TimeStyle); //Create a variable to store the formatted Time string /////////////// //Edit page// /////////////// PAGE(EditPage,MainPg) { POSN(159,10); TEXT(Title,"Time and Date Demo",Htext); //Time and Date Title POSN(159,11); TEXT(TitleU,"___________________",Htext); //Time and Date Underline POSN(29,38); TEXT(DayT,"Day",Htext); //Day Heading POSN(29,82); IMG(DayB,button,stGenImg); //Box to show day value POSN(74,67); IMG(DayP,Pkeys,stGenImg); //Increase day button POSN(74,97); IMG(DayM,Mkeys,stGenImg); //Decrease day button POSN(29,80); TEXT(DayV,days,Htext); //day value POSN(74,67); KEY(DayPK,[RUN(DayPF);],24,20,TOUCHR); //Key that increases the day POSN(74,97); KEY(DayMK,[RUN(DayMF);],24,20,TOUCHR); //key that decreases the day POSN(119,38); TEXT(MonthT,"Month",Htext); //Month heading POSN(119,82); IMG(MonthB,button,stGenImg); //Box to show month value POSN(164,67); IMG(MonthP,Pkeys,stGenImg); //Increase month button POSN(164,97); IMG(MonthM,Mkeys,stGenImg); //Decrease day button POSN(119,80); TEXT(MonthV,months,Htext); //month value POSN(164,67); KEY(MonthPK,[RUN(MonthPF);],24,20,TOUCHR);//key that increases the month POSN(164,97); KEY(MonthMK,[RUN(MonthMF);],24,20,TOUCHR);//key that decreases the month POSN(236,38); TEXT(YearT,"Year",Htext); //Year heading POSN(234,82); IMG(YearB,ybutton,stGenImg); //Box to show year value POSN(303,67); IMG(YearP,Pkeys,stGenImg); //Increase year button POSN(303,97); IMG(YearM,Mkeys,stGenImg); //Decrease year button POSN(234,80); TEXT(YearV,years,Htext); //Year value POSN(303,67); KEY(YearPK,[RUN(YearPF);],24,20,TOUCHR); //Key that increases the year POSN(303,97); KEY(YearMK,[RUN(YearMF);],24,20,TOUCHR); //Key that decreases the year POSN(29,122); TEXT(HourT,"Hour",Htext); //Hour heading POSN(29,166); IMG(HourB,button,stGenImg); //Box to show the hour value POSN(74,151); IMG(HourP,Pkeys,stGenImg); //Increase hour button POSN(74,181); IMG(HourM,Mkeys,stGenImg); //Decrease hour button POSN(29,164); TEXT(HourV,hours,Htext); //Hour Value POSN(74,151); KEY(HourPK,[RUN(HourPF);],24,20,TOUCHR); //key that increases the hour POSN(74,181); KEY(HourMK,[RUN(HourMF);],24,20,TOUCHR); //key that decreases the hour POSN(119,122); TEXT(MinuteT,"Minute",Htext); //Minute heading POSN(119,166); IMG(MinuteB,button,stGenImg); //box to show the minute heading POSN(164,151); IMG(MinuteP,Pkeys,stGenImg); //increase minute button POSN(164,181); IMG(MinuteM,Mkeys,stGenImg); //decrease minute button POSN(119,164); TEXT(MinuteV,mins,Htext); //Minute value POSN(164,151); KEY(MinutePK,[RUN(MinutePF);],24,20,TOUCHR); //key that increase the minute POSN(164,181); KEY(MinuteMK,[RUN(MinuteMF);],24,20,TOUCHR); //key that decreases the minute POSN(209,122); TEXT(SecondT,"Second",Htext); //Second heading POSN(209,166); IMG(SecondB,button,stGenImg); //box to show the second heading POSN(254,151); IMG(SecondP,Pkeys,stGenImg); //increase second button POSN(254,181); IMG(SecondM,Mkeys,stGenImg); //decrease second button POSN(209,164); TEXT(SecondV,secs,Htext); //second value POSN(254,151); KEY(SecondPK,[RUN(SecondPF);],24,20,TOUCHR); //key that incresae the second POSN(254,181); KEY(SecondMK,[RUN(SecondMF);],24,20,TOUCHR); //key that decreases the second POSN(159,218); DRAW(ConfirmB,94,40,BoxYellow); //Confirm Button POSN(159,218); DRAW(ConfirmB1,88,34,BoxYellow); //Confirm Button POSN(159,216); TEXT(ConfirmT,"Confirm",Btext); //Confirm Text POSN(159,218); KEY(KeyC,[RUN(FDateStr);RUN(UpdateT);],94,40,TOUCH); //Key to pass the values to the RTC and show on Timepage } /////////////// //Functions// /////////////// //Format Date and Time String FUNC(FDateStr) { IF(days<10?[LOAD(dayst,"0",days);]:[LOAD(dayst,days);]); //Formats the day to 2 char if less than 10 and loads into the variable IF(months<10?[LOAD(monthst,"0",months);]:[LOAD(monthst,months);]); //Formats the month to 2 char if less than 10 and loads into the variable LOAD(yearst,years); //Load the Year value into a variable IF(hours<10?[LOAD(hourst,"0",hours);]:[LOAD(hourst,hours);]); //Formats the hour to 2 char if less than 10 and loads into the variable IF(mins<10?[LOAD(minst,"0",mins);]:[LOAD(minst,mins);]); //Formats the minutes to 2 char if less than 10 and loads into the variable IF(secs<10?[LOAD(secst,"0",secs);]:[LOAD(secst,secs);]); //Formats the seconds to 2 char if less than 10 and loads into the variable LOAD(RTC,yearst,":",monthst,":",dayst,":",hourst,":",minst,":",secst); //Loads the RTC with the variables put together } //Upper and lower limits //keys to increase or decrease the values and update edit page as well as limit values FUNC(DayPF){IF(days<31?[CALC(days,days,1,"+");TEXT(DayV,days);]:[LOAD(days,1);TEXT(DayV,days);]);;} FUNC(DayMF){IF(days>1?[CALC(days,days,1,"-");TEXT(DayV,days);]:[LOAD(days,31);TEXT(DayV,days);]);;} FUNC(MonthPF){IF(months<12?[CALC(months,months,1,"+");TEXT(MonthV,months);]:[LOAD(months,1);TEXT(MonthV,months);]);;} FUNC(MonthMF){IF(months>1?[CALC(months,months,1,"-");TEXT(MonthV,months);]:[LOAD(months,12);TEXT(MonthV,months);]);;} FUNC(YearPF){IF(years<2099?[CALC(years,years,1,"+");TEXT(YearV,years);]:[LOAD(years,1900);TEXT(YearV,years);]);;} FUNC(YearMF){IF(years>1900?[CALC(years,years,1,"-");TEXT(YearV,years);]:[LOAD(years,2099);TEXT(YearV,years);]);;} FUNC(HourPF){IF(hours<23?[CALC(hours,hours,1,"+");TEXT(HourV,hours);]:[LOAD(hours,0);TEXT(HourV,hours);]);;} FUNC(HourMF){IF(hours>0?[CALC(hours,hours,1,"-");TEXT(HourV,hours);]:[LOAD(hours,23);TEXT(HourV,hours);]);;} FUNC(MinutePF){IF(mins<59?[CALC(mins,mins,1,"+");TEXT(MinuteV,mins);]:[LOAD(mins,0);TEXT(MinuteV,mins);]);;} FUNC(MinuteMF){IF(mins>0?[CALC(mins,mins,1,"-");TEXT(MinuteV,mins);]:[LOAD(mins,59);TEXT(MinuteV,mins);]);;} FUNC(SecondPF){IF(secs<59?[CALC(secs,secs,1,"+");TEXT(SecondV,secs);]:[LOAD(secs,0);TEXT(SecondV,secs);]);;} FUNC(SecondMF){IF(secs>0?[CALC(secs,secs,1,"-");TEXT(SecondV,secs);]:[LOAD(secs,59);TEXT(SecondV,secs);]);;} FUNC(UpdateT) //Time Loop { LOAD(CNTSECS,0); //Loads the CNTSECS to 0 so the loop on the timepage operates LOAD(SecondVar,RTC); //Loads the seconds part of the RTC into SecondVar LOAD(TimeVar,RTC); //Loads the Hours and minutes part of the RTC to the TimeVar LOAD(DateVar,RTC); //Loads the Date part of the RTC to the DateVar TEXT(SecondV1,SecondVar); //Writes the variable into the seconds part on the TimePage TEXT(Time,TimeVar); //Writes the variable into the time part on the TimePage TEXT(Date,DateVar); //Writes the variable into the Date part on the TimePage SHOW(TimePage); //Show TimePage, acts a refresh when accessed from the loop on the TimePage } FUNC(ShowFnc) //Shows time and date editor with present times { LOAD(DayVar,RTC); //Loads the Day part of the RTC into the variable LOAD(MonthVar2,RTC); //Loads the Month part of the RTC into the variable LOAD(YearVar,RTC); //Loads the Year part of the RTC into the variable LOAD(HourVar,RTC); //Loads the Hour part of the RTC into the variable LOAD(MinuteVar,RTC); //Loads the Minute part of the RTC into the Variable //It is not necessary to load the seconds variable as this is the same as in the updateT function LOAD(days,DayVar); //Load the dayvar(formatted variable) into the days variable LOAD(months,MonthVar2); //Load the monthVar2(formatted variable) into the months variable LOAD(years,YearVar); //Load the Yearvar(formatted variable) into the years variable LOAD(hours,HourVar); //Load the HourVar(formatted variable) into the hour variable LOAD(mins,MinuteVar); //Load the MinuteVar(formatted variable) into the mins variable LOAD(secs,SecondVar); //Load teh SecondVar(formatted variable) into the secs variable TEXT(DayV,days); //Write the days variable into the day box TEXT(MonthV,months); //write the months variable into the month box TEXT(YearV,years); //write the years variable into the year box TEXT(HourV,hours); //write the hours variable into the hour box TEXT(MinuteV,mins); //write the mins variable into the minute box TEXT(SecondV,secs); //write the secs variable into the second box SHOW(EditPage); //Show the editpage } //////////////// //Time Page// //////////////// PAGE(TimePage,MainPg) { POSN(159,10);TEXT(Title,"Time and Date Demo",Htext); //Time and Date title POSN(+0,+1); TEXT(TitleU,"___________________",Htext); //Time and Date underline POSN(139,80); TEXT(Time,"11:28",HMtext); //Hours and Minute Text POSN(+95,+17);TEXT(MCS,":",Stext); //Seconds seperator POSN(+23,+0); TEXT(SecondV1,"07",Stext); //Seconds Text POSN(159,+48);TEXT(Date,"16th August 2011",Dtext); //Date Text POSN(+0,218);DRAW(EditB,94,40,BoxGreen); //Edit Button DRAW(EditB1,88,34,BoxGreen); //Edit Button POSN(+0,-2); TEXT(EditT,"Edit",Btext); //Edit Text POSN(+0,+2); KEY(KeyE,[RUN(ShowFnc);],120,60,TOUCHR); //Key to Show Edit Page with the current time and date values LOOP(timeloop,FOREVER) { IF(CNTSECS>0?UpdateT); //Loop which constantly updates time and date } } SHOW(EditPage);