XPL command missing??

Questions about deployment and use of Air Manager Instruments

Moderators: Ralph, russ

Post Reply
Message
Author
Mikemike
Posts: 41
Joined: Thu Feb 11, 2021 11:33 pm

XPL command missing??

#1 Post by Mikemike » Thu Feb 25, 2021 2:48 am

Hi, here's real quiz for the smart folks,

If there isn't a command in the dataref tool list for a particular Xplane switch, (in my case I'm looking for the Cessna 172 fuel valve shut off) can this be assigned in some other fashion to control it with hardware?

I found this ( laminar/c172/fuel/fuel_cutoff_selector ) The dataref tool toggles a value of 1 and zero when I activate it on and off with my mouse, but it wasn't under the command list.

Hope this makes sense.

Mikemike

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

Re: XPL command missing??

#2 Post by Sling » Thu Feb 25, 2021 3:12 am

Yes is the simple answer. If that Datarefs is writable then just change the dataref with xpl_dataref_write(). If not then you can do it by setting the fuel selector to 0. If you want to get smart you can inhibit the fuel selector moving when you do this so the graphic at least stays where you left it.

Mikemike
Posts: 41
Joined: Thu Feb 11, 2021 11:33 pm

Re: XPL command missing??

#3 Post by Mikemike » Thu Feb 25, 2021 3:21 am

Ok, I will give that a try.

Thanks!

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

Re: XPL command missing??

#4 Post by Ralph » Thu Feb 25, 2021 5:31 am

sim/fuel/fuel_selector_lft and sim/fuel/fuel_selector_ctr for example don't work? Then you'll indeed have to write the dataref.

Mikemike
Posts: 41
Joined: Thu Feb 11, 2021 11:33 pm

Re: XPL command missing??

#5 Post by Mikemike » Thu Feb 25, 2021 2:31 pm

ok thanks,
I wasn't aware that you could write new datarefs. I just assumed that if it wasnt originally coded into the sim program then I would be out of luck.

Mikemike

Mikemike
Posts: 41
Joined: Thu Feb 11, 2021 11:33 pm

Re: XPL command missing??

#6 Post by Mikemike » Thu Feb 25, 2021 6:42 pm

  1.  
  2.  
  3. --function fuel_valve (position)
  4.  
  5. --   if position == 0 then
  6.  
  7. --   print("switch position moved 0")
  8.  
  9. -- end
  10.  
  11. --   if position == 1 then
  12.  
  13. --    print("switch position moved 1")
  14.  
  15. --  end  
  16.  
  17. --end
  18.  
  19.  
  20.  
  21. ---------------------------------------------------------------------------------------
  22.  
  23. function fuel_valve(position)
  24.  
  25.    if position == 1 then    
  26.  
  27.    xpl_dataref_write("sim/cockpit/engine/fuel_tank_selector", "INT", 0)
  28.  
  29.  
  30.  
  31.    elseif position == 0 then
  32.  
  33.    xpl_dataref_write("sim/cockpit/engine/fuel_tank_selector", "INT", 4)
  34.  
  35.  end
  36.  
  37. end
  38.  
  39.  
  40.  
  41. ---------------------------------------------------------------------------------------
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. hw_switch_add ("ARDUINO_MEGA2560_A_D12", fuel_valve)
Got it =) Now I can operate the single fuel "shutoff" switch in the sim with a simple hardware switch. It doesn't actually move the fuel shutoff graphics, but I won't need to see that panel anyway. I think I read that I should remove that "print" function after the final script is complete? Is that true and why?

Mikemike

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

Re: XPL command missing??

#7 Post by Sling » Fri Feb 26, 2021 2:47 am

Yes all prints should be removed from final code. Each print takes time and slows down execution.

Strictly speaking if they only get used a few time’s in code you shouldn’t notice it but you certainly wouldn’t want them in a fast updating callback. It’s just good practice to remove or comment out them all.

Mikemike
Posts: 41
Joined: Thu Feb 11, 2021 11:33 pm

Re: XPL command missing??

#8 Post by Mikemike » Fri Feb 26, 2021 3:05 pm

Sling wrote:
Fri Feb 26, 2021 2:47 am
Yes all prints should be removed from final code. Each print takes time and slows down execution.

Strictly speaking if they only get used a few time’s in code you shouldn’t notice it but you certainly wouldn’t want them in a fast updating callback. It’s just good practice to remove or comment out them all.
I see, Thank you.

Mike

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests