What's new
Aloft Forums

Welcome to Aloft Forums. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

a 3 position switch for a timer and also a throttle cutoff

ark

New User
I'm. very new to OpenTX but not to embedded development I've even used Lua a bit in other projects. I'm excited about what I'd like to do with my transmitter but I'm also not sure if what I'd like to do is possible. Here I'll explain what I'd really like.

I have a 3 position switch that starts off down. in this position the throttle is cut off.
When I move the switch to up the throttle is enabled and I might as well play the airplane fasten seatbelt audio file :)
However moving the switch up also starts a countdown timer.
The timer stops whenever the switch is in the down position and resumes when it's back up.
putting the switch in the middle position for a few seconds will reset the timer to the start time.
the timer will play sounds when it gets to 5, 2, 1 minutes and 30 seconds. and all done.

It seems like this should all be possible in OpenTX right? Are there existing timer functions I could take a look at?

Next level is I'd like the time for each model to be stored with the model as a variable, but have one script for all models. possible?

Then later on I can actually monitor the throttle level and count down faster or slower depending on how much power I'm using.
Later still, I thought I could use a telemetry receiver to log data for flights and then crunch the numbers then I can come up with a power usage profile for a model and switch to a cheaper receiver and still have a pretty good reconning of how much power I have left.

I'd appreciate any advice you might have, thanks.
 
I like to create logical switches and then base things off of those, that way the actual physical switch can be changed if desired. For your mid-position timer reset, you would set a delay value on the switch, like this:
1640132192959.png

As an aside, there is a setting in the system menu that prevents the mid-position of a 3 position switch to be ignored unless held for a certain period of time, this would allow you to do a "normal" top to bottom movement of the switch without the center position being recognized. This may actually work for your timer reset...but if you want a longer delay, do as in the above.
In the image below notice the "Play delay" setting of 150ms.
1640132359009.png
 
  • Like
Reactions: ark
Wow, I just got to play with my radio and openTX for the first time and I was amazed that along with OpenTX Companion I was able to make it do exactly what I wanted without even having to write any Lua code at all.

This video was a good first little project and really helped me understand Logical Switches and Special Functions.


and then this next video showed me how easy timers are and it was easy to make the middle switch setting reset them. Thanks for the tips gnichola!


It was especially cool that I can just use the throttle to start/stop the timer (throttle% seems interesting). I added some logical switches so the timer only goes if the throttle is not cut.
 
There you go..good job.

I doubt you will ever need to write anything in Lua.
 
Back
Top