Z-Stack API Reference  3.3.0
Keypress Functions
#define KEY_SELECT   0x01
 
#define KEY_UP   0x02
 
#define KEY_DOWN   0x04
 
#define KEY_LEFT   0x08
 
#define KEY_RIGHT   0x10
 
#define KEY_DEBOUNCE_TIMEOUT   200
 
typedef void(* Board_Key_keysPressedCB_t) (uint8_t keysPressed)
 
uint8_t Board_Key_initialize (Board_Key_keysPressedCB_t appKeyCB)
 Enable interrupts for keys on GPIOs. More...
 
uint8_t board_key_getValues (void)
 Get the current value for all the keys. More...
 

Detailed Description


This module handles the definition, initilization and key bounce for key presses. To use this module, call Board_Key_initialize() with a callback function as the parameter, then when a key or keys are pressed, the callback function will be called (after a debounce period). Single or multiple key presses are detected and passed to the callback function.

Macro Definition Documentation

§ KEY_DEBOUNCE_TIMEOUT

#define KEY_DEBOUNCE_TIMEOUT   200

Debounce timeout in milliseconds

§ KEY_DOWN

#define KEY_DOWN   0x04

Down Key ID

§ KEY_LEFT

#define KEY_LEFT   0x08

Left Key ID

§ KEY_RIGHT

#define KEY_RIGHT   0x10

Right Key ID

§ KEY_SELECT

#define KEY_SELECT   0x01

Select Key ID

§ KEY_UP

#define KEY_UP   0x02

Up Key ID

Typedef Documentation

§ Board_Key_keysPressedCB_t

typedef void(* Board_Key_keysPressedCB_t) (uint8_t keysPressed)

Key Press Callback function typedef

Function Documentation

§ board_key_getValues()

uint8_t board_key_getValues ( void  )

Get the current value for all the keys.

Returns
bit mapped representation of all keys

§ Board_Key_initialize()

uint8_t Board_Key_initialize ( Board_Key_keysPressedCB_t  appKeyCB)

Enable interrupts for keys on GPIOs.

Parameters
appKeyCB- application key pressed callback
Returns
current state of all keys, check for bit masked KEY_SELECT, KEY_UP, etc.