New Page 1

How To Do - Example Projects

Click on the title to open the example project
Click on the How to projects above to see the basic sample code to help you create your projects quickly and efficiently.
Each "How To" has a overall description as well as a basic line by line detail of code.
You can download the project or copy the menu file to clipboard
 
Basic Entities     Basic animation     Basic functions  
Add Image   Create button   Basic math operations
Draw colour boxes   Show page - multiple pages   Math functions
Draw colour lines   Flashing text message   Create random number
Draw colour vectors   Animation with pointers   Plus and Minus
Draw colour circles   Scroll text message   Show and format Time and Date
Draw colour ellipses   Move images (TouchX, TouchY)   Save Timestamp to text file  
Draw arcs (ellipses with angle)   Move images with buttons   Password Entry Lock  
Add multiple rows text     Move images (press button)     Menu Selection  
Use pointers   Create slider      
Text Hello World   Show and hide entities   Graphs
Create Dynamic Entities     Dial needle   Create X-Bar Graph
      PNG Transparency     Create Y-Bar Graph  
Interfaces and Hardware             Trace graph from array  
Create IO Counter           Draw sinusoid graph   
External Key             Draw graph - DNA style
Use A to D converters           Draw line graph  
Send and receive data - RS232          
Keyboard Control            
           
 
  

How to do - Dial needle

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);