I had my cockpit hardware working fairly well but of course all the code was written for XP11.
Now I am starting again and getting my head around events and variables.
For a couple of weeks I have been working on what I know is a fairly basic project - Parking Brake.
I have set up a motor vehicle parking brake that presses against a button when it is released.
Now I have it working except that the image of the park brake in the virtual cockpit does not reflect the changed state of the aircraft's park brake.
I know that the brake is being set and released by my "Park Brake instrument" because the notification banner in the simulator responds appropriately to my use of the brake handle.
Below is my code:
Code: Select all
parkbrake = ""
function parkbrake_callback(position)
if position then
parkbrake = "ON"
else
parkbrake = "OFF"
end
print("Parking brake position is ".. parkbrake)
end -- End Function "parkbrake_callback".
function released_callback() --Park Brake ON; handle pulled out = button released
if parkbrake ~= "ON" then
fsx_variable_write("BRAKE PARKING POSITION", "BOOL", false)
end
print("Parking brake handle is OUT so brake is ON")
end
function pressed_callback()--Park Brake OFF; handle moved in = button pressed.
if parkbrake ~= "OFF" then
fsx_variable_write("BRAKE PARKING POSITION", "BOOL", true)
end
print("Parking brake handle is IN so parkbrake is OFF.")
end
hw_button_add("ARDUINO_MEGA2560_A_D53", pressed_callback, released_callback)
fsx_variable_subscribe("BRAKE PARKING POSITION", "BOOL", parkbrake_callback)
Should I be using something other than fsx_variable_write?