Jump to content
The simFlight Network Forums
jgoggi

Automatic landing lights action

Recommended Posts

Hi, I know nothing of such things, but is it possible, through FSUIPC, to have the landing lights automatically turn OFF then quickly ON during approach below 1000 ft AGL? This as a workaround to an issue I have with an addon airplane.

Thank you.

James

Share this post


Link to post
Share on other sites
1 hour ago, jgoggi said:

I know nothing of such things, but is it possible, through FSUIPC, to have the landing lights automatically turn OFF then quickly ON during approach below 1000 ft AGL

Sure, should be possible via a lua plugin. 

Share this post


Link to post
Share on other sites
27 minutes ago, jgoggi said:

Where could I find any instructions to build such a plugin?

All the information you need is in the provided FSUIPC documents. If you haven't used lua before, check the provided examples.

@spokes2112 is very good with such plugins, he may have or know of a similar plugin that you could adapt.

Share this post


Link to post
Share on other sites

James,

Believe it or not I pondered what needed to be done for this with the morning coffee!
I also read the thread over at Avsim.
I believe it could be done - yes... 
The problem is, I do not own the FSL Airbus. *
If a SDK is somehow available I may be able to help.* With that being said -
1) if the landing light control can be done with L:Vars or stock landing light commands then a XML gauge would be the way to go for sure - if not...
2) then lua would do it, a bit more work in coding, but doable. 

A hypothesis on operation -
Arming - once the aircraft gets above, say, 2500 ft RA the system would arm. ( a cushion for varying terrain )
Trigger - If armed and the aircraft gets below 1000 ft RA then :
     If the lights are on - turn off the lights and wait for about 1 second or less, turn them back on, then disarm the system.
     If the lights are off - just wait until they are turned on then do the above.
The arm / disarm system is there so the turn off/on procedure is only done once. ( IE not repeating < 1000 ft RA )
 
* Found the LINDA kit for A3xx-X 1.5  and was able to see what is needed. It can be done in LUA.
Won't be able to get into it fully until Tuesday, it is Labor day weekend in the US..  
Testing will be tough not owning the aircraft, but again, doable.

Roman   

  • Like 1

Share this post


Link to post
Share on other sites

Here's a quick & dirty lua.
Maybe someone could put another set of eyes on it or even test it with the Bus.
It is far as I can go for the weekend.
It has been tested for syntax errors, proper RA conversion to feet & the arm/disarm.

Roman
 

-- Special FSL Airbus LL toggle controller, 05SEP20, Roman Stoviak (spokes2112) 

-- USER ADJUSTMENTS
samples = 4000 		-- The time between RAlt samples. In milliseconds.
wait = 1000 			-- The wait time between LLs turning off, then back on. In milliseconds.
arm_alt = 2500			-- the altitude (at or above), in feet, where the system will arm.
trigger_alt = 1000   -- the altitude (at or below), in feet, where the system will trigger the LL toggle, if armed. 
-- END USER ADJUSTMENTS

armed = 0
-- convert the user RAlt adjustments in feet to the "raw" FSUIPC read RAlt value in meters
arm_alt = arm_alt * 19975.3728
trigger_alt = trigger_alt * 19975.3728

function do_it()
	local alt = ipc.readUD(0x31E4)	-- get the current RAlt
	if (armed == 1 and alt > trigger_alt) or (armed == 0 and alt < arm_alt) then -- bypass most of code, nothing valid 
		return
	elseif armed == 0 and alt > arm_alt then -- arm it
		armed = 1
	elseif armed == 1 and alt < 998768.64 then -- disarm it if the trigger was never met. IE on, or very close (50 ft.) to the ground
		armed = 0
	elseif armed == 1 and alt < trigger_alt then -- trigger it
		local l_llit = ipc.readLvar("L:VC_OVHD_EXTLT_Land_L_Switch")
		local r_llit = ipc.readLvar("L:VC_OVHD_EXTLT_Land_R_Switch")
		if l_llit == 20 and r_llit == 20 then -- !!! BOTH left and right LLs MUST be ON to trigger !!!
			ipc.control(66587, 72496)  -- turn off left LL
			ipc.control(66587, 72506)  -- turn off right LL
			ipc.sleep(wait) -- delay between turning off lights, then turning back on
			ipc.control(66587, 72497)  -- turn back on the left LL
			ipc.control(66587, 72507)  -- turn back on the right LL
			armed = 0 -- disarm the system until next take off / climb			
		end	
	end
end

event.timer(samples, "do_it")

--[[ Notes..

(L:VC_OVHD_EXTLT_Land_L_Switch, number)
(L:VC_OVHD_EXTLT_Land_R_Switch, number) 
LVAR ON = 20 
LVAR OFF = 10
LVAR RETRACT = 0
FSL COMMAND  = 66587
LEFT LL INC = 72497
LEFT LL DEC = 72496
RIGHT LL INC = 72507
RIGHT LL DEC = 72506

31E4 4 Radio altitude in metres * 65536
]]

 

Edited by spokes2112
did the feet to meter conversion prior to the function instead of in the function - saves cycles
  • Like 1

Share this post


Link to post
Share on other sites

@John Dowson It is for the FSLabs A320.. Kind of weird problem with this user, maybe others. (here)
Just a nice, quick, little project.
@jgoggi What is the command for the landing gear lever? Is it the stock P3D landing gear command?  If I knew that, it could even get better, if it works in the first place.
Right now, the lua is constantly on - getting RAlt values every 4 seconds. Not much really. But, if the landing gear lever was monitored - if the lever was up the lua wouldn't do a thing except listen for the lever being moved. If the lever was down then the lua would monitor RAlt as it does now. Just a little more efficient.

Roman 

Share this post


Link to post
Share on other sites
6 minutes ago, spokes2112 said:

It is for the FSLabs A320.. Kind of weird problem with this user, maybe others. (here)
Just a nice, quick, little project.

Ah, sorry, was getting confused - I was in MSFS/FSUIPC7 mode for some reason.....! 

 

  • Haha 1

Share this post


Link to post
Share on other sites

Thank you very much, @spokes2112, you are great! Unfortunately at the moment I can't test it, I will check in the evening or tomorrow. Anyway yes, the landing gear lever is commanded by the stock G key.

All of this is just out of curiosity unti the next FSLabs update, since they said they have a workaround in the next release. 

Thank you again for your help, I will report as soon as possible.

Many thanks also to @John Dowson!

Share this post


Link to post
Share on other sites
On 9/5/2020 at 10:30 AM, John Dowson said:

Ah, sorry, was getting confused - I was in MSFS/FSUIPC7 mode for some reason.....! 

@John Dowson  I can only imagine how little hair you have left!  👍😅
 

52 minutes ago, jgoggi said:

It works! Thanks a lot!

@jgoggi Good news! You're welcome. I really like these little projects, even if not for myself. They go well with the morning coffee, it gets the brain cell working again.  😅
This morning I started the version with the landing gear lever, but will stop.
1) If FSL, on the next update, gets this fixed then great! If not, I may revisit the landing gear lever arming.
2) Without the landing gear lever arming the lua above reads these 3 lines every 4 seconds throughout the whole flight.

local alt = ipc.readUD(0x31E4)	-- get the current RAlt	
	if (armed == 1 and alt > trigger_alt) or (armed == 0 and alt < arm_alt) then -- bypass most of code, nothing valid
		return

 It is not much at all in the whole scheme of things but would be nice if it didn't have to read the var / decide for the whole flight.   
I do have the variable I need to do this but it's output could be reversed, there is no way I can tell, this would make testing a possible "back and forth" chore. ( would the negligible gains be worth it? )

Roman

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.