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
tessamito
Posts: 4
Is it possible to make it so that when the encoder is rotated, one parameter changes (for example, height), and when the encoder button is pressed and simultaneously rotated, another parameter (for example, vertical speed)? MF 9.1, Arduino Mega 2560, MSFS 2020.
2021-12-23 16:45
Avatar
Whiteknuckle157
From: Bayern - Bibertal, Germany
Posts: 50
This shall be possible with a precondition.
I use it in the way, that the encoder button click toggles the input. In my autopilot module, I toggle with encoder click between altitude and rate of climb and with my transponder module I toggle between the digits.
I use FSUIPC offset variable (like 66E0) for this purpose. There is no need to hold the encoder switch pressed while simultaneously turning.

cheers

Volker
2021-12-23 20:36
Avatar
tessamito
Posts: 4
Whiteknuckle157
I can't understand without screenshots, sorry. Please do them.
2021-12-24 19:40
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi

100% Correct.

Maybe in the future we will have the posiblilty to use a "state" of a Input device as a precondition.....
Like "Check if ButtonX on Pin Y is Pressed.... if yes, do A else do B" .
This is NOT Possible at the moment..... But we can use a symply trick to simulate the same.

As Volker say....
For a Precondition we need currently a Status/Value of a existing Output Config.
Means we can not read the Button Position..... BUT we can write a Offset or Variable by our Button and finally read again this Variable in a Output Config.... And that Config we use for Precondition.

In your case....
1. The Button write a Variable ( MF Variable or a empty FSUIPC Offset) to 1 or 0 .....
2. You create a Output Config that read this Variable or Offset. Call it e.g. "Status"
3. You create 2 Configs for the Encoder.... one e.g. for the Altitude, the second for vertical Speed with the corespondending Events.
And you say in both configs there is a precondition....
Alt Config e.g. only work if the Config "Status" =0 and VS Config only work if "Status" = 1

***

About the handling..... Also here BOTH ways are possible!

Way 1 Toggle .... Like Voler say.
You say ON PRESS for the Button if($=1,0,1)
This means on every momentary press (with release) the Status toggle between 0 and 1 .
So you are in Alt Mode.... You press the button momentary and release it. Then you are in VS Mode.... Another press swap back to alt mode.

Way 2 HOLD ( as you request)
You say ON PRESS 1 ..... ON RELEASE 0
Means if Button is released then ALT Mode If Pressed (and hold) VS Mode ...... If you release it again it swap back to Alt Mode.
Good Luck !
2021-12-24 19:48
Avatar
tessamito
Posts: 4
Yes, it works! Many thanks!!!
But I dont understand, how it works: "You say ON PRESS for the Button if($=1,0,1)"?
2021-12-24 20:32
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
icontessamito:

Yes, it works! Many thanks!!!
But I dont understand, how it works: "You say ON PRESS for the Button if($=1,0,1)"?



This is a IF Statement ..... A verry rudimentary part pof Programming Code.

Its like we would say " IF Weather is sunny, THEN where a shirt, ELSE ( so if weather is NOT sunny) where a Jacket.
Syntax is if(Condition,Then,Else)

In our Example above we have a Variable that can/should be 1 or 0 ( to define the 2 different States of the Encoder Funktion) .
We like to "toggle" the Number by a Button Press . So we swap between 0 and 1 by every press.

This is done by the If-Statement : if($=1,0,1)
Command is "if" .....
Condition is "$=1" ( Means current Value of the used Variable ($) is 1
Then is "0" .... So If Condition is True (1) then we would send "0"
Else is "1" ..... So if Condition is False ( Not 1) then we would send "1"

In easy words.... IF Current Value of the Variable is "1" THEN send "0" ELSE send "1"
If it´s currently 1 then we would send 0 ..... If its currently 0 then the ELSE would act and send a 1 again.
So.... Swapping between 0 and 1 by every press !
Good Luck !
2021-12-29 20:35
icon