Draws a moving line graph from a given source in OpenTX
Example screens on X7 display with single/multiple graphs ...
... and inside a widget grid*.
*part of the opentx-lua-widgets package
Please go to the releases page to download the latest files.
- OpenTX v2.3.1 on Taranis Q X7
- OpenTX Companion v2.3.1 (FrSky platforms only)
-
SCRIPTS/GRAPHS/
graphs.lua
main scripttrigger.lua
user inputs
-
SCRIPTS/MIXES/
graphs.lua
model script
-
SCRIPTS/TELEMETRY/
telemetry screen examples -
SCRIPTS/WIDGETS/
graph.lua
widget for the opentx-lua-widgets grid system
-
WIDGETS/Graph/
Horus integration example
createGraph(id, opts)
Init and display the graph.
Option | Type | Description |
---|---|---|
id | number | Systemwide unique ID of the graph |
opts.src | function/string/number | Data source |
opts.max | number | Largest possible value |
opts.min | number | Smallest possible value |
opts.speed | number (optional, default 75 ) |
Update speed in 100ths second intervals, smaller is faster |
opts.lnStyle | number (optional, default SOLID - DOTTED at 'min' and 'max' values) |
SOLID for a full solid line, DOTTED for a dotted line |
opts.lnSize | number (optional, default 1) | Line thickness in px |
opts.crit | number (optional) | If set, the line style is DOTTED below and SOLID above this value. The Y-axis gets a mark at the values position |
getGraphRange(id)
Get minimum and maximum stored values of a graph, specified by id
.
Option | Type | Description |
---|---|---|
id | number | ID of the graph |
Returns table { min:number, max:number }
getGraphAverage(id)
Get average value of a graph, specified by id
.
Option | Type | Description |
---|---|---|
id | number | ID of the graph |
Returns number
Set input condition for the pause toggle. Relates to all graphs global.
SCRIPTS/GRAPHS/trigger.lua
return {
pause = {
func=function()
return getValue("sa") > 100
end
},
}
Switch [SA] value greater than 100 toggles pause event. To disable trigger, return false
(default).
Unzip the files from the release package and drag the contents to your radio. If you do this correctly, the SCRIPTS
directory will merge with your existing directories, placing the scripts in their appropriate paths.
The src
directory is not required for use and is only available for maintenance of the code. While it may work to use this directory, you may encounter some issues.
How to copy to the Transmitter:
A) Bootloader Method
- Power off your transmitter and power it back on in boot loader mode.
- Connect a USB cable and open the SD card drive on your computer.
- Unzip the file and copy the scripts to the root of the SD card.
- Unplug the USB cable and power cycle your transmitter.
B) Manual method (varies, based on the model of your transmitter)
- Power off your transmitter.
- Remove the SD card and plug it into a computer
- Unzip the file and copy the scripts to the root of the SD card.
- Reinsert your SD card into the transmitter
- Power up your transmitter.
If you copied the files correctly, you can now go to the CUSTOM SCRIPTS
screen and select the script graphs
:
- Hit the [MENU] button
- Long-press [PAGE] and repeat til page
CUSTOM SCRIPTS
- Select a free slot and [ENT]
- Select the script
graphs
and [ENT] - Press [EXIT] to return.
Go to the telemetry screen setup page and select telemetry pages.
Setting up the script as a telemetry page will enable access at the press of a button (on X7/X9 platforms).
- Hit the [MENU] button and select the model for which you would like to enable the script.
- While on the
MODEL SELECTION
screen, long-press the [PAGE] button to navigate to theDISPLAY
page. - Move the cursor to a free screen and hit [ENT].
- Select the
Script
option and press [ENT]. - Move the cursor to the script selection field
---
and hit [ENT]. - Select one of the listed telemetry scripts and hit [ENT].
- Long-press [EXIT] to return to your model screen.
To invoke the script, simply long-press the [PAGE] button from the model screen.
If you just copied the files, launched the script and a not enough memory
warning appears, probably restarting the radio is the only thing to do here (maybe several times). If OpenTX still complains try to delete all .luac
files and restart.
- Be sure to have
LUA 5.2
andNode.js
installed - Run
npm install
from the root folder to install node modules - Run
npm start
,make
or./bin/build.sh min
from the root folder with appropriate privileges (omit themin
switch to build without minifying) - Compiled/minified files will be created at the
obj
folder. Copy the files to your transmitter.