Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
This section describes the Lua libraries, functions and constants that are provided by EdgeTX.
This section describes various constants that are provided for Lua by EdgeTX.
These constants are used with logical switch functions.
Constant name | Logical switch function |
---|---|
For detailed function explanation see Logiacal Switches functions in EdgeTX manual.
Name | Description |
---|
LS_FUNC_NONE
-
LS_FUNC_VEQUAL
a = x
LS_FUNC_VALMOSTEQUAL
a ~ x
LS_FUNC_VPOS
a > x
LS_FUNC_VNEG
a < x
LS_FUNC_RANGE
LS_FUNC_APOS
a > |x|
LS_FUNC_ANEG
a < |x|
LS_FUNC_AND
AND
LS_FUNC_OR
OR
LS_FUNC_XOR
XOR
LS_FUNC_EDGE
Edge
LS_FUNC_EQUAL
a = b
LS_FUNC_GREATER
a > b
LS_FUNC_LESS
a < b
LS_FUNC_DIFFEGREATER
∆ ≥ x
LS_FUNC_ADIFFEGREATER
|∆| ≥ x
LS_FUNC_TIMER
Timer
LS_FUNC_STICKY
Sticky
LCD_W | width in pixels |
LCD_H | height in pixels |
On radios with color display, a color may be added to the flags described above.
There are two types of color constants: one that is an index into a table holding a palette of theme colors, and one that is just a color.
These are the theme colors plus CUSTOM_COLOR, and they can be changed with the function lcd.setColor(color_index, color). Please note: if an indexed color is changed, then it changes everywhere that it is used. For the theme colors, this is not only in other widgets, but everywhere throughout the radio's user interface!
COLOR_THEME_PRIMARY1
COLOR_THEME_PRIMARY2
COLOR_THEME_PRIMARY3
COLOR_THEME_SECONDARY1
COLOR_THEME_SECONDARY2
COLOR_THEME_SECONDARY3
COLOR_THEME_FOCUS
COLOR_THEME_EDIT
COLOR_THEME_ACTIVE
COLOR_THEME_WARNING
COLOR_THEME_DISABLED
CUSTOM_COLOR
These color constants cannot be changed:
BLACK
WHITE
LIGHTWHITE
YELLOW
BLUE
DARKBLUE
GREY
DARKGREY
LIGHTGREY
RED
DARKRED
GREEN
DARKGREEN
LIGHTBROWN
DARKBROWN
BRIGHTGREEN
ORANGE
These should no longer be used, but they are included for backwards compatibility. The old OpenTX API had a large number of indexed theme colors, and these have been mapped to the new theme colors as follows:
ALARM_COLOR -> COLOR_THEME_WARNING
BARGRAPH_BGCOLOR -> COLOR_THEME_SECONDARY3
BARGRAPH1_COLOR -> COLOR_THEME_SECONDARY1
BARGRAPH2_COLOR -> COLOR_THEME_SECONDARY2
CURVE_AXIS_COLOR -> COLOR_THEME_SECONDARY2
CURVE_COLOR -> COLOR_THEME_SECONDARY1
CURVE_CURSOR_COLOR -> COLOR_THEME_WARNING
HEADER_BGCOLOR -> COLOR_THEME_FOCUS
HEADER_COLOR -> COLOR_THEME_SECONDARY1
HEADER_CURRENT_BGCOLOR -> COLOR_THEME_FOCUS
HEADER_ICON_BGCOLOR -> COLOR_THEME_SECONDARY1
LINE_COLOR -> COLOR_THEME_PRIMARY3
MAINVIEW_GRAPHICS_COLOR -> COLOR_THEME_SECONDARY1
MAINVIEW_PANES_COLOR -> COLOR_THEME_PRIMARY2
MENU_TITLE_BGCOLOR -> COLOR_THEME_SECONDARY1
MENU_TITLE_COLOR -> COLOR_THEME_PRIMARY2
MENU_TITLE_DISABLE_COLOR -> COLOR_THEME_PRIMARY3
OVERLAY_COLOR -> COLOR_THEME_PRIMARY1
SCROLLBOX_COLOR -> COLOR_THEME_SECONDARY3
TEXT_BGCOLOR -> COLOR_THEME_SECONDARY3
TEXT_COLOR -> COLOR_THEME_SECONDARY1
TEXT_DISABLE_COLOR -> COLOR_THEME_DISABLED
TEXT_INVERTED_BGCOLOR -> COLOR_THEME_FOCUS
TEXT_INVERTED_COLOR -> COLOR_THEME_PRIMARY2
TITLE_BGCOLOR -> COLOR_THEME_SECONDARY1
TRIM_BGCOLOR -> COLOR_THEME_FOCUS
TRIM_SHADOW_COLOR -> COLOR_THEME_PRIMARY1
WARNING_COLOR -> COLOR_THEME_WARNING
There are several option types that can be specified in the widget options table, which are exposed to the user via the Widget Settings menu.
Type | Description |
---|
Maximum fiveoptions
are allowed.
Note: from 2.11 ten options are allowed per widget.
Option variable name's length must be 10 characters or less and no spaces.
Index | Unit | Defined as |
---|
In addition to the key events described in the previous section, radios with a color touch screen also provide touch events to the widget scripts.
The following touch events are passed in the event
argument to the widget script refresh
function (when in full screen mode), just like the key events. The following touch events are provided:
Touch Event Name | Description |
---|
In addition to the above touch events a touchState
table is passed to refresh
with the following addional data fields:
touchState fields | Description |
---|
touchState
is nil
if event
is not a touch event. This can be used to test if we have a touch event or a key event.
Since Lua evaluates a nil
value to false
and everything else to true
:
if touchState then
we have a touch event.
x, y
are present for all touch events.
startX, startY, slideX, slideY
are only present with EVT_TOUCH_SLIDE
.
swipeUp
/ swipeDown
/ swipeLeft
/ swipeRight
may be present only withEVT_TOUCH_SLIDE
.
tapCount
is zero for anything but EVT_TOUCH_TAP
.
Displays prevoiusly loaded bitmap at (x,y) and optionally scales it.
Name | Req | Type | Description |
---|
none
Omitting scale draws image in 1:1 scale and is faster than specifying 100 for scale parameter.
Name | Description | EdgeTX ver | Notes |
---|---|---|---|
Name | Description | EdgeTX ver | Notes |
---|---|---|---|
EdgeTX version | Action |
---|
EdgeTX version | Action |
---|
0
normal font, default precision for numeric
2.3
XXLSIZE
jumbo font
2.3
DBLSIZE
double size font
2.3
MIDSIZE
mid sized font
2.3
SMLSIZE
small font
2.3
BOLD
bold font
2.3
Only color displays. This is a font size on its own - cannot be combined with other font size flags.
SHADOWED
shadow font
2.3
Only color displays
INVERS
inverted display
2.3
BLINK
blinking text
2.3
LEFT
left justify
2.3
Default for most functions not related to bitmaps
RIGHT
right justify
2.3
CENTER
center justify
2.3
Only color displays
VCENTER
center vertically
2.5.0
Only color displays
PREC1
single decimal place
2.3
display with one decimal place (number 386 is displayed as 38.6)
PREC2
two decimal places
2.3
display with one decimal place (number 386 is displayed as 3.86)
GREY_DEFAULT
grey fill
2.3
TIMEHOUR
display hours
2.3
Only for lcd/drawTimer
FORCE
pixels will be black
2.3
ERASE
pixels will be white
2.3
SOLID
lines will appear soild
2.3
DOTTED
lines will appear dotted
2.3
0 | Raw unit (no unit) | UNIT_RAW |
1 | Volts | UNIT_VOLTS |
2 | Amps | UNIT_AMPS |
3 | Milliamps | UNIT_MILLIAMPS |
4 | Knots | UNIT_KTS |
5 | Meters per Second | UNIT_METERS_PER_SECOND |
6 | Feet per Second | UNIT_FEET_PER_SECOND |
7 | Kilometers per Hour | UNIT_KMH |
8 | Miles per Hour | UNIT_MPH |
9 | Meters | UNIT_METERS |
10 | Feet | UNIT_FEET |
11 | Degrees Celsius | UNIT_CELSIUS |
12 | Degrees Fahrenheit | UNIT_FAHRENHEIT |
13 | Percent | UNIT_PERCENT |
14 | Milliamp Hour | UNIT_MAH |
15 | Watts | UNIT_WATTS |
16 | Milliwatts | UNIT_MILLIWATTS |
17 | dB | UNIT_DB |
18 | RPM | UNIT_RPMS |
19 | G | UNIT_G |
20 | Degrees | UNIT_DEGREE |
21 | Radians | UNIT_RADIANS |
22 | Milliliters | UNIT_MILLILITERS |
23 | Fluid Ounces | UNIT_FLOZ |
24 | Ml per minute | UNIT_MILLILITERS_PER_MINUTE |
35 | Hours | UNIT_HOURS |
36 | Minutes | UNIT_MINUTES |
37 | Seconds | UNIT_SECONDS |
38 | Virtual unit | UNIT_CELLS |
39 | Virtual unit | UNIT_DATETIME |
40 | Virtual unit | UNIT_GPS |
41 | Virtual unit | UNIT_BITFIELD |
42 | Virtual unit | UNIT_TEXT |
EVT_TOUCH_FIRST | When the finger touches down on the screen |
EVT_TOUCH_TAP | If the finger leaves the screen after a quick tap |
EVT_TOUCH_BREAK | If the finger leaves the screen without tap or slide |
EVT_TOUCH_SLIDE | Repeats while the finger is sliding on the screen |
x, y | Current touch point |
startX, startY | Point where slide started |
slideX, SlideY | Movement since previous SLIDE event (or start of slide) |
swipeUp / swipeDown / swipeLeft / swipeRight | The field is present and equal to |
tapCount | Counts the number of consecutive taps |
2.3.0 | Introduced |
2.3.0 | Introduced |
COLOR | Displays a color picker, returns a color flag value |
BOOL | Displays a toggle/checkbox, value toggles between 0 and 1 |
STRING | Text input option, limited to 8 characters in 2.10 or earlier, 12 characters in 2.11. |
TIMER | Choice option, lets you pick from available timers |
SOURCE | Choice option, lets you pick from available sources (i.e. sticks, switches, LS) |
SWITCH | Choice option to select from available switches. |
VALUE | Numerical input option, can specify default, min and max value |
TEXT_SIZE | Choice option, lets you pick from the available text sizes (i.e. small, large) |
ALIGNMENT | Choice option, lets you pick from available alignment options (i.e. left, center, right) |
SLIDER | Select numerical value using a slider control (available in 2.11) |
CHOICE | Select numerical value using a custom popup list (available in 2.11) |
FILE | Select a file from SD card / internal storage (available in 2.11). Filename is limited to 12 characters maximum. |
Draw a combo box
@status current Introduced in 2.0.0
x,y
(positive numbers) top left corner position
w
(number) width of combo box in pixels
list
(table) combo box elements, each element is a string
idx
(integer) index of entry to highlight
flags
(unsigned number) drawing flags, the flags can not be combined:
BLINK
combo box is expanded
INVERS
combo box collapsed, text inversed
0 or not present
combo box collapsed, text normal
none
Only available on Taranis
The radio's special characters can be used with the following text constants.
CHAR_RIGHT
CHAR_LEFT
CHAR_UP
CHAR_DOWN
CHAR_DELTA
CHAR_STICK
CHAR_POT
CHAR_SLIDER
CHAR_SWITCH
CHAR_TRIM
CHAR_INPUT
CHAR_FUNCTION
CHAR_CYC
CHAR_TRAINER
CHAR_CHANNEL
CHAR_TELEMETRY
CHAR_LUA
These constants determine the type of a Special Function
FUNC_OVERRIDE_CHANNEL
FUNC_TRAINER
FUNC_INSTANT_TRIM
FUNC_RESET
FUNC_SET_TIMER
FUNC_ADJUST_GVAR
FUNC_VOLUME
FUNC_SET_FAILSAFE
FUNC_RANGECHECK
FUNC_BIND
FUNC_PLAY_SOUND
FUNC_PLAY_TRACK
FUNC_PLAY_VALUE
FUNC_PLAY_SCRIPT
FUNC_RESERVE5
FUNC_BACKGND_MUSIC
FUNC_BACKGND_MUSIC_PAUSE
FUNC_VARIO
FUNC_HAPTIC
FUNC_LOGS
FUNC_BACKLIGHT
FUNC_SCREENSHOT
FUNC_RACING_MODE
FUNC_DISABLE_TOUCH
Draw a straight line on LCD
@status current Introduced in 2.0.0, flags introduced in 2.3.6
x1,y1
(positive numbers) starting coordinate
x2,y2
(positive numbers) end coordinate
pattern
SOLID or DOTTED
flags
lcdflags
none
If the start or the end of the line is outside the LCD dimensions, then the whole line will not be drawn (starting from OpenTX 2.1.5)
Draw a rectangle from top left corner (x,y) of specified width and height
@status current Introduced in 2.0.0, changed in 2.2.0
x,y
(positive numbers) top left corner position
w
(number) width in pixels
h
(number) height in pixels
flags
(unsigned number) drawing flags
t
(number) thickness in pixels, defaults to 1 (only on Horus)
none
Draw a single pixel at (x,y) position
@status current Introduced in 2.0.0
x
(positive number) x position
y
(positive number) y position
flags
(optional) lcdflags
none
Taranis has an LCD display width of 212 pixels and height of 64 pixels. Position (0,0) is at top left. Y axis is negative, top line is 0, bottom line is 63. Drawing on an existing black pixel produces white pixel (TODO check this!)
Draw a simple gauge that is filled based upon fill value
@status current Introduced in 2.0.0, changed in 2.2.0
x,y
(positive numbers) top left corner position
w
(number) width in pixels
h
(number) height in pixels
fill
(number) amount of fill to apply
maxfill
(number) total value of fill
flags
(unsigned number) drawing flags
none
Draw a text representation of switch at (x,y)
@status current Introduced in 2.0.0
x,y
(positive numbers) starting coordinate
switch
(number) number of switch to display, negative number displays negated switch
flags
(unsigned number) drawing flags, only SMLSIZE, BLINK and INVERS.
none
Display a value formatted as time at (x,y)
@status current Introduced in 2.0.0, SHADOWED
introduced in 2.2.1
x,y
(positive numbers) starting coordinate
value
(number) time in seconds
flags
(unsigned number) drawing flags:
0 or not specified
normal representation (minutes and seconds)
TIMEHOUR
display hours
other general LCD flag also apply
SHADOWED
Horus only, apply a shadow effect
none
color | integer (colorFlag) |
bitmap | bitmapPointer |
x | integer | top coordinate |
y | integer | left coordinate |
scale | integer (0-100) | scale in percent ie. 50 divides size by two, 100 displays bitmap in original size, 200 doubles size. |
Description
Lcd functions allow scripts to interact with the transmitter display. This access is limited to the 'run' functions of One-Time and Telemetry scripts. Widget scripts on the Horus (X10 and X12S) can make use of the lcd functions as well.
Notes:
The run function is periodically called when the screen is visible. In OpenTX 2.0 each invocation starts with a blank screen (unless lcd.lock() is used). Under OpenTX 2.1 screen state is always persisted across calls to the run function. Many scripts originally written for OpenTX 2.0 require a call to lcd.clear() at the beginning of their run function in order to display properly under 2.1 and 2.2.
Many of the lcd functions accept parameters named flags and patterns. The names and their meanings are described below.
Name | Description | Version | Notes |
---|---|---|---|
Draw a text beginning at (x,y)
@status current Introduced in 2.0.0, SHADOWED
introduced in 2.2.1
x,y
(positive numbers) starting coordinate
text
(string) text to display
flags
(unsigned number) drawing flags. All values can be combined together using the + character. ie BLINK + DBLSIZE. See the for available characters in each font set.
0 or not specified
normal font
XXLSIZE
jumbo sized font
DBLSIZE
double size font
MIDSIZE
mid sized font
SMLSIZE
small font
INVERS
inverted display
BLINK
blinking text
SHADOWED
Horus only, apply a shadow effect
none
Display a number at (x,y)
@status current Introduced in 2.0.0, SHADOWED
introduced in 2.2.1
x,y
(positive numbers) starting coordinate
value
(number) value to display
flags
(unsigned number) drawing :
0 or not specified
display with no decimal (like abs())
PREC1
display with one decimal place (number 386 is displayed as 38.6)
PREC2
display with tow decimal places (number 386 is displayed as 3.86)
other general LCD also apply\
none
see
stored in variable pointer to a bitmap previously opened with
Name | Description |
---|---|
Name | Description |
---|---|
Radio | LCD_W | LCD_H | Colours |
---|---|---|---|
0
normal font, default precision for numeric
DBLSIZE
double size font
MIDSIZE
mid sized font
SMLSIZE
small font
INVERS
inverted display
BLINK
blinking text
XXLSIZE
jumbo font
2.0.6
LEFT
left justify
2.0.6
Default for most functions not related to bitmaps
RIGHT
right justify
PREC1
single decimal place
PREC2
two decimal places
GREY_DEFAULT
grey fill
TIMEHOUR
dislay hours
Only for drawTimer
FORCE
pixels will be black
ERASE
pixels will be white
DOTTED
lines will appear dotted
LCD_W
width in pixels
LCD_H
height in pixels
X7
128
64
1 bit
X9D
212
64
4 bit
X9D+
212
64
4 bit
X9E
212
64
4 bit
X10
480
272
RGB565
X12S
480
272
RGB565
Draw a line only inside a rectangle
@status current Introduced in 2.4.0
x1,y1,x2,y1
(positive numbers) coordinates of the start and end of the unclipped line
xmin,xmax,ymin,ymax
(positive numbers) the limits of the rectangle inside which the line is drawn
pattern
(FORCE, ERASE, DOTTED) please see Lcd functions overview
none
Invert a rectangle zone from top left corner (x,y) of specified width and height
@status current Introduced in 2.8.0
Parameters
x,y
(positive numbers) top left corner position
w
(number) width in pixels
h
(number) height in pixels
flags
(optional) please see Lcd functions overview
Return value
none
Draw text inside rectangle (x,y,w,h) with line breaks
x,y
(positive numbers) starting coordinate
w,h
(positive numbers) width and height of bounding rectangle
text
(string) text to display
flags
(optional) please see for drawing flags and colors, and for available characters in each font set. RIGHT, CENTER and VCENTER are not implemented.
x,y (integers) point where text drawing ended
EdgeTX version | Action |
---|
2.5.0 | Introduced |
2.11.0 | x,y return added |
Set a color for specific area
@status current Introduced in 2.2.0
area
(unsigned number) specific screen area in the list bellow
CUSTOM_COLOR
DEFAULT_COLOR
DEFAULT_BGCOLOR
FOCUS_COLOR
FOCUS_BGCOLOR
LINE_COLOR
CHECKBOX_COLOR
MENU_BGCOLOR
MENU_COLOR
MENU_TITLE_DISABLE_COLOR
HEADER_COLOR
ALARM_COLOR
HIGHLIGHT_COLOR
TEXT_DISABLE_COLOR
HEADER_COLOR
DISABLE_COLOR
CURVE_CURSOR_COLOR
TITLE_BGCOLOR
TRIM_BGCOLOR
TRIM_SHADOW_COLOR
MAINVIEW_PANES_COLOR
MAINVIEW_GRAPHICS_COLOR
MENU_BGCOLOR
HEADER_ICON_BGCOLOR
HEADER_CURRENT_BGCOLOR
MAINVIEW_PANES_COLOR
MAINVIEW_GRAPHICS_COLOR
OVERLAY_COLOR
BARGRAPH1_COLOR
BARGRAPH2_COLOR
BARGRAPH_BGCOLOR
CUSTOM_COLOR
color
(number) color in 5/6/5 rgb format. The following prefined colors are available
WHITE
GREY
LIGHTGREY
DARKGREY
BLACK
YELLOW
BLUE
RED
DARKRED
none
Only available on Colorlcd radios
Raises a pop-up on screen that asks for confirmation
@status current Introduced in 2.2.0, changed from (title, event) to (title, message, event) in 2.3.8
title
(string) title to display
message
(string) text to display
event
(number) the event variable that is passed in from the Run function (key pressed)
"CANCEL"
user pushed EXIT key
Use only from stand-alone and telemetry scripts.
Displays a bitmap pattern at (x,y)
@status current Introduced in 2.8.0
Parameters
bitmap
(pointer) point to a bitmap previously opened with Bitmap.open()
x,y
(positive numbers) starting coordinates
flags
(optional) please see Lcd functions overview
Return value
none
Notice
Only available on Horus
Raises a pop-up on screen that allows uses input
@status current Introduced in 2.0.0
title
(string) text to display
event
(number) the event variable that is passed in from the Run function (key pressed)
input
(number) value that can be adjusted by the +/- keys
min
(number) min value that input can reach (by pressing the - key)
max
(number) max value that input can reach
number
result of the input adjustment
"OK"
user pushed ENT key
"CANCEL"
user pushed EXIT key
Use only from stand-alone and telemetry scripts.
Displays a bitmap pattern pie at (x,y)
@status current Introduced in 2.8.0
Parameters
bitmap
(pointer) point to a bitmap previously opened with Bitmap.open()
x,y
(positive numbers) starting coordinates
startAngle
Start angle
endAngle
End angle
flags
(optional) please see Lcd functions overview
Return value
none
Notice
Only available on Horus
Raises a pop-up on screen that shows a warning
@status current Introduced in 2.2.0
title
(string) text to display
event
(number) the event variable that is passed in from the Run function (key pressed)
"CANCEL"
user pushed EXIT key
Use only from stand-alone and telemetry scripts.
Constants defined for use in LVGL layouts.
Name | Description |
---|
Some simple example scripts to set the stage.
When run this produces the page shown below.
The user can exit the script by tapping the 'CLOSE' button or tapping the 'EdgeTX' button in the top-left corner. In both cases a popup dialog will be shown - if the user selects 'Yes' the script will close.
LVGL version of the 'Counter' script.
BW radios
Color radios
2.11.0
Introduced
lvgl.FLOW_ROW |
lvgl.FLOW_COLUMN |
lvgl.PAD_TINY |
lvgl.PAD_SMALL |
lvgl.PAD_MEDIUM |
lvgl.PAD_LARGE |
Display a button showing a text alignment name. When tapped a popup menu is opened to choose a text alignment from. Uses EdgeTX styling.
lvgl.align([parent], {settings})
parent:align({settings})
See the API page for parameter description and common settings.
Choice specific settings:
Name | Type | Description | Default if not set |
---|---|---|---|
The popup menu is closed when the user selects an item, and the 'set' function is called.
If the user taps outside the menu or the RTN key is pressed, the popup menu is closed and the 'set' function is not called.
Avail | Status | Comment | |
---|---|---|---|
Returns colorFlag in RGB565 format that can be used with lcd draw functions.
Name | Req | Type | Description |
---|---|---|---|
or
Name | Req | Type | Description |
---|---|---|---|
color_flag
. See Drawing Flags
LVGL objects are created and manipulated using the 'lvgl' functions.
Most of these functions follow the syntax below. A few function have only the optional 'parent' parameter.
Parameter | Notes | Description |
---|---|---|
Most of the functions return an LVGL object that can be used to update the UI or in other API calls.
API functions can also be called using Lua OO syntax.
For example the following two lines are equivalent.
There are a number of settings that are common to all of the LVGL functions that take a 'settings' table parameter.
Name | Type | Description | Default if not set |
---|---|---|---|
The functions associated with settings are called periodically by the firmware. Where a setting is defined using a function, the UI will automatically update whenever the function returns a different value.
Although width and height, and the size function, can be defined for all objects they may not be used in some cases. For example when creating a circle or arc object the radius property should be used instead.
Display a button showing an option value. When tapped a popup menu is opened with multiple options to choose from. Uses EdgeTX styling.
lvgl.choice([parent], {settings})
parent:choice({settings})
See the API page for parameter description and common settings.
Choice specific settings:
Name | Type | Description | Default if not set |
---|---|---|---|
LVGL object
The popup menu is closed when the user selects an item, and the 'set' function is called.
If the user taps outside the menu or the RTN key is pressed, the popup menu is closed and the 'set' function is not called.
Display a solid or filled circle.
lvgl.circle([parent], {settings})
parent:circle({settings})
See the API page for parameter description and common settings.
Note: 'w', 'h' and 'size' should not be used with lvgl.circle. Use 'radius' instead.
Circle specific settings:
Name | Type | Description | Default if not set |
---|
LVGL object
Avail | Status | Comment |
---|
EdgeTX widgets and One-Time scipts can make use of LVGL controls and objects to create the script user interface. In addition to providing much better performance, this gives Lua scripts the same styles applied to firmware LVGL pages and controls.
The LVGL API can be used to add varios objects such as labels, rectangles, circles, buttons, toggle switches, sliders and more. Objects can be grouped, e.g. a rectangle can contain child labels or any other object. Objects can be moved, resized and updated as needed.
Many object properties can be set dynamically through functions in the Lua script - whenever the function returns a new value the objects property is automaticall changed. This removes the need for manually re-drawing the user interface.
Direct drawing via the 'lcd' API is not available for scripts using LVGL to create the UI.
A script that wants to use LVGL to create the UI must return 'useLvgl = true' in the table returned by the script:
Once activated a new 'lvgl' object will be available to use in the script. This is the primary interface to the LVGL API.
Scripts should check that 'lvgl' is not nil before use. If the 'lvgl' object is nil it is most likely the script is running on an earlier version of EdgeTX (prior to 2.11), or you forgot to set 'useLvgl = true'. Scripts should either display an error or fall back to using the lcd API in LVGL is not available.
One-Time scripts have only two functions. Prior to the LVGL API, the 'init' function would be used to set up the initial state for the script and the 'run' function would re-draw the UI whenever called as well as process key and touch events.
With the LVGL API, the 'init' function should still set up the initial state for the script; but should also create the UI from LVGL objects. The 'run' function may handle key and touch events; but in most cases the LVGL objects themselves will do the heavy lifting. When set up correctly the LVGL UI will be automatically updated as the local state is changed, and the script will be automatically updated as the user interacts with the LVGL objects.
Widget scripts using LVGL should create their UI in the 'update' function using the widget size to determine what elements to create and how to lay them out.
The 'background' and 'run' functions should just update essential state changes that are not being managed directly by the LVGL objects.
EdgeTX version | Change |
---|---|
EdgeTX version | Action |
---|---|
Avail | Status | Comment | |
---|---|---|---|
EdgeTX version | Change |
---|---|
EdgeTX version | Change |
---|
get
Function
Called to get the currently selected alignment, when the popup menu is first opened.
nil
set
Function
Called when the user taps on an alignment button. The function is passed a single parameter wihich is the selected alignement value.
nil
BW radios
Color radios
Only available for One-Time script
2.11.0
Introduced
r
integer
number between 0 (0x00) and 255 (0xFF) that expresses te amount of red in the color
g
interer
number between (0x00) and 255 (0xFF) that expresses te amount of green in the color
b
integer
number between (0x00) and 255 (0xFF)that expresses te amount of blue in the color
rgb
integer
number between 0 (0x00) and 16777215 (0xFFFFFF) that expresses the RGB value (0xFF0000=RED, 0x00FF00=GREEN, 0x0000FF=BLUE)
2.3.0
Introduced
parent
Optional (with some exceptions) If present must be an LVGL object
Parent object. If set then whatever LVGL objects are created by the function are set as children of 'parent'. If not set then objects are created in the top level script window.
settings
Mandatory (with some exceptions) Must be a table
Contains all of the settings required to create the LVGL object.
x
Number
Horizontal position of the object relative to the top left corner of the parent object.
0
y
Number
Vertical position of the object relative to the top left corner of the parent object.
0
w
Number
Width of the object
Auto size to fit content
h
Number
Height of the object
Auto size to fit content
color
Color or Function
Primary color for the object.
COLOR_THEME_SECONDARY1
pos
Function
Position of the object relative to the top left corner of the script window. Must return a table with two values - x, y.
nil
size
Function
Size of the object. Must return a table with two values - width, height.
nil
visible
Function
Controls visibility of the object. Must return a boolean - true if the object is shown, false to hide it.
nil
title
String
Text to be displayed in the header of the popup menu.
Empty string
values
Table
Must contain a simple table of strings. Each string defines an options shown in the popup menu.
Empty list
get
Function
Called to get the index of the currently selected option, when the popup menu is first opened. Must return a number between 0 and the number of values - 1.
nil
set
Function
Called when the user taps on a menu item. The function is passed a single parameter wihich is the index of the selected item (0 .. number of values - 1)
nil
BW radios
Color radios
Only available for One-Time script
2.11.0
Introduced
thickness | Number | Sets the width of the line used to draw the arc. | 1 |
filled | Boolean | If true the circle is filled with the 'color'value | false |
radius | Number or Function | Sets the radius of the arc | 0 |
BW radios |
Color radios | active |
2.11.0 | Introduced |
Create a container for managing object layout.
Build a complex UI in a single operation.
lvgl.build([parent], {{settings}})
parent:build({{settings}})
See the API page for parameter description and common settings.
Build specific settings:
Name | Type | Description | Default if not set |
---|---|---|---|
Table of named LVGL objects.
The 'settings' parameter to lvgl.build should be a table of tables. Each inner table creates a separate LVGL object based on the 'type' value.
For example the code below creates two object, a label and a rectangle.
Objects can be nested by using the 'children' setting, this should be another table of tables just like the build settings.
For example this code creates another label as a child of the rectangle object. The x & y co-ordinates for the second label are relative to the top left corner of the parent rectangle.
The lvgl.build function will return a table of LVGL objects. This table will contain named references to any objects created that have the 'name' setting, Only references to named objects are returned.
For example this code assigns a name to the inner label and then updates the color.
Very large nested tables or very deeply nested tables may not work when compiled to a .luac script. If your script works when run from the .lua file; but fails when run from .luac, try breaking the lvgl.build call into multiple calls with smaller tables.
Display a 'Yes' / 'No' confirmation dialog box.
Hide an LVGL object.
lvgl.hide(parent)
parent:hide()
See the API page for parameter description and common settings.
The 'parent' parameter is mandatory.
The 'settings' parameter is not used.
The 'visible' setting function can also be used to dynamically show and hide objects.
Avail | Status | Comment |
---|
Display an image. The image will be centered in the frame (x, y, w, h). Images can be scaled to either fit entirely within the frame or completely fill the frame.
Display a horizontal line.
lvgl.hline([parent], {settings})
parent:hline({settings})
See the API page for parameter description and common settings.
The 'w' setting determinse the length of the line.
The 'h' setting determines the thickness of the line.
Hline specific settings:
Name | Type | Description | Default if not set |
---|
LVGL object
Avail | Status | Comment |
---|
Display a button showing a font name. When tapped a popup menu is opened to choose a font from. Uses EdgeTX styling.
lvgl.font([parent], {settings})
parent:font({settings})
See the API page for parameter description and common settings.
Choice specific settings:
Name | Type | Description | Default if not set |
---|
LVGL object
The popup menu is closed when the user selects an item, and the 'set' function is called.
If the user taps outside the menu or the RTN key is pressed, the popup menu is closed and the 'set' function is not called.
Display a button showing a color swatch. When tapped the color picker dialog is opened allowing the user to select a new color. Uses EdgeTX styling.
lvgl.color([parent], {settings})
parent:color({settings})
See the API page for parameter description and common settings.
Choice specific settings:
Name | Type | Description | Default if not set |
---|
LVGL object
The popup menu is closed when the user selects an item, and the 'set' function is called.
If the user taps outside the menu or the RTN key is pressed, the popup menu is closed and the 'set' function is not called.
Add a text button using the EdgeTX style.
EdgeTX version | Change |
---|---|
Avail | Status | Comment | |
---|---|---|---|
EdgeTX version | Change |
---|---|
EdgeTX version | Change |
---|
EdgeTX version | Change |
---|
EdgeTX version | Change |
---|
Avail | Status | Comment |
---|
EdgeTX version | Change |
---|
Avail | Status | Comment |
---|
EdgeTX version | Change |
---|
EdgeTX version | Change |
---|
title
String
Text to be displayed in the header of the dialog box.
Empty string
close
Function
Called when the dialog box is closed.
nil
flexFlow
Flow type - lvgl.FLOW_COLUMN or lvgl.FLOW_ROW
Enable flex layout for this box.
not used
flexPad
Number
When flex layout is used, set the padding between rows or columns. Recommended to use the lvgl.PAD_xxx values.
0
BW radios
Color radios
2.11.0
Introduced
flexFlow
Flow type - lvgl.FLOW_COLUMN or lvgl.FLOW_ROW
Enable flex layout for this box.
not used
flexPad
Number
When flex layout is used, set the padding between rows or columns. Recommended to use the lvgl.PAD_xxx values.
0
BW radios
Color radios
2.11.0
Introduced
type
String
Mandatory on each table entry to determine what type of LVGL object to create.
name
String
Empty string
children
Table
nil
BW radios
Color radios
2.11.0
Introduced
title
String
Text to be displayed in the header of the dialog box.
Empty string
message
String
Text to be displayed in the body of the dialog box
Empty string
confirm
Function
Called when the user taps the 'Yes' button.
nil
cancel
Function
Called when the user taps the 'No' button.
nil
BW radios
Color radios
2.11.0
Introduced
BW radios |
Color radios | active |
2.11.0 | Introduced |
file | String | File name of the image to display. Must include full path to image file on the SD card. | Empty string |
fill | Boolean | If true the image is scaled to completely fill the frame. The image may be cropped. If false it is scaled to fit entirely in the frame. The result may have empty borders. | false |
BW radios |
Color radios | active |
2.11.0 | Introduced |
rounded | Boolean | If true then the end caps of the line are rounded. | false |
BW radios |
Color radios | active |
2.11.0 | Introduced |
get | Function | Called to get the currently selected font, when the popup menu is first opened. | nil |
set | Function | Called when the user taps on a font button. The function is passed a single parameter wihich is the selected font value. | nil |
BW radios |
Color radios | active | Only available for One-Time script |
2.11.0 | Introduced |
get | Function | Called to get the currently selected color, when the popup menu is first opened. | nil |
set | Function | Called when the user taps on an color button. The function is passed a single parameter wihich is the selected color value. | nil |
BW radios |
Color radios | active | Only available for One-Time script |
2.11.0 | Introduced |
text | String | Text to be displayed in the button. | Empty string |
press | Function | Called when the user taps on the button. | nil |
BW radios |
Color radios | active | Only available for One-Time scripts |
2.11.0 | Introduced |
Display one or more connected lines.
lvgl.line([parent], {settings})
parent:line({settings})
See the API page for parameter description and common settings.
The 'x, 'y, 'w' and 'h' settings are not used.
Line specific settings:
Name | Type | Description | Default if not set |
---|---|---|---|
LVGL object
Avail | Status | Comment | |
---|---|---|---|
Create a page layout for a One-Time script using EdgeTX styling. The page layout has a menu bar at the top with title and sub-title lines as well as a 'back' button in the top left corner.
lvgl.page({settings})
The lvgl.page function uses only the settings shown below. The common settings shown on the API page are not used.
Name | Type | Description | Default |
---|---|---|---|
LVGL object
The 'page' object should be created as the top level LVGL object in the script window, and all other LVGL objects added as children of the 'page' object.
Update the settings for an LVGL object.
lvgl.set([parent], {settings})
parent:set({settings})
See the API page for parameter description and common settings.
See the function description pages for settings specific to each LVGL object type.
This can be used to update one or more settings for an existing LVGL object. The 'settings' parameter should contain values relevant to the type of object being created.
This can be used to update settings that do not support being controlled by functions (e.g. rectangle thickness).
Avail | Status | Comment | |
---|---|---|---|
Display a QR code.
lvgl.qrcode([parent], {settings})
parent:qrcode({settings})
See the API page for parameter description and common settings.
Note: 'w' and 'h' should be set to the same value for a QR code.
QR code specific settings:
Name | Type | Description | Default if not set |
---|---|---|---|
LVGL object
Avail | Status | Comment | |
---|---|---|---|
Create a container for managing object layout.
Delete LVGL objects.
lvgl.clear([parent])
parentclear()
See the API page for parameter description and common settings.
The 'settings' parameter is not used.
If 'parent' is not set then the entire script UI is deleted. Use this when the UI changes dramatically (e.g. widget size changes).
When the 'parent' parameter is defined, only the child LVGL objects within the parent are deleted. Use this to remove and replace a specific set of objects.
Avail | Status | Comment | |
---|---|---|---|
Show an LVGL object.
lvgl.show(parent)
parent:show()
See the API page for parameter description and common settings.
The 'parent' parameter is mandatory.
The 'settings' parameter is not used.
The 'visible' setting function can also be used to dynamically show and hide objects.
Avail | Status | Comment | |
---|---|---|---|
Display a text label.
Display a button showing a source name. When tapped the switch select popup is opened to allow the user to select a new source. Uses EdgeTX styling.
lvgl.source([parent], {settings})
parent:source({settings})
See the API page for parameter description and common settings.
Source specific settings:
Name | Type | Description | Default if not set |
---|
LVGL object
The popup menu is closed when the user selects an item, and the 'set' function is called.
If the user taps outside the menu or the RTN key is pressed, the popup menu is closed and the 'set' function is not called.
Display a vertical line.
lvgl.vline([parent], {settings})
parent:hline({settings})
See the API page for parameter description and common settings.
The 'h' setting determinse the length of the line.
The 'w' setting determines the thickness of the line.
Vline specific settings:
Name | Type | Description | Default if not set |
---|
LVGL object
Avail | Status | Comment |
---|
Add a slider using the EdgeTX style.
Display a button showing a switch name. When tapped the switch select popup is opened to allow the user to select a new switch. Uses EdgeTX styling.
lvgl.switch([parent], {settings})
parent:switch({settings})
See the API page for parameter description and common settings.
Switch specific settings:
Name | Type | Description | Default if not set |
---|
LVGL object
The popup menu is closed when the user selects an item, and the 'set' function is called.
If the user taps outside the menu or the RTN key is pressed, the popup menu is closed and the 'set' function is not called.
EdgeTX version | Change |
---|---|
EdgeTX version | Change |
---|---|
Avail | Status | Comment | |
---|---|---|---|
EdgeTX version | Change |
---|---|
EdgeTX version | Change |
---|---|
EdgeTX version | Change |
---|---|
EdgeTX version | Change |
---|---|
EdgeTX version | Change |
---|---|
EdgeTX version | Change |
---|---|
Avail | Status | Comment |
---|
EdgeTX version | Change |
---|
EdgeTX version | Change |
---|
EdgeTX version | Change |
---|
Avail | Status | Comment |
---|
EdgeTX version | Change |
---|
title
String
Text to be displayed in the header of the dialog box.
Empty string
message
String
Text to be displayed in the body of the dialog box
Empty string
details
Function
Text to be displayed in the body of the dialog box
Empty string
BW radios
Color radios
2.11.0
Introduced
rounded
Boolean
If true then the end caps of the line are rounded.
false
thickness
Number
Sets the thickness of each line segment.
1
pts
Table of points. Each point must be a table with two number values ({x, y})
Defines the points used to draw the line segments. There must be at least two points.
nil
BW radios
Color radios
2.11.0
Introduced
text
String or Function
Set the text to be displayed on the label
Empty string
font
Font value or Function
Sets the font size and justification for the text. E.G.: - MIDSIZE - DBLSIZE + RIGHT
0 (standard size)
BW radios
Color radios
2.11.0
Introduced
title
String
Text to be displayed as the title in the header of the page.
Empty string
subtitle
String
Text to be displayed as the sub-title in the header of the page.
Empty string
icon
String
Full path to an image file on the SD card to be displayed as the icon in the 'back' button (top left corner). If not set then the EdgeTX logo icon is used. The icon file is a mask image and should be 30x30 pixels in size and be a grey-scale image. White pixels are transparent and black pixels are fully opaque.
Empty string
back
Function
Called when the user taps the 'back' button in the top left corner.
nil
flexFlow
Flow type - lvgl.FLOW_COLUMN or lvgl.FLOW_ROW
Enable flex layout for this page.
not used
flexPad
Number
When flex layout is used, set the padding between rows or columns. Recommended to use the lvgl.PAD_xxx values.
0
BW radios
Color radios
Only available for One-Time scripts
2.11.0
Introduced
BW radios
Color radios
2.11.0
Introduced
data
String
Sets the URL or other content to be enccoded in the QR code.
Empty string
bgColor
Color
Sets the background color for the QR code image.
COLOR_THEME_SECONDARY3
BW radios
Color radios
2.11.0
Introduced
BW radios
Color radios
2.11.0
Introduced
BW radios
Color radios
2.11.0
Introduced
BW radios
Color radios
2.11.0
Introduced
BW radios
Color radios
Only available for One-Time scripts
2.11.0
Introduced
BW radios
Color radios
2.11.0
Introduced
thickness
Number
Sets the width of the line used to draw the border.
1
filled
Boolean
If true the rectangle is filled with the 'color' value.
false
rounded
Number
If greater than 0 makes the corners rounded with a radius set this value. When set to a value greater than 0, must also be >= thickness.
0
BW radios
Color radios
2.11.0
Introduced
get | Function | Called to get the currently selected source, when the popup menu is first opened. | nil |
set | Function | Called when the user taps on an source button. The function is passed a single parameter wihich is the selected source value. | nil |
BW radios |
Color radios | active | Only available for One-Time script |
2.11.0 | Introduced |
rounded | Boolean | If true then the end caps of the line are rounded. | false |
BW radios |
Color radios | active |
2.11.0 | Introduced |
BW radios |
Color radios | active | Only available for One-Time scripts |
2.11.0 | Introduced |
min | Number | Minimum value for the slider range (left end). | 0 |
max | Number | Maximum value for the slider range (right end). | 100 |
get | Function | Called to get the currrent value for the slider knob. Should rethrn a value between min and max (inclusive). | nil |
set | Function | Called when the user interacts with the slider and changes the knob position. The function is passed a single number parameter with the new value. |
BW radios |
Color radios | active | Only available for One-Time scripts |
2.11.0 | Introduced |
get | Function | Called to get the currently selected switch, when the popup menu is first opened. | nil |
set | Function | Called when the user taps on an switch button. The function is passed a single parameter wihich is the selected switch value. | nil |
BW radios |
Color radios | active | Only available for One-Time script |
2.11.0 | Introduced |
Display a button showing a timer name. When tapped a popup menu is opened to choose a timer from. Uses EdgeTX styling.
lvgl.timer([parent], {settings})
parent:timer({settings})
See the API page for parameter description and common settings.
Timer specific settings:
Name | Type | Description | Default if not set |
---|---|---|---|
LVGL object
The popup menu is closed when the user selects an item, and the 'set' function is called.
If the user taps outside the menu or the RTN key is pressed, the popup menu is closed and the 'set' function is not called.
Add a toggle switch using the EdgeTX style.
Display a filled triangle.
lvgl.triangle([parent], {settings})
parent:triangle({settings})
See the API page for parameter description and common settings.
The 'x, 'y, 'w' and 'h' settings are not used.
Triangle specific settings:
Name | Type | Description | Default if not set |
---|---|---|---|
LVGL object
Unlike the line drawing objects, there is no built in triangle drawing in LVGL. The method used to draw triangles is quite simple and does not do any anti-aliasing.
Display an arc.
lvgl.arc([parent], {settings})
parent:arc({settings})
See the API page for parameter description and common settings.
Note: 'w', 'h' and 'size' should not be used with lvgl.arc. Use 'radius' instead.
Arc specific settings:
Name | Type | Description | Default if not set |
---|---|---|---|
LVGL object
Avail | Status | Comment | |
---|---|---|---|
EdgeTX version | Change |
---|---|
EdgeTX version | Change |
---|---|
EdgeTX version | Action |
---|---|
Avail | Status | Comment | |
---|---|---|---|
EdgeTX version | Change |
---|---|
Avail | Status | Comment | |
---|---|---|---|
EdgeTX version | Change |
---|---|
get
Function
Called to get the currently selected timer, when the popup menu is first opened.
nil
set
Function
Called when the user taps on an timer button. The function is passed a single parameter wihich is the selected timer value.
nil
BW radios
Color radios
Only available for One-Time script
2.11.0
Introduced
get
Function
Called to get the curent state of the toggle switch. Must return a number value - 0 if the toggle switch is off, 1 if it should be on.
nil
set
Function
Called when the user interacts with the toggle switch. The function is passed a single number parameter - 0 if the toggle switch is off, 1 if it is on.
nil
BW radios
Color radios
Only available for One-Time scripts
2.11.0
Introduced
BW radios
Color radios
2.4.0
Introduced
x
top coordinate
y
left coordinate
source
can be a source identifier (number) or a source name (string). See getValue()
flags
See Drawing Flags
2.3.0
Introduced
inputID
number
input ID number. Zero based. Use 0 for Input 1, 7 for Input 8 etc.
lineID
number
line ID number. Zero based. Use 0 for line 1, 1 for line 2 etc.
BW radios
Color radios
2.4.0
Introduced
pts
Table of points. Each point must be a table with two number values ({x, y})
Defines the points used to draw the triangle. There must be three points.
nil
BW radios
Color radios
2.11.0
Introduced
thickness
Number
Sets the width of the line used to draw the arc.
1
radius
Number or Function
Sets the radius of the arc
0
startAngle
Number or Function
Sets the starting angle or the arc. Measured in degrees - 0 - 360. 0 is to the right (3 o'clock).
0
endAngle
Number or Function
Sets the ending angle for the arc.
0
BW radios
Color radios
2.11.0
Introduced
BW radios
Color radios
2.4.0
Introduced