Radio tuner with a single encoder and pushbutton - MobiFlight/MobiFlight-Connector GitHub Wiki
If you only have single encoders with a pushbutton, it is possible to create a radio tuner where pressing the button will switch between MHz (whole numbers) and kHz (the decimal part) of the frequency.
You first need to create an input configuration for the pushbutton, that switches between 0 and 1 when the button is pressed. This can be done with a Mobiflight Variable by writing a bit of ncalc code in the value field. Ncalc is a programming language a bit like the formulas on spreadsheet cells.
Switch to toggle functinality
So create a input config for your pushbutton, and set it to a MobiFlight variable like radio-mhz-khz-switch
for example. The code in the Value field if($=1,0,1)
checks the current value of the variable ($) and sets it to zero if it is 1, and vice versa. This creates a toggle value that we will use later.
Output to read the switch variable
To use this toggle variable, we create a simple output configuration with the variable.
Choose MobiFlight Variable and select the name from the dropdown list, it should be available after you created the input configuration first, you can also type the variable name yourself, but they just need to match with the input config variable name of course.
Press "Run" in MobiFlight and lets quickly test that it works, you can see the value in the "Flight Sim value" and "Output value" columns.
Now the remaining task is to create two encoder configurations for the same single encoder, one to adjust MHz and the other to adjust kHz, and set preconditions for them, so that one is active when the variable is 1, and the other when it is 0.