Lua Script position Logical Switch

openTx has introduced a range of new features, ideas and bling. It is fast becoming the firmware of choice for many users. openTx will run on ALL current hardware platforms, including the gruvin9x and sky9x boards. Work has already started to support the new FrSky X9D radio!
Post Reply
bnwgraaf
Posts: 18
Joined: Sun Sep 03, 2017 7:18 am
Country: -

Lua Script position Logical Switch

Post by bnwgraaf »

When making telemetry scripts, is it possible to get the position of a Logical Switch (false or true)?

The same question for the position of the physical switches?
These ones I check now with its value (<-100 = up, >100 = down, else is middle position)

User avatar
rcdiy
Posts: 190
Joined: Fri Jul 01, 2016 6:13 am
Country: Canada
Contact:

Re: Lua Script position Logical Switch

Post by rcdiy »

Yes
See
https://opentx.gitbooks.io/opentx-2-2-l ... e/content/
I'm on the road using my mobile else Id give the exact page to look at.
My battery remaining script accesses logical switches.
RCdiy.ca
Stay Safe & Have Fun
OpenTX Manual http://rcdiy.ca
Paying it forward by sharing my Lua scripts, documentation and videos.
rdeanchurch
Posts: 750
Joined: Tue Dec 27, 2011 11:22 pm
Country: United States
Location: Carson City, Nv

Re: Lua Script position Logical Switch

Post by rdeanchurch »

https://opentx.gitbooks.io/opentx-2-2-l ... Value.html
SwPos = getValue("sa")

returns numerical value, you must make it true or false if that is needed.
Dean
OldDmbThms: 1. Takeoff, 2. Crash, 3. Repair, GOTO 1
bnwgraaf
Posts: 18
Joined: Sun Sep 03, 2017 7:18 am
Country: -

Re: Lua Script position Logical Switch

Post by bnwgraaf »

Thank you both! With the physical switches I had already solved it, like I wrote in my openings post, but with the logical switches I did not succeed.....

It turned out I used the wrong ID (l1 instead of ls1)!
Now it works!

@rdeanchurch: on the website you mentioned, I also found a code to make an extra function to convert the value into a letter: "U", "M" and "D". That also works nice.

Again, thanks to both of you!

Verstuurd vanaf mijn A0001 met Tapatalk


Post Reply

Return to “openTx”