Lots of questions... This will get a long Posting
About the 2 Configs for your Display.....
Mobiflight not allow us to "read" a Switch Position (Pin Status) for a precondition.
The "precondition" MUST be a existion Output Config..... And Those Configs can only read a FSUIPC Offset.
Its not possible to check a Pin like in your posted Code Part from the Arduino IDE.
So there are two ways.....
1. You use a existing Offset Information as a idicator.
For example you can say..... If your Gear is down ( So your on the Ground or in departure or final aproach) then Display should show Value A .... If Gear is UP then it should show Value B .
This is verry usefull for example in the Radio. Hear you can say if Active Microphone is set to Com1 then show Com1 Frequency on Display..... If active is Com 2 then show Com2 ..... If Active is ADF then show ADF and so on.
2. Using CUSTOM Offset ! ( Thats what you need pretty sure)
In FSUIPC exist "free" Offsets for personal use. This Offsets are "0" Zero at Systemstart and can be written and read by the User. For Example Offset 66C0 ( 1 BYte INT)
If you make a Input Config for your Switch ( On OFF Switch on a single Pin) with Press.... Write Offset 66C0 1 Byte to "1" and Release.... Write Offset 66C0 1 Byte to "0"
Now THIS Offset is 1 or 0 whitchever your switch is used....
Now you make a Output Config (without device) that Read exactly this Offset.
And THIS Config now is used as a precondition for your 2 Configs of the Display.
The ALT Value should be shown aslong this Readout Config of Custom Offset = 0
The QNH Value should be shown aslong this config is "1" .
About your Altitude and Heading.
You must know what you need and what you want
As Stephan said.... There is not one Altitude... There are multiple....
Alt over GRD .... Alt over Sealevel in Standarf Atmosphere ..... Alt over sealevel in real atmosphere ..... Altitude from Ground in relation to sea level .... Radar Altitude ..... GPS Altitude .
Same like Heading/CRS.
You got magnetic North , geographic north. Heading ...Noseposition in releation to crosswinds and so on.
there is True Air Speed , Indicated Air Speed , Speed over ground , Speed with or without wind factor and so on.
Summary.... Some Values can be readout directly on a Offset.... Others must be calculated with multiple offsets ( as you said) .
Its not possible to do that with Mobilflight.... We can NOT say Offset A minus Offset B for example.
BUT: Normaly we not need such Values. In a real Aircraft you have only basic Informations..... And all those standard Informations are available directly !