Mikroelektronika MIKROE-350 データシート

ページ / 526
Keypad_Init
Keypad_Key_Press
Keypad_Key_Click
235
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
Prototype
sub procedure Keypad_Init()
Returns
Nothing.
Description
Initializes port for working with keypad.
Requires
Global variables : 
keypadPort_Reg
- Keypad port 
keypadPort_Reg_Direction
- Direction of the Keypad port 
must be defined before using this function.
Example
' Initialize PORTB for communication with keypad
dim keypadPort as byte at PORTB
dim keypadPort_Direction as byte at DDRB
...
Keypad_Init()
Prototype
sub function Keypad_Key_Press() as byte
Returns
The code of a pressed key (1..16).
If no key is pressed, returns 0.
Description
Reads the key from keypad when key gets pressed.
Requires
Port needs to be initialized for working with the Keypad library, see Keypad_Init.
Example
dim kp as byte
...
kp = Keypad_Key_Press()
Prototype
sub function Keypad_Key_Click() as byte
Returns
The code of a clicked key (1..16).
If no key is clicked, returns 0.
Description
Call to Keypad_Key_Click is a blocking call: the function waits until some key is
pressed and released. When released, the function returns 1 to 16, depending
on the key. If more than one key is pressed simultaneously the function will wait
until all pressed keys are released. After that the function will return the code of
the first pressed key.
Requires
Port needs to be initialized for working with the Keypad library, see Keypad_Init.
Example
dim kp as byte
...
kp = Keypad_Key_Click()