EasyManua.ls Logo

TELINK SEMICONDUCTOR TLSR8232 - Page 153

Default Icon
211 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1 152 Ver.1.0.0
#define KB_RETURN_KEY_MAX 6
typedef struct{
u8 cnt;
u8 ctrl_key;
u8 keycode[KB_RETURN_KEY_MAX];
}kb_data_t;
kb_data_t kb_event;
The “kb_event” consists of 8 bytes:
“cnt” is used to indicate valid count number of pressed buttons currently;
“ctrl_key” is not used generally, and it will be used only for standard USB HID keyboard
(user is not allowed to set keycode in keymap as 0xe0~0xe7).
keycode[6] indicates keycode of up to six pressed buttons can be stored (if more than six
buttons are pressed actually, only the former six can be reflected).
Keycode definition of 30 buttons in app_config.h is shown as below:
#define KB_MAP_NORMAL {\
{VK_NONE, VK_UP, VK_ENTER, VK_DOWN, VK_NONE}, \
{KEY_MODE_SWITCH, VK_LEFT, CR_MENU, CR_VOL_MUTE, VK_RIGHT}, \
{VK_POWER, CR_HOME, VK_7, VK_2, CR_BACK}, \
{VK_NONE, CR_VOL_DN, VK_NONE, VK_5, CR_VOL_UP}, \
{VK_NONE, VK_1, VK_0, VK_8, VK_3}, \
{VK_NONE, VK_4, VK_NONE, VK_9, VK_6}, }
The keymap follows the format of 5*6 matrix structure. The keycode of pressed button
can be configured accordingly, for example, the keycode of the button between Row0
and CoL1 is VK_UP”.
In the kb_scan_key function, the “kb_event.cnt” will be cleared before each scan, while
the arraykb_event.keycode[]” won’t be cleared automatically. Whenever “1” is returned
to indicate valid update, the “kb_event.cnt” will be used to check current valid count
number of pressed buttons.
1) If current kb_event.cnt = 0, previous valid matrix state “kb_event.cnt must be
uncertain non-zero value; the update must be button release, but the released button
number is uncertain. Data in kb_event.keycode[] (if available) is invalid.
2) If kb_event.cnt = 1, the previous kb_event.cnt indicates button state update. If
previous kb_event.cnt is 0, it indicates the update is one button is pressed; if
previous kb_event.cnt is 2, it indicates the update is one of the two pressed buttons
is released; if previous kb_event.cnt is 3, it indicates the update is two of the three
pressed buttons are released……
kb_event.keycode[0] indicates the key value of currently pressed button. The
subsequent keycodes are negligible.
3) If kb_event.cnt = 2, the previous kb_event.cnt indicates button state update. If
previous kb_event.cnt is 0, it indicates the update is two buttons are pressed at the

Table of Contents