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
Public Static Attributes
| Type | Name |
|---|---|
| constexpr uint8_t | DEFAULT_EWMA_SHIFT = 3EWMA α = 1/2^3 = 1/8. |
| constexpr uint16_t | DEFAULT_HYSTERESIS = 128counts on the 16-bit output. |
| constexpr uint8_t | MAX_EWMA_SHIFT = 15cap: scaled<<shift must fit int32 at full scale. |
| constexpr uint16_t | POLL_MS = 8min interval between ADC reads (ms). |
Public Functions
| Type | Name |
|---|---|
| AnalogInput (uint16_t controlId, PinRef pin, bool reverse=false, uint16_t minRaw=0, uint16_t maxRaw=65535, uint16_t hysteresis=DEFAULT_HYSTERESIS, uint8_t ewmaShift=DEFAULT_EWMA_SHIFT) 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 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 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 ×2), 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 — so a settled pot is silent and the endpoints are always reached.
The ADC is re-read at most every POLL_MS (8 ms); 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.
configure() does not enable internal pull-ups; the wiper drives the pin directly.
Used by: AN/ARC-51A VOL (volume potentiometer).
Public Static Attributes Documentation
variable DEFAULT_EWMA_SHIFT
EWMA α = 1/2^3 = 1/8.
constexpr uint8_t OpenSkyhawk::AnalogInput::DEFAULT_EWMA_SHIFT;
variable DEFAULT_HYSTERESIS
counts on the 16-bit output.
constexpr uint16_t OpenSkyhawk::AnalogInput::DEFAULT_HYSTERESIS;
variable MAX_EWMA_SHIFT
cap: scaled<<shift must fit int32 at full scale.
constexpr uint8_t OpenSkyhawk::AnalogInput::MAX_EWMA_SHIFT;
variable POLL_MS
min interval between ADC reads (ms).
constexpr uint16_t OpenSkyhawk::AnalogInput::POLL_MS;
Public Functions Documentation
function AnalogInput
Construct a continuous analog input.
OpenSkyhawk::AnalogInput::AnalogInput (
uint16_t controlId,
PinRef pin,
bool reverse=false,
uint16_t minRaw=0,
uint16_t maxRaw=65535,
uint16_t hysteresis=DEFAULT_HYSTERESIS,
uint8_t ewmaShift=DEFAULT_EWMA_SHIFT
)
Parameters:
controlIdDCSIN_* or CTRL_* constant. Determines PanelBridge routing.pinanalog PinRef (STM32 ADC GPIO or ADS1115 channel).reversefalse (default): minRaw → 0, maxRaw → 65535. true: inverted.minRawraw ADC value mapping to 0 (default 0). Readings below are clamped.maxRawraw ADC value mapping to 65535 (default 65535). Above are clamped.hysteresisoutput counts of movement required before a new value is emitted.ewmaShiftEWMA smoothing strength: α = 1/2^ewmaShift (default 3 → 1/8). Capped to MAX_EWMA_SHIFT (15) — beyond that the int32 accumulator (scaled << shift) would overflow at full scale.
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
The documentation for this class was generated from the following file Firmware/Libraries/PanelGroup/Inputs/AnalogInput/AnalogInput.h