Commands for Cursor Position, Text, Draw, Image and Keys
Command Description
POSN(X,Y,Page/Name,Style) Position Cursor +X or –X or X,Y or X, Y, Page with a defined style.
The cursor can be positioned on the display using absolute co-ordinates or moved in relation to it’s current position by using +/- offset values. The origin is located at the top left of the screen.
 
Re-position a previously placed entity by specifying the new coo-ordinates and it's name.
This can be useful for indicator bars, simple movement animations and moving text.

Examples:
POSN(+25,+0);  moves the cursor 25 pixels to the right.
POSN(236,48); absolute position of x=236, y=48.
POSN(24,56,CalcPage); position cursor on calc page at x=24, y=56.
POSN(VarX,Vary); use variables with absolute values to control position of cursor
POSN(VarX,Vary,VertBar); use variables to move an entity - vertical bar
POSN(TOUCHX,TOUCHY,MyRectCursor); move a cursor to the contact point on the screen. 

Operational
 
TEXT(Name,Text,Style) Create or update Text. Use Carriage Return and Line Feed for multi line entry \\0A\\0D The font and colour are defined in the style. If the cursor relative position is ’CC’ (Centre Centre) it is easy to locate text in the centre of images like buttons.

Text areas can overlap other text areas when for example a 'drop shadow' is required. Text can include embedded hex codes to access Unicode fonts and a cursor.

Faster display updates occur
if text uses a solid background colour (ie no alpha blending). 

Examples:
TEXT(EditBox,"Hello World",st8Red12);  //creates Edit Box with user defined style st8Red12
TEXT(EditBox,"Hello People");           //modifies content of EditBox
TEXT(EditBox,TextVar);                   //modifies content of EditBox with content of variable
TEXT(EditBox,"Hello\\w0020World"); // example of unicode embedded character (see fonts page)

Editable Text and Visible Cursor
A text can contain single byte hex of the form \\00 to \\FF
A text can contain hidden codes for use in password and editable fields.
\\01 defines the text as a PASSWORD so that only ***** are shown.
\\02 defines a hidden cursor and \\03 a hidden cursor with insert ON
\\04 defines an underline cursor and \\05 an underline cursor with insert ON
\\06 defines a block cursor and \\07 a vertical cursor with insert ON
Always place the cursor before the applicable character.
When a page or text is hidden, the cursor remains at it's current location.
The CALC command can then be used to manipulate the text and cursor in EditBox.

Example Editable Text:
TEXT(EditBox,"Hello \\04World",8ptTextRed); this places an underline cursor at W
 
TEXT Styles
Fonts are available using single byte, 2 byte and UTF8 multi-byte coding.
Built in ASCII fonts have the reserved names Ascii8, Ascii16, Ascii32 (case sensitive).
Other library fonts are uploaded using the LIB command and have file type .FNT
These are available for download from the character fonts web page at www.itrontft.com.
Unique Font Overlay
It is possible to overlay one font over another to enable single byte operation with ASCII from 20H to 7FH and Cyrillic, Greek, Hebrew, Bengali, Tamil, Thai or Katakana from 80H to FFH. The LIB command is used to load the extended font at 0080H instead of it's normal UNICODE location. The style for a text can then specify font="MyASCII,MyThai"; causing the Thai to overlap the ASCII from 80H to FFH.

STYLE(Txt32ASC16,TEXT)      //assign a name for the style like Txt32ASC16
    {
    font="ASC16B,16THAI";    //define fonts using built in or preloaded .FNT files via LIB command
    size=2;                           //a 24x24 font is expanded to a 48x48 font. default=1
    col=white;                       //“\\000000”  to “\\FFFFFF” or reserved words from the colour chart.
    maxLen=64;                   //maximum length of text. default =32, maximum=512
    maxRows=4;                   //maximum number of rows=32 where new line code \\0D\\0A is used.
    rotate=90;                     //rotation relative to screen 0, 90, 180, 270. default=0 
    curRel=CC;                     //specify placement relative to cursor. CC Centre Centre , TC Top Centre,
    }                                   //BC Bottom Centre, LC Left Centre, RC Right Centre, TL Top Left,
                                        // BL Bottom Left, TR Top Right, BR Bottom Right
 

Operational
 
DRAW(Name,X,Y,Style) Draw or update a Line, Box, Circle  or Graph of size X,Y. The entities can be an outline or filled.
The colour can be enhanced using alpha blending within the draw style.
Graphs of a different colour can be superimposed on top of each other.
Faster display updates occur
if draw uses a solid background colour (ie no alpha blending). 

DRAW accepts VARs, signed/unsigned integers
             (U8, U16, U32, S8, S16, S32), floats (FLT) and pointers (PTR)

DRAW( PTR, VAR|INT|FLT|PTR, VAR|INT|FLT|PTR, Style );
             Note PTR refers to the entity being pointed to by PTR and not
             the PTR itself. Use LOAD( PTR > "Name" ); to set a pointer.


Example Draw
DRAW(MyCircle, 32, 32, DrawCircle);
DRAW(MyCircle, 64, 64);                 //modified circle is double diameter.
DRAW(MyBox,VarX,VarY);               //modified box using variables. Should not exceed MaxX,maxY.

DRAW(MyLine,10,10,lineStyle); //draws line 45 degrees top left to bottom right.
DRAW(MyLine2,10,-10,lineStyle); //draws line 45 degrees bottom left to top right.

Graph
DRAW(MyGraph,100,100,GraphStyle); //draws a graph window of 100x100 pixels.
DRAW(MyGraph,20,30); //draws a pixel on the graph at 20,30 relative to the origin.
DRAW(MyGraph,varX,varY); //use variables to plot a pixel on the graph.
RESET(MyGraph); //clears the graph

Graphs   
A number of graph styles now exist as draw types:
  type=p; type=pixel;     // Pixel Scatter - places a point at x,y
  type=t; type=trace;     // Trace/Line - joins the dots between current point and previous point.
 
type=y; type=yBar;      // Bar Y - draws vertical line from 0 to y and clears from y+1 to ymax
 
type=x; type=xBar;      // Bar X - draws horizontal line from 0 to x and clears from x+1 to xmax
           
 The origin on the graph can be changed
   xOrigin=val; // (default=0)
   yOrigin=val; // (default=0)

 The scaling of pixels can be set:
   xScale=val; // (default=100.0) [val can be float and is a percentage]
  
yScale=val; // (default=100.0) [val can be float and is a percentage]
Note to draw graph with 0,0 at top and n,n at bottom, use
yScale=-100;

The graph can be made to scroll (currently right-to-left only supported)
 
xScroll=val; // where val=0 (default - no scroll); val=n (scroll left n pixels before each plot

Please refer to the ADC analogue input section for a graph application example.

Draw Styles
It is possible to specify transparency values with colours if the colour is entered as a 32-bit hex number the top 8 bits specify the alpha blending level.
col =
\\aarrggbb;     back = \\aarrggbb;   where  aa = alpha level.
For example, col = \\80FFFF00; gives 50% transparent yellow.


STYLE(gstyle,DRAW)  {   
    type=trace;
//The shape to draw. type = B/Box; C/Circle;  L/Line;, T/Trace; P/Pixel; y/yBar; x/xBar; 
    maxX=100; 
// Declare the maximum width allowing for rotation
    maxY=100; 
// Declare the maximum height allowing for rotation
    col=green; 
//Specify the line border colour of the shape. Use hex, colour name + alpha
    back=black;
//Specify the fill colour of the shape. Use hex, colour name + alpha
    width=3;   
//Specify the line border width of the shape default = 1
   
rotate=0;     //  Specify the rotation of the shape with respect to the screen. 0,90,180,270
    curRel=cc;  
//specify placement relative to cursor. CC Centre Centre , TC Top Centre etc.
    xOrigin=50;   //specify graph x origin wit respect to declared graph
    yOrigin=50;  //specify graph y origin wit respect to declared graph
    xScale=200; //scale the value automatically to fit the graph
    yScale=200; //scale the value automatically to fit the graph
    xScroll=1;    //define scroll direction and increment 1=left to right one pixel, 0=none, -1=right to left
    }


Operational  Box/Circle/Line v39   Graph = v47
 
IMG(Name,Source,Style) Draw or update an Image. Source has several techniques.
If an image is pre-stored in the library, it’s entity name is used for Source.
If it is to be directly loaded from the SDHC card or NAND flash, the path is the Source.
Scaling and rotation can also be specified in the LIB command.
The system does not recognize directory structures in the SDHC card.
Please put all active files in the root. All file names are 8 characters maximum length.

Example:
IMG(MyPic,TopBtn,MyImage);          //previously stored as TopBtn using LIB command
IMG(MyPic,"sdhc/TopBtn.bmp",90,60,MyImage);  //stored on SDHC card

Image Styles
The image may be larger than the size specified so it is necessary to define how it will be scaled.
STYLE(MyImage,Image)
   {

   scale=100;         //
The image is scaled down or up by a percentage.
                             //Supports 5% steps below 100 and 100% steps above 100.
 
   maxX=160;         // Declare the maximum width allowing for rotation
   maxY=40;           // Declare the maximum height allowing for rotation
   rotate=0;            // Specify the rotation of the shape with respect to the screen. 0,90,180,270
   curRel=CC;         // specify placement relative to cursor. CC Centre Centre , TC Top Centre,
   }                       // BC Bottom Centre, LC Left Centre, RC Right Centre, TL Top Left,
                            // BL Bottom Left, TR Top Right, BR Bottom Right

If maxX and maxY are the same size as the loaded file or unspecified, the library image is used rather than a copy created which saves memory space. 24 bit images are stored as 32 bit data. 16 bit images are stored as 16 bit and only expanded to 32 bit during page refresh so optimizing memory usage.

Operational
 
KEY(Name,Function,X,Y,Style) Create a Touch Area  of size X,Y or define a Key on the external keyboard.
 
The touch area can have a One Touch function by using the built in style TOUCH or TOUCHR (repeat)
An external key can use the default style KEYIO.
Both these built in styles process when the key is depressed.
For processing at press and release, create 2 keys at the same location with different styles, one with action=DOWN; and the other with action=UP;.
 
When specifying an external key action, the values for X and Y indicate the contact points on the key board matrix where K0 is \\00  through to K23 which is \\17 .
This method allows dual key press capability as in SHIFT key operation.
Key scan uses ports K0-K23 which can be configured as shown in the I/O section.
Switches connected to 0V should use the I/O interrupt command INT(...); 

The last touch co-ordinates are stored in predefined variables TOUCHX and TOUCHY

The touch screen can be calibrated using the command setup( system ) { calibrate=y; }
The position of touch keys can be temporarily viewed as a grey area using
setup( system ) { test=showTouchAreas; } and hidden again using test=hideTouchAreas.
The built in style TOUCHR
provides auto repeat after 1sec with 200ms repetition.
See  the SYSTEM command for global touch screen debounce,
sampling and accuracy parameters.

KEY(name,func,width,height,style); now accepts ints and vars for width and height. v47
 
Examples KEY
Key(TopKey,TopFnc,90,50,MyTouch);  a touch area 90x50 pixels. Create your own style MyTouch
Key(ExtKey,ExFunc,\\07,\\10,KEYIO);  This external key operates when K7 and K16 connect.
Key(TKey,[Hide(SPage);Show(TPage);],50,50,TOUCH); Inline commands instead of function

Plan: Key(ExtKey,ExFunc,K07,K16,PushKey);    This external key operates when K7 and K16 connect.
 

KEY Styles

Specify the source of key data. Touch debounce and sampling is setup globally in SYSTEM
If you require a dual action, specify 2 keys at the same location, one with action D and one with U.

STYLE(myTouch,key)
     {
     type=touch;       //specify 'touch' screen  or external 'keyio'
      debounce=250;  //
Specify the time delay to allow external key press to stabilise in milliseconds.
      delay=1000;
       //Specify the time delay before key auto repeat occurs in milliseconds. 0=off.
      repeat=500;       //Specify the repeat period if the key is held down in milliseconds
      action = D;         //Specify D or Down and U or Up. Specify the up or down action point for the key.
     curRel=CC;       //specify touch key placement relative to cursor. CC Centre Centre , TC Top Centre,
     }                     //BC Bottom Centre, LC Left Centre, RC Right Centre, TL Top Left,
                            // BL Bottom Left, TR Top Right, BR Bottom Right

  
Operational.