Jump to content
Sign in to follow this  
CageHound

Synchronizing Light Switch States (Panel to Controller) LUA?

Recommended Posts

Hello,

Searching for a few days now to figure out how to synchronize HoneyComb switch states (BCN, TAXI, NAV, STROBE, LANDING) to Prepar3dv4 (Any Aircraft). I have latest FSUIPC installed and came across several references of using LUA Scripts to get this done. Simply put, when starting up in any aircraft I'd like for the SIM to read the switch states of the controller so they stay synchronized. This works OK with the LANDING LIGHTS because there is a landing light OFF and ON in FSUIPC, however you have to flip the switch when starting up in order for it to sync. 

I'm thinking that a LUA Script would work to read the state of the controller, and then set the sim state. I'm just not sure how to get there.

 

With no assignments whatsoever, here is an FSUIPC log output for the above mentioned buttons. 

Running inside Prepar3D v4 on Windows 10
Module base=7FFC9F5C0000
  8249110 **** Restarting traffic scanning due to non-reception ****
  8266563 *** Entered Buttons option page ***
  8267454 FirstButtonChange res=00000114 (0.1, 20)
  8268579 FirstButtonChange res=00000115 (0.1, 21)
  8275938 FirstButtonChange res=00000116 (0.1, 22)
  8276391 FirstButtonChange res=00000117 (0.1, 23)
  8277094 FirstButtonChange res=00000118 (0.1, 24)
  8277485 FirstButtonChange res=00000119 (0.1, 25)
  8278188 FirstButtonChange res=0000011A (0.1, 26)
  8278563 FirstButtonChange res=0000011B (0.1, 27)
  8279297 FirstButtonChange res=0000011C (0.1, 28)
  8279625 FirstButtonChange res=0000011D (0.1, 29)
  8289860 *** Exiting Buttons option page ***

 

Thanks,
Robert

Share this post


Link to post
Share on other sites

Hi Robert @CageHound,

this is usually a problem if the hardware uses SPST switches. best practice, from my perspective and in my build, is to use SPDT switches so that both positions have a defined state.

that said, for the hardware with SPST switches, I do a couple of things for cold and dark startup.....

first, almost every airplane checklist (certainly the military ones) have a cockpit check that require the pilot to put every switch in a pre-defined position (usually OFF) before doing anything else.

second, i run a Lua script to make every variable value that is affected by the switches match the position in the cockpit check before proceeding with any other procedures.

does that make sense? 

to me this is more realistic and consistent than using software to check the position of every switch.

hope this helps. best of luck in your studies and experimentation.

Edited by yurei

Share this post


Link to post
Share on other sites

I wrote a function to do this in LINDA. It works great, except for restoring the states of push-buttons that invoke toggle actions (which is impossible).


MarkH

gGzCVFp.jpg
Core i7-7700K / 32Gb DDR4 / Gigabyte GTX1070 / 1080p x 3 x weird / Win7 64 Pro

Share this post


Link to post
Share on other sites

@MarkDH This is great - thank you!

@yurei I do agree that a checklist is a good option, but when the entire environment is via hardware control, it's sometimes annoying to have to reach for a mouse. But as you mention if you set and save both as cold n dark it would work.

  • Upvote 1

Share this post


Link to post
Share on other sites
7 hours ago, LesOReilly said:

Spad.Next makes this easy to do...

Are you sure? It can read the switch positions and synchronize the switch settings in the simulator?

Edited by MarkDH

MarkH

gGzCVFp.jpg
Core i7-7700K / 32Gb DDR4 / Gigabyte GTX1070 / 1080p x 3 x weird / Win7 64 Pro

Share this post


Link to post
Share on other sites
43 minutes ago, MarkDH said:

Are you sure? It can read the switch positions and synchronize the switch settings in the simulator?

I've found that with SPAD.next, the first change of a switch position (any switch) on the Saitek Switch Panel causes all the other switches in the sim to match the switch positions on the Saitek panel. What I don't know is why it waits till I move a switch before it decides to read all the others.

Share this post


Link to post
Share on other sites
4 hours ago, Muklum said:

I've found that with SPAD.next, the first change of a switch position (any switch) on the Saitek Switch Panel causes all the other switches in the sim to match the switch positions on the Saitek panel. What I don't know is why it waits till I move a switch before it decides to read all the others.

I wonder if this is something specific to Saitek panels. I think I noticed this too, and I wasn't using SPAD.neXt. I don't have a switch panel any more so I can't try it out.


MarkH

gGzCVFp.jpg
Core i7-7700K / 32Gb DDR4 / Gigabyte GTX1070 / 1080p x 3 x weird / Win7 64 Pro

Share this post


Link to post
Share on other sites
8 hours ago, MarkDH said:

I wonder if this is something specific to Saitek panels. I think I noticed this too, and I wasn't using SPAD.neXt. I don't have a switch panel any more so I can't try it out.

You may well be right about that, but I can't test that on my system, since without SPAD.next my Saitek panels don't work (I understand that the Saitek drivers don't work in P3D4, which is the sim I normally use). I have noticed that in X-Plane, both with Xsaitekpanels and with SPAD.next, each switch on the Switch Panel causes only into own target switch in the sim to change its position, so there is no overall sync action.

Share this post


Link to post
Share on other sites
On 11/26/2019 at 11:50 PM, CageHound said:

I do agree that a checklist is a good option, but when the entire environment is via hardware control, it's sometimes annoying to have to reach for a mouse. But as you mention if you set and save both as cold n dark it would work.

I have a hardware cockpit as well. Approximately 4 dozen switches, etc. 

The goal is to not use mouse or keyboard after the sim is started.

Share this post


Link to post
Share on other sites

Yes I think you have to switch something on load in to the aircraft.....But that said switching the Landing Light on or off will send all light switch settings to the plane accordingly.

More Important is that for the Lights that require Toggles --- I have no idea why they have not fixed some of those switches in Simconnect to have ON/OFF commands...but I digress.  More important with Span.next is that I can create checks so that when the switch goes into the ON position it first will check with the Simconnect value for that light / Switch to see if it is OFF and if so then and only then would it send the the "toggle" command.  For all of the lights / Switches that support Sim commands for ON/OFF this is not needed, but there are ones that this is why I like it a lot......Also now with all the support that has been going in for Arduino!!! Making your own controls is even easier 🙂

 


Les O'Reilly

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...