How many options can I put in lvgl roller?

Description

Is there a limit on the lvgl roller for having options? I am trying to put 60 options on a singular roller and it seems to be crashing, but works fine when the roller options are reduced. Just wished to try out a way to input hour and minute options on the roller for my small lvgl project (novice).

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

ESP32 WROOM

What LVGL version are you using?

8.3.4

What do you want to achieve?

Wanted to know the upper limit of the roller.

What have you tried so far?

I have looked at the documentation but did not seem to find a specific number. I have tried and put a smaller number of options, the maximum that I was able to make it run with was 24 options.

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The code block(s) should be formatted like:

/*You code here*/
void create_rollers(lv_obj_t* act_scr){
const char* roller_opt = "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n";

lv_obj_t* t1 = lv_roller_create(lv_scr_act());
    lv_obj_add_style(t1, &time_roller_style, 0);
    lv_obj_set_style_bg_opa(t1, LV_OPA_TRANSP, LV_PART_SELECTED);

    lv_roller_set_options(t1, roller_opt,LV_ROLLER_MODE_INFINITE);
    lv_roller_set_visible_row_count(t1, 3);
    lv_obj_align(minute_time_roller, LV_ALIGN_CENTER, 40, 0);
    lv_obj_add_event_cb(t1, NULL, LV_EVENT_ALL, NULL);
}

Thanks in advance!

Hi @Eidolon ,

As far as I can remember the roller gets into trouble with more than around 60 items if you don’t enable the extended coordinate feature in lv_conf.h

I would try enabling the extended coordinate range as follows:

/*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/
#define LV_USE_LARGE_COORD 1

Also please note when you enable LV_ROLLER_MODE_INFINITE with a large quantity of items in the list, the memory requirement for the widget also increases considerably so make sure you have plenty of memory available.

The other think to mention is you don’t need a \n at the end of the options string.

Kind Regards,

Pete

It would be nice if there was a version of the roller that allowed for adding “items” or other widgets. I am not sure how it is done with the roller but the way the zoom effect works when setting the selected font to a larger font. There is a hard line where the text part way into that area will be partially increased in size. Having that kind of a feature but with a roller that can support other widgets instead of text would be something neat.

Hi @pete-pjb! Thanks for replying. After the change of the config file (lv_conf.h) the roller is running a little smooth but I think putting 60 options on it is already pushing it to its limits. I would need to find another alternative to selecting hours and minutes. Your advice helped me solve my issue! When I used infinite roller mode, the other options seemed to leak out and show up instead of the correct options so I went ahead with LV_ROLLER_MODE_NORMAL

1 Like

@kdschlosser that feature would be neat!