-
-
Notifications
You must be signed in to change notification settings - Fork 104
Cockpit lights logic for warning lights, power and lights test function
An aircraft warning light reacts to two things (or well, three): electrical power, the actual thing it is a warning for, like "Engine 1 is on fire", and in many cases a lights test button that is useful during the preflight checks to see that all warning lights are working.
For obvious reasons the warning light test button cannot set the engine on fire for real, so that the fire warning light can be checked, so there is often a separate, parallel logic using a different simulator variable just for the test case. Some aircraft, like the PMDG 737 for MSFS2020 have the simulator variables for warning lights also react to the light test function, but many times this is not the case, and the warning light objects in the virtual cockpits check for the light test internally, and this is not visible to MobiFlight directly.
Most of the time we thus need to do the same logic in MobiFlight: either read the "light test" state from the simulator, if it is available, or do such state variable ourselves using a mobiflight variable. We also need to check that the aircraft panel actually is powered up. These can differ per airplane a bit, but "Microsoft > Generic > Miscellaneous > CIRCUIT GENERAL PANEL ON" is a good starting point. This will also make sure your cockpit is "cold and dark" when power is off, all lights work only when you have power.
Note
You will learn a new concept: Config references. A config reference lets you use the value of another output config item in your logic.
While the actual config refers to a simvar like our "ENGINE IS ON FIRE!!", config references lets you bring in additional things you can compare and check your simvar against.
While outputs usually are tied to actual leds or displays, it's often also useful to just configure some simulator variables as "outputs" but just leave the LED / display hardware unconfigured. They will still work for our purposes. You can see their state in the "Flight Sim value" column, and they should be either 0 or 1 depending on the state of panel power, and whether the "lights test" button is pressed. And by using those configs from other configs, you can create more complicated schemes for things like electricity and so on.
Use these two things as additional config references for your warning light, you can very easily take care of the two additional cases your warning light should react to.
Now, the image above has a lot to unpack, but pay attention to two things:
- the Config references and their symbols A and B, and
- Transform Modifier with the cryptic code we will explain next
The config references are on the bottom: panel is powered and light test. Those are given two symbols, they are by default special characters like ! and # but they can be changed, and I find A and B to be more clear in the example. Just remember the symbols cannot be characters that are used in other function names etc in the Transform, like if you use Round() you should not use "R" as a reference name.
In the Transform field, "$" refers always to the sim variable the current config is referring to, the "ENG ON FIRE" state in this case.
Then we have logical OR, represented by the pipe character "|" between $ and A, basically stating "light this light up if engine is on fire, OR, if lights test is pressed".
The final multiplication is with the logical state of power: If panel power is zero, multiplication results in a zero, so there is no light no matter how much fire there is on the engine, or if the test button is being pressed.
The transform field uses NCalc mathematical expression library that has quite a few useful functions and operators, you can check out the NCalc GitHub page for more documentation on the syntax.
- MobiFlight Connector Installation
- Mobiflight Connector BETA version installation
- Modules
- MobiFlight Connector Files Structure
- MobiFlight Connector Uninstall
- Modules Reset to factory default
- Verifying the WASM module installation and locating the MSFS2020 community folder
- Using a Winwing FCU with MobiFlight
- Providing logs from MobiFlight
- MobiFlight Connector How does it work
- Mobiflight Connector Main Window
- Flash module with MobiFlight firmware
- Input and Output devices
- Joysticks
- Midi Boards
- Sim Variables (for Output)
- Input Actions
- Merging configuration files
- Disabling specific COM ports
- Examples Output LEDs
- Examples Input Switch
- Example 7 segment display
- Example Servo motor
- Controlling LEDs with an output shift register
- Adding lots of buttons with an input shift register
- Beginner's guide to input multiplexers
- Key Matrix with standard MobiFlight and Multiplexers
- Tutorial Easy Driver and x.27 or x.40 Stepper Motor
- Tutorial for Airbus VS display via 7-Segment LED Module
- Example Analog Input Potentiometer
- Baron G58 Tutorial Gear, Flaps, Mags, ELT Input Output Programming
- Using Mobiflight to control arduino-based 3rd party panels (RealSimGear GNS530)
- How to use a VNH2SP30 DC motor shield with MobiFlight
- Using 3D printer mainboards
- Playing sounds by sending keystrokes to AutoHotKey
- Using the selector knob on a Honeycomb Bravo
- Using an adjustable 12 position switch as a GA starter
- Brightness of LCD displays with I2C
- Using three-position switches
- Transponder with one Rotary
- MSFS2020 RPN Tips and Tricks
- MSFS2020 Using the Custom Input Code Box
- MSFS2020 Install WASM module and Event List
- MSFS2020 How to Create and Use User Defined Lvars
- MSFS2020 How to Create a Blinking LED configuration
- MSFS2020 User Defined WASM Module Events Best Practices
- MSFS2020 Developer Mode, Model Behavior dialog and Console window
- MSFS2020 PMDG 737‐700 List of Events that require use of FSUIPC7
- MSFS2020 PMDG 737‐700 Calibrate throttle idle and reverse thrust using interpolation (Valkyrie)
- MSFS2020 PMDG 737-700 Chrono unit functions implemented in Mobiflight
- Configuring PMDG 737 Parking Brake Lever Auto-Release with a Servo in Mobiflight
- Using encoder to drive a value back and forth within a given range
- Adding a custom board to MobiFlight
- User guide - Community Board and Custom Devices
- Developing your own custom devices/boards