Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Return flight mode data.
@status current Introduced in 2.1.7
mode
(number) flight mode number to return (0 - 8). If mode parameter
is not specified (or contains invalid value), then the current flight mode data is returned.
multiple
returns 2 values:
(number) (current) flight mode number (0 - 8)
(string) (current) flight mode name
sourceName
: string naming a value source as it is shown on radio menus where you can select it. Notice that many names have special characters in them.
Return value
sourceIndex
: integer. The source index, which can be used as input for getSourceName(sourceIndex)
, getValue(sourceIndex)
, and getFieldInfo(sourceIndex)
.
The source names shown on the screen are not the same as the names used by getFieldInfo
and getValue
. But the indices are the same, so e.g. getValue(index)
will work with the indices obtained here.
This function is rather time consuming, and should not be used repeatedly in a script, if it can be avoided.
Current Introduced in 2.6
Return detailed information about field (source)
The list of valid sources is available:
OpenTX Version | Radio |
---|---|
@status current Introduced in 2.0.8, 'unit' field added in 2.2.0
source
can be an identifier (number) or a name (string) of the source.
table
information about requested field, table elements:
id
(number) field identifier
name
(string) field name
desc
(string) field description
'unit' (number) unit identifier Full list
nil
the requested field was not found
Returns the value of a source. Supersedes getValue
.
The list of fixed sources:
OpenTX Version | Radio |
---|
In OpenTX 2.1.x the telemetry sources no longer have a predefined name. To get a telemetry value simply use it's sensor name. For example:
Altitude sensor has a name "Alt"
to get the current altitude use the source "Alt"
to get the minimum altitude use the source "Alt-", to get the maximum use "Alt+"
value is nil for non-existing sources. all non-allowed sensors while FAI MODE is active, or if a telemetry item value has never been received
value is a table for GPS position:
lat
(number) latitude, positive is North
lon
(number) longitude, positive is East
pilot-lat
(number) pilot latitude, positive is North
pilot-lon
(number) pilot longitude, positive is East
value is a table for date/time, see getDateTime()
value is a table for battery cells(except where no cells were detected in which case the returned value is 0):
table has one item for each detected cell:
key (number) cell number (1 to number of cells)
value (number) current cell voltage
@status current Introduced in 2.8.0
source
can be an index (number) (which was obtained by getFieldInfo
or getSourceIndex
) or a name (string) of the source.
value
current source value (number), or last known telemetry item value.
isCurrent
is true for telemetry sources that are within the "Sensor Lost" duration and telemetry is streaming . Always true for non-telemetry items.
isFresh
is true for telemetry sources which have been recently updated and telemetry is streaming. Always true for non-telemetry items.
Getting a value by its numerical identifier is much faster than by its name. While Cels
sensor returns current values of all cells in a table, a Cels+
or Cels-
will return a single value - the maximum or minimum Cels value.
2.0
2.1
2.2
2.3
X9D and X9D+, X9E, X7, Horus
Gets the value of a shared memory variable that can be used for passing data between Lua widgets and other Lua scripts.
@status current Introduced in 2.6
Parameters
id:
integer between 1 and 16 identifying the shared memory variable.
Return value
value:
integer. The value of the shared memory variable.
Notice
Only available on radios with color display
Sets the value of a shared memory variable that can be used for passing data between Lua widgets and other Lua scripts.
@status current Introduced in 2.6
Parameters
id:
integer between 1 and 16 identifying the shared memory variable.
value:
integer. The value of the shared memory variable.
Return value
none
Notice
Only available on radios with color display
@status current Introduced in 2.6
switchIndex
: integer identifying a switch as returned by getSwitchIndex(positionName)
or fields in the table returned by model.getLogicalSwitch(switch)
identifying switches.
value: string naming the switch position as it is shown on radio menus where a switch can be chosen.
Sets the value of a sticky logical switch.
@status current Introduced in 2.6
id: integer identifying the sticky logical switch (zero for LS1 etc.).
value: true/false. The new value of the sticky logical switch.
bufferFull: true/false. This function sends a message from Lua to the logical switch processor via a buffer with eight slots that are read 10 times per second. If the buffer is full, then a true value is returned, and no message was sent (i.e. the switch was not changed).
This is an iterator function over switch positions.
for switchIndex, switchName in switches() do ...
will iterate over all available switch positions.
first
: the first switch index. If nil
or omitted, the first available switch is used.
last
: the last switch index. If nil
or omitted, the last available switch is used.
Current Introduced in 2.6
2.0 |
2.1 |
2.2 |
2.3 |
,
, ,
, , ,
This is an iterator function over value sources.
for sourceIndex, sourceName in sources() do ...
will iterate over all available value sources.
first
: the first source index. If nil
or omitted, the first available source is used.
last
: the last soure index. If nil
or omitted, the last available source is used.
current Introduced in 2.6
@status current Introduced in 2.8.0
Parameters
outputIndex:
integer identifying the output channel number 0 for CH1, up to MAX_OUTPUT_CHANNELS - 1.
Return value
value
current output value (number). Zero is returned for:
non-existing outputs
@status current Introduced in 2.6
positionName
: string naming a switch position as it is shown on radio menus where you can select a switch. Notice that many names have special characters in them like arrow up/down etc. (see Special Character Constants).
value: integer. The switchIndex, which can be used as input for `getSwitchName(switchIndex)` and `getSwitchValue(switchIndex)`. Also corresponds to the fields in the table returned by `model.getLogicalSwitch(switch)` identifying switches.
sourceIndex
: integer identifying a value source as returned by getSourceIndex(sourceName)
or the id
field in the table returned by getFieldInfo
.
sourceName
: string naming the value source as it is shown on radio menus where a source can be chosen.
The source names shown on the screen are not the same as the names used by getFieldInfo
and getValue
. But the indices are the same, so e.g. getValue(index)
will work with the indices used here.
Current Introduced in 2.6
Returns the value of a source.
The list of fixed sources:
OpenTX Version | Radio |
---|---|
In OpenTX 2.1.x the telemetry sources no longer have a predefined name. To get a telemetry value simply use it's sensor name. For example:
Altitude sensor has a name "Alt"
to get the current altitude use the source "Alt"
to get the minimum altitude use the source "Alt-", to get the maximum use "Alt+"
@status current Introduced in 2.0.0, changed in 2.1.0, Cels+
and Cels-
added in 2.1.9
source
can be an identifier (number) (which was obtained by the getFieldInfo())
or a name (string) of the source.
value
current source value (number). Zero is returned for:
non-existing sources
for all telemetry source when the telemetry stream is not received
far all non allowed sensors while FAI MODE is active
table
GPS position is returned in a table:
lat
(number) latitude, positive is North
lon
(number) longitude, positive is East
pilot-lat
(number) pilot latitude, positive is North
pilot-lon
(number) pilot longitude, positive is East
table
GPS date/time, see getDateTime()
table
Cells are returned in a table (except where no cells were detected in which case the returned value is 0):
table has one item for each detected cell:
key (number) cell number (1 to number of cells)
value (number) current cell voltage
Getting a value by its numerical identifier is faster then by its name. While Cels
sensor returns current values of all cells in a table, a Cels+
or Cels-
will return a single value - the maximum or minimum Cels value.
2.0
2.1
2.2
2.3
X9D and X9D+, X9E, X7, Horus