100askTeam / lv_lib_100ask

lv_lib_100ask is a reference for various out of the box schemes based on lvgl library or an enhanced interface for various components of lvgl library.
MIT License
90 stars 26 forks source link

Keypad input integration #6

Open everedero opened 6 months ago

everedero commented 6 months ago

Hi! I have been using the 2048 app with Zephyr RTOS on a board with keypad buttons.

In order to make it work, I had to add an object group (lv_group_t ), as mentionned in LVGL Readme . Then I put the 2048 button matrix in it:

lv_group_add_obj(btn_matrix_group, game_2048->btnm);

and then link it to the keypad input object:

lv_indev_set_group(lvgl_input_get_indev(lvgl_keypad), btn_matrix_group);

The whole commit is here.

Do you think it could be missing in your lvgl port too?

100ask commented 4 months ago

hi,

You need to register your input device. For 2048 games, you need to register keypads:

static lv_indev_drv_t keypad_driver;
lv_indev_drv_init(&keypad_driver);      /*Basic initialization*/
keypad_driver.type =LV_INDEV_TYPE_KEYPAD;                 /*See below.*/
keypad_driver.read_cb =you_read_cb ;             /*See below.*/
/*Register the driver in LVGL and save the created input device object*/
lv_indev_t * keypad_indev = lv_indev_drv_register(&keypad_driver);

Then:

lv_group_t * g = lv_group_create();
lv_group_set_default(g);
lv_indev_set_group(keypad_indev, g);

Reference: