Spinbox (lv_spinbox)
Spinbox contains an integer displayed as a decimal number with a possible fixed decimal point position and a configurable number of digits. The value can be increased or decreased by Keys or API fu...
Overview
Spinbox contains an integer displayed as a decimal number with a possible fixed decimal point position and a configurable number of digits. The value can be increased or decreased by Keys or API functions. Under the hood Spinbox is a Text Area (lv_textarea) with behaviors extended to enable a numeric value to be viewed and modified with configurable constraints.
Parts and Styles
Spinbox's parts are identical to those of Text Area.
Value, range and step
lv_spinbox_set_value(spinbox, 1234)sets a new value for the Spinbox.lv_spinbox_increment(spinbox)andlv_spinbox_decrement(spinbox)increments/decrements the value of the Spinbox according to the currently-selected digit.lv_spinbox_set_range(spinbox, -1000, 2500)sets its range. If the value is changed bylv_spinbox_set_value(spinbox), by Keys, bylv_spinbox_increment(spinbox)orlv_spinbox_decrement(spinbox)this range will be respected.lv_spinbox_set_step(spinbox, 100)sets which digit to change on increment/decrement. Only multiples of ten can be set.lv_spinbox_set_cursor_pos(spinbox, 1)sets the cursor to a specific digit to change on increment/decrement. Position '0' sets the cursor to the least significant digit.
If an encoder is used as input device, the selected digit is shifted to
the right by default whenever the encoder button is clicked. To change this behavior to shifting
to the left, the lv_spinbox_set_digit_step_direction(spinbox, LV_DIR_LEFT) can be used.
Format
lv_spinbox_set_digit_format(spinbox, digit_count, separator_position)
sets the number format. digit_count is the total number of digits to display.
separator_position is the number of leading digits before the decimal point.
Pass 0 for separator_position to display no decimal point.
Rollover
lv_spinbox_set_rollover(spinbox, true/false) enables/disables
rollover mode. If either the minimum or maximum value is reached with
rollover enabled, and the user attempts to continue changing the value in
the same direction, the value will change to the other limit. If rollover
is disabled the value will stop at the minimum or maximum value.
Events
LV_EVENT_VALUE_CHANGEDSent when value has changed.
Data binding
To get familiar with observers, subjects, and data bindings in general visit the Observer page.
This method of subscribing to an integer Subject affects a Subject Widget's integer value directly. Note that this is a two-way binding (Subject <===> Widget), so an end user's direct interaction with the Spinbox Widget updates the Subject's value and vice versa.
It supports integer subjects.
Keys
LV_KEY_LEFT/RIGHTWith Keypad move the cursor left/right. With Encoder decrement/increment the selected digit.LV_KEY_UP/DOWNWith Keypad and Encoder increment/decrement the value.LV_KEY_ENTERWith Encoder, move focus to next digit. If focus is on last digit, focus moves to first digit.
Further Reading
Learn more about Keys.
Example
Simple Spinbox
API
How is this guide?
Last updated on
Spangroup (lv_spangroup)
The Spangroup Widget is used to display rich text. Different from the Label Widget, Spangroups can render text styled with different fonts, colors, and sizes into the Spangroup Widget.
Spinner (lv_spinner)
The Spinner Widget is a spinning arc over a ring, typically used to show some type of activity is in progress.