Encoder not working

Description

What MCU/Processor/Board and compiler are you using?

STM32F205RGT6

What LVGL version are you using?

8.3

What do you want to achieve?

Working with the LVGL encoder. When turning the knob to the right in data->enc_diff = 1; and on the left data->enc_diff = -1; in normal position data->enc_diff = 0; When I rotate the encoder and press the button, I observe the event in the debugger. But nothing works. Works well with touch screen. Please help. Sorry, English is not my native language, I can’t explain it better. Thank you.

What have you tried so far?

Code to reproduce

Encoder_Init();
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_ENCODER;
indev_drv.read_cb = encoder_read;

void encoder_read(lv_indev_drv_t * drv, lv_indev_data_t*data){
data->enc_diff = StateRead();
if(!enc_pressed()) data->state = LV_INDEV_STATE_PRESSED;
else data->state = LV_INDEV_STATE_RELEASED;
}

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Read Input device interface — LVGL documentation
To use an Encoder (similarly to the Keypads ) the objects should be added to groups. Because system dont know what is controlled as on touch.

Thanks for your help. I did this and it worked.
Encoder_Init();
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_ENCODER;
indev_drv.read_cb = encoder_read;
encoder_indev = lv_indev_drv_register(&indev_drv);
g = lv_group_create();
lv_group_set_default(g);
lv_indev_set_group(encoder_indev, g);

bool encoder_read(lv_indev_drv_t * drv, lv_indev_data_t*data)
{
data->enc_diff = TIM4_read();
if (data->enc_diff > 0)
{
data->key = LV_KEY_LEFT;
data->state = LV_INDEV_STATE_PR;
}
if (data->enc_diff < 0)
{
data->key = LV_KEY_RIGHT;
data->state = LV_INDEV_STATE_PR;
}
if (!enc_pressed())
{
data->key = LV_KEY_ENTER;
data->state = LV_INDEV_STATE_PR;
}
else data->state = LV_INDEV_STATE_REL;
return false;
}