Description
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?
7
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.