//Menu File for iSMART TFT module /////////// //Setup// ////////// SETUP(system) {touchsamples=15; touchdebounce=5; touchaccuracy=50;} //set up the system for a better touch interface ////////// //Files// ///////// LIB(borderb,"SDHC/Image2.bmp?back=\\00ff00"); //load borders of the scroll bar + transparency LIB(Backg,"SDHC/Sydney.bmp"); //load image LIB(WImg,"SDHC/Sydney.bmp?scale=60"); //load smaller scale of image LIB(Horiz,"SDHC/Horizs.bmp"); //load horizontal scroll bar slider LIB(Verti,"SDHC/Verts.bmp"); //load vertical scroll bar slider /////////////// //Variables// /////////////// VAR(TX,205,U16E); //create an unsigned 16 bit EEPROM variable to hold the last known touch X coordinate VAR(TY,205,U16E); //create an unsigned 16 bit EEPROM variable to hold the last known touch Y coordinate VAR(BGX,902,U16E); //create an unsigned 16 bit EEPROM variable to hold the last known X coordinate of the image VAR(BGY,486,U16E); //create an unsigned 16 bit EEPROM variable to hold the last known Y coordinate of the image VAR(slide,0,U8); //create an unsigned 8 bit variable to determine whether the horizontal or vertical scroll bar is touched /////////////// //Functions// /////////////// FUNC(TXFnc) //when slide value is 1,calculate the X coordinates of the horizontal slider { LOAD(TX,TOUCHX); //load the last known touch X coordinate of the user to the variable TX IF(TX<18?[LOAD(TX,18);]); //set the lower limit on how far the horizontal slider can go along the X axis IF(TX>434?[LOAD(TX,434);]); //set the upper limit on how far the horizontal slider can go along the X axis POSN(TX,255,HSlide); //set the position of the horizontal slider image to (TX,255) CALC(BGX,902,TX,"-"); //calculate how much the image moves, 902-TX(X coordinate)=new BGX value POSN(BGX,BGY,BG); //place the position of image with the new BGX value POSN(TX,255,dnH); //place the touch event dnH position of the horizontal slider to (TX,255) POSN(TX,255,upH); //place the touch event upH position of the horizontal slider to (TX,255) } FUNC(TYFnc) //when slide value is 2,calculate the Y coordinates of the vertical slider { LOAD(TY,TOUCHY); //load the last known touch Y coordinate of the user to the variable TY IF(TY<18?[LOAD(TY,18);]); //set the lower limit on how far the vertical slider can go along the Y axis IF(TY>227?[LOAD(TY,227);]); //set the lower limit on how far the vertical slider can go along the Y axis POSN(463,TY,VSlide); //set the position of the vertical slider image to (463,TY) CALC(BGY,486,TY,"-"); //calculate how much the image moves, 486-TY(Y coordinate)=new BGY coordinate POSN(BGX,BGY,BG); //place the position of image with the new BGY value POSN(463,TY,dnV); //place the touch event dnV position of the vertical slider to (463,TY) POSN(463,TY,upV); //place the touch event upV position of the vertical slider to (463,TY) //////////// //Styles// /////////// STYLE(MainP,PAGE) {back=white;} //create a style for the main page STYLE(BGIMG,IMAGE) {curRel=BR;} //create a style for the background image STYLE(CCImg,IMAGE) {curRel=CC;} //create a style for the scaled background image STYLE(TkeyU,key) {type=touch; action=U; delay=0;} //create a style with an UP touch(released) event STYLE(TkeyD,key) {type=touch; action=D; delay=0;} //create a style with a DOWN touch(pressed) event ////////// //Page// ////////// PAGE(HomePg,MainP) //set up the contents of main page { POSN(BGX,BGY); //set the position of the background image to variable (BGX,BGY) IMG(BG,Backg,BGIMG); //create the background image on the stated position above POSN(239,135); //set the position for the border image IMG(Border,borderb,CCImg); //create the border image on the stated position above //enable horizontal scrolling POSN(TX,255); //set the position of the following three entities to TX(variable),255 IMG(HSlide,Horiz,CCImg); //create the horizontal scroll slider image KEY(dnH,[VAR(slide,1);],30,30,TkeyD); //create an UP touch event and change Slide value to 1 KEY(upH,[VAR(slide,0);],30,30,TkeyU); //create a DOWN touch event and change Slide value to 0 //enable vertical scrolling POSN(463,TY); //set the position of the following three entities to 463,TY(variable) IMG(VSlide,Verti,CCImg); //create the vertical scroll slider image KEY(dnV,[VAR(slide,2);],30,30,TkeyD); //create an UP touch event and change Slide value to 2 KEY(upV,[VAR(slide,0);],30,30,TkeyU); //create a DOWN touch event and change Slide value to 0 POSN(225,121); KEY(SImg,[SHOW(WSimg,Sscrl);HIDE(SImg,dnH,upH,dnV,upV);],420,210,TOUCH); //create touch event to show the image and the hide scroll bar, scaled image POSN(239,135); //set the position of the image and touch event bellow IMG(WSimg,WImg,CCImg); //create the scaled image KEY(Sscrl,[HIDE(WSimg,Sscrl);SHOW(SImg,dnH,upH,dnV,upV);],470,260,TOUCH); //create touch event to hide the image and show the scroll bar, scaled image LOOP(scroll,FOREVER) //create a loop to define what touch instances should call what function { IF(slide=1?TXFnc); //if Slide value is 1 then move the horizontal scroll bar slider IF(slide=2?TYFnc);; //if Slide value is 2 then move the vertical scroll bar slider } } HIDE(WSimg,Sscrl); //hide the image WSimg and touch event Sscrl SHOW(HomePg); //show the page HomePg