Skip to content

Class OpenSkyhawk::AnalogMultiPos

ClassList > OpenSkyhawk > AnalogMultiPos

Resistor-ladder multi-position selector — one analog PinRef , a different voltage per position. Emits the resolved position index 0..N-1 over CAN (MULTIPOS dispatch).More...

  • #include <AnalogMultiPos.h>

Inherits the following classes: OpenSkyhawk::MultiPosInput

Public Static Attributes

Type Name
constexpr uint16_t DEFAULT_DEADBAND = 1000
counts trimmed from each band edge
constexpr uint16_t POLL_MS = 8
min interval between ADC reads (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
AnalogMultiPos (uint16_t controlId, PinRef pin, uint8_t numPos, const uint16_t * posVals, uint16_t deadband=DEFAULT_DEADBAND)
Explicit resistor-ladder selector.
AnalogMultiPos (uint16_t controlId, PinRef pin, uint8_t numPos, uint16_t deadband=DEFAULT_DEADBAND)
Equal-spacing shorthand — positions evenly spaced across the full ADC range.
virtual void configure () override
Configure the pin as an input. Called by PanelGroup::setup() .
virtual void forceReport () override
Force a fresh ADC sample (bypassing the read throttle), then emit the baseline.

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
Resolve the instantaneous position index, or NO_POSITION to hold the last.

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

Subclass of MultiPosInput — it shares the debounce / emit-on-change / hold-last / forceReport contract and provides only the analog read: it maps the 16-bit ADC reading to a position via detection bands centred on each position's expected value.

Two constructions: * explicit ladder — pass posVals[], the expected 16-bit ADC value per position. A position whose entry is ANALOG_NC has no detent and is never emitted; its neighbours' bands span its place. * equal-spacing shorthand — pass only N; positions are evenly spaced 0..65535.

Detection bands: each position's band reaches half-way to its nearest valid neighbours, minus deadband counts on each edge (default 1000). A reading in the deadband gap between two bands resolves to NO_POSITION, so the base holds the last position — this gives switch hysteresis, no flicker at a boundary. The ADC is re-read at most every POLL_MS (8 ms).

The base debounce window is 0: the deadband gaps provide the filtering, not a timer.

Public Static Attributes Documentation

variable DEFAULT_DEADBAND

counts trimmed from each band edge

constexpr uint16_t OpenSkyhawk::AnalogMultiPos::DEFAULT_DEADBAND;

variable POLL_MS

min interval between ADC reads (ms)

constexpr uint16_t OpenSkyhawk::AnalogMultiPos::POLL_MS;

Public Functions Documentation

function AnalogMultiPos [1/2]

Explicit resistor-ladder selector.

OpenSkyhawk::AnalogMultiPos::AnalogMultiPos (
    uint16_t controlId,
    PinRef pin,
    uint8_t numPos,
    const uint16_t * posVals,
    uint16_t deadband=DEFAULT_DEADBAND
) 

Parameters:

  • controlId DCSIN_* or CTRL_* constant. Determines PanelBridge routing.
  • pin analog PinRef (STM32 ADC GPIO or ADS1115 channel).
  • numPos N — number of positions (valid indices 0..N-1).
  • posVals caller-owned array of N expected 16-bit ADC values, one per position. Must outlive this object. Use ANALOG_NC for a position with no detent.
  • deadband counts trimmed from each band edge for hysteresis (default 1000).

function AnalogMultiPos [2/2]

Equal-spacing shorthand — positions evenly spaced across the full ADC range.

OpenSkyhawk::AnalogMultiPos::AnalogMultiPos (
    uint16_t controlId,
    PinRef pin,
    uint8_t numPos,
    uint16_t deadband=DEFAULT_DEADBAND
) 

Parameters:

  • controlId DCSIN_* or CTRL_* constant.
  • pin analog PinRef.
  • numPos N — number of positions.
  • deadband counts trimmed from each band edge (default 1000).

function configure

Configure the pin as an input. Called by PanelGroup::setup() .

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

Implements OpenSkyhawk::InputBase::configure


function forceReport

Force a fresh ADC sample (bypassing the read throttle), then emit the baseline.

virtual void OpenSkyhawk::AnalogMultiPos::forceReport () override

The boot EVT burst and SYNC_REQ must report the current position, never a stale cache: at boot — before millis() reaches POLL_MS — the throttle would otherwise return the uninitialised NO_POSITION cache and the base would emit position 0; and a SYNC arriving within POLL_MS of the last poll-read would echo an old reading. Overrides the base.

Implements OpenSkyhawk::InputBase::forceReport


Protected Functions Documentation

function readRaw

Resolve the instantaneous position index, or NO_POSITION to hold the last.

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

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.

Implements OpenSkyhawk::MultiPosInput::readRaw



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