I installed the latest version of openTx 2.2 on the taranis and I activated the options lua and luac in companion.
I wrote a short lua script (here below).
Code: Select all
local timeprev
local running = false
local function init()
end
local function run()
if not running then
running = true
timeprev = getTime()
end
local timenow = getTime() -- 10ms tick count
if timenow - timeprev > 50 then -- more than 500 msec since previous run
timeprev = timenow
sportTelemetryPush( 0x48 , 0x32 , 0x52FF , 0)
end
end
return { init=init, run=run }
The name of the script is short rstful.lua
The script is installed on the SD card in the folder SCRIPTS/FUNCTIONS.
In the special function screen, I added en entry saying that when SA is up, the script must run.
This script seems to run in simulator in companion (e.g. if I add a line of code with print("test") just before the line sportTelemetryPush(), the debugger windows from companion shows the text "test" when the switch is activated).
Still, when I try the script on the Tx and if I connect a digital analyser on the SPORT bus from the Rx, I only see the normal polling code (0X7E + the device ID) and I never see the bytes that the Tx is supposed to send.
I do not know where I make a mistake.
Perhaps there are some special codes to use in the sportTelemetryPush() in order to let the RX output them on the SPORT?
Has someone already thy some similar functionality?