Skip to content

Class OpenSkyhawk::Switch3Pos

ClassList > OpenSkyhawk > Switch3Pos

Three-position switch (ON-OFF-ON / spring-centred) on two pins. Emits 0 / 1 / 2 over CAN (MULTIPOS dispatch). More...

  • #include <Switch3Pos.h>

Inherits the following classes: OpenSkyhawk::MultiPosInput

Public Static Attributes

Type Name
constexpr uint16_t DEBOUNCE_MS = 20
index stability window (ms).

Public Static Attributes inherited from OpenSkyhawk::MultiPosInput

See OpenSkyhawk::MultiPosInput

Type Name
constexpr uint16_t NO_POSITION = 0xFFFF
readRaw() sentinel: "nothing active right now — hold the last position".

Public Functions

Type Name
Switch3Pos (uint16_t controlId, PinRef pinA, PinRef pinB, bool reverse=false, uint16_t debounceMs=DEBOUNCE_MS)
Construct a 3-position switch.
virtual void configure () override
Configure both pins as inputs. Called by PanelGroup::setup() .

Public Functions inherited from OpenSkyhawk::MultiPosInput

See OpenSkyhawk::MultiPosInput

Type Name
virtual void forceReport () override
Resolve the current position and emit a CAN EVT unconditionally — no debounce.
virtual void poll () override
Resolve the position, debounce it, emit a CAN EVT on confirmed change.
uint16_t position () const
The last confirmed position index (0..N-1).

Public Functions inherited from OpenSkyhawk::InputBase

See OpenSkyhawk::InputBase

Type Name
virtual void configure ()
Configure hardware pins for this input.
virtual void forceReport () = 0
Read hardware state and emit a CAN EVT unconditionally.
InputBase * next () const
Next input in the list; nullptr at end.
virtual void poll () = 0
Read hardware state and emit a CAN EVT if state changed.

Public Static Functions inherited from OpenSkyhawk::InputBase

See OpenSkyhawk::InputBase

Type Name
InputBase * head ()
Head of the self-registered linked list.

Protected Attributes inherited from OpenSkyhawk::MultiPosInput

See OpenSkyhawk::MultiPosInput

Type Name
uint16_t _controlId
DCS/HID control id (routing).
uint8_t _numPositions
N — number of discrete positions.

Protected Functions

Type Name
virtual uint16_t readRaw () override
pin A → 0, pin B → 2, neither → 1 (centre). pin A wins if both read active.

Protected Functions inherited from OpenSkyhawk::MultiPosInput

See OpenSkyhawk::MultiPosInput

Type Name
MultiPosInput (uint16_t controlId, uint8_t numPositions, uint16_t debounceMs)
Construct the base.
virtual uint16_t readRaw () = 0
Resolve the instantaneous position index, or NO_POSITION to hold the last.

Protected Functions inherited from OpenSkyhawk::InputBase

See OpenSkyhawk::InputBase

Type Name
InputBase ()
Registers this instance into the linked list.

Detailed Description

A MULTIPOS-family input (N = 3) — self-registers via MultiPosInput, which owns the debounce / emit-on-change / forceReport contract. This class supplies only the read.

Two pins, one per outer throw; the centre needs no pin of its own: * pin A active → position 0 * pin B active → position 2 * neither → position 1 (centre — a real, emitted position)

Mirrors DcsBios Switch3Pos: if both pins read active (impossible mechanically — a bounce during a throw), pin A wins (position 0); the debounce absorbs the transient either way. Because the centre is resolved directly, readRaw() never returns NO_POSITION — the base's hold-last path is unused.

One-hot read (reverse = false, default): the active pin reads LOW (closed to GND). reverse = true inverts it (active pin reads HIGH). configure() does not enable internal pull-ups; the schematic supplies input bias (typically 10 kΩ to +3.3V, switch to GND).

Used by: AN/ASN-41 LAT/LON slew (spring-centred momentary L / centre / R).

Public Static Attributes Documentation

variable DEBOUNCE_MS

index stability window (ms).

constexpr uint16_t OpenSkyhawk::Switch3Pos::DEBOUNCE_MS;

Public Functions Documentation

function Switch3Pos

Construct a 3-position switch.

OpenSkyhawk::Switch3Pos::Switch3Pos (
    uint16_t controlId,
    PinRef pinA,
    PinRef pinB,
    bool reverse=false,
    uint16_t debounceMs=DEBOUNCE_MS
) 

Parameters:

  • controlId DCSIN_* or CTRL_* constant. Determines PanelBridge routing.
  • pinA outer throw → position 0 (active-LOW unless reverse).
  • pinB outer throw → position 2.
  • reverse false (default): active pin reads LOW. true: active pin reads HIGH.
  • debounceMs index stability window before a change is confirmed (default 20 ms).

function configure

Configure both pins as inputs. Called by PanelGroup::setup() .

virtual void OpenSkyhawk::Switch3Pos::configure () override

Does not enable internal pull-ups; board wiring supplies input bias.

Note:

Must not run from the constructor — MCP23017 register writes require the expander to be initialised first.

Implements OpenSkyhawk::InputBase::configure


Protected Functions Documentation

function readRaw

pin A → 0, pin B → 2, neither → 1 (centre). pin A wins if both read active.

virtual uint16_t OpenSkyhawk::Switch3Pos::readRaw () override

Implements OpenSkyhawk::MultiPosInput::readRaw



The documentation for this class was generated from the following file Firmware/Libraries/PanelGroup/Inputs/Switch3Pos/Switch3Pos.h