Widget Scripts
Last updated
Was this helpful?
Last updated
Was this helpful?
Widget scripts are avaiable on radios equiped with color LCD. They are designed to run constantly in the background performinfg various task. Widget scripts are mostly used to extend EdgeTX functionality via Widgets that are places by user on Main Views. They are equivalent of Telemetry Scripts on radios equiped with B&W LCD.
Most of the time, widget scripts show some info in a Widget's zone in one of the user defined Main Views. They cannot receive direct input from the user via key events with exeption of being displayed in so called Full Screen mode. Full screen mode can be entered by selecting the widget, pressing ENTER and selecting Full screen from the widget's contextual menu, or by double tapping the widget on radios with a touch screen. Full screen mode can be exited by long pressing the EXIT (RTN) button, or by calling the Lua function lcd.exitFullScreen()
.
Each model can have up to nine Main Views, with up to 8 widgets per screen, depending on their size and layout. Each instance of a widget has his own options table.
Widget scripts are only available on radios with color LCD screens, such as e.g. FrSky X10 or X12, Radiomaster TX16S, Jumper T16 or T18, Flysky NV14., etc. Read more about radios.
All widget scripts on the SD card are loaded into memory when the model is selected, even widgets that are not used. This has the side effect that any global functions defined in a widget script will always be available to other widget scripts. It also means that any Widget Script placed in proper location on the SD card will consume part of the radio's memory - even if it is not being used.
It is important to either keep Widget Scripts small, or to use Lua's function to load code dynamically
Script executes until:
it misbehaves (e.g. too long runtime, run-time error, or low memory)
One-Time script is running. When One-time script finishes execution, Wigdet Script resumes execution.
Widget scripts are located on the SD card, each one in their specific folder: /WIDGETS/<folder name>/
Widget script folder name length must be 8 characters or less
Widget script name is constant and has to be named main.lua
Every Widget Script must include a return
statement at the end, defining its interface to EdgeTX. This statement returns a table with the following fields:
name
string
This variable holds a name that is displayed to user as Widget scripts name in available Widgets list.
The name
length must be 10 characters or less.
options
table
create
function
function is called once when the widget instance is registered (started).
Parameters
zone table
This parameter will hold visible dimensions of Widget (height & width)
options table
Initial options table as described above
Return values
widget table
Create function will return table that has to be later passed to update
, background
& refresh
functions allowing to access widget's unique variables
update
function
This function is called when Widget's Settings are changed by the user. It is mostly used to modify Widget Script variables or behaviour basing on options values entered by user.
Parameters
widget table
Widget's table returned by create
function, decribed above.
options table
Initial options table as described above
Return values none
background
function
This function is called periodically when the widget instance is NOT VISIBLE.
Parameters
widget table
Widget's table returned by create
function, decribed above.
Return values none
refresh
function
This function is called periodically when the widget instance IS VISIBLE.
Parameters
widget table
Widget's table returned by create
function, decribed above.
event number
When the widget is not in full screen mode, then event
is nil
touchState table
This parameter is only present when radio is equiped with touch interface and event
is a touch event.
When the widget is not in full screen mode then touchState
is nil
Return values none
Options table is to store Widget's options available to EdgeTX user via Widget's Settings menu. To see valid options read .
When Widget Script is in full screen mode, then event
is either 0, a , or a .
See .
If event
is a , then touchState
is a table. Otherwise, it is nil
.
See .