
Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1
162
Ver.1.0.0
The two macros serve to define current repeat key values: KB_REPEAT_KEY_NUM
specifies the number of keycodes, while the KB_MAP_REPEAT defines a map to
specify all repeat keycodes. Note that the keycodes in the KB_MAP_REPEAT must
be the values in the KB_MAP_NORMAL.
Following example shows a 6*6 matrix keyboard: by configuring the four macros, eight
buttons including UP, DOWN, LEFT, RIGHT, V+, V-, CHN+ and CHN- are set as repeat
keys with repeat interval of 100ms, while other buttons are set as non-repeat keys.
Users can search for the four macros in the project to locate the code about repeat key.
7.7 Stuck Key Processing
Stuck key processing is used to save power when one or multiple buttons of a remote
control/keyboard is/are pressed and held for a long time unexpectedly, for example a RC
is pressed by a cup or ashtray. If keyscan detects some button is pressed and held,
without the stuck key processing, MCU wo
n’t enter deepsleep or other low power state
since it always considers the button is not released.
Two related macros in app_config.h are:
//stuck key
#define
STUCK_KEY_PROCESS_ENABLE
0
#define
STUCK_KEY_ENTERDEEP_TIME
60
//in s
By default the stuck key processing function is masked. User can set the
“STUCK_KEY_PROCESS_ENABLE” as 1 to enable this function. The
“STUCK_KEY_ENTERDEEP_TIME” serves to set the stuck key time: if it’s set as 60s, it
indicates when button state stays fixed for more than
60s with some button held, it’s
considered as stuck key, and MCU will enter deepsleep.
Users can search for the macro
“STUCK_KEY_PROCESS_ENABLE” to locate related
code in keyboard.c, as shown below:
#if
(STUCK_KEY_PROCESS_ENABLE)
u8
stuckKeyPress[ARRAY_SIZE(drive_pins)];
#endif
An u8-type array stuckKeyPress[5] is defined to record row(s) with stuck key in current
key matrix. The array value is obtained in the function “key_debounce_filter”.
Upper-layer processing is shown as below:
kb_event.
keycode
[0] = 0;