List - manual navigation problems

Documentation mentions that I can manually navigate the list with :

lv_list_up(list) and lv_list_down(list)

So if I want to move down by pressing a button attached to a GPIO ( I don’t want to use touch for this)

The problem is that I get compile errors (scope) while calling the _up and _down methods saying the list i am passing list is not declared. How can I make the list visible in other functions?

EDIT: lv_list_focus does the same but in a direct mode like it doesn’t have to sequentially move the focus up or down till it reaches the button ?

EDIT 2: This explains my question:

static lv_obj_t * list1;

Keep in mind that it’s generally cleaner to use a proper keypad input device for this; that way LVGL can manage the input automatically depending on the focused object.

Thanks, I am happy to use an encoder!
My project is an OBS controller, so I am displaying scenes in my TFT. The list widget seems to be perfect but the way OBS works makes hard to scroll the list without to changing the current scene by mistake. At this point I need to make a difference between a focus navigation like move up or down over the buttons but not clicking on them. I might need to create a video that explains this situation but there is two states:

A) the button is the current selected (this one works perfect)
b) while navigating the list I need a way to determine over which button I am passing.

I was able to implement lv_list_up(list) and lv_list_down(list) so the list seems to scroll but I don’t know where I am.

The thing is that I add the buttons dynamically and I don’t know the name of the objects (buttons) in order to be able to set the focus on them. What could I do in this case?

If you add the button to a group, I think it should handle all of this for you. Have you tried that?

I ensured to enable LV_USE_GROUP in lv_conf.h.

I’ve created a group then add the buttons of the list to the group. Then registered an input device type encoder, then binding the device to the group.

Then created encoder_read() function but get compile errors:
‘enc_get_new_moves’ was not declared in this scope
data->enc_diff = enc_get_new_moves();

Could be I don’t have the function because is missing in the library?

I believe you have to implement that function yourself, returning the distance the encoder has moved.

Thanks a lot, it’s clear. I will implement the functions. Any advice regarding Encoder? I will be using ESP32Encoder library which uses interruptions, is it all good with LVGL?

I have implemented enc_get_new_moves() but… no clear what value the function returns?
In my implementation the function can return a value that is a count that starts from zero and depending the direction the count will be negative or positive.

serial print:

20:45:27.502 -> encoderLastValue: 0
20:45:27.502 -> encoder CounttValue: 1
20:45:28.281 -> encoderLastValue: 1
20:45:28.281 -> encoder CounttValue: 2
20:45:28.393 -> encoderLastValue: 2
20:45:28.393 -> encoder CounttValue: 3
20:45:28.543 -> encoderLastValue: 3
20:45:28.543 -> encoder CounttValue: 4
20:45:28.690 -> encoderLastValue: 4
20:45:28.690 -> encoder CounttValue: 5
20:45:28.878 -> encoderLastValue: 5
20:45:28.878 -> encoder CounttValue: 6
20:45:29.469 -> encoderLastValue: 6
20:45:29.507 -> encoder CounttValue: 7
20:45:29.731 -> encoderLastValue: 7

the focus jumps from extremes or jumps 4 buttons instead of going one by one.

I am using ESP32Encoder lib

I believe you have to give LVGL the difference between the current value and the last one, not the value itself. Is that what you’re doing?

Based on your post here it looks like that is part of the problem.

I created a new post with headers-description and more detail.

Yes I was providing the encoder count rather than the diff. I just fixed and still does not work. I can see the current button that very fast blinks if I rotate the encoder but keeps in the same place. At the same time when I rotate the encoder the event_handler says I am clicking.