Open source software & hardware to build a homemade Airbus cockpit

oacexp.h

This library provides classes and functions to manage Open Airbus Cockpit expansion cards. These cards enable the access to common ICs as digital shift registers, keyboard controllers, LED drivers, etc.

Class ExpansionCard

Use the ExpansionCard class in order to manage IO expansion cards to shift in and out digital data.

ExpansionCard is a very bad name for this class, and it is susceptible to be renamed in the future.

In this example, we are controlling the status of the aircraft lights. The corresponding expansion cards would have switches in its inputs to manage landing lights, taxi lights, strobe, and so on. The output is connected to the LEDs that indicate what light is turned on.

First of all, we declare an object of class ExpansionCard. We declare a variable lights as well to maintain the current status of the output LEDs. The setup() function prepares the expansion card by indicating what are the pins the card is connected to. The rest of the magic is in loop() function.

readInput() function may be used to shift-in one byte from the expansion card and store it in the internal state of the object. After that, inputActivated() and inputDeactivated() functions will operate over that byte that has been read. The first one would return what input bits has been set to 1 since last read, e.g., what inputs have been activated (switched on). The second function does the opposite: indicates what bits have been set to 0 since last read (deactivated or switched off).

In this example, we set the corresponding bit in the lights variable representing the LED indicator for that light. Finally, the writeOutput() function may be used to write a byte through the shift-out register of the expansion card, illuminating the right LEDs.