Hi, ive tested this and it does not work for me
steps to reproduce:
1) start airmanager
2) start x-plane
3) my panel physical battery switch is in the ON position
4) x-plane is set to start cold and dark everything off
x-plane launches, and the battery is off. Airmanager wont turn on the battery matching the switch position.
i have to move the battery switch to off and then on again for it to work
actual code im using:
Code: Select all
local switch_36_pos
function switch_36_callback(position)
print("The battery switch got changed to position " .. position)
if position == 0 then
xpl_command("sim/electrical/battery_1_off")
xpl_command("laminar/c90/fltctrl/switch/elev_trim_control_dn") -- c90 laminar
elseif position == 1 then
xpl_command("sim/electrical/battery_1_on")
xpl_command("laminar/c90/fltctrl/switch/elev_trim_control_up") -- c90 laminar
end
switch_36_pos = position
end
switch_36_id = hw_switch_add("ARDUINO_MEGA2560_A_D36", switch_36_callback)
switch_36_pos = hw_switch_get_position(switch_36_id)
function switch_36_subscribe(position)
if position ~= switch_36_pos then
switch_36_callback(switch_36_pos)
end
end
xpl_dataref_subscribe("sim/cockpit/electrical/battery_on", "INT", switch_36_subscribe)