Page 2 of 2

Re: Lua Telemetry scripts

Posted: Wed Jul 23, 2014 6:09 am
by bertrand35
This lib costs 4k RAM, is it really needed?

Re: Lua Telemetry scripts

Posted: Wed Jul 23, 2014 6:15 am
by nicodh
Damn Bertrand, that would be awesome to be added in next versions. :-D

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

Posted: Wed Jul 23, 2014 6:17 am
by nicodh
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

Posted: Wed Jul 23, 2014 6:32 am
by nicodh
So it's just a define line to add the string functions?

Just adding:

#include <lstrlib.c>

should work?

Re: Lua Telemetry scripts

Posted: Wed Jul 23, 2014 9:33 am
by bertrand35
I will enable it in 2.1
You have to modify the Makefile and linit.c

Re: Lua Telemetry scripts

Posted: Wed Jul 23, 2014 9:39 am
by nicodh
Ok thanks!

Re: Lua Telemetry scripts

Posted: Sat Jul 26, 2014 4:10 pm
by Helitamer
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

Re: Lua Telemetry scripts

Posted: Sat Jul 26, 2014 6:33 pm
by paulj
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

Posted: Sat Jul 26, 2014 6:54 pm
by Kilrah
DJI_F550.

Sent via mobile

Re: Lua Telemetry scripts

Posted: Mon Jul 28, 2014 12:02 pm
by Helitamer
Thx, now it works if i replace the blank..

Re: Lua Telemetry scripts

Posted: Mon Jul 28, 2014 4:35 pm
by bertrand35
For the same reason than the Naze32, OpenTX is not compatible with DJI 550 :)

Re: Lua Telemetry scripts

Posted: Tue Aug 05, 2014 9:39 am
by nicodh
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!

Re: Lua Telemetry scripts

Posted: Tue Aug 05, 2014 11:16 pm
by lvale
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

Re: Lua Telemetry scripts

Posted: Mon Aug 11, 2014 7:54 am
by nicodh
thanks for that info!
that is perfect.

Re: Lua Telemetry scripts

Posted: Mon Aug 11, 2014 3:42 pm
by jlsalas
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

Re: Lua Telemetry scripts

Posted: Mon Aug 11, 2014 5:35 pm
by Kilrah
lcd.drawNumber(210, 10, getValue("altitude")+25, XXLSIZE) ?

Re: Lua Telemetry scripts

Posted: Tue Aug 12, 2014 3:55 pm
by jlsalas
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.

Re: Lua Telemetry scripts

Posted: Wed Aug 13, 2014 6:23 am
by Kilrah
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

Re: Lua Telemetry scripts

Posted: Thu Aug 14, 2014 4:25 pm
by a944734
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

Re: Lua Telemetry scripts

Posted: Thu Aug 14, 2014 6:10 pm
by Kilrah
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.

Re: Lua Telemetry scripts

Posted: Mon Sep 29, 2014 3:43 pm
by nicodh
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:

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
thanks

Re: Lua Telemetry scripts

Posted: Mon Sep 29, 2014 4:20 pm
by nicodh
I will answer myself.... the string module is not loaded in the opentx, so i cant do the string.char()...

Re: Lua Telemetry scripts

Posted: Tue Sep 30, 2014 7:30 am
by nicodh
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.

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

Re: Lua Telemetry scripts

Posted: Tue Sep 30, 2014 7:44 am
by bertrand35
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

Posted: Wed Dec 03, 2014 7:36 am
by nicodh
Hello Bertrand, after some time without touching my script (that works. :-D ) 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