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! 

icon
Avatar
RydyB
Posts: 18
Hello Sebastian,

First of all … what a wonderful piece of software you built. It’s a joy to use when interfacing home built hardware with the flight sim.

I have a Youtube channel on Arduino and on Flight Sim Navigation and I plan to do some videos on Mobiflight to promote it some more.

I have a couple of encoders and switches working and so far all is OK. I have trouble though to figure out how to use the ‘precondition’ option. I plan to use encoders and switches in combination with the Android app called FS Radio Panel, which has a complete radio stack display. That way I don’t need separate 7 segment displays. Autopilot and HSI are also included in FS Radio Panel, so heading bug, OBS1 and OBS2 and autopilot encoders are also in the plan.

To avoid having too many encoders I like to use one encoder for multiple functions, for example to tune NAV1_RADIO_WHOLE and NAV2_RADIO_FRACT, or to tune COM1 or COM2, and to use a switch to select which of the two. Or better even to use the encoder push button to toggle between the two.

I thought to use a precondition, which I read in the manual is meant for this. But I don’t know how to do it with an Arduino? There is a precondition ‘pin’ option, but that is only available with Arcaze which I don’t have. I wonder if changing the function of an encoder via a switch or a push button can be done with an Arduino, and if so how? I hope you could you be so kind as to try lead the way?

Greetings, Ruud.

The blogs / Youtube channels:
https://flightsimnavigation.wordpress.com/
https://rudysarduinoprojects.wordpress.com/
Always have fun.
2020-05-03 12:28
Avatar
RydyB
Posts: 18
A search for precondition led me to another search for Custom Offset. I'll try to figure that out ... will get back if I get stuck.
Always have fun.
2020-05-03 13:05
Avatar
RydyB
Posts: 18
Oops, yes ... figured it out. These are the steps to use one encoder for different functions, using a precondition. In this example we'll tune NAV1 before the decimal (MHz) and after the decimal (kHz). The encoder push button is used to toggle between the two.

We use a FSUIPC Custom Offset as a memory location where we can store a value. Offsets in the range of 66C0 - 66FF are available for this.

Create an Input Config which we use to monitor the switch / push button and to store / toggle the value in FSUIPC memory.
Module / Device: select the switch or button you wish to use.
Type: FSUIPC Offset
Offset 0x66C0, Type Int, Bytes 1, Mask 0xFF, BCD off.
Value for a push button: Press if($=1,0,1), Release none. This toggles on every press.
Value for a switch: Press 1, Release 0. This changes if the switch is thrown.

Create an Output Config. I gave it the name NAV1 Toggle State. This makes the stored value available to us for read out.
Preset empty, Offset 0x66C0, Type Int, Bytes 1, Mask 0xFF, BCD off.

Create an Input Config. I gave it the name NAV1 MHz. This is the encoder for MHz.
Module / Device: select the encoder you wish to use.
Left tab: Event ID, NAV1_RADIO_WHOLE_DEC
Right tab: Event ID, NAV1_RADIO_WHOLE_INC
Precondition tab: Use type Config Item, Choose NAV1 Toggle State, value = 1

Create an Input Config. I gave it the name NAV1 kHz. This is the same encoder, nor for kHz.
Module / Device: select the encoder you wish to use.
Left tab: Event ID, NAV1_RADIO_FRACT_DEC
Right tab: Event ID, NAV1_RADIO_FRACT_INC
Precondition tab: Use type Config Item, Choose NAV1 Toggle State, value = 0

Ruud.
Always have fun.
2020-05-03 14:10
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 4465
Supporter
Hi Ruud.
Welcome to Mobiflight.

I see you still found out the disadvantage of Mobiflight here and you still be able to solve it.

The "bad" factor here is Mobiflight NOT allow us to use a real swtich state ( Pin hi low) as a precondtion.... This is cause Mobiflight basicly not know the current position of our Input switches. Sebastian build the software in a way so a INPUT is just send from Mega to Mobiflight in the moment of changing the condition of the Switch. Then MF execute the Command we create for the action (Press or Release) ..... But finaly it "forgot" the Information again and at systemstart it also NOT know the switchpositions at all.
MAYBE this will come in the future.... But at the moment here are no plans.

Solution is correct......
MF allow us as precondition only one thing.... An existing Output Config based on a FSUIPC Offset. !
So we need the "bypass" over a Offset.... As you said we build something like a "Memory-Register" that is filled by our Switch Inputs and that is finaly read by a Output Config without device.

Just two important notes to make your life more easy:

1. Get sure you use the Logical Option for Value "0" correctly.
At systemstart the Custom Offsets are Empty (means Value zero "0" ) . As i said above Mobiflight NOT initial Read a Switch Position.... So whatever your selecting Switch is in "1" Position..... The Offset is still Zero until you use the switch first time (Or run the Sync Function by hand)
Same for Momentary Buttons..... At Systemstart there Offset is also "0" .
So its high recommend to use the most important function with Precondition "0" cause thats what you get after Systemstart everytime.
For example in Nav1 we use normaly MHZ at first ..... Or if you build another toggle for Encoder that should controll Com1 OR Com2 by pressing..... Here pretty sure COM1 should be active at systemstart instead com2.


2. Combine that Offset for mutliple things.
Whatever you can build that system individual for every swapping Button.... Like Offset 66C0 for "Nav1 Toggle State" and another 66C1 for "Nav2 Toggle State" and so on..... BUT this is not needed and to much difficult. More logical (for me) is using only ONE Toggle for a gorup of Elements that work same way.
In Your case lets talk about COM1, COM2, NAV1, NAV2 .... For the Khz-->Mhz Toggle you can simply use ONE Offset...... Whatever you use 4 Encoders and 4 Buttons..... Then simply every Button write SAME Offset ( e.g. 66c0) by "if($=1,0,1) .
Result: You can use the Toggle on the correct Encoder.... And it will togle correct between MHZ and KHZ for that Encoder ....
In Backround It will also toggle the other 3 Encoders same time but thats no matter cause you will never turn two Encoders same time with both hands.
Result: If you swap for example NAV1 to Mhz then also Com1, Com2 and Nav2 encoders are currently in Mhz Mode.
Benefit.... You need only ONE Output Config ..... All Switches use same Precondition Indicator and Offset.... So its much more comfortable to "duplicate and rework" configs instead of build every config by hand.


Hope you understand...... If not ask again then i try to give a example !
Good Luck !
2020-05-03 19:26
Avatar
RydyB
Posts: 18
Thanks 'pizman82' for your extensive reply. Yes, I already gathered MF only uses transition to read buttons and switches when I saw there there is not even a 'switch option as input, only a button. I understand what you say in your point 1 as a consequence, yes surely something to be aware of.

Thanks for explaining your point 2, that indeed is a neat trick to avoid excessive configuration effort. It would be nice if Sebastian could some day incorporate memory locations we can use inside MF that we can name and then fill based on inputs. The current way of working with the FSUIPC Custom Offset feels like sort of a workaround, but hey, it works!

I did the first tests with a pro mini I had lying around. When I got it to work I decided to give the project a go and I just ordered a mega and a bag of encoders. :) And I threw in some 7 segment displays also.

I plan to do a couple of videos, later, when it starts to look like something.

Thanks again, Ruud.
Always have fun.
2020-05-03 19:53
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 4465
Supporter
Nice to hear.... We looking forward for Users who can make videos and tutorials for the comunity.

If you like Join us at Discord..... Pretty more easy to awnser short questions or talk a bit via VOIP.
Here we can also talk bout your videos if you like.

Last note:
Not get confused about the missing SWITCH Device.
A Switch is nothing else like a button with a latching mechanic.
So we just use PRESS Tab for the ON position and RELEASE Tab for the OFF Position ... ( A Momentary Button also "can" have a Release but here it makes no sense normaly.)

If you use special ON-ON Switches then here each line is a single Button and you use mostly 2x Press ( Without Release)
A 3Way ON-OFF-ON Switch also use 2 Button Devices.... Each Got Press for ON and Release for OFF .... So Both Buttons use the SAME Release.
Multiposition like ON-ON-ON or Rotary switches with 4-12 Positions finaly are again single Buttons.... All with ON PRESS Only.
Good Luck !
2020-05-03 20:01
icon