LUA – Momentary switches to latching?

I was trying the voice command functions in DC-24 today and noticed that while it works as it should the voice-commanded switches are momentary. And since I was after a ON-OFF function I needed a way to make a function that on first activation would make things go ON and on the next activation would make things go OFF.

Perfect opportunity to learn some more LUA…

What does this LUA-script do?

A few things actually:

  • Possibility to configure 5 switches
  • Has a monitor screen for easy testing
  • Activate momentary switch -> latching switch goes ON
  • Activate momentary switch again -> latching switch goes OFF
  • All switches created bu application are OFF on initialization of model

There is one important thing to remember, the momentary switch is allowed to be ON for max. 2 seconds. Any longer than that makes the latching switch return to its previous state. Leaving the momentary switch ON for a long period results in application switch jumping between states every two seconds.

Where to get it

Event Counter is included in RC-Thoughts Jeti Tools found here. You can get the RCT-Mome.lua from github here.

 

Use of application

 

This is easy to use. Open from menu “Application” -> “Momentary to Latching” and from the applications “Momentary To Latching”-screen set switches as you would normally do:

rc-thoughts_tools_15  rc-thoughts_tools_022

To the left of your switch is the status display of corresponding latching function:

rc-thoughts_tools_105

In the picture above we can see the latching switch 1 being active even when selected switch Sf is not. Activating Sf again will return the latching switch 1 to OFF.

This application is perfect for those voice command switches, after giving a voice command the voice switches are active only for a small moment, they are not latching. This gives you more possibilities to use them.

rc-thoughts_tools_027

After setting the desired amount of momentary to latching switches up you can use them where ever you would use switches:

rc-thoughts_tools_104

That was so easy!

Afterwords

If you use this I’d very much would like to hear it so post in the comments or drop me an email!

4 thoughts on “LUA – Momentary switches to latching?

  1. Hey…Very good work.
    I try these but when i activated the voice commands and use the C01 as push to talk so it works one time and stay on off after this. Both selected switches in Momentary to Latching menü ( time and Height ) was on off. When i turn on possible the Height and let the Time off so the selected voice command switch C01 jump every 2 seconds from on to off. That means i can speak a command every 2 seconds and then must wait 2 seconds. How it works that the voice command switch C01 comes back when i used it with the adjustments in the Momentary to Latching menu are both on off ?

    1. The switch used for activating momentary to latching is supposed to be a momentary, If you are experiencing a 2-second on-off behavior your switch is on for the whole time and not momentary.

      I did not quite get a clear picture of what you are trying to do?

  2. I noticed that there is a short interval (varies) before the latch takes effect; specifically, a momentary press may, or may not, cause the latch to occur and, similarly, for the unlatch to take effect. Holding for about one second seemed to work reliably, but that is not how I prefer to use ("bump") a momentary switch.

    I also noticed that the two-second window appeared to be more on the order of four seconds; at least counting the interval, while holding a momentary switch down, from latching to 1, then back to 0, back to 1, etc.

    This was on a brand new model ("Lua Sandbox"); nothing else added. Otherwise, quite nice. Thank you.

    1. We've been discussing this with PM on RCG, but as a sidenote, I cannot reproduce this in any way, we need to make more comparisons. The "four second" is worrying since the 2 second limit is transmitters operating systems timestamps, that really should not be wrong.

Leave a Reply

Your email address will not be published. Required fields are marked *