Page 1 of 1

Park Brake in Air Manager & P3Dv5 with Arduino Mega

Posted: Tue Oct 20, 2020 12:58 am
by BaronD55
I have moved to P3Dv5 from FSX.
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?

Re: Park Brake in Air Manager & P3Dv5 with Arduino Mega

Posted: Tue Oct 20, 2020 3:17 am
by Ralph
Do you mean that the parking brake in the simulator doesn't change or in a Air Manager panel?

Re: Park Brake in Air Manager & P3Dv5 with Arduino Mega

Posted: Tue Oct 20, 2020 3:52 am
by BaronD55
Hi Raph,
I meant to say that the parking brake in the simulator doesn't change.

However, I have discovered two things since my original post:-
1. I was looking at the wrong item in my P3D main cockpit view. The Park Brake handle is obscured by the Yoke handle so the yoke needs to be held hard right to expose that particular control to view. :)
2. I found an event that worked. Replacing the two lines in my code that read "fsx_variable_write("BRAKE PARKING POSITION", "BOOL", false)." with "fsx_event("PARKING BRAKE")" got the whole thing working correctly.

Solved.

Re: Park Brake in Air Manager & P3Dv5 with Arduino Mega

Posted: Tue Oct 20, 2020 6:19 am
by Ralph
I've said it before and I'll say it again :) FSX and Prepar3D are a wreck. I came to realize that 14 years ago, Microsoft brought a simulator to the market, abandoned the development and left a trail of bugs, quirks, etc...
So now, 14 years later, they bring a simulator to the market again, which is full of bugs and quirky stuff. For me 1+1 = 2 and I suspect it'll be the same story all over again. They cash in on sales, do some patches here and there, cash in on some more sales, cash in on add-ons, then quit developing and in 2034 I'll probably be repeating myself ;)

Re: Park Brake in Air Manager & P3Dv5 with Arduino Mega

Posted: Tue Oct 20, 2020 8:16 am
by Sling
Ralph wrote: Tue Oct 20, 2020 6:19 am I've said it before and I'll say it again :) FSX and Prepar3D are a wreck. I came to realize that 14 years ago, Microsoft brought a simulator to the market, abandoned the development and left a trail of bugs, quirks, etc...
So now, 14 years later, they bring a simulator to the market again, which is full of bugs and quirky stuff. For me 1+1 = 2 and I suspect it'll be the same story all over again. They cash in on sales, do some patches here and there, cash in on some more sales, cash in on add-ons, then quit developing and in 2034 I'll probably be repeating myself ;)
1000% agree. Seen nothing so far with this new sim to make me believe differently. I hope it becomes what we wish but no hope for anything with the MS name involved.

Re: Park Brake in Air Manager & P3Dv5 with Arduino Mega

Posted: Sat Dec 05, 2020 2:05 pm
by Mike Horsten
Yes and introducing a sim with no multi monitor support, no good interfase to external software, no outside gps support, no ... no... etc. Its really a shame.

I have been moving all my stuff back to xplane. Although the view of MSF2020 is better unfortunatly i cant combine the x-plane model with the view of MSF2020

Mike

Re: Park Brake in Air Manager & P3Dv5 with Arduino Mega

Posted: Sun Dec 06, 2020 4:23 am
by Sling
I’m dreaming that XP12 will be the great Xplane of old with FS2020 visuals as default. If this happens, why anyone would use the other sims for a serious setup is beyond me.

MS fan boys aside. :D

Re: Park Brake in Air Manager & P3Dv5 with Arduino Mega

Posted: Sat Apr 03, 2021 7:00 am
by BaronD55
Hi there Mark & Ralph, I've managed to get multi-monitor views working in FS2020 using P34D as the driver.
I achieved this just today and thought, because of the way this thread went, that you two might be interested.
If you want to see it here is the link:-
https://www.facebook.com/groups/flights ... &ref=notif
Cheers