Kp Object

Top  Previous  Next

object_kp

The kp. object of TiOS running on Tibbo hardware devices works with attached matrix or binary keypads.

The kp. object of TiOS Simulator works with 16 buttons placed in the Simulator's window.

 

Differences from the "real" kp. object:

 

kp.idlecode

Must be set to 255.

kp.mode

Must be set to 1- PL_KP_MODE_BINARY.

kp.pressdelay

The recommended value is 1. This is because the Simulator's buttons are already "debounced".

kp.returnlinesmapping

Not implemented. Changing the value of this property will have no effect on the operation of the virtual keypad.

kp.scanlinesmapping

Not implemented. Changing the value of this property will have no effect on the operation of the virtual keypad.

kp.setlabel

This method is supported only on the Simulator (see below).

 

All other aspects of the kp. object follow our "real" kp. object found on Tibbo devices.

 

The kp.setlabel method

This method has been added to allow labeling the buttons of the virtual keypad displayed by the Simulator.

By default, each button label shows the key code of the button.

You can change this to something more meaningful. For example, here is the code that sets button labels in the Calculator sample project:

 

Tibbo BASIC:

kp.setlabel(0,"+") 'the first argument is the key code, the second argument is the label for the button with the matching key code
kp.setlabel(1,"-")
kp.setlabel(2,"*")
kp.setlabel(3,"/")
kp.setlabel(4,"1")
kp.setlabel(5,"2")
kp.setlabel(6,"3")
kp.setlabel(7,"+/-")
kp.setlabel(8,"4")
kp.setlabel(9,"5")
kp.setlabel(10,"6")
kp.setlabel(11,"=")
kp.setlabel(12,"7")
kp.setlabel(13,"8")
kp.setlabel(14,"9")
kp.setlabel(15,"0")

 

And here is the result: see the screenshot in The Simulator's Window.