Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.
You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks!
05/03/2024 - This forum is read-only
The community support for MobiFlight has moved exclusively over to our Discord server. Register for free and enjoy more interactive functions like image and video upload, voice chat. More than 7,000 registered users around the world make it a great experience!
A HUGE Thank You to everyone who participated in the forum, especially obviously to Pizman and Stephan who did an outstanding job over so many years providing an incredible service to the MobiFlight community.
The forum is still providing a lot of good content, hence we keep this information accessible.
Index > MobiFlight General > LED's won't switch off - Multi selection encoder and momentary button
I have searched the Forum for posts related to this topic but could not find anything specifically related to it. Please excuse me and refer me to it, if there are. It is quite an extensive Forum.
I have setup a single encoder and momentary button to enable selection between various options to set the HDG bug, OBS CRS, ADF, etc. I have set it up to write the values (0 to 5) to FSUIPC7 offset 0x66c0. From there Input Configs with Preconditions enables me to change the various settings with the single encoder. THAT PART WORKS FANTASTICALLY WELL. Thanks to the you guys at Mobiflight for the functionality. (Coding is definitely not my thing).
In order to help me see what “state” the selection is in, I have setup 5 LED’s to be switched by Output Configs with Preconditions, using the same values in the FSUIPC7 offset 0x66c0. What now happens is that the LED’s get switched on correctly as I cycle through the button presses, but they do not switch off again. So after 5 button presses, I have 5 LED’s that are all on.
I have tried setting up a separate Input Config, to offset 0x66c1, which uses the same button. But the results are the same. All LED’s are on after 5 button presses.
I assume that each LED pin output HIGH, must now be forced LOW when the offset value changes with each button press. I have no idea how to do this.
You are correct in thinking that you have to tell the leds to turn off. Here is a small excerpt showing how its done. Dont worry about the fact this is reading an Lvar as the main thing is looking at an offset and effecting the desired result from that.
--Panel Lights
BattSw = ipc.readLvar("L:BATTERY1SWITCH")
PanelSW = ipc.readUB(0x2E80) -- reading simconnect AvionicsMaster
if ( BattSw ~= 0 and PanelSW ~= 0 ) then
PANELLIGHT = 1
else
PANELLIGHT = 0
In this example it is looking to see if both the panel switch and the battery switch are unequal to 0 then panellight (which is the led) is 1 or on, otherwise the led is off.
STOP !
Two fully different thematics.....
Your problem is not located to the information from Krono !
************
In order to help me see what “state” the selection is in, I have setup 5 LED’s to be switched by Output Configs with Preconditions, using the same values in the FSUIPC7 offset 0x66c0.
Thats wrong here.... Or better said thats not profitable here, and if you like to do it this way you need to do it correclty..... Not as you try.
Problem: If you use a Precondition in a OUTPUT Config then this config get Disabled ( if Precondition is not true) .... Same like your Input Configs.
But a Disabled Config NOT mean that the used Device ( LED) get disabled. It means the Config no longer work and no longer controll the LED. So the Device remain in it´s last status it got before the config get disabled.
So.... In your case your Config Light up LED 1 if Switch is in 1 Posiiton.... After you turn into Pos 2 the Confg of the First LED is disabled by precondition.... But the LED still light in case "Nobody" tell it, that it should go OFF.
With a Precondition Logic here EACH Config need a "Counterpart" ...... Cause a Device must be controlled at all times!
So you would make 2 Configs for each LED....
Config 1 Say Preconditon : Work if "indicator" is "X" and Light up the Config ( Value 1)
Config 2 Say Preconditon: Work if "indicator" is not X and set LED to OFF ( Value 0)
BUT
Here we not need all this difficult stuff..... You can simply use the Indicator itself.
All LED Condigs simply read Offset 66C0.
Config 1 should Light LED if Indicator = 0.... So you say in transform if($=0,1,0) OR you say in Compare If Value = 0 THEN 1 ELSE 0
Config 2 should Light LED if Indicator =1 .... Here you say in transform if($=1,1,0) or again you can use Compare instead if you enjoy more.
Same logic for all Configs.
(In theroy lots of other formulas will work. Important is that the Resulted Value is 0 if it should be OFF and >0 (e.g.1) if it should be ON