spen25 Posted April 8, 2012 Report Posted April 8, 2012 Hello, Trying to see if there is a command to make a goflight LED, ex RP48 , blink or flash, vice a steady light? If not is there something I can pair with gfdisplay to make it flash? sleep or something? Thanks
Pete Dowson Posted April 8, 2012 Report Posted April 8, 2012 Trying to see if there is a command to make a goflight LED, ex RP48 , blink or flash, vice a steady light? If not is there something I can pair with gfdisplay to make it flash? sleep or something? In a Lua plug-in, either use a loop with an ipc.sleep statement to set the time "on" and time "off", or use the event.timer facility to call a function to turn it on and off at regualr intervals. Pete
spen25 Posted April 8, 2012 Author Report Posted April 8, 2012 Would something like below cause a blinking led? function ENG1FIRE(offset, value) gfd.SetBright(GFP8, 1, 15) if logic.And(value,0x0001) ~=0 then event.timer (30, gfd.SetLights(GFP8,1,2)) else gfd.ClearLight(GFP8, 1, 2) end end event.offset("94EC", "UB", "ENG1FIRE")
Pete Dowson Posted April 8, 2012 Report Posted April 8, 2012 Would something like below cause a blinking led? No. You've not read the details for event.timer correctly, have you. event.timer (30, gfd.SetLights(GFP8,1,2))[/CODE]Three things wrong there:1. 30 milliseconds is very short! You want it flashing 33 times per second? I think all that'll do is dim it.2. The function which the event calls must be its name in "", just like the other event you are using. All the events are similar in that way. Why go and do something completely different?3. The function it calls must be your own function, not a library one. You cannot specify the parameters it receives.You want something more like:[CODE]gfd.SetBright(GFP8, 1, 15)light = falsefunction FLASH() if light then gfd.ClearLight(GFP8, 1, 2) light = false else gfd.SetLight(GFP8, 1, 2) light = true endendfunction ENG1FIRE(offset, value) if logic.And(value,0x0001) ~=0 then gfd.SetLight(GFP8, 1, 2) light = true event.timer(500, "FLASH") else event.cancel("FLASH") gfd.ClearLight(GFP8, 1, 2) light = false endendevent.offset("94EC", "UB", "ENG1FIRE")[/CODE]Pete
spen25 Posted April 8, 2012 Author Report Posted April 8, 2012 Pete no joy, just adds a delay to the initial light. Will try a few things.
Pete Dowson Posted April 8, 2012 Report Posted April 8, 2012 Pete no joy, just adds a delay to the initial light. Will try a few things. Sorry, I didn't finish it properly in my haste. In the FLASH function you will need to set "light = true" when you turn it on and "light=false" when you turn it off. Obviously without the condition it is testing there changing it is not doing anything different on each timer event. If you want the LED to come on immediaely, that needs doing in the original function, along with "light = true". Additionally the "SetBright" line only needs executing once, so you can put that right at the beginning, outside of the functions. I've edited the original. Pete
spen25 Posted April 8, 2012 Author Report Posted April 8, 2012 Woohoo works like a champ! Thank you soo much.
Pete Dowson Posted April 8, 2012 Report Posted April 8, 2012 Woohoo works like a champ! Thank you soo much. That was quick! Your test crossed with some other improvements I added, editing the last message again and the original code. Please re-check. Regards Pete
dimatrixxx Posted May 15, 2013 Report Posted May 15, 2013 Hello Pete! I've tried to use your script in order to make my led regular blinking, because my led blinking unstable for example it blinks first very quickly than very slow.... Here is my script: gfd.SetBright(GFWP6, 0, 15) light = false function FLASH() if light then gfd.ClearLight(GFWP6, 0, 3) light = false else gfd.SetLight(GFWP6, 0, 3) light = true end end function ATAMBER(offset, value) if logic.And(value,0x0010) ~=0 then gfd.SetColour(GFWP6,0, 3, 2) gfd.SetLight(GFWP6,0,3) light = true event.timer(500, "FLASH") else event.cancel("FLASH") gfd.ClearLight(GFWP6,0,3) light = false end end event.offset("940B", "UB", "ATAMBER") I have a feeling that thios script do not work because when I changing the intervall from 500 to 1000 I do not see any difference. Any help would be great. Thanks in advance
Pete Dowson Posted May 15, 2013 Report Posted May 15, 2013 I have a feeling that thios script do not work because when I changing the intervall from 500 to 1000 I do not see any difference. Any help would be great. Thanks in advance Sorry, I don't know what offset 940B is nor what you see when you run this. What is using offst 940B in any case? I think that belongs to "iFlyToFsuipc". Can you describe what you see wrong? Have you tried using the Debug/Trace option to see what happens? Pete
dimatrixxx Posted May 16, 2013 Report Posted May 16, 2013 Yes, you are correct this is iflytofsuipc. Here the 940B offset I want touise: 940B 5 AT_Indicators_Light_Status amber So this is Autothrottle light status (amber) which should go on flashing when AT disconnected etc. Here is my whole script : function FireWarning(offset, value) if logic.And(value,0x0001) ~=0 then gfd.SetColour(GFWP6,0, 0, 2) gfd.SetLight(GFWP6,0,0) else gfd.ClearLight(GFWP6,0,0) end end event.offset("9420", "UB", "FireWarning") function MasterCaution(offset, value) if logic.And(value,0x0002) ~=0 then gfd.SetColour(GFWP6,0, 1, 6) gfd.SetLight(GFWP6,0,1) else gfd.ClearLight(GFWP6,0,1) end end event.offset("9420", "UB", "MasterCaution") function APIndicatorRed(offset, value) gfd.SetBright(GFWP6, 0, 15) if logic.And(value,0x0008) ~=0 then gfd.SetColour(GFWP6,0, 2, 6) gfd.SetLight(GFWP6,0,2) else gfd.ClearLight(GFWP6,0,2) end end event.offset("940B", "UB", "APIndicatorRed") function APIndicatorAmber(offset, value) if logic.And(value,0x0010) ~=0 then gfd.SetColour(GFWP6,0, 2, 2) gfd.SetLight(GFWP6,0,2) else gfd.ClearLight(GFWP6,0,2) end end event.offset("940B", "UB", "APIndicatorAmber") function ATRED(offset, value) if logic.And(value,0x0020) ~=0 then gfd.SetColour(GFWP6,0, 3, 6) gfd.SetLight(GFWP6,0,3) else gfd.ClearLight(GFWP6,0,3) end end event.offset("940B", "UB", "ATRED") gfd.SetBright(GFWP6, 0, 15) light = false function FLASH() if light then gfd.ClearLight(GFWP6, 0, 3) light = false else gfd.SetLight(GFWP6, 0, 3) light = true end end function ATAMBER(offset, value) if logic.And(value,0x0010) ~=0 then gfd.SetColour(GFWP6,0, 3, 2) gfd.SetLight(GFWP6,0,3) light = true event.timer(500, "FLASH") else event.cancel("FLASH") gfd.ClearLight(GFWP6,0,3) light = false end end event.offset("940B", "UB", "ATAMBER") function FMC(offset, value) if logic.And(value,0x0040) ~=0 then gfd.SetColour(GFWP6,0, 4, 6) gfd.SetLight(GFWP6,0,4) else gfd.ClearLight(GFWP6,0,4) end end event.offset("940B", "UB", "FMC") function SPEEDBRAKEARM(offset, value) if logic.And(value,0x0004) ~=0 then gfd.SetColour(GFWP6,0, 5, 3) gfd.SetLight(GFWP6,0,5) else gfd.ClearLight(GFWP6,0,5) end end event.offset("9414", "UB", "SPEEDBRAKEARM") When using this script OR the same script but without the flash function I have problem that the Amber lights (Autopilot, Autothrottle and FMC) flashing all not at the same time (when performing light test) AND every light flashes with different interval between flashes. That means that while light test for example first start to flash AT Amber light then the others start flashing. Every light flashes for example very quick and then starting to flash very slow, then again very quick. It is chaotic. Also I mentiones that the brightness of every light changes. While so flashes of the same light are bright, the others very dark. I do not know what causes this problem, as I understand this lights should flash automatically without flash function, but because I get all this problems I though the flash function will solve them. GoFlight software is off.
dimatrixxx Posted May 16, 2013 Report Posted May 16, 2013 I will try to use debug to see what happens.
Pete Dowson Posted May 16, 2013 Report Posted May 16, 2013 Here is my whole script : It's rather inefficient and it may not work predictably. Every time offset 9420 or 940B changes the thread has to be re-entered 2 times for 9420 and FIVE (!) times for 940B. Since it isn't re-entered when already just reentered (as it will be), the results will be rather unpredictable. You should have just one event per different offset. So, try it rewritten this way: gfd.SetBright(GFWP6, 0, 15)light = falsefunction Warnings(offset, value) if logic.And(value,0x0001) ~=0 then gfd.SetColour(GFWP6,0, 0, 2) gfd.SetLight(GFWP6,0,0) else gfd.ClearLight(GFWP6,0,0) end if logic.And(value,0x0002) ~=0 then gfd.SetColour(GFWP6,0, 1, 6) gfd.SetLight(GFWP6,0,1) else gfd.ClearLight(GFWP6,0,1) endendevent.offset(0x9420, "UB", "Warnings")function FLASH() if light then gfd.ClearLight(GFWP6, 0, 3) light = false else gfd.SetLight(GFWP6, 0, 3) light = true endendfunction APIndicators(offset, value) if logic.And(value,0x0008) ~=0 then gfd.SetColour(GFWP6,0, 2, 6) gfd.SetLight(GFWP6,0,2) elseif logic.And(value,0x0010) ~=0 then gfd.SetColour(GFWP6,0, 2, 2) gfd.SetLight(GFWP6,0,2) else gfd.ClearLight(GFWP6,0,2) end if logic.And(value,0x0020) ~=0 then gfd.SetColour(GFWP6,0, 3, 6) gfd.SetLight(GFWP6,0,3) else gfd.ClearLight(GFWP6,0,3) elseif logic.And(value,0x0010) ~=0 then gfd.SetColour(GFWP6,0, 3, 2) gfd.SetLight(GFWP6,0,3) light = true event.timer(500, "FLASH") else event.cancel("FLASH") gfd.ClearLight(GFWP6,0,3) light = false end if logic.And(value,0x0040) ~=0 then gfd.SetColour(GFWP6,0, 4, 6) gfd.SetLight(GFWP6,0,4) else gfd.ClearLight(GFWP6,0,4) endendevent.offset("940B", "UB", "APIndicators")function SPEEDBRAKEARM(offset, value) if logic.And(value,0x0004) ~=0 then gfd.SetColour(GFWP6,0, 5, 3) gfd.SetLight(GFWP6,0,5) else gfd.ClearLight(GFWP6,0,5) endendevent.offset("9414", "UB", "SPEEDBRAKEARM")[/CODE]RegardsPete
dimatrixxx Posted May 16, 2013 Report Posted May 16, 2013 Thanks Pete! I will try it tommorow evening and write you the result.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now