I am modifying an old Jeppesen FS200 console to work with Xplane and arduino.
When starting AM it should take the position of the switches. Switch ON, Xplane ON. Switch OFF, Xplane OFF.
I used the command "hw switch get position". I am programming all the switches as one hardware.
The "hw switch get position" command would seem to work for NAV2 ON, but not for NAV1 ON.
Here is part of the code I am using.
Code: Select all
---------------------------------------------NAV1----------------------------------------------------
function swnav1on(position)
local position = hw_switch_get_position(swnav1on)
if position == 0 then
xpl_command("sim/radios/power_nav1_off")
elseif position == 1 then
xpl_command("sim/radios/power_nav1_on")
end
end
swnav1on = hw_switch_add("ARDUINO_MEGA2560_A_D9", swnav1on)
---------------------------------------------NAV2----------------------------------------------------
function swnav2on(position)
local position = hw_switch_get_position(swnav2on)
if position == 0 then
xpl_command("sim/radios/power_nav2_off")
elseif position == 1 then
xpl_command("sim/radios/power_nav2_on")
end
end
swnav2on = hw_switch_add("ARDUINO_MEGA2560_A_D50", swnav2on)