根据 https://littlevgl.com/porting
Keypad or keyboard
indev_drv.type = LV_INDEV_TYPE_KEYPAD;
indev_drv.read_fp = my_input_read;
The read function should look like this:
bool keyboard_read(lv_indev_data_t *data)
{
if(key_pressed()) {
data->state = LV_INDEV_EVENT_PR;
data->key = get_key();
} else {
data->state = LV_INDEV_EVENT_REL;
data->key = 0;
}
return false; /*No buffering so no more data read*/
}
To use a keyboard:
LV_OBJ_GROUP has to be enabled in lv_conf.h
An object group has to be created: lv_group_create() and objects have to be added: lv_group_add_obj()
The created group has to be assigned to an input device: lv_indev_set_group(my_indev, group1);
Use LV_GROUP_KEY_... to navigate among the objects in the group
然后打开这个例程 lv_examples/lv_tests/lv_test_group/,修改部分代码,可以接受键盘输入了
离线