Hello.
I’ve been dealing with LVGL recently. I faced a problem that I could not overcome. I really hope for your help.
Description
I am trying to implement the processing of keyboard button presses. I get the codes of the pressed buttons. I tried to register my driver in LVGL, but the callback is never called.
What MCU/Processor/Board and compiler are you using?
STM32F429ZIT6 / FreeRTOS / STMCubeMX
What LVGL version are you using?
7.11
What do you want to achieve?
Operability of the input device
What have you tried so far?
Implemented the KEYPAD input device driver according to the LVGL documentation, but the breakpoints in the callback never fire.
Code to reproduce
Variable declaration, initialization, and input callback:
lv_obj_t * label_1;
lv_obj_t * ta1;
lv_obj_t * table1;
lv_obj_t * calendar;
lv_obj_t * list1;
lv_obj_t * dropdown;
static lv_disp_drv_t disp_drv;
static lv_indev_drv_t indev_drv;
static lv_indev_t * indev_keypad;
lv_group_t * group;
void Lvgl_Init ()
{
lv_init ();
static lv_disp_buf_t disp_buf;
static lv_color_t buf_1[LV_HOR_RES_MAX * LV_VER_RES_MAX / DIVIDER_SCR_SIZE];
static lv_color_t buf_2[LV_HOR_RES_MAX * LV_VER_RES_MAX / DIVIDER_SCR_SIZE];
lv_disp_buf_init (&disp_buf, buf_1, buf_2, LV_HOR_RES_MAX * LV_VER_RES_MAX / DIVIDER_SCR_SIZE);
lv_disp_drv_init (&disp_drv);
disp_drv.flush_cb = Lvgl_DisplayFlush;
disp_drv.buffer = &disp_buf;
lv_disp_drv_register (&disp_drv);
KeyReader_Init ();
lv_indev_drv_init (&indev_drv);
indev_drv.type = LV_INDEV_TYPE_KEYPAD;
indev_drv.read_cb = Lvgl_Keyboard_CB;
indev_keypad = lv_indev_drv_register (&indev_drv);
group = lv_group_create ()
lv_group_add_obj (group, label_1);
lv_group_add_obj (group, ta1);
lv_group_add_obj (group, table1);
lv_group_add_obj (group, calendar);
lv_group_add_obj (group, list1);
lv_group_add_obj (group, dropdown);
lv_indev_set_group (indev_keypad, group);
}
static bool Lvgl_Keyboard_CB(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
uint16_t last_key = 0;
uint16_t act_key = KeyReader_Get();
if(act_key != KEY_NONE)
{
data->state = LV_INDEV_STATE_PR;
data->key = act_key;
switch(act_key)
{
case KEY_RIGHT:
act_key = LV_KEY_NEXT;
break;
case KEY_LEFT:
act_key = LV_KEY_PREV;
break;
case KEY_DOWN:
act_key = LV_KEY_DOWN;
break;
case KEY_UP:
act_key = LV_KEY_UP;
break;
case KEY_ENTER:
act_key = LV_KEY_ENTER;
break;
default:
break;
}
last_key = act_key;
}
else
{
data->state = LV_INDEV_STATE_REL;
}
data->key = last_key;
return false;
}
As recommended i call lv_tick_inc in Application Hook of freertos which gets called once every ms:
void vApplicationTickHook( void )
{
lv_tick_inc(1);
}
There was no answer to a similar question asked earlier: