| 
                     
                    
Add background image to library 
Create page style 
Create vector style 
Create elipse style 
Create text style 
Create key style 
Create status variable 
Create variables for mph and kmh 
Create variable for angle 
Load timer0 to runforver expiring every 50ms 
Create interupt that runs chF on Timer0 
 
Define a page named "pageName" with style "pageStyle" 
 
Create needle entity 
Create center point entity 
Create mph text entity 
Create kmh text entity 
Create minus key which sets status to 1 when pressed and to 3 when released 
Create plus key which sets status to 2 when pressed and to 3 when released 
 
Create Function that gets called on TIMER0 interupt which checks status so knows which function to run 
Create plF which adds 2 to value if not at upper limit then runs mvF 
Create miF which takes 2 from value if not at lower limit then runs mvF 
Create mvF 
Calculate angle using val variable 
Redraw the needle using the angle 
Convert the mph into kmh 
Load the new mph and kmh values to the text entities and refresh screen 
 
After loading show the page named "pageName"
                    
                  | 
                
                     
LIB(background,"SDHC/bground.png");
 STYLE(pageStyle,Page){image=background;}
 STYLE(dSt,Draw){type=v;col=red;width=3;currel=SC;maxX=123;maxY=123;}
 STYLE(dStC,Draw){type=e;col=white;back=black;width=0;}
 STYLE(tSt,Text){font=Ascii16;col=white;back=dimgrey;currel=RC;}
 STYLE(kSt,key){type=touch;action=c;delay=0;repeat=10;}
 VAR(stat,0,U8);VAR(val,0,U16);
 VAR(val2,0,U16);VAR(CR,0,S16);
 LOAD(TIMER0,50,0);
 INT(inttim,TIMER0,chF);
 
 PAGE(pageName, pageStyle)
 {
 DRAW(ned,83,210,0,dSt,300,136);
 DRAW(cen,12,12,0,360,dStC,300,136);
 TEXT(Sp1,val,tSt,315,220);
 TEXT(Sp2,val2,tSt,315,240);
 KEY(kmi,[LOAD(stat,1);],[LOAD(stat,3);],40,40,kSt,40,136);
 KEY(kpl,[LOAD(stat,2);],[LOAD(stat,3);],40,40,kSt,120,136);
 }
 FUNC(chF){IF(stat=2?plF);IF(stat=1?miF);}
 FUNC(plF){IF(val<280?[CALC(val,val,2,"+");RUN(mvF);]);}
 FUNC(miF){IF(val>0?[CALC(val,val,2,"-");RUN(mvF);]);} 
 FUNC(mvF)
 {
 CALC(CR,val,150,"-");
 DRAW(ned,83,CR,0); 
 CALC(val2,val,0.62,"*");
 TEXT(Sp1,val);TEXT(Sp2,val2);;
 }
 SHOW(pageName);
 
                 |