Lua Telemetry scripts
-
- 9x Developer
- Posts: 2764
- Joined: Fri Dec 30, 2011 11:11 pm
- Country: -
Re: Lua Telemetry scripts
This lib costs 4k RAM, is it really needed?
Re: Lua Telemetry scripts
Damn Bertrand, that would be awesome to be added in next versions.
I'm trying to put some strings on a precise place of the screen and i hate to do it manually. .
I also want to send a couple of data that i will decode on the script but also need the string functions.
I'm trying to put some strings on a precise place of the screen and i hate to do it manually. .
I also want to send a couple of data that i will decode on the script but also need the string functions.
Re: Lua Telemetry scripts
bertrand35 wrote:This lib costs 4k RAM, is it really needed?
For me is, (and some 2 or 3 people trying to use the mikrokopter->frsky decoder).
Re: Lua Telemetry scripts
So it's just a define line to add the string functions?
Just adding:
#include <lstrlib.c>
should work?
Just adding:
#include <lstrlib.c>
should work?
-
- 9x Developer
- Posts: 2764
- Joined: Fri Dec 30, 2011 11:11 pm
- Country: -
Re: Lua Telemetry scripts
I will enable it in 2.1
You have to modify the Makefile and linit.c
You have to modify the Makefile and linit.c
Re: Lua Telemetry scripts
Ok thanks!
Re: Lua Telemetry scripts
Hi,
i use the opentx firmware 2.0.8 (opentx-taranis-haptic-lua-de-2.0.8.bin) and copy the lua script into this folder \SCRIPTS\DJI F550\tele2.lua but it do not work? i only see three telemetry screens.. is it necessary activate lua scripting ? Firmware Lua option is enabled..
possible the blank inside the model name DJI F550 is a problem?
regards Patrick
i use the opentx firmware 2.0.8 (opentx-taranis-haptic-lua-de-2.0.8.bin) and copy the lua script into this folder \SCRIPTS\DJI F550\tele2.lua but it do not work? i only see three telemetry screens.. is it necessary activate lua scripting ? Firmware Lua option is enabled..
possible the blank inside the model name DJI F550 is a problem?
regards Patrick
Re: Lua Telemetry scripts
Helitamer wrote:Hi,
i use the opentx firmware 2.0.8 (opentx-taranis-haptic-lua-de-2.0.8.bin) and copy the lua script into this folder \SCRIPTS\DJI F550\tele2.lua but it do not work? i only see three telemetry screens.. is it necessary activate lua scripting ? Firmware Lua option is enabled..
possible the blank inside the model name DJI F550 is a problem?
regards Patrick
The blank in the name is a problem, based on my experience. Also, the script should be called telem2.lua, not tele2.lua
Rgds.,
Paul
Re: Lua Telemetry scripts
DJI_F550.
Sent via mobile
Sent via mobile
Re: Lua Telemetry scripts
Thx, now it works if i replace the blank..
-
- 9x Developer
- Posts: 2764
- Joined: Fri Dec 30, 2011 11:11 pm
- Country: -
Re: Lua Telemetry scripts
For the same reason than the Naze32, OpenTX is not compatible with DJI 550
Re: Lua Telemetry scripts
Hello Bertrand, I have a new awesome stupid question concerning lua scripts.
If i use a lua custom script, can i use the values from him in a telemetry script?
I'm thinking on using the variables created from Fig newton gheading script into my telemetry script, so i can use the home heading.
another way is to include the gheading script into my lua script and adapt it.
What do you think is the best thing?
Thanks!
If i use a lua custom script, can i use the values from him in a telemetry script?
I'm thinking on using the variables created from Fig newton gheading script into my telemetry script, so i can use the home heading.
another way is to include the gheading script into my lua script and adapt it.
What do you think is the best thing?
Thanks!
Re: Lua Telemetry scripts
You only need lines 115 to 131 from the gheading script to achieve a Course to Home feature.
I've opened a issue on OpenTX github and Bertrand kept it open.
https://github.com/opentx/opentx/issues/1581
I've opened a issue on OpenTX github and Bertrand kept it open.
https://github.com/opentx/opentx/issues/1581
Re: Lua Telemetry scripts
thanks for that info!
that is perfect.
that is perfect.
Re: Lua Telemetry scripts
Hi Friends, I am quite knew with Lua and I need some help.
I use the script Telem2.lua which show me both the "altitude" and "altitude-max" from the vario on my TX screen.
I practice F5J altimeter and I have a RC Electronics basic 2 altimeter on board, which show the official FAI altitude, but I have a difference about 25 m between the altimeter 2 and the vario altitude, so I am thinking about to increase in 25 m the values that the script shows on my TX.
As you know the script is:
lcd.drawNumber(210, 10, getValue("altitude"), XXLSIZE)
lcd.drawText(150, 54, "MAX", 0)
lcd.drawChannel(172, 54, "altitude-max", LEFT)
I suppose that I need to create two new variables that increase the "altitude" and "altitude-max" in 25 metres, and show on the screen these new variables. I don't know how to do it and if it is possible to do that.
Could you help me
thanks in advance
Jose
I use the script Telem2.lua which show me both the "altitude" and "altitude-max" from the vario on my TX screen.
I practice F5J altimeter and I have a RC Electronics basic 2 altimeter on board, which show the official FAI altitude, but I have a difference about 25 m between the altimeter 2 and the vario altitude, so I am thinking about to increase in 25 m the values that the script shows on my TX.
As you know the script is:
lcd.drawNumber(210, 10, getValue("altitude"), XXLSIZE)
lcd.drawText(150, 54, "MAX", 0)
lcd.drawChannel(172, 54, "altitude-max", LEFT)
I suppose that I need to create two new variables that increase the "altitude" and "altitude-max" in 25 metres, and show on the screen these new variables. I don't know how to do it and if it is possible to do that.
Could you help me
thanks in advance
Jose
Re: Lua Telemetry scripts
lcd.drawNumber(210, 10, getValue("altitude")+25, XXLSIZE) ?
Re: Lua Telemetry scripts
Thanks Klirah, it works, now I can see the new altitude on the screen.
The voice of the TX is still reading aloud the value "Alt" when I press a switch, I don't know if I be able to change that.
The voice of the TX is still reading aloud the value "Alt" when I press a switch, I don't know if I be able to change that.
Re: Lua Telemetry scripts
Nope. Unless you do the audio play from the script too with the same correction instead of using the built-in method.
Sent via mobile
Sent via mobile
Re: Lua Telemetry scripts
Can someone give me a pointer to all the telemetry "channels" there are to be read and then used in scripting.
So far I have seen two different call methods, to my surprise they both seem to get the same values
Variant 1
altitude = getValue("altitude")
Variant 2
CurrentAlt = getValue(206)
Thanks a lot in advance
So far I have seen two different call methods, to my surprise they both seem to get the same values
Variant 1
altitude = getValue("altitude")
Variant 2
CurrentAlt = getValue(206)
Thanks a lot in advance
Re: Lua Telemetry scripts
http://www.open-tx.org/2014/07/19/Lua-reference-guide/
"altitude" is simply a constant that equals 206 to make things simpler. These were added recently.
"altitude" is simply a constant that equals 206 to make things simpler. These were added recently.
Re: Lua Telemetry scripts
I'm having an issue with a telemetry script (the same as allways).
I need to use a function to convert an integer into a binary string. I'm trying to use the for do sentence, but it seems not to be working... Is it available?
this is the function:
thanks
I need to use a function to convert an integer into a binary string. I'm trying to use the for do sentence, but it seems not to be working... Is it available?
this is the function:
Code: Select all
function NumberToStringBytes(num,optionalNumberOfBytes)
local retString=""
optionalNumberOfBytes = optionalNumberOfBytes or 4
for i=1,optionalNumberOfBytes do
retString = string.char(num%256) .. retString
num = math.floor(num/256)
end
return retString
end
Re: Lua Telemetry scripts
I will answer myself.... the string module is not loaded in the opentx, so i cant do the string.char()...
Re: Lua Telemetry scripts
And i resolve it. It's a bit of a hack but seems to work.
it will return a 8 bits string from a number.
Now i can continue.
it will return a 8 bits string from a number.
Now i can continue.
Code: Select all
function tobits(num)
local retString=""
local i = 8
while i >= 0 do
if math.floor(num /(2^i)) >= 1 then
retString = retString .."1"
num = num-math.pow(2,i)
else
retString = retString .. "0"
end
i = i-1
end
return retString
end
-
- 9x Developer
- Posts: 2764
- Joined: Fri Dec 30, 2011 11:11 pm
- Country: -
Re: Lua Telemetry scripts
I recently integrated the LTR patch to Lua. It allowed us to add the bitlib library without using more RAM. Perhaps we could do the same with stringlib. It would only cost more flash, but I think we have some available
Re: Lua Telemetry scripts
Hello Bertrand, after some time without touching my script (that works. ) I want to do some changes. I want to be able to change a global variable value or a logical switch. The logical switch need to change depending on what i receive from telemetry and will start and stop the Timer. For now i'm using stick system that works but i want to try the telemetry way.
I see that i could use the model.setLogicalSwitch but maybe it could be easier to just change a GV with model.setGlobalVariable and keep the logical hardcoded same as now.
Is there an example of the setLogicalSwitch?
Thanks
I see that i could use the model.setLogicalSwitch but maybe it could be easier to just change a GV with model.setGlobalVariable and keep the logical hardcoded same as now.
Is there an example of the setLogicalSwitch?
Thanks