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 - Trace graph from array

Add background image to library

Create a style for page
Create a style for trace graph col-blue
Create a style for trace graph col-red

Create Variables for graph
Num-point no Rand-Random Number (Yposn) Set-set interval(XPosn)
FuncV-which graph to draw GraphSel-name of grph to draw
Create array for 2 graphs X and Y Points with 22 points

Create function that creates array values
Loop goes round 22 times
Calculates a number from 0-189.99 and stores in Rand variable
Loads the array Y value with the Random number for desired graph
Loads the array X value with the Set number for desired graph
Increments the Set number by 20
Increments the Num by 1
Reset the Num and Set variable so function can be re-run

Define a page named "pageName" using "pageStyle"

Draw graph0 420 x 190 at 240,130
Draw graph1 420 x 190 at 240,130
Create Key for Graph0 draw with inline function that loads which graph todraw and runs graphdraw function
Create key that resets both of the graphs
Create Key for Graph0 draw with inline function that loads which graph todraw and runs graphdraw function

Create Function that Draws Graphs
Run Loop to load array with values
Load variable with which graph to has been selected
Reset the selected graph
Draw the selected graph with X and Y points from array

After loading show the page

LIB(background,"SDHC/bground.png");

STYLE(pageStyle, Page) {image=background;}
STYLE(gstyle,DRAW){type=trace;col=blue;back=none;width=2;curRel=CC;}
STYLE(gstyle2,DRAW){type=trace;col=red;back=none;width=2;curRel=CC;}

VAR(Num,0,U16);VAR(Rand,0,U16);VAR(Set,0,U16);
VAR(FuncV,0,U8);VAR(GraphSel,"",TXT);
VAR(G1Plots,0,U16,2,2,22);

FUNC(ArrayLoad)
{
LOOP(Loop1,22)
{
CALC(Rand,190,"RND");
LOAD(G1Plots.FuncV.1.Num,Rand);
LOAD(G1Plots.FuncV.0.Num,Set);
CALC(Set,Set,20,"+");
CALC(Num,Num,1,"+");
}
LOAD(Num,0);
LOAD(Set,0);
}
PAGE(pageName,pageStyle)
{
DRAW(graph0,420,190,gstyle,240,130);
DRAW(graph1,420,190,gstyle2,240,130);
KEY(Graph0A0D,[LOAD(FuncV,0);RUN(GraphDraw);],100,30,TOUCHR,120,250);
KEY(ResetGK,[RESET(graph0,graph1);;],100,30,TOUCH,240,250);
KEY(Graph1A1D,[LOAD(FuncV,1);RUN(GraphDraw);],100,30,TOUCHR,360,250);
}
FUNC(GraphDraw)
{
RUN(ArrayLoad);
LOAD(GraphSel,"graph",FuncV);
RESET(GraphSel);
DRAW(GraphSel,G1Plots.FuncV.0,G1Plots.FuncV.1);;
}
SHOW(pageName);