Command |
KEY |
|
|
Description |
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)
More sophisticated function is available on touch change with TOUCHC
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.
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.00.
Restriction: If processing a function called from a KEY() command then further key presses will be ignored. Each touch key press function must be processed to completion before another can be processed. Please refer to the project example 'keyboard' for the technique to process keys. |
|
|
Syntax/Parameters |
KEY(Name,Function,X,Y,Style)
KEY(Name,Function,X,Y,Style,PosX,PosY);
KEY(name,downFunc,upFunc,X,Y,style,Posx,Posy);
KEY(name,downFunc,upFunc,repFunc,X,Y,style,Posx,Posy); |
|
|
Style |
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 and C for change. See note below
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
Specify the source of key
data. Touch debounce and sampling is setup globally in SYSTEM or in
SETUP(TOUCH) for resistive touch, projective capacitive touch and Immediate
capacitive touch.
If you require a dual action, specify 2 keys at the same location, one
with action D and one with U. |
|
|
Options |
Extended touch key repeat function - 49.16
Extended touch key repeat function. Supported repeatnum, repeatdec and repeatend parameters to KEY style.
If none of these parameters are specified or any of them are 0 the repeat function is as before. If they are specified, after the initial delay the value in 'repeat' is used 'repeatnum' times. Then the repeat value is reduced by the value specified in repeatdec. The key repeats 'repeatnum times again and then the time is again reduced. This cycle repeats until the repeat value reaches the value in repeatend. The key then repeats with this interval until it is released.
Example, initial delay of 1s, 3x330, 3x280, 3x230, 3x180, 3x130, 100 ...
delay = 1000
repeat = 330
repeatnum = 3
repeatdec = 50
repeatend = 100
KEY Style event handler - evfunc - 49.27
An Additional parameter in the key style. evfunc allows a function to be called when any key using that style is pressed.
This function is run before the function specified in the KEY entity.
A typical use for this would be to provide a method to add a key beep.
STYLE(myTouch,key)
{
. .
evfunc = fncBeep;
.
.
}
FUNC(fncBeep)
{
LOAD(BUZZ, 100);
}
Last Key Pressed - LAST_KEYIO_NAME and LAST_TOUCH_NAME - v49.51
* Added two built-in text vars that give the entity names of the last
external and touch keys pressed
LAST_KEYIO_NAME
LAST_TOUCH_NAME
eg press touch key named "key1". LOAD(RS2,LAST_TOUCH_NAME); // Outputs
"key1"
Action Types
Styles for touch keys action=u|d|c; (up|down|change) - where change
detects key down and key up
Built in touch styles
- TOUCH with type=touch; debounce=50; repeat1=0; repeat2=0; action=D;
- TOUCHR with type=touch; debounce=50; repeat1=1000; repeat2=200; action=D;
- TOUCHC with type=touch; debounce=50; repeat1=1000; repeat2=200; action=C;
a) KEY(name,func,width,height,style);
- supports existing implementation plus must be used for external keys
- 'func' is called for key down, up and repeat, depending on key style action
b) KEY(name,downFunc,upFunc,width,height,style);
- 'downFunc' called when key down detected and for key repeat, depending on key
style action
- 'upFunc' called when key up detected, depending on key style action
- either 'downFunc' and/or 'upFunc' can be omitted if no function call required
c) KEY(name,[downFunc],[upFunc],[repFunc],width,height,style);
- 'downFunc' called when key down detected, depending on key style action
- 'repFunc' called when key up detected, depending on key style action
- 'upFunc' called when key up detected, depending on key style action
- either 'downFunc' and/or 'upFunc' and/or 'repFunc' can be omitted if no
function call required
Note external keys still only support actions of up and down and command
KEY(name,func,x,y,style); |
|
|
Example |
KEY(TopKey,TopFnc,90,50,MyTouch); a touch area 90x50 pixels.
Create your own style MyTouch
KEY(ExtKey,ExFunc,\\07,\\10,MyIOK); This external key operates
when K7 and K16 connect.
Create your own style MyIOK {type=keyio}
KEY(ExtKey,ExFunc,K07,K16,MyIOK); This external key operates
when K7 and K16 connect.
Create your own style MyIOK {type=keyio}
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.
Examples
KEY(key1,[LOAD(rs2,"a");],90,84,TOUCH);
- 'a' is output on key down only
KEY(key2,[LOAD(rs2,"b");],90,84,TOUCHR);
- 'b' are output on key down and key repeat
KEY(key3,[LOAD(rs2,"c");],90,84,TOUCHC);
- 'c' are output on key down, key repeat and key up
KEY(key4,[LOAD(rs2,"d");],[LOAD(rs2,"e");],90,84,TOUCHC);- 'd' are output on key down and key repeat, 'e' is output on key up
KEY(key5,[LOAD(rs2,"f");],[LOAD(rs2,"g");],[LOAD(rs2,"h");],90,84,TOUCHC);- 'f' is output on key down, 'h' on key repeat, 'g' on key up
KEY(key6,,[LOAD(rs2,"i");],[LOAD(rs2,"j");],90,84,TOUCHC);- 'j' are output on key repeat, 'i' on key up
KEY(key7,,,[LOAD(rs2,"k");],90,84,TOUCHC);- 'k' are output on key repeat only
KEY(key8,,[LOAD(rs2,"l");],,90,84,TOUCHC);- 'l' is output on key up only |
|
|
|