I have an Arduino hooked up to AM via SiMessagePort. I have wired up the key switch for Magneto. (off, R, L , both, start).
I have the key switch events flowing through to my hardware function nicely.
Here is my .lua script:
Code: Select all
hw_message_port_add("ARDUINO_MEGA2560_A", function (id, payload)
print("received new message with id " .. id .. " " .. payload)
local position = id
if payload == "true" then -- true for button pressed, false for button released.
-- Mappings:
-- Magneto 1
--Off = 58
--Right = 54
--Left = 55
--Both = 56
--Start = 57
-- Magneto 2
--Off = 4
--Right = 5
--Left = 7
--Both = 2
--Start = 3
if position == 58 then --1 OFF
xpl_command("sim/magnetos/magnetos_off_1")
fsx_event("MAGNETO1_OFF")
fs2020_event("MAGNETO1_SET", 0)
elseif position == 4 then --2 OFF
xpl_command("sim/magnetos/magnetos_off_2")
fsx_event("MAGNETO2_OFF")
fs2020_event("MAGNETO2_SET", 0)
elseif position == 54 then --1 R
xpl_command("sim/magnetos/magnetos_right_1")
fsx_event("MAGNETO_RIGHT")
fs2020_event("MAGNETO1_SET", 1)
elseif position == 5 then --2 R
xpl_command("sim/magnetos/magnetos_right_2")
fsx_event("MAGNETO2_RIGHT")
fs2020_event("MAGNETO2_SET", 1)
elseif position == 55 then --1 L
xpl_command("sim/magnetos/magnetos_left_1")
fsx_event("MAGNETO_LEFT")
fs2020_event("MAGNETO1_SET", 2)
elseif position == 7 then --2 L
xpl_command("sim/magnetos/magnetos_left_2")
fsx_event("MAGNETO2_LEFT")
fs2020_event("MAGNETO2_SET", 2)
elseif position == 56 then --1 BOTH
xpl_command("sim/magnetos/magnetos_both_1")
fsx_event("MAGNETO_BOTH")
fs2020_event("MAGNETO1_SET", 3)
elseif position == 2 then --2 BOTH
xpl_command("sim/magnetos/magnetos_both_2")
fsx_event("MAGNETO2_BOTH")
fs2020_event("MAGNETO2_SET", 3)
elseif position == 57 then --1 START
xpl_command("sim/starters/engage_starter_1")
fsx_event("MAGNETO_START")
fs2020_event("MAGNETO1_SET", 4)
elseif position == 3 then --2 START
xpl_command("sim/starters/engage_starter_2")
fsx_event("MAGNETO2_START")
fs2020_event("MAGNETO2_SET", 4)
end
elseif payload == "false" then
if position == 57 then --1 START
xpl_command("sim/starters/engage_starter_1", "END")
elseif position == 3 then --2 START
xpl_command("sim/starters/engage_starter_2", "END")
end
end
end)
Code: Select all
elseif position == 57 then --1 START
xpl_command("sim/starters/engage_starter_1")
fsx_event("MAGNETO_START")
fs2020_event("MAGNETO1_SET", 4)
Code: Select all
fs2020_event("MAGNETO1_SET", 4)
I can confirm it is not an issue with my Arduino sketch as I see the print log
Code: Select all
INFO - received new message with id 57 false
INFO - received new message with id 56 true
I have tested this in the default Cessna 172 and also some pay ware aircraft with the same result.
This is a major issue since I can't hold the starter long enough for the engine to start...
This seems like a bug in MSFS or AM? Since again, when I return the key switch back to both the log says so.
I have also tried these data events for MSFS2020 with the same result:
Code: Select all
MAGNETO1_START