Jump to content

Sign in to follow this  
QuaxTheSnoopie

Switch off taxi lights from FSUIPC LUA ?

Recommended Posts

I try to switch off the taxi lights by FSUIPC LUA (triggered by an external switch) with the following sequence:

      dummy=ipc.clearbitsUW(0x0D0C, 0x08)        -- Clear Taxi-Lights Bit
      ipc.sleep(500)
      ipc.writeLvar("SW_TAXI_LIGHTS",0)            -- Set Taxi-Lights Switch to OFF

The switch changes its position and the taxi light goes out but one second later goes on again.
So, how could I switch off the taxi lights correctly by FSUIPC ? Is it possible ?

 

 

 

 

Share this post


Link to post
Share on other sites
Posted (edited)
On 5/22/2020 at 1:32 PM, QuaxTheSnoopie said:

I try to switch off the taxi lights by FSUIPC LUA (triggered by an external switch) with the following sequence:

      dummy=ipc.clearbitsUW(0x0D0C, 0x08)        -- Clear Taxi-Lights Bit
      ipc.sleep(500)
      ipc.writeLvar("SW_TAXI_LIGHTS",0)            -- Set Taxi-Lights Switch to OFF

The switch changes its position and the taxi light goes out but one second later goes on again.
So, how could I switch off the taxi lights correctly by FSUIPC ? Is it possible ?

 

 

 

 

Try this:

taxi_lt_switch=ipc.readLvar("L:SW_TAXI_LIGHTS")             -- get current light switch position: 0=off, 1=on
  if taxi_lt_switch == nil or (taxi_lt_switch~= 0 and taxi_lt_switch ~= 1) then   
   ipc.writeLvar("L:SW_TAXI_LIGHTS",0)                                -- sw to off position                 
  elseif taxi_lt_switch == 0 then             
    ipc.writeLvar("L:SW_TAXI_LIGHTS",1)                      -- move switch to on position
    ipc.control(66240)                                                       -- toggle taxi lights on
    ipc.writeLvar("L:XMLSND68",1)                                 -- switch sound
  elseif taxi_lt_switch == 1 then             
     ipc.writeLvar("L:SW_TAXI_LIGHTS",0)                    -- move switch to off position
    ipc.control(66240)                                                      -- toggle taxi lights off
    ipc.writeLvar("L:XMLSND68",1)                                 -- switch sound                                      
  end
  return  

Al                                                 

                                                

 

Edited by ark

Share this post


Link to post
Share on other sites

Unfortunatly, setting SW_TAXI_LIGHTS alone doesn't help.

But I found formerly your hint "with respect to the beacon and strobe lights" in another thread:

So, I checked fsuipc.log and found another control call as I switched on the taxi lights in VC:
344622 *** EVENT: Cntrl= 66240 (0x000102c0), Param= 0 (0x00000000) TOGGLE_TAXI_LIGHTS

So I changed my coding and the combination of setting SW_TAXI_LIGHTS and calling ipc.control(66240) shortly after each other seems to work now:

...
--	
-- Parm 7/8   :  Taxi Lights ON/OFF
--
elseif ipcPARAM == 7 then
	taxi_lt_switch=ipc.readLvar("L:SW_TAXI_LIGHTS")		-- get current taxi light switch value:0=off, 1=on
	if taxi_lt_switch < 1 then             
	    ipc.control(66240)								-- Toggle Taxi Lights
		ipc.writeLvar("L:SW_TAXI_LIGHTS",1)				-- lights off
		ipc.writeLvar("L:XMLSND68",1)					-- switch sound
	end
elseif ipcPARAM == 8 then
	taxi_lt_switch=ipc.readLvar("L:SW_TAXI_LIGHTS")		-- get current taxi light switch value:0=off, 1=on
	if taxi_lt_switch > 0 then             
		ipc.writeLvar("L:SW_TAXI_LIGHTS",0)				-- lights off
	    ipc.control(66240)								-- Toggle Taxi Lights
		ipc.writeLvar("L:XMLSND68",1)					-- switch sound
	end
elseif ...      

Just to explain: for the lights, I use the On/Off-Switches of a VRInsight Tact&Toggle , so I cannot toggle, instead I have to separate the ON and OFF part.

(For me, it's a shame that most/all "aircraft manufacturers" 😉 don't give specifications for their internal whistles and bells (LVAR and controls), as many "pilots" 😝 have external hardware...so we have to find it out the hard way...).

BTW: your setting of XMLSND68 shed some light to the sound mechanism.
So I will replace by the your inline setting of XMLSND68:

function SwitchClick(fswsound)
  wavname="SND" .. fswsound .. ".wav"
  sound.path("FSW")
  SNDREF=sound.play(wavname)
--  ipc.display("Playing " .. wavname)
end  

...

SwitchClick(68)

Thanks !

Share this post


Link to post
Share on other sites
Posted (edited)
On 5/24/2020 at 5:39 AM, QuaxTheSnoopie said:

I use the On/Off-Switches of a VRInsight Tact&Toggle , so I cannot toggle, instead I have to separate the ON and OFF part.

Glad you got it working. For future reference, if you are using SPST (On/Off) type of switches (like seems to be on the VR Insight controller) instead of a momentary switch, you can use a FSUIPC event.button() command to set up a toggle operation. Consider the script below called F50_Taxi_Lts. The key here is the command event.button("J",2,3, "Falcon_Taxi_Lts") . The "J", 2 in the command is how FSUIPC identifies a particular Joystick and switch on that controller -- in this case switch 2 on the controller named  "J" (The J can be replaced with the number FSUIPC uses for that controller if you don't use letter joy names).  In your case it would be whatever FSUIPC uses to identify a particular switch on the VR Insight controller. The '3' in the command means detect every change in the switch (there are other options, see the FSUIPC documentation for this command). So the way it works is, every time switch 2 on controller J changes state (On to Off, or Off to On) the function Falcon_Taxi_Lts() is called and executed, thus toggling the taxi lights on and off.

Of course for this to work you have to load the lua script F50_Taxi_Lts.lua into memory -- but just once. Then the even.button() command just 'waits' until it detects a switch change and every time it does, calls the Falcon_Taxi_Lts function to toggle the taxi lights. You can load the script with a key or button as is typical, but a better way to load an "event" type of script is to load it automatically , in this case to load it when the Falcon50 a/c is loaded with an "auto" entry in the FSUIPC.ini file that looks something like this:

[Auto.Falcon 50]
1=Lua F50_Taxi_Lights  

where Falcon 50 is your FSUIPC profile name for the Falcon.  Or you can have the script loaded whenever FSUIPC loads with an entry like this:

[Auto]
1=Lua F50_Taxi_Lights

So the point of all this is just that FSUIPC provides ways to handle switches that are not momentary like the typical switches on a yoke, or the keys on a keyboard. See the "event library" in the FSUIPC Lua documentation if interested in more info on this.

Al

 

  function Falcon_Taxi_Lts(a,b,c)
  taxi_lt_switch=ipc.readLvar("L:SW_TAXI_LIGHTS")             -- get current light switch position: 0=off, 1=on
  if taxi_lt_switch == nil or (taxi_lt_switch~= 0 and taxi_lt_switch ~= 1) then   
   ipc.writeLvar("L:SW_TAXI_LIGHTS",0)                                -- switch to off position                 
  elseif taxi_lt_switch == 0 then             
    ipc.writeLvar("L:SW_TAXI_LIGHTS",1)                      -- move switch to on position
    ipc.control(66240)                                                       -- toggle taxi lights on
    ipc.writeLvar("L:XMLSND68",1)                                 -- switch sound
  elseif taxi_lt_switch == 1 then             
     ipc.writeLvar("L:SW_TAXI_LIGHTS",0)                    -- move switch to off position
    ipc.control(66240)                                                      -- toggle taxi lights off
    ipc.writeLvar("L:XMLSND68",1)                                 -- switch sound                                      
  end
  return    
end
  -- Main program
event.button("J",2,3, "Falcon_Taxi_Lts")

Edited by ark

Share this post


Link to post
Share on other sites
Posted (edited)

Is there a script available for the Falcon like Al's great lua for multiple functions on the Lear and Mu2 ?

Edited by julian46

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, julian46 said:

Is there a script available for the Falcon like Al's great lua for multiple functions on the Lear and Mu2 ?

I have a controls script for the Falcon50 that implements the functions below -- I think (most of this script was developed with an early version of the Falcon50). If anyone thinks this might be useful to you PM me an email address and I'll send the Lua script and some instructions. Note running Lua scripts requires a registered (payware) copy of FSUIPC.

Al

      --     FUNCTION                     Flag #
   -- F50_Hdg_Bug_Sync()              1                 Aligns Heading Bug with current a/c heading
   -- F50_Yaw_Damper()                 2                 Toggles Yaw Damper On and Off
   -- F50_Auto_Pilot_Sw()              3                 Toggles F50 Autopilot Master switch On and Off; turning on the AP Master also turns on the Yaw Damper
   -- F50_Landing_Lts()                  4                 3-way toggle of Falcon50 Landing Lights Switch between off, pulse mode, steady on, then back to off
   -- F50_Altitude_Decrement()      5                 Decrement altitude window setting by 100ft
   -- F50_Altitude_Increment()       6                 Increment altitude window setting by 100ft
   -- F50_Inc_AirBrakes()               7                 Increment Airbrake settings
   -- F50_Dec_AirBrakes()             8                 Decrement Airbrake settings
   -- F50_Silence_Horns()             9                 Silence warning horns
   -- F50_Stop_Watch()               10                 3-way toggle of the panel 'stop watch'
   -- F50_Go_Around()                11                 F50 Go-Around button
   -- F50_Gnd_Eng_Start()         12                 Starts F50's 3 engines; first put throttles at idle, push Ready to Start, turn on all 3 engine generators.
   -- F50_Panel_Lights()             13                 Toggles F50's Panel Lights Switch
   -- F50_set_AP_Vertical_Speed()    14                 Sets Autopilot vertical speed (enter + or - and 4 digits max ending in 00)
   -- F50_set_Nav_or_GPS()       15                 Toggles between Nav and GS mode
   -- F50_TCS_Toggle()              16                 Toggles Touch Control Steering On and Off
   -- F50_TCS_On()                    17                 Touch Control Steering On
   -- F50_TCS_Off()                    18                 Touch Control Steering Off
   -- F50_Gross_Wt_Cntr()         19                 Load and start Falcon50 Panel Gross Weight Counter
   -- F50_Landing_Lights_On()   20
   -- F50_Landing_Lights_Off()   21
   -- F50_Yaw_Damper_On()     22     
   -- F50_Yaw_Damper_Off()     23
   -- F50_Taxi_Lts()                    24                -- Taxi lights toggle

Edited by ark
  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
  • Donation Goals

    AVSIM's 2020 Fundraising Goal

    Donate to our annual general fundraising goal. This donation keeps our doors open and providing you service 24 x 7 x 365. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. We reset this goal every new year for the following year's goal.


    28%
    $7,145.00 of $25,000.00 Donate Now
×
×
  • Create New...