Class OpenSkyhawk::RotaryEncoder
ClassList > OpenSkyhawk > RotaryEncoder
Incremental quadrature encoder on two pins (A/B). Emits a signed relative value per detent over CAN — direction in the sign, magnitude set by the mode. Self-registers intoPanelGroup 'sInputBase list.More...
#include <RotaryEncoder.h>
Inherits the following classes: OpenSkyhawk::InputBase
Public Static Attributes
| Type | Name |
|---|---|
| constexpr int16_t | DEFAULT_STEP = 3200REL per-detent magnitude (DCS suggested_step). |
Public Functions
| Type | Name |
|---|---|
| RotaryEncoder (uint16_t controlId, PinRef pinA, PinRef pinB, EncoderStepsPerDetent stepsPerDetent=EncoderStepsPerDetent::One, EncoderMode mode=EncoderMode::Rel, int16_t step=DEFAULT_STEP) Construct a quadrature encoder. |
|
| virtual void | configure () override Configure both pins as inputs. Called by PanelGroup::setup() . |
| virtual void | forceReport () override Resync the last state; emit nothing (relative control — no baseline). |
| virtual void | poll () override Read the quadrature state, accumulate, emit a direction once a detent completes. |
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
| Type | Name |
|---|---|
| uint8_t | readState () (pinA << 1) | pinB → 0..3. |
Protected Functions inherited from OpenSkyhawk::InputBase
| Type | Name |
|---|---|
| InputBase () Registers this instance into the linked list. |
Detailed Description
A relative control — it reports motion, not an absolute position. Ports DcsBios RotaryEncoder: each poll reads the 2-bit Gray state (A<<1)|B, a transition table accumulates a signed delta, and when |delta| >= stepsPerDetent one detent fires (CW positive / CCW negative) and the delta is reduced by one detent. stepsPerDetent sets how many quadrature transitions make one emitted click — set it to the encoder's transitions-per-detent so one physical click = one EVT.
Two modes, chosen at construction (see EncoderMode):
* REL (variable_step knob, e.g. ASN-41 nav): emits ±step on canIdEvtRel; the bridge sends %+d (e.g. "+3200"). step is build-side feel (default 3200 ≈ DCS suggested_step, ~20 detents per full throw); lower it for a finer knob. The magnitude lives here on the node, so retuning needs only a node reflash — never a bridge rebuild.
* DIR (fixed_step selector with no indicator, e.g. ARC-51 freq): emits ±1 on canIdEvtDir; the bridge sends INC/DEC. Stateless — DCS owns the position and clamps at the band edges.
Both modes are preset-safe: forceReport() resyncs the last Gray state and emits nothing — a relative control has no baseline to assert at boot / SYNC, so it never clobbers a mission preset. configure() does not enable internal pull-ups; the schematic biases both pins (external pull-ups; the encoder commons to GND).
Dispatch is sourced from the class (the CAN frame), not the input map — see #147.
Public Static Attributes Documentation
variable DEFAULT_STEP
REL per-detent magnitude (DCS suggested_step).
constexpr int16_t OpenSkyhawk::RotaryEncoder::DEFAULT_STEP;
Public Functions Documentation
function RotaryEncoder
Construct a quadrature encoder.
OpenSkyhawk::RotaryEncoder::RotaryEncoder (
uint16_t controlId,
PinRef pinA,
PinRef pinB,
EncoderStepsPerDetent stepsPerDetent=EncoderStepsPerDetent::One,
EncoderMode mode=EncoderMode::Rel,
int16_t step=DEFAULT_STEP
)
Parameters:
controlIdDCSIN_* or CTRL_* constant. Determines PanelBridge routing.pinAquadrature channel A.pinBquadrature channel B (swap A/B to reverse the sensed direction).stepsPerDetentquadrature transitions per emitted click (default One; match the encoder).modeEncoderMode::Rel (variable_step, ±step) or Dir (fixed_step, ±1). Default Rel.stepREL magnitude emitted per detent (default DEFAULT_STEP). Ignored in DIR.
function configure
Configure both pins as inputs. Called by PanelGroup::setup() .
virtual void OpenSkyhawk::RotaryEncoder::configure () override
Implements OpenSkyhawk::InputBase::configure
function forceReport
Resync the last state; emit nothing (relative control — no baseline).
virtual void OpenSkyhawk::RotaryEncoder::forceReport () override
Implements OpenSkyhawk::InputBase::forceReport
function poll
Read the quadrature state, accumulate, emit a direction once a detent completes.
virtual void OpenSkyhawk::RotaryEncoder::poll () override
Implements OpenSkyhawk::InputBase::poll
Protected Functions Documentation
function readState
(pinA << 1) | pinB → 0..3.
uint8_t OpenSkyhawk::RotaryEncoder::readState ()
The documentation for this class was generated from the following file Firmware/Libraries/PanelGroup/Inputs/RotaryEncoder/RotaryEncoder.h