// Menu file TU480A.MNU for Elevator System using TU480X272C // Updated 20-Sep-2010 // Floors are 15(15)..01(1), G(0), P1(-1), B2(-2) ////////// //Files// ///////// LIB(libImgNum0,"SDHC/Lift0.bmp?back=\\0000CD"); //Load Number 0 + transparency LIB(libImgNum1,"SDHC/Lift1.bmp?back=\\0000CD"); //Load Number 1 + transparency LIB(libImgNum2,"SDHC/Lift2.bmp?back=\\0000CD"); //Load Number 2 + transparency LIB(libImgNum3,"SDHC/Lift3.bmp?back=\\0000CD"); //Load Number 3 + transparency LIB(libImgNum4,"SDHC/Lift4.bmp?back=\\0000CD"); //Load Number 4 + transparency LIB(libImgNum5,"SDHC/Lift5.bmp?back=\\0000CD"); //Load Number 5 + transparency LIB(libImgNum6,"SDHC/Lift6.bmp?back=\\0000CD"); //Load Number 6 + transparency LIB(libImgNum7,"SDHC/Lift7.bmp?back=\\0000CD"); //Load Number 7 + transparency LIB(libImgNum8,"SDHC/Lift8.bmp?back=\\0000CD"); //Load Number 8 + transparency LIB(libImgNum9,"SDHC/Lift9.bmp?back=\\0000CD"); //Load Number 9 + transparency LIB(libImgBChar,"SDHC/LiftB.bmp?back=\\0000CD"); //Load Character B + transparency LIB(libImgGChar,"SDHC/LiftG.bmp?back=\\0000CD"); //Load Character G + transparency LIB(libImgPChar,"SDHC/LiftP.bmp?back=\\0000CD"); //Load Character P + transparency LIB(libImgDTri,"SDHC/LiftDown.bmp?back=\\0000CD"); //Load red triangle + transparency LIB(libImgUTri,"SDHC/LiftUp.bmp?back=\\0000CD"); //Load green triangle + transparency LIB(libImgPMTD,"SDHC/LiftClos.bmp"); //Load the warning message LIB(libImgSelFlr,"SDHC/LiftSel.bmp"); //Load the Select Floor Page LIB(libImgDoors,"SDHC/LiftOpen.bmp"); //Load the Doors Page LIB(fntAscii32, "SDHC/asc_32.fnt" ); //Load Ascii Font 32 /////////// //Styles// /////////// STYLE(stLiftPg,Page){back=\\0000CD;} //create a style for the lift page STYLE(stLiftMainPg,Page){back=\\0000CD;image=libImgSelFlr;} //create a style for the lift main page STYLE(stGenImg,Image){curRel=CC;} //create a style to be used for the images with the cursor placement set to CC STYLE(stTxt32Wht64, Text){font=fntAscii32; col=white; maxLen=64; maxRows=1; curRel=CC;} //set the attributes to the text style used and the font style used from the library /////////////// //Variables// ////////////// VAR(vS8,0,S8); //create a signed 8 bit variable to calculate floor levels VAR(ptrLiftArr>"libImgUTri",PTR); //create a pointer to show the arrow images on the floor indication page VAR(ptrLiftTens>"libImgGChar",PTR); //create a pointer to display current floor number images with the tenth place value (tens) VAR(ptrLiftOnes>"libImgNum1",PTR); //create a pointer to display current floor number images with the first place value (ones_ VAR(vReqd,0,S8); //create a signed 8 bit variable to store the user's required floor value VAR(vThis,0,S8); //create a signed 8 bit variable to store the user's current floor value VAR(vMove,0,U8); //create an unsigned 8bit variable to indicate if the lift is moving move=1, stop=0 /////////////// //Functions// ////////////// FUNC(fncGo) //start lift moving when key pressed on main page { LOAD(vMove,1); //identify the lift as moving vMove=1, when vMove = 0 lift stops. RUN(fncDoorClose); //indicate doors are closing RUN(fncShowFlr); //indicate floor numbers while moving to the selected floor } FUNC(fncDoorClose) //start a door closing animation { //show the page called pgShut for 400ms then the pgBlnk for 100ms, this is repeated 3 times SHOW(pgShut);WAIT(400); SHOW(pgBlnk);WAIT(100); SHOW(pgShut);WAIT(400); SHOW(pgBlnk);WAIT(100); SHOW(pgShut);WAIT(400); SHOW(pgBlnk);WAIT(100); } FUNC(fncShowFlr) //determing and show current floor { IF(vThis>0?[RUN(fncvThisup);]); //if current floor is higher than ground floor and determine the correct place value of the required floor IF(vThis=0?[RUN(fncvThis);]); //if current floor is ground floor, display "G" level IF(vThis=-1?[RUN(fncvThiso);]); //if current floor is 1st parking level, display "P1" level IF(vThis=-2?[RUN(fncvThist);]); //if current floor is 2nd basement level, display "B2" level IMG(img10s,ptrLiftTens); //set the img10s for the tenth place value using the tens pointer IMG(img1s,ptrLiftOnes); //img1s for first place value using the ones pointer SHOW(pgIND); //show the level indication page WAIT(1000); //each level change indication is displayed for 1 second } FUNC(fncvThisup) //calculate and display current floor with appropriate place values { CALC(vS8,vThis,10,"/"); //divide the current floor level by 10 LOAD(ptrLiftTens>"libImgNum",vS8); //load the calculated value to the tens pointer CALC(vS8,vThis,10,"%"); //ensures that the floor level is always positive LOAD(ptrLiftOnes>"libImgNum",vS8); //load the calculated value to the ones pointer SHOW(img10s,img1s); //show the tenth and first place value images } FUNC(fncvThis) //display ground level { LOAD(ptrLiftTens>"libImgGChar"); //use the tens pointer to display "G" SHOW(img10s); //display G on the tenth place value image HIDE(img1s); //hide the first place value image } FUNC(fncvThiso) //display 1st parking level { LOAD(ptrLiftTens>"libImgPChar"); //use the tens pointer to display "P" LOAD(ptrLiftOnes>"libImgNum1"); //use the ones pointer to display "1" SHOW(img10s,img1s); //show the tenth and first place value images } FUNC(fncvThist) //display 2nd basement level { LOAD(ptrLiftTens>"libImgBChar"); //use the tens pointer to display "B" LOAD(ptrLiftOnes>"libImgNum2"); //the ones pointer to display "2" SHOW(img10s,img1s); //show the tenth and first place value images } FUNC(fncMove) //indicate floor number while the lift is moving { IF(vThis>vReqd?[RUN(fncVthishVreqd);]); //if the current floor is higher than the required floor, indicate lift is moving DOWN IF(vThis"libImgDTri"); //use the pointer to show DOWN arrow IMG(imgTri,ptrLiftArr); //display DOWN arrow SHOW(imgTri); //show arrow image RUN(fncShowFlr); //determine the correct floor level to display CALC(vThis,vThis,1,"-"); //vThis-1=new vThis value(floor destination) } FUNC(fncVthislVreqd) //show UP arrow and floor level increasing { LOAD(ptrLiftArr>"libImgUTri"); //use the pointer to show UP arrow IMG(imgTri,ptrLiftArr); //display UP arrow SHOW(imgTri); //show arrow image RUN(fncShowFlr); //determine the correct floor level to display CALC(vThis,vThis,1,"+"); //vThis+1=new vThis value(floor destination) } FUNC(fncVthisVreqd) //show door opening animation and back to floor selection page { LOAD(vMove,0); //lift is not moving HIDE(imgTri); //hide the floor arrow direction RUN(fncShowFlr); //determine the correct floor level to display RUN(fncDoorOpen); //indicate doors opening SHOW(pgLiftMain); //show the page pgLiftMain } FUNC(fncDoorOpen) //start a door opening animation { //show the page called pgOpen for 400ms then the pgBlnk for 100ms, this is repeated 3 times SHOW(pgOpen);WAIT(400); SHOW(pgBlnk);WAIT(100); SHOW(pgOpen);WAIT(400); SHOW(pgBlnk);WAIT(100); SHOW(pgOpen);WAIT(400); SHOW(pgBlnk);WAIT(100); } //////////// //Pages// /////////// PAGE(pgLiftMain,stLiftMainPg) //set the contents of the floor selection page { //when a touch area is pressed, the associated number is loaded into vReqd and the destination txtCurFlr and function fncGo is run POSN(69,78); KEY(keyFlr15,[LOAD(vReqd,15);TEXT(txtCurFlr,"15");RUN(fncGo);],90,84,TOUCH); //create touch area 15 at position x=69,y=78 POSN(184,+0); KEY(keyFlr14,[LOAD(vReqd,14);TEXT(txtCurFlr,"14");RUN(fncGo);],90,84,TOUCH); //create touch area 14 at position x=69,y=78 POSN(298,+0); KEY(keyFlr13,[LOAD(vReqd,13);TEXT(txtCurFlr,"13");RUN(fncGo);],90,84,TOUCH); //create touch area 13 at position x=69,y=78 POSN(409,+0); KEY(keyFlr12,[LOAD(vReqd,12);TEXT(txtCurFlr,"12");RUN(fncGo);],90,84,TOUCH); //create touch area 12 at position x=69,y=78 POSN(69,178); KEY(keyFlr11,[LOAD(vReqd,11);TEXT(txtCurFlr,"11");RUN(fncGo);],90,84,TOUCH); //create touch area 11 at position x=69,y=78 POSN(184,+0); KEY(keyFlrG, [LOAD(vReqd, 0);TEXT(txtCurFlr, "G");RUN(fncGo);],90,84,TOUCH); //create touch area 0 at position x=69,y=78 POSN(298,+0); KEY(keyFlrP1,[LOAD(vReqd,-1);TEXT(txtCurFlr,"P1");RUN(fncGo);],90,84,TOUCH); //create touch area -1 at position x=69,y=78 POSN(409,+0); KEY(keyFlrB2,[LOAD(vReqd,-2);TEXT(txtCurFlr,"B2");RUN(fncGo);],90,84,TOUCH); //create touch area -2 at position x=69,y=78 POSN(160,249);TEXT(txtCurFlrLbl,"CURRENT FLOOR",stTxt32Wht64); //set the position and create the static words "CURRENT FLOOR" POSN(330,+0); TEXT(txtCurFlr,"G",stTxt32Wht64); //set the position and create the text value for the current floor } PAGE(pgShut,stLiftPg) //create door closing page contents { POSN(239,135);IMG(imgDC,libImgPMTD,480,272,stGenImg); } PAGE(pgOpen,stLiftPg) //create the door opening page contents { POSN(239,135);IMG(imgDO,libImgDoors,480,272,stGenImg); } PAGE(pgBlnk,stLiftPg) //create a blank page to aid with simple animation { } PAGE(pgIND,stLiftPg) //set the contents of the level indication page { POSN(48,136);IMG(imgTri,ptrLiftArr,86,200,stGenImg);HIDE(imgTri); //create the UP or DOWN arrow which shows the direction of travel POSN(199,+0);IMG(img10s,ptrLiftTens,172,240,stGenImg); //create the floor level image (tenth place value) using the ptrLiftTens as the source POSN(396,+0);IMG(img1s,ptrLiftOnes,172,240,stGenImg); //create the floor level image (first place value) using the ptrLiftOnes as the source LOOP(lpLiftInd,FOREVER){IF(vMove=1?fncMove);} //create a loop to define when to call the function fncMove } SHOW(pgLiftMain); //RUN Main page