// Menu file for iSMART TFT module // 03-Jan-2011 // Example of using RS232 to send and recieve information ///////// //Files// ///////// LIB( asc16,"SDHC/asc_16b.fnt" ); // Load 16 font /////////// //Setup// ////////// setup(RS2) { baud=19200; //num = 110 to 115200. Any value can be set to allow trimming for deviating clocks i.e. 38450 data=8; //num = 5,6,7,8 stop=15; //num = 1,15,2 - note 15 is 1.5 bits parity=N; //first letter of Odd,Even,None,Mark,Space rxi=Y; //set receive interface as active (Y),a command processing source (C) or disable (N). Default = N proc=CR; //process on receive termination character. See below procDel=Y; //remove or keep the termination character(s) before processing rxb=128; //set size of receive buffer in bytes. Default = 8192 bytes txi=Y; //set transmit interface as active (Y),to echo command processing (E) or disable (N) txb=128; //set size of transmit buffer in bytes. Default = 8192 bytes encode=sr; //set s=ASCII,w=UNICODE,m=UTF8 or use sr,wr and mr specifying raw data bytes. flow=N; //none,hardware RTS/CTS or DTR/DSR,software XON XOFF } /////////////// //Variables// ////////////// VAR(RcvBuf," ",TXT); //variable to store as1 data recieved VAR(RcvFlg," ",TXT); //variable to store as1 data after split VAR(row,1,U8); //row number VAR(recnum,1,U16); //rec number upto ~65000 VAR(recptr>"",PTR); //pointer to row VAR(stkptr>"",PTR); //pointer to stk number VAR(prdptr>"",PTR); //pointer to prd number VAR(wgtptr>"",PTR); //pointer to wgt number /////////// //Styles// /////////// STYLE(BlackPg,Page) {back=white;} //Style for page STYLE(texthd,Text) {font=asc16;col=black;maxLen=32;maxRows=1;curRel=CC;} //Title & headers texts STYLE(texts,Text) {font=asc16;col=navy;maxLen=32;maxRows=1;curRel=CC;} //Text in boxes STYLE(textbt,Text) {font=asc16;col=red;maxLen=32;maxRows=1;curRel=CC;} //Button Text STYLE(stBoxRed,DRAW){type=B;col=red;width=1;back=lightskyblue;maxX=480;maxY=272;curRel=CC;} //Recieved data boxes STYLE(stBoxYel,DRAW){type=B;col=red;width=1;back=yellow;maxX=480;maxY=272;curRel=CC;} //Button boxes ////////// //Page// ////////// PAGE( MainPg,BlackPg ) { POSN(240,9); TEXT(Title,"RS232 Raw Data and Pointer Demo",texthd); //Title for page POSN(29,25); TEXT(LabelR,"Rec",texthd); //Header for record number POSN(29,50); DRAW(rec1,50,25,stBoxRed); //Box for record No TEXT(Trec1,"",texts); //text to display record No POSN(+0,+30);DRAW(rec2,50,25,stBoxRed); //Box for record No TEXT(Trec2,"",texts); //text to display record No POSN(+0,+30);DRAW(rec3,50,25,stBoxRed); //Box for record No TEXT(Trec3,"",texts); //text to display record No POSN(+0,+30);DRAW(rec4,50,25,stBoxRed); //Box for record No TEXT(Trec4,"",texts); //text to display record No POSN(+0,+30);DRAW(rec5,50,25,stBoxRed); //Box for record No TEXT(Trec5,"",texts); //text to display record No POSN(+0,+30);DRAW(rec6,50,25,stBoxRed); //Box for record No TEXT(Trec6,"",texts); //text to display record No POSN(119,25);TEXT(Label1,"Stock No",texthd); //Header for stock number POSN(119,50);DRAW(stk1,110,25,stBoxRed); //Box for Stock No TEXT(Tstk1,"",texts); //text to displap stock no POSN(+0,+30);DRAW(stk2,110,25,stBoxRed); //Box for Stock No TEXT(Tstk2,"",texts); //text to displap stock no POSN(+0,+30);DRAW(stk3,110,25,stBoxRed); //Box for Stock No TEXT(Tstk3,"",texts); //text to displap stock no POSN(+0,+30);DRAW(stk4,110,25,stBoxRed); //Box for Stock No TEXT(Tstk4,"",texts); //text to displap stock no POSN(+0,+30);DRAW(stk5,110,25,stBoxRed); //Box for Stock No TEXT(Tstk5,"",texts); //text to displap stock no POSN(+0,+30);DRAW(stk6,110,25,stBoxRed); //Box for Stock No TEXT(Tstk6,"",texts); //text to displap stock no POSN(254,25);TEXT(Label2,"Product",texthd); //Header for Product POSN(254,50);DRAW(Prd1,140,25,stBoxRed); //Box for Product Name TEXT(Tprd1,"",texts); //text to display product POSN(+0,+30);DRAW(prd2,140,25,stBoxRed); //Box for Product Name TEXT(Tprd2,"",texts); //text to display product POSN(+0,+30);DRAW(prd3,140,25,stBoxRed); //Box for Product Name TEXT(Tprd3,"",texts); //text to display product POSN(+0,+30);DRAW(prd4,140,25,stBoxRed); //Box for Product Name TEXT(Tprd4,"",texts); //text to display product POSN(+0,+30);DRAW(prd5,140,25,stBoxRed); //Box for Product Name TEXT(Tprd5,"",texts); //text to display product POSN(+0,+30);DRAW(prd6,140,25,stBoxRed); //Box for Product Name TEXT(Tprd6,"",texts); //text to display product POSN(404,25);TEXT(Label3,"Weight",texthd); //Header for Weight POSN(404,50);DRAW(wgt1,140,25,stBoxRed); //Box for weight value TEXT(Twgt1,"",texts); //text to display weight POSN(+0,+30);DRAW(wgt2,140,25,stBoxRed); //Box for weight value TEXT(Twgt2,"",texts); //text to display weight POSN(+0,+30);DRAW(wgt3,140,25,stBoxRed); //Box for weight value TEXT(Twgt3,"",texts); //text to display weight POSN(+0,+30);DRAW(wgt4,140,25,stBoxRed); //Box for weight value TEXT(Twgt4,"",texts); //text to display weight POSN(+0,+30);DRAW(wgt5,140,25,stBoxRed); //Box for weight value TEXT(Twgt5,"",texts); //text to display weight POSN(+0,+30);DRAW(wgt6,140,25,stBoxRed); //Box for weight value TEXT(Twgt6,"",texts); //text to display weight POSN(68,243);DRAW(A,80,50,stBoxYel); //Box for salami button TEXT(At,"Salami",textbt); //Text for salami button KEY(Key1,[LOAD(RS2,"^A TG704SA\\0D^B Salami\\0D^C 1.4Kg\\0D");],80,50,TOUCH); //Key sends string to RS232 POSN(154,243);DRAW(B,80,50,stBoxYel); //Box for Sausage button TEXT(Bt,"Sausage",textbt); //Text for sausage button KEY(Key2,[LOAD(RS2,"^A TG754SG\\0D^B Sausage\\0D^C 1.2Kg\\0D");],80,50,TOUCH); //Key sends string to RS232 POSN(240,243);DRAW(C,80,50,stBoxYel); //Box for Pate button TEXT(Ct,"P\\E2t\\E9",textbt); //Text for Pate button KEY(Key3,[LOAD(RS2,"^A TG345PT\\0D^B P\\E2t\\E9\\0D^C 500g\\0D");],80,50,TOUCH);//Key sends string to RS232 POSN(+86,243);DRAW(D,80,50,stBoxYel); //Box for cheese button TEXT(Dt,"Cheese",textbt); //Text for cheese button KEY(Key4,[LOAD(RS2,"^A TG4231CH\\0D^B Cheese\\0D^C 723g\\0D");],80,50,TOUCH); //key sends string to RS232 POSN(+86,243);DRAW(E,80,50,stBoxYel); //Box for Ham button TEXT(Et,"Ham",textbt); //text for Ham button KEY(Key5,[LOAD(RS2,"^A TG1284HM\\0D^B Ham\\0D^C 625g\\0D");],80,50,TOUCH); //Key sends string to RS232 } ////////////// //Interupt// ///////////// INT(DataRc,RS2RXC,SplitEvent); //If the RS232 Buffer recieves data it runs the split event function /////////////// //Functions// /////////////// FUNC(SplitEvent) { LOAD(RcvBuf,RS2); //Loads the RS232 string into the RcvBuf variable for splitting CALC(RcvFlg,RcvBuf," ","SPLIT"); //Splits the RcvBuf everytime a " " (space) appears in string IF(RcvFlg="^A"?[LOAD(recptr>"Trec",row);TEXT(recptr,recnum);LOAD(stkptr>"Tstk",row);TEXT(stkptr,RcvBuf);]); //Load the rcvBuf into the correct boxes and row IF(RcvFlg="^B"?[LOAD(prdptr>"Tprd",row);TEXT(prdptr,RcvBuf);]); IF(RcvFlg="^C"?[LOAD(wgtptr>"Twgt",row);TEXT(wgtptr,RcvBuf);RUN(chkrow);]); } FUNC(chkrow) //Increment or reset to first row { IF(row<6?[CALC(row,row,1,"+");]:[LOAD(row,1);]); //Limits the row incrementation for showing data CALC(recnum,recnum,1,"+");; //Increments record number } SHOW( MainPg );