Description
I have a small project with a few pages, I want to move between pages using a/an keyboard/encoder
What MCU/Processor/Board and compiler are you using?
visual studio
What LVGL version are you using?
7.11
What do you want to achieve?
Move between objects/buttons using a keyboard and typing to text areas
What have you tried so far?
This post Input device interface
Code to reproduce
static void home_open(uint32_t delay) {
lv_group_t* g = lv_group_create();
lv_obj_t * icon;
lv_obj_t * box = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_size(box, box_w, 260);
lv_obj_align(box, NULL, LV_ALIGN_IN_TOP_MID, 0, 100);
delay += LV_DEMO_PRINTER_ANIM_DELAY;
lv_demo_printer_anim_in(box, delay);
lv_group_add_obj(g, box);
LV_IMG_DECLARE(lv_demo_printer_img_copy);
LV_IMG_DECLARE(lv_demo_printer_img_scan);
LV_IMG_DECLARE(lv_demo_printer_img_print);
LV_IMG_DECLARE(lv_demo_printer_img_setup);
icon = add_icon(box, &lv_demo_printer_img_btn_bg_3, &lv_demo_printer_img_copy, "Page1");
lv_obj_align_origo(icon, NULL, LV_ALIGN_IN_LEFT_MID, 1 * (box_w - 20) / 8 + 10, 0);
lv_obj_set_event_cb(icon, copy_open_icon_event_cb);
lv_obj_fade_in(icon, LV_DEMO_PRINTER_ANIM_TIME * 2, delay + LV_DEMO_PRINTER_ANIM_TIME + 50);
lv_group_add_obj(g, icon);
icon = add_icon(box, &lv_demo_printer_img_btn_bg_3, &lv_demo_printer_icon_tel, "Page2");
lv_obj_align_origo(icon, NULL, LV_ALIGN_IN_LEFT_MID, 4 * (box_w - 20) / 8 + 10, 0);
lv_obj_fade_in(icon, LV_DEMO_PRINTER_ANIM_TIME * 2, delay + LV_DEMO_PRINTER_ANIM_TIME + 50);
lv_obj_set_event_cb(icon, print_open_event_cb);
lv_group_add_obj(g, icon);
icon = add_icon(box, &lv_demo_printer_img_btn_bg_3, &lv_demo_printer_img_setup, "Page3");
lv_obj_align_origo(icon, NULL, LV_ALIGN_IN_LEFT_MID, 7 * (box_w - 20) / 8 + 10, 0);
lv_obj_fade_in(icon, LV_DEMO_PRINTER_ANIM_TIME * 2, delay + LV_DEMO_PRINTER_ANIM_TIME + 50);
lv_obj_set_event_cb(icon, print_open_event_cb);
lv_group_add_obj(g, icon);
lv_indev_drv_t real_kb_drv;
lv_indev_drv_init(&real_kb_drv);
real_kb_drv.type = LV_INDEV_TYPE_KEYPAD;
real_kb_drv.read_cb = keyboard_read;
lv_indev_t* real_kb_indev = lv_indev_drv_register(&real_kb_drv);
lv_indev_set_group(real_kb_indev, g);
}
bool keyboard_read(lv_indev_drv_t* drv, lv_indev_data_t* data) {
data->key = last_key(); /*Get the last pressed or released key*/
if (key_pressed()) data->state = LV_INDEV_STATE_PR;
else data->state = LV_INDEV_STATE_REL;
return false; /*No buffering now so no more data read*/
}
until now I’m getting an error when running this code in keyboard_read