Class OpenSkyhawk::AnalogInput
ClassList > OpenSkyhawk > AnalogInput
Continuous analog input — one analog PinRef , normalised to a 16-bit value 0..65535. Emits the smoothed value over CAN (MULTIPOS transport). Self-registers intoPanelGroup 'sInputBase list.More...
#include <AnalogInput.h>
Inherits the following classes: OpenSkyhawk::InputBase
Inherited by the following classes: OpenSkyhawk::AngleSensorInput
Public Functions
| Type | Name |
|---|---|
| AnalogInput (uint16_t controlId, PinRef pin, const AnalogConfig & cfg={}) Construct a continuous analog input. |
|
| virtual void | configure () override Configure the pin as an input. Called by PanelGroup::setup() . |
| virtual void | forceReport () override Sample fresh (bypassing the throttle) and emit the current value as the baseline. |
| virtual void | poll () override Throttled ADC read + EWMA; emit when the value clears the hysteresis or a rail. |
Public Functions inherited from OpenSkyhawk::InputBase
| Type | Name |
|---|---|
| virtual void | configure () Configure hardware pins for this input. |
| virtual void | forceReport () = 0 Re-assert the control's current absolute state, or emit nothing. |
| 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. |
| virtual void | sampleTick () High-rate sample hook — called from a sampling ISR when the node runs one (e.g. ShiftBus timer sampling, -DSHIFTBUS_ISR_HZ). Default no-op. |
Public Static Functions inherited from OpenSkyhawk::InputBase
| Type | Name |
|---|---|
| InputBase * | head () Head of the self-registered linked list. |
Protected Functions
| Type | Name |
|---|---|
| virtual uint16_t | readRaw () Read the raw 16-bit source value. The one hook a family member overrides. |
Protected Functions inherited from OpenSkyhawk::InputBase
| Type | Name |
|---|---|
| InputBase () Registers this instance into the linked list. |
Detailed Description
A linear input, not a selector. It shares the MULTIPOS wire transport with the selector family only because DCS-BIOS set_state has no separate "continuous" dispatch — the 16-bit value is the control position, not an index.
Read path (ports DcsBios PotentiometerEWMA): read the ADC (already 16-bit — STM32 ×16, or ADS1115 0–3.3V → 0–65534), clamp to [minRaw, maxRaw], map to 0..65535 (reverse-aware), then apply an integer EWMA low-pass filter (α = 1/2^ewmaShift). A new value is emitted only when the smoothed value moves more than hysteresis counts from the last sent value, or when it reaches a rail (0 / 65535) moving toward it — a settled pot is silent, the endpoints always reached.
The ADC is re-read at most every pollMs — an AnalogConfig field, default DEFAULT_POLL_MS (8 ms). It is per instance, not per node: two AnalogInputs on one board may read at different rates, and PanelGroup owns no analog timer of its own (it calls poll() every iteration and lets each input decide). forceReport() samples fresh (bypassing the throttle) and emits the current value as the baseline. Integer EWMA (a shift, not a divide) keeps it cheap on the FPU-less STM32F103.
pollMs and ewmaShift are coupled: the filter time constant is τ ≈ 2^ewmaShift × pollMs — the defaults give 2^3 × 8 = 64 ms. Halving pollMs halves τ unless ewmaShift rises to match, so the two are chosen together, never one alone.
configure() does not enable internal pull-ups; the wiper drives the pin directly.
Used by: AN/ARC-51A VOL (volume potentiometer).
Public Functions Documentation
function AnalogInput
Construct a continuous analog input.
OpenSkyhawk::AnalogInput::AnalogInput (
uint16_t controlId,
PinRef pin,
const AnalogConfig & cfg={}
)
Parameters:
controlIdDCSIN_* or CTRL_* constant. Determines PanelBridge routing — and, with the default config, the hysteresis (AnalogConfig::HYSTERESIS_AUTO).pinanalog PinRef (STM32 ADC GPIO or ADS1115 channel).cfgtuning; set only the fields that differ, e.g.{ .reverse = true }.
function configure
Configure the pin as an input. Called by PanelGroup::setup() .
virtual void OpenSkyhawk::AnalogInput::configure () override
Implements OpenSkyhawk::InputBase::configure
function forceReport
Sample fresh (bypassing the throttle) and emit the current value as the baseline.
virtual void OpenSkyhawk::AnalogInput::forceReport () override
Implements OpenSkyhawk::InputBase::forceReport
function poll
Throttled ADC read + EWMA; emit when the value clears the hysteresis or a rail.
virtual void OpenSkyhawk::AnalogInput::poll () override
Implements OpenSkyhawk::InputBase::poll
Protected Functions Documentation
function readRaw
Read the raw 16-bit source value. The one hook a family member overrides.
virtual uint16_t OpenSkyhawk::AnalogInput::readRaw ()
Default: the analog PinRef (or the injected value under ANALOGINPUT_TEST). A subclass that reinterprets the reading overrides this and calls AnalogInput::readRaw() for the source value — AngleSensorInput re-centres it on its centre angle. Everything after this point (clamp, scale, EWMA, hysteresis, emit) is the base's and is shared unchanged.
The documentation for this class was generated from the following file Firmware/Libraries/PanelGroup/Inputs/AnalogInput/AnalogInput.h