Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
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
.
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 true
if a swipe event occurred in that direction
tapCount
Counts the number of consecutive taps
This section describes various constants that are provided for Lua by EdgeTX.
The radio's special characters can be used with the following text constants.
Please note that the special characters are only available for standard and BOLD
font sizes.
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
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
This page describes the value that is passed to scripts in the event parameter. It is used in Telemetry and One-Time scripts, as well as widget scripts in full screen mode.
Each time a key is pressed, held and released a number of events get generated. Here is a typical flow:
when a key is pressed a FIRST
event is generated
if the key continues to be pressed, then after a while a LONG
event is generated
if the key continues to be pressed, then a REPEAT
events are being generated
when the key is released a BREAK
event is generated
Couple of examples:
a short press on key would generate: FIRST
, BREAK
a longer pres on key would generate: FIRST
, LONG
, BREAK
even longer press: FIRST
, LONG
, REPEAT,
REPEAT, ..., BREAK
This normal key event sequence can be altered with the function. Any time this function is called (after the FIRST
event) all further key events for this key will be suppressed until the next key press of this key. Examples:
kill immediately after the key press would generate: FIRST
kill after the long key press would generate: FIRST
, LONG
The event
parameter in the and scripts run function actually carries two pieces of information:
key number
type of event
The two fields are combined into one single number. Some of these combinations are defined as constants and are available to Lua scripts:
Radios with rotary encoder (X7 and Horus) have also:
Given the large number of radios supported by OpenTX, and the large difference in keys available on those, a set of VIRTUAL KEYS has been defined and are mapped to best fit available hardware
Name | Description |
---|
Key Event Name | Comments |
---|
Key Event Name | Comments |
---|
Virtual Key Event Name | Comments |
---|
0 | normal font, default precision for numeric |
XXLSIZE | jumbo font | 2.0.6 |
DBLSIZE | double size font |
MIDSIZE | mid sized font |
SMLSIZE | small font |
BOLD | bold font | Only color displays. This is a font size on its own - cannot be combined with other font size flags. |
SHADOWED | shadow font | Only color displays |
INVERS | inverted display |
BLINK | blinking text |
LEFT | left justify | 2.0.6 | Default for most functions not related to bitmaps |
RIGHT | right justify |
CENTER | center justify | Only color displays |
VCENTER | center vertically | 2.5.0 | Only color displays |
PREC1 | single decimal place |
PREC2 | two decimal places |
GREY_DEFAULT | grey fill |
TIMEHOUR | display hours | Only for drawTimer |
FORCE | pixels will be black |
ERASE | pixels will be white |
DOTTED | lines will appear dotted |
EVT_MENU_BREAK | MENU key release |
EVT_PAGE_BREAK | PAGE key release |
EVT_PAGE_LONG | MENU key long press |
EVT_ENTER_BREAK | ENT key release |
EVT_ENTER_LONG | ENT key long press |
EVT_EXIT_BREAK | EXIT key release |
EVT_PLUS_BREAK | + key release |
EVT_MINUS_BREAK | - key release |
EVT_PLUS_FIRST | + key press |
EVT_MINUS_FIRST | - key press |
EVT_PLUS_REPT | + key repeat |
EVT_MINUS_REPT | - key repeat |
EVT_ROT_BREAK | rotary encoder release |
EVT_ROT_LONG | rotary encoder long press |
EVT_ROT_LEFT | rotary encoder rotated left |
EVT_ROT_RIGHT | rotary encoder rotated right |
EVT_VIRTUAL_NEXT_PAGE | for PAGE navigation |
EVT_VIRTUAL_PREV_PAGE | for PAGE navigation |
EVT_VIRTUAL_ENTER |
EVT_VIRTUAL_ENTER_LONG |
EVT_VIRTUAL_MENU |
EVT_VIRTUAL_MENU_LONG |
EVT_VIRTUAL_NEXT | for FIELDS navigation |
EVT_VIRTUAL_NEXT_REPT | for FIELDS navigation |
EVT_VIRTUAL_PREV | for FIELDS navigation |
EVT_VIRTUAL_PREV_REPT | for FIELDS navigation |
EVT_VIRTUAL_INC | for VALUES navigation |
EVT_VIRTUAL_INC_REPT | for VALUES navigation |
EVT_VIRTUAL_DEC | for VALUES navigation |
EVT_VIRTUAL_DEC_REPT | for VALUES navigation |
These constants give the type of logical switch function.
LS_FUNC_NONE
LS_FUNC_VEQUAL
LS_FUNC_VALMOSTEQUAL
LS_FUNC_VPOS
LS_FUNC_VNEG
LS_FUNC_RANGE
LS_FUNC_APOS
LS_FUNC_ANEG
LS_FUNC_AND
LS_FUNC_OR
LS_FUNC_XOR
LS_FUNC_EDGE
LS_FUNC_EQUAL
LS_FUNC_GREATER
LS_FUNC_LESS
LS_FUNC_DIFFEGREATER
LS_FUNC_ADIFFEGREATER
LS_FUNC_TIMER
LS_FUNC_STICKY
Name | Description |
---|---|
LCD_W
width in pixels
LCD_H
height in pixels
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