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.
Hi,
I am new to MOBIFLIGHT and building hardware for a MFSF 2000. I would like to know if it is possible to have a push button act as a toggle? For example, push once to put up the landing gear, push again to put down the landing gear?
If so, how would I do this?
Hi magicnorm,
Sure it is. Run Mobiflight with your arduino Mega connected. You go to settings -> extras -> modules then click add device, button, set the pins you connected to the button and give it a name like Gear toggle or something, it's a name for you to recognize on a list later. Make sure you hit "upload current config to module". Then create an input on the main inputs tab (click where it says "double click to add new..." and type Gear or something), click the three dots on the right, modules click your arduino, device is the button you added before (gear toggle). On Press choose option Key, click the grey rectangle underneath and give it a G on your keyboard (if that's the key you use to toggle the gear). Also instead of Key you could use EVENT_ID GEAR_TOGGLE 65570. Up to you. On release you leave empty. Press Ok. Tick the config as active and press RUN. You can now switch windows to your sim and give it a test. Does it work?
Thanks to patEGWU for your quick reply..... But i think here a more complex awnser is needed.
What "pat" is explane is just the usage of a "existing Toggle" Cause the "G" Key or the Event "GEAR_TOGGLE 65570" are already internal toggle things.
I think "magicnorm" like to know how he can build a toggle..... specialy if there exist no internal one already.
At first.... You must understand there is no real difference between a latching switch and a momentary button.
Both have a ON and OFF or lets say a PRESS and a RELEASE . The only difference is that the switch is latch (hold) in a position.... the Button will be swap back to OFF by itself.
So.... If you press a Button then this send a PRESS to Mobiflight.... And if you put your finger away it swap to OFF and send a RELEASE to Mobiflight.
And a switch do the same.... If you move it to ON it send the press.... And if you move it to OFF again it send a release. Only difference is the latching fact !
With a Latching Switch we mostly use Systems that have 2 fixed states.... So we say e.g. if Switch it is ON Position it should SET the virtual Landing Lights to ON..... If Switch is in OFF Position it should SET the virtual Lights to OFF..... Here we use simply the PRESS and RELEASE commands.
Now about the Toggle.....
Basicly we only use PRESS here.... Cause we press the button only momentary and like to execute just ONE command.
And this command must say something like " If Function is currently ON then set to OFF..... Otherwise if it is currently OFF then set to ON"
And here we got two ways.
1. The system of "patEGWU" by using a premade EventID if there exisiting a special one to toggle things
OR
2. By OFFSET WRITE
Lets make a Example with "Standard Aircrafts Flight Director"
2EE0 4 Flight Director Active, control and indicator. 1=active, 0=inactive.
If we make a Input for your Button.... Use this Offset and write Value "1" it will activate the FD .... if we write "0" it disable the FD.
And now we use instead a formula and say as value if($=1,0,1) ( Only on PRESS cause we just want a single execute of this logic)
This means.... If current Value ($) is 1.... THEN set value to "0" .... ELSE ( so if value is currently NOT 1) set value to "1".
**************
NOTE.... With this logic we can do also more complex things like toggle between more then 2 modes....
Lets say a Function got 4 Modes ( Offset Value 0,1,2,3) and we like to toggle through we use a formula like if($=3,0,$+1)
This means if current value is 3 (Mode 4) then set the Value to "0" (Mode 1) ELSE ( So value is 0,1, or 2) send Current Value +1 and increase to the next mode.
**********
I hope this awnser all your questions.... If not tell us the problem.... We try to help !
I've finally found what I'm looking for. You've explaned us the solution perfect.
Becasue like the magicnorm I have push buttons for MCP. For example I want to enable HDG-HOLD switch by pushing the button and disable again pushing the same button.
if($=1,0,1) this solves the problem.
These logics actually little far away from me that's why I'm not an developer but thank God we have you.