Encoder not moving focus in list


Everything is working so far except for the encoder that does not do anything but everytime I move the encoder event == LV_EVENT_CLICKED will be true… which I don’t know if that is correct.
The push button of the encoder works fine.

my questions:
What kind of value enc_get_new_moves() i supposed to return?
Do I have to implement myself the event handler for the Encoder?

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

ESP32 /SPI TFT Arduino IDE

What LVGL version are you using?


What do you want to achieve?

move focus of buttons in a list using an encoder

What have you tried so far?

Got the list
Got the buttons
Put the buttons inside a group
Created a new input device and binded to a group
Created encoder_read() function from example in documentation
Encoder works as I can serial print the count inside encoder_read().

Code to reproduce

static void event_handler(lv_obj_t * obj, lv_event_t event)
    if(event == LV_EVENT_CLICKED) {
        printf("Clicked: %s\n", lv_list_get_btn_text(obj));

bool encoder_read(lv_indev_drv_t * drv, lv_indev_data_t*data){

   data->enc_diff = enc_get_new_moves();

   if(enc_pressed()) data->state = LV_INDEV_STATE_PR;
   else data->state = LV_INDEV_STATE_REL;

   return false; /*No buffering now so no more data read*/

int enc_get_new_moves(){
  int encoderCount = encoder.getCount();
  Serial.println("encoderLastValue: " +String((int32_t)encoderLastValue));
  Serial.println("encoder CounttValue: " +String((int32_t)encoderCount));
  encoderLastValue = encoderCount;
 return encoderCount;

Screenshot and/or video

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

First problem found: I was passing the encoder count rather than the difference with last time.
Still does not work but closer

int enc_get_new_moves(){
  int encoderCount = encoder.getCount();
  int diff = encoderLastValue - encoderCount;
  encoderLastValue = encoderCount;
 return encoderCount;

Second problem found:

If I comment out this piece of code that handles the encoder push button the encoder works

   if(enc_pressed()) data->state = LV_INDEV_STATE_PR;
   else data->state = LV_INDEV_STATE_REL;

I can move the focus inside the list, but if the list is bigger than the list window …the focus will be only for visible buttons.

The encoder button is not working but I would that the click behaves the same as the TFT click.

Did you get it working, I have the same problem. Touch is working but encoder does nothing.