MobiFlight Community Support

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!

See you on our MobiFlight Community Discord server.

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.

icon
Avatar
e4rthdog
Posts: 10
I have a rotary encoder that i need to use for 2 cases:

  • Increase / Decrease Heading
  • Increase/Decrease V/S


I have a button where i want to press to switch between modes.

How can i do it?

Logically i would set a local variable when the button is pressed and then the rotary would have to check somehow the variable value and use different MSFS event id.

Is this possible?
2022-01-14 19:34
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
100% Correct!

In MF you would build TWO Parts.

Part 1 is the "Toggle" of the local Var.

With a INPUT Config ( by the Button you like to use for that toggle) write a "Mobiflight Variable" e.g. to 1 or 0 ( latching switch) or "toggle" it with e.g. " if($=1,0,1) " on Press for a Momentary Button.

Next step is to build a OUTPUT Config, that READ this Variable you former write with that button.
We NEED this Output Config, cause we can not make a precondition or a Formula Syntax just with a Variable Value.... MF only accept a existing OUTPUT CONFIG as a refference/indicator in those logics.... So we MUST Read the Information by a Output Config.

Last Step....
You would create 2 Input Configs for your Encoder....
One use the Events for the Heading.... The Other for the VS
The rist e.g. use a Precondition like " Only work if Output Config xxx ( where you read the Var) = 0
The other use same Preconditon but now Only work if Var = 1

***********
This can be done also more complex....
E.g. a Button set a Variable to 0,1,2,3,4,0,1,2,3,4,0,1,2,3,4 and so on....
then you can change e.g. ALT, CRS, HDG, SPD and VS with only one Encoder.

******

Please check THIS Video.....
Here the basic logic is explaned in a cool way ! https://www.youtube.com/watch?v=DZuVu4qU9Uc
Good Luck !
2022-01-15 22:12
Avatar
e4rthdog
Posts: 10
iconpizman82:


E.g. a Button set a Variable to 0,1,2,3,4,0,1,2,3,4,0,1,2,3,4 and so on....
then you can change e.g. ALT, CRS, HDG, SPD and VS with only one Encoder.

******



Thanks man! That cleared a lot of things, and also thanks for the video. I will study it and come back if i need something...

Regarding the multiple checks on a variable , is there any other command or i have to do it with nested IF statements?
2022-01-20 14:26
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
icone4rthdog:


Regarding the multiple checks on a variable , is there any other command or i have to do it with nested IF statements?



Thats a question what you need to do.....

Every situation is different, and there are often multiple ways ....

For example:
You like to include a logic that say "IF Batteryswitch is ON, then Show Status of a LED .... If not and Battery is OFF then always show "0"
Lets say the Battery switch Config represent the Placeholder "a"
In the LED Config you can say " if(a=1,$,0) " ( If Bat =1 then show $ (status of Sim LED) Else show "0" )
But same will work if you just say "$*a" Cause if "a" is "0" (Battery off) Then whatever the Sim Function is "1" ..... We would say 1*0=0 .... So LED is off.

Lets make it more Complex..... Lets say we want Battery switch (a) and Lighttest Switch (b)
We will say If Battery is OFF, then always "0"..... If Lighttest is ON ( and Battery also) then always "1" .... If battery is ON and no lighttest in Progress then show Status of Virtual LED.
Logical Formula..... if(a=0,0,if(b=1,1,$))

But same work with ($+b)*a We say ADD Lighttest Value to the status .... If no lighttest Status is 1 or 0 ( Whatever on or OFf in Sim) .... If Lighttest is ON then it change into 1 or 2 (cause we add 1) .... So we set the Value to 1 or greater to have it on for lighttest..... And again the Mutliply with "a" Battery switch occure in a "0" always if Battery is OFF.

*********
Finally.... You could also work with Multiple Configs....
ConfigA make the first check..... Config B use the Result of ConfigA as a Value and do the second Check.

There are 1000 ways.... Important is it work, and is logical and comfortable to you !
Good Luck !
2022-01-20 14:57
icon