Class OpenSkyhawk::MultiPosInput
ClassList > OpenSkyhawk > MultiPosInput
Base for the MULTIPOS input family — selectors that emit an absolute position index 0..N-1 over CAN. Self-registers into PanelGroup 'sInputBase list.More...
#include <MultiPosInput.h>
Inherits the following classes: OpenSkyhawk::InputBase
Inherited by the following classes: OpenSkyhawk::AnalogMultiPos, OpenSkyhawk::Switch3Pos, OpenSkyhawk::SwitchMultiPos
Public Static Attributes
| Type | Name |
|---|---|
| constexpr uint16_t | NO_POSITION = 0xFFFFreadRaw() sentinel: "nothing active right now — hold the last position". |
Public Functions
| 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
| 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
| Type | Name |
|---|---|
| InputBase * | head () Head of the self-registered linked list. |
Protected Attributes
| Type | Name |
|---|---|
| uint16_t | _controlId DCS/HID control id (routing). |
| uint8_t | _numPositions N — number of discrete positions. |
Protected Functions
| 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
| Type | Name |
|---|---|
| InputBase () Registers this instance into the linked list. |
Detailed Description
A subclass reports the instantaneous resolved position via readRaw(); this base debounces it (configurable window) and emits a CAN EVT only when the confirmed position changes. The emitted value is the absolute index, never a delta — a jump from any position to any other (even skipping intermediates) emits the new index directly; there is no ±1 or adjacency assumption.
readRaw() returns NO_POSITION when nothing resolves (e.g. a non-shorting rotary mid-throw with no pin closed); the base then holds the last confirmed position — no spurious EVT.
Subclasses: SwitchMultiPos (one-hot pins), AnalogMultiPos (resistor ladder, #114).
Public Static Attributes Documentation
variable NO_POSITION
readRaw() sentinel: "nothing active right now — hold the last position".
constexpr uint16_t OpenSkyhawk::MultiPosInput::NO_POSITION;
Public Functions Documentation
function forceReport
Resolve the current position and emit a CAN EVT unconditionally — no debounce.
virtual void OpenSkyhawk::MultiPosInput::forceReport () override
Called by PanelGroup during the boot EVT burst and on SYNC_REQ. Establishes the baseline so subsequent poll() calls have a valid reference.
Implements OpenSkyhawk::InputBase::forceReport
function poll
Resolve the position, debounce it, emit a CAN EVT on confirmed change.
virtual void OpenSkyhawk::MultiPosInput::poll () override
Called by PanelGroup::loop(). No-op until forceReport() has run once.
Implements OpenSkyhawk::InputBase::poll
function position
The last confirmed position index (0..N-1).
inline uint16_t OpenSkyhawk::MultiPosInput::position () const
Updated by forceReport() (immediately) and poll() (after the debounce confirms a change). Useful as a query — a node can read its current selector position — and for tests to assert the resolved index without capturing the CAN frame.
Protected Attributes Documentation
variable _controlId
DCS/HID control id (routing).
uint16_t OpenSkyhawk::MultiPosInput::_controlId;
variable _numPositions
N — number of discrete positions.
uint8_t OpenSkyhawk::MultiPosInput::_numPositions;
Protected Functions Documentation
function MultiPosInput
Construct the base.
OpenSkyhawk::MultiPosInput::MultiPosInput (
uint16_t controlId,
uint8_t numPositions,
uint16_t debounceMs
)
Parameters:
controlIdDCSIN_* or CTRL_* constant. Determines PanelBridge routing.numPositionsnumber of discrete positions N (valid indices 0..N-1).debounceMsstability window before a changed position is confirmed. 0 = confirm on the next poll (subclass does its own filtering).
function readRaw
Resolve the instantaneous position index, or NO_POSITION to hold the last.
virtual uint16_t OpenSkyhawk::MultiPosInput::readRaw () = 0
Implemented per subclass (one-hot pin scan, analog band-resolve, ...). Must be non-blocking. Return a value in 0..numPositions-1, or NO_POSITION when nothing is currently active.
Returns:
resolved index, or NO_POSITION.
The documentation for this class was generated from the following file Firmware/Libraries/PanelGroup/Inputs/MultiPosInput/MultiPosInput.h