MSFS2020 - Manage switch with AirManager & Arduino
- PilotOlivier
- Posts: 12
- Joined: Sun Aug 07, 2022 7:17 pm
MSFS2020 - Manage switch with AirManager & Arduino
Hi Team
I have the project to build a KingAir 350i home cockpit with MSFS 2020, Arduino and Air Manager.
After spending a lot of time, I can't find the answer to my problem. On the same computer, I have :
- MSFS2020
- FSUIPC (latest registered version)
- Air Manager (latest registered version)
- SPAD.neXt (latest registered version)
- Arduino MEGA2560 (original board)
I wrote a lua logic to change the position of the light beacons. It works fine between the switch and Air Manager but nothing happens in the MSFS.
I use the LVAR LIGHTING_BEACON_1 which is assigned to the aircraft button according to SPAD.neXt tool
Here attached 3 examples of code.
Do you know why it doesn't work?
Thank you by advance for your support.
I have the project to build a KingAir 350i home cockpit with MSFS 2020, Arduino and Air Manager.
After spending a lot of time, I can't find the answer to my problem. On the same computer, I have :
- MSFS2020
- FSUIPC (latest registered version)
- Air Manager (latest registered version)
- SPAD.neXt (latest registered version)
- Arduino MEGA2560 (original board)
I wrote a lua logic to change the position of the light beacons. It works fine between the switch and Air Manager but nothing happens in the MSFS.
I use the LVAR LIGHTING_BEACON_1 which is assigned to the aircraft button according to SPAD.neXt tool
Here attached 3 examples of code.
Do you know why it doesn't work?
Thank you by advance for your support.
Pilot Olivier
MSFS 2020 - KIng Air 350i - Steam Gauge Overhaul - Analog King Air
Air Manager - SPAD.neXt
Arduino MEGA2560
MSFS 2020 - KIng Air 350i - Steam Gauge Overhaul - Analog King Air
Air Manager - SPAD.neXt
Arduino MEGA2560
- PilotOlivier
- Posts: 12
- Joined: Sun Aug 07, 2022 7:17 pm
Re: MSFS2020 - Manage switch with AirManager & Arduino
Following my previous email.... I have made some progress that I would like to share with you.
First of all, I create a hardware instrument that is certainly better and I put my LUA script here.
Then I wrote a new script according to an example provided in the Air Manager software and now my switch is able to change the value to LVAR.
But this script has no action on the aircraft ..... I discovered that I had to use "TOGGLE_BEACON" and this variable is accessible via FSUIPC.
My question: what is the script to call this variable?
Thank you !
First of all, I create a hardware instrument that is certainly better and I put my LUA script here.
Then I wrote a new script according to an example provided in the Air Manager software and now my switch is able to change the value to LVAR.
But this script has no action on the aircraft ..... I discovered that I had to use "TOGGLE_BEACON" and this variable is accessible via FSUIPC.
My question: what is the script to call this variable?
Thank you !
Pilot Olivier
MSFS 2020 - KIng Air 350i - Steam Gauge Overhaul - Analog King Air
Air Manager - SPAD.neXt
Arduino MEGA2560
MSFS 2020 - KIng Air 350i - Steam Gauge Overhaul - Analog King Air
Air Manager - SPAD.neXt
Arduino MEGA2560
-
- Posts: 5336
- Joined: Thu Jul 27, 2017 12:22 am
Re: MSFS2020 - Manage switch with AirManager & Arduino
This is not variable, for MSFS2020, this is called "events", what is called "commands" in X-Plane simPilotOlivier wrote: ↑Mon Oct 31, 2022 6:10 pm Following my previous email.... I have made some progress that I would like to share with you.
First of all, I create a hardware instrument that is certainly better and I put my LUA script here.
Then I wrote a new script according to an example provided in the Air Manager software and now my switch is able to change the value to LVAR.
But this script has no action on the aircraft ..... I discovered that I had to use "TOGGLE_BEACON" and this variable is accessible via FSUIPC.
My question: what is the script to call this variable?
Thank you !
We're using "fs2020_event" in Air Manager to trigger such event to the sim, see "TOGGLE_BEACON_LIGHTS" in the Lights section here :https://docs.flightsimulator.com/html/P ... aft-lights
- PilotOlivier
- Posts: 12
- Joined: Sun Aug 07, 2022 7:17 pm
Re: MSFS2020 - Manage switch with AirManager & Arduino
Hi SimPassion
Thank you for your answer.... it is working now !!
Hereafter the script which can help someone who is facing to the same issue.
Thank you for your answer.... it is working now !!
Hereafter the script which can help someone who is facing to the same issue.
Pilot Olivier
MSFS 2020 - KIng Air 350i - Steam Gauge Overhaul - Analog King Air
Air Manager - SPAD.neXt
Arduino MEGA2560
MSFS 2020 - KIng Air 350i - Steam Gauge Overhaul - Analog King Air
Air Manager - SPAD.neXt
Arduino MEGA2560
Re: MSFS2020 - Manage switch with AirManager & Arduino
Hello Gilles,SimPassion wrote: ↑Mon Oct 31, 2022 7:13 pmThis is not variable, for MSFS2020, this is called "events", what is called "commands" in X-Plane simPilotOlivier wrote: ↑Mon Oct 31, 2022 6:10 pm Following my previous email.... I have made some progress that I would like to share with you.
First of all, I create a hardware instrument that is certainly better and I put my LUA script here.
Then I wrote a new script according to an example provided in the Air Manager software and now my switch is able to change the value to LVAR.
But this script has no action on the aircraft ..... I discovered that I had to use "TOGGLE_BEACON" and this variable is accessible via FSUIPC.
My question: what is the script to call this variable?
Thank you !
We're using "fs2020_event" in Air Manager to trigger such event to the sim, see "TOGGLE_BEACON_LIGHTS" in the Lights section here :https://docs.flightsimulator.com/html/P ... aft-lights
I don't use MSFS, but am thinking that the use of 'BEACON_LIGHTS_ON' and 'BEACON_LIGHTS_OFF' would be a better solution as otherwise the switch can be out of sync ?
Joe
Joe. CISSP, MSc.
-
- Posts: 5336
- Joined: Thu Jul 27, 2017 12:22 am
Re: MSFS2020 - Manage switch with AirManager & Arduino
Hi Joe, fully right, I've just not gone in deep into this, so it would be fine to suggest an appropriate snippet for this goal, using your mentioned events
If I have time, I will also check what's occurring using the OP original variables
For info, two other parts to check before, at the moment, around plugins. Next I will see if I still have time before going out around 12am
- PilotOlivier
- Posts: 12
- Joined: Sun Aug 07, 2022 7:17 pm
Re: MSFS2020 - Manage switch with AirManager & Arduino
Hello JPH
I tested your solution and it works! I'm not a programmer but this script seems better!
Air Manager is really an amazing tool .... happy to have it !
I tested your solution and it works! I'm not a programmer but this script seems better!
Air Manager is really an amazing tool .... happy to have it !
Pilot Olivier
MSFS 2020 - KIng Air 350i - Steam Gauge Overhaul - Analog King Air
Air Manager - SPAD.neXt
Arduino MEGA2560
MSFS 2020 - KIng Air 350i - Steam Gauge Overhaul - Analog King Air
Air Manager - SPAD.neXt
Arduino MEGA2560
-
- Posts: 5336
- Joined: Thu Jul 27, 2017 12:22 am
Re: MSFS2020 - Manage switch with AirManager & Arduino
Here's the snippet using Joe's suggested events :PilotOlivier wrote: ↑Tue Nov 01, 2022 7:47 am Hi SimPassion
Thank you for your answer.... it is working now !!
Hereafter the script which can help someone who is facing to the same issue.
Code: Select all
local pos_save = 0
function switch_A1(position)
print("Switch A1 initial position " .. pos_save)
if position == 0 then
fs2020_event("BEACON_LIGHTS_OFF")
elseif position == 1 then
fs2020_event("BEACON_LIGHTS_ON")
end
pos_save = position
print("Switch A1 new position " .. position)
end
hw_switch_add("ARDUINO_MEGA2560_A_D2", switch_A1)
[EDIT] Corrected in place as it works with the default KA 350i using "LIGHT BEACON:1" as a Boolean in place
So the working snippet using variable write :
Code: Select all
local pos_save = 0
function switch_A1(position)
print("Switch A1 initial position " .. pos_save)
fs2020_variable_write("LIGHT BEACON:1","Bool",position == 1)
pos_save = position
print("Switch A1 new position " .. position)
end
As we see here :
[attachment=0]image.png[/attachment]
hw_switch_add("ARDUINO_MEGA2560_A_D2", switch_A1)
-
- Posts: 5336
- Joined: Thu Jul 27, 2017 12:22 am
Re: MSFS2020 - Manage switch with AirManager & Arduino
Previous post edited to add the proper working snippet using variable write
Re: MSFS2020 - Manage switch with AirManager & Arduino
Hey Gilles, nice one.
I am considering using msfs2020 for experimentation and I must confess that I have a steep hill to climb to get my head around the way MSFS is addressed with AM.
I am happy with X-Plane datarefs and commands but the MSFS communication is a new area. At least the simvar api is reasonably well documented. It seems to be improving all the time as well (the documentation) as well as the sim.
I will be trying to pick your brains on several areas in the future if you don't mind ?. At the moment I am still confused when I read about Lvars and Hvars as there is so much legacy stuff written that is sometimes referring to the older fsuipc days. It will be 'fun' though.
I am considering using msfs2020 for experimentation and I must confess that I have a steep hill to climb to get my head around the way MSFS is addressed with AM.
I am happy with X-Plane datarefs and commands but the MSFS communication is a new area. At least the simvar api is reasonably well documented. It seems to be improving all the time as well (the documentation) as well as the sim.
I will be trying to pick your brains on several areas in the future if you don't mind ?. At the moment I am still confused when I read about Lvars and Hvars as there is so much legacy stuff written that is sometimes referring to the older fsuipc days. It will be 'fun' though.
Joe. CISSP, MSc.