XPL command missing??

Questions about deployment and use of Air Manager Instruments

Moderators: russ, Ralph

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

XPL command missing??

#1 Post by Mikemike »

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: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: XPL command missing??

#2 Post by Sling »

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 »

Ok, I will give that a try.

Thanks!

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

Re: XPL command missing??

#4 Post by Ralph »

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 »

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 »

Code: Select all


--function fuel_valve (position)
-- if position == 0 then
-- print("switch position moved 0")
-- end
-- if position == 1 then
-- print("switch position moved 1")
-- end
--end

---------------------------------------------------------------------------------------
function fuel_valve(position)
if position == 1 then
xpl_dataref_write("sim/cockpit/engine/fuel_tank_selector", "INT", 0)

elseif position == 0 then
xpl_dataref_write("sim/cockpit/engine/fuel_tank_selector", "INT", 4)
end
end

---------------------------------------------------------------------------------------



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: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: XPL command missing??

#7 Post by Sling »

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 »

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

Voyager
Posts: 41
Joined: Mon Apr 17, 2023 1:00 am

Re: XPL command missing??

#9 Post by Voyager »

Hi,

Did you get the fuel cutoff valve working? If you did, can you please send me a copy? I would like to add it to my simulator.

Thanks,

Rich

Post Reply