Lv_slider set step

The slider can only step by + - 1 increments. A cool feature would be to add a lv_slider_set_step function that change the increment to a user value.

There is already a step for the spinbox with: lv_spinbox_set_step .

As a side note I have to say that I am unsure how it works on the spinbox. Maybe I understand it wrong? When I try the online python simulator using the code from the spinbox doc page and add the spinbox.set_step(2), the step is only changing for one of the digits.

Thanks for the idea. I’ll think about it it.

For the spinbox it can be only 1, 10, 100, etc.

It’s not the cleanest solution, but you can do this with an event handler. When you receive a VALUE_CHANGED event, round the current value to the nearest multiple of your step, and set the value using lv_slider_set_value(slider, new_value, LV_ANIM_OFF).

You will not receive another VALUE_CHANGED event after calling lv_slider_set_value (only moving the slider with an input device produces this event), so recursion will not be an issue.

1 Like