"Encoder" doing nothing but working in Serial Monitor


Hello, I have been trying to get my code from SquareLine Studio to work with 3 buttons as an input device, imitating an encoder. I want to navigate the menus with it, but it is doing nothing at all :frowning:

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

I am using an ESP32, with the module M5Stack Core2.

What LVGL version are you using?


What do you want to achieve?

To get the buttons working, but nothing happens.

What have you tried so far?

Debugging using log function

Code to reproduce

/* Deceleration of the button driver */ 
void lv_three_button_read(lv_indev_drv_t * drv, lv_indev_data_t * data){
  if(digitalRead(btn_left_pin) == LOW) { /* when digitalRead returns LOW, means the button is pressed */
    data->state = LV_INDEV_STATE_PRESSED;
    data->key = LV_KEY_LEFT;

  else if(digitalRead(btn_center_pin) == LOW) {
    data->state = LV_INDEV_STATE_PRESSED;
    data->key = LV_KEY_ENTER;

  else if(digitalRead(btn_right_pin) == LOW) {
    data->state = LV_INDEV_STATE_PRESSED;
    data->key = LV_KEY_RIGHT;

  else {
      data->state = LV_INDEV_STATE_RELEASED;
/* Deceleration of the touch driver (removed because it's unnecessary for this post)  */ 

void lv_setup() {
   /* Code to set up the display buffer and ect, removed since its unnecessary */

   /* Initialise the touch display driver, again removed since its unnecessary */

   /* Initialise the button encoder driver */
   static lv_indev_drv_t three_button_indev_drv;
   three_button_indev_drv.type = LV_INDEV_TYPE_ENCODER;
   three_button_indev_drv.read_cb = lv_three_button_read; /* Callback to touchscreen read function */

Screenshot and/or video

Third party video hosting service “Streamable”

I am having exactly the same problem, I have debugged the code, tried with different values of the “diff” of the encoder, I have changed all the available flag options (focus, scroll, etc), but there is no way, it does nothing in the screen I have also changed the color of the objects on the screen for each type of state, just in case it moves but the selection is not visible

For this control is objects under control required place into lvgroup an group assigned to indev control.

lv_group_add_obj(g1, cont);