Skip to content

Class OpenSkyhawk::SwitchMultiPos

ClassList > OpenSkyhawk > SwitchMultiPos

Multi-position rotary selector — N discrete pins, exactly one active at a time. Emits the active position index 0..N-1 over CAN (MULTIPOS dispatch). More...

  • #include <SwitchMultiPos.h>

Inherits the following classes: OpenSkyhawk::MultiPosInput

Public Static Attributes

Type Name
constexpr uint16_t DEBOUNCE_MS = 20

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
SwitchMultiPos (uint16_t controlId, const PinRef * pins, uint8_t numPins, bool reverse=false)
Construct an N-position selector.
virtual void configure () override
Configure each non-NC pin as an input. 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
One-hot scan: return the index of the first active pin, or the PIN_NC detent index, or NO_POSITION if nothing is 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

Self-registers into PanelGroup's InputBase list (via MultiPosInput).

One-hot read (reverse = false, default): the active pin reads LOW (closed to GND); its array index is the position. reverse = true inverts it (active pin reads HIGH).

If no pin reads active — e.g. a non-shorting rotary mid-throw — the last confirmed position is held; no spurious EVT. A PIN_NC entry marks a mechanical-only detent (a position with no physical pin, such as a sprung OFF): when no electrical pin is active, that detent's index is reported.

Debounce: 20 ms on the resolved index — a changed position must hold steady for the window before it is confirmed and emitted. Absorbs contact bounce and fast throws (intermediate detents held < 20 ms are skipped; only the settled position emits). The value is an absolute index, so jumping across positions is safe.

configure() does not enable internal pull-ups; the schematic supplies input bias (typically 10 kΩ to +3.3V, switch to GND).

Public Static Attributes Documentation

variable DEBOUNCE_MS

constexpr uint16_t OpenSkyhawk::SwitchMultiPos::DEBOUNCE_MS;

Public Functions Documentation

function SwitchMultiPos

Construct an N-position selector.

OpenSkyhawk::SwitchMultiPos::SwitchMultiPos (
    uint16_t controlId,
    const PinRef * pins,
    uint8_t numPins,
    bool reverse=false
) 

Parameters:

  • controlId DCSIN_* or CTRL_* constant. Determines PanelBridge routing.
  • pins Pointer to a caller-owned array of N PinRefs, one per position. The array must outlive this object (define it static/global, like the sketch wiring map). Use PIN_NC for a mechanical-only detent.
  • numPins N — number of entries in pins (valid indices 0..N-1).
  • reverse false (default): active pin reads LOW. true: active pin reads HIGH.

function configure

Configure each non-NC pin as an input. Called by PanelGroup::setup() .

virtual void OpenSkyhawk::SwitchMultiPos::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

One-hot scan: return the index of the first active pin, or the PIN_NC detent index, or NO_POSITION if nothing is active.

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

Implements OpenSkyhawk::MultiPosInput::readRaw



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