Park Brake in Air Manager & P3Dv5 with Arduino Mega

Are you building a cockpit, planning to build one or just dreaming, this is your cockpit builder meeting point

Moderators: Ralph, russ

Post Reply
Message
Author
djw4250@gmail.com
Posts: 7
Joined: Tue Jul 21, 2020 3:52 am

Park Brake in Air Manager & P3Dv5 with Arduino Mega

#1 Post by djw4250@gmail.com » Tue Oct 20, 2020 12:58 am

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:
  1. parkbrake = ""
  2.  
  3.  
  4.  
  5. function parkbrake_callback(position)
  6.  
  7.     if position then
  8.  
  9.         parkbrake = "ON"
  10.  
  11.     else
  12.  
  13.         parkbrake = "OFF"
  14.  
  15.     end
  16.  
  17.     print("Parking brake position is  ".. parkbrake)
  18.  
  19. end -- End Function "parkbrake_callback".
  20.  
  21.  
  22.  
  23. function released_callback() --Park Brake ON; handle pulled out = button released
  24.  
  25.     if parkbrake ~= "ON" then    
  26.  
  27.         fsx_variable_write("BRAKE PARKING POSITION", "BOOL", false)
  28.  
  29.     end
  30.  
  31.     print("Parking brake handle is OUT so brake is ON")
  32.  
  33.  
  34.  
  35. end
  36.  
  37.  
  38.  
  39. function pressed_callback()--Park Brake OFF; handle moved in = button pressed.
  40.  
  41.     if parkbrake ~= "OFF" then    
  42.  
  43.         fsx_variable_write("BRAKE PARKING POSITION", "BOOL", true)      
  44.  
  45.     end
  46.  
  47.      print("Parking brake handle is IN so parkbrake is OFF.")
  48.  
  49.  
  50.  
  51. end
  52.  
  53.  
  54.  
  55. hw_button_add("ARDUINO_MEGA2560_A_D53", pressed_callback, released_callback)
  56.  
  57.  
  58.  
  59. fsx_variable_subscribe("BRAKE PARKING POSITION", "BOOL", parkbrake_callback)

Should I be using something other than fsx_variable_write?

User avatar
Ralph
Posts: 4764
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

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

#2 Post by Ralph » Tue Oct 20, 2020 3:17 am

Do you mean that the parking brake in the simulator doesn't change or in a Air Manager panel?

djw4250@gmail.com
Posts: 7
Joined: Tue Jul 21, 2020 3:52 am

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

#3 Post by djw4250@gmail.com » Tue Oct 20, 2020 3:52 am

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.

User avatar
Ralph
Posts: 4764
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

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

#4 Post by Ralph » 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 ;)

User avatar
Sling
Posts: 4290
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

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

#5 Post by Sling » Tue Oct 20, 2020 8:16 am

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.

Mike Horsten
Posts: 61
Joined: Tue Dec 01, 2020 8:50 am

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

#6 Post by Mike Horsten » Sat Dec 05, 2020 2:05 pm

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
Building a home Cessna 172SP Steam. X-plane/MFS2020
(ex Name on Airmanager forum Polarair)

User avatar
Sling
Posts: 4290
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

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

#7 Post by Sling » Sun Dec 06, 2020 4:23 am

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

djw4250@gmail.com
Posts: 7
Joined: Tue Jul 21, 2020 3:52 am

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

#8 Post by djw4250@gmail.com » Sat Apr 03, 2021 7:00 am

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest