lvgl.switch
lvgl.switch([parent, ]params)
Display a button showing a switch name. Tapping it opens the switch-select popup, using EdgeTX styling.
Parameters
| Name | Req | Type | Description |
|---|
parent | no | object | optional LVGL object to attach the new object to; if omitted the object is created in the top-level script window |
params | yes | table | |
| Field | Type | Description |
|---|
x | number | position relative to the top-left of the parent | y | number | position relative to the top-left of the parent | w | number | width | h | number | height | color | color or function | primary color for the object | pos | function | dynamic position callback returning x, y | size | function | dynamic size callback returning w, h | visible | function | dynamic visibility callback | floating | boolean | keep the object fixed inside a scrollable container, added in 2.11.6, defaults to false | get | function | called on every refresh cycle to keep the displayed value in sync, to get the currently selected switch, defaults to nil | set | function | called when the user picks a switch; passed the selected switch value, defaults to nil | active | function | sets the enabled/disabled state; must return a boolean, true to enable, defaults to nil | filter | number | controls which switch types the user can pick; combine lvgl.SW_xxx constants to build a custom filter, defaults to lvgl.SW_ALL |
|
Returns
| Name | Type | Description |
- | table | LVGL object, or nil if not running as a One-Time script or fullscreen widget |
Availability
- Since:
2.11.0 - Radio support:
color-lcd
Notes
- Only available for One-Time scripts and widgets running in full screen mode -- returns nil otherwise. @notice The popup closes and
set is called when the user selects an item. @notice If the user taps outside the popup or presses RTN, the popup closes without calling set.
Source
radio/src/lua/api_colorlcd_lvgl.cpp