Class OpenSkyhawk::Switch2Pos
ClassList > OpenSkyhawk > Switch2Pos
Debounced 2-position switch. Self-registers into PanelGroup 'sInputBase list.More...
#include <Switch2Pos.h>
Inherits the following classes: OpenSkyhawk::InputBase
Public Static Attributes
| Type | Name |
|---|---|
| constexpr uint16_t | DEBOUNCE_MS = 20 |
Public Functions
| Type | Name |
|---|---|
| Switch2Pos (uint16_t controlId, PinRef pin) Construct a 2-position switch with default settings. |
|
| Switch2Pos (uint16_t controlId, PinRef pin, bool reverse) Construct a 2-position switch with explicit polarity. |
|
| virtual void | configure () override Configure the input pin. Called by PanelGroup::setup() after chip.begin(). |
| virtual void | forceReport () override Read current pin state and emit EVT unconditionally — no debounce. |
| virtual void | poll () override Read current pin state, apply debounce, emit EVT if confirmed state changed. |
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
VALUE semantics (reverse = false, default): 1 — active (pin LOW — switch closed, pulling pin to GND via board pull-up) 0 — inactive (pin HIGH)
VALUE semantics (reverse = true): 1 — active (pin HIGH — switch drives pin HIGH; external pull-down holds pin LOW when open) 0 — inactive (pin LOW)
Debounce: fixed 20 ms. The pin must hold its new level for the debounce period before the state is confirmed and a CAN EVT is emitted. Any level change during the window restarts the timer.
forceReport() emits the current physical state immediately without debounce — called by PanelGroup during the boot EVT burst and on SYNC_REQ.
Public Static Attributes Documentation
variable DEBOUNCE_MS
constexpr uint16_t OpenSkyhawk::Switch2Pos::DEBOUNCE_MS;
Public Functions Documentation
function Switch2Pos [1/2]
Construct a 2-position switch with default settings.
OpenSkyhawk::Switch2Pos::Switch2Pos (
uint16_t controlId,
PinRef pin
)
Active-LOW (reverse = false), 20 ms debounce.
Parameters:
controlIdDCSIN_* or CTRL_* constant. Determines PanelBridge routing.pinPinRef for the switch input pin (GPIO or MCP23017).
function Switch2Pos [2/2]
Construct a 2-position switch with explicit polarity.
OpenSkyhawk::Switch2Pos::Switch2Pos (
uint16_t controlId,
PinRef pin,
bool reverse
)
Parameters:
controlIdDCSIN_* or CTRL_* constant. Determines PanelBridge routing.pinPinRef for the switch input pin (GPIO or MCP23017).reversefalse (default): active-LOW — board wiring holds HIGH, switch pulls LOW. true: active-HIGH — board wiring holds LOW, switch drives HIGH. configure() does not enable internal pull-ups; the schematic must provide the required pull-up, pull-down, or active drive.
function configure
Configure the input pin. Called by PanelGroup::setup() after chip.begin().
virtual void OpenSkyhawk::Switch2Pos::configure () override
Configures the pin as an input. Does not enable internal pull-ups; board wiring supplies the input bias. Typical OpenSkyhawk switch nets use external 10 kΩ pull-ups to +3.3V and switch to GND.
Note:
Must not be called from the constructor — MCP23017 register writes require the chip to be initialised first.
Implements OpenSkyhawk::InputBase::configure
function forceReport
Read current pin state and emit EVT unconditionally — no debounce.
virtual void OpenSkyhawk::Switch2Pos::forceReport () override
Called by PanelGroup during the boot EVT burst and on SYNC_REQ. Confirms the current reading as the baseline so subsequent poll() calls have a valid reference.
Implements OpenSkyhawk::InputBase::forceReport
function poll
Read current pin state, apply debounce, emit EVT if confirmed state changed.
virtual void OpenSkyhawk::Switch2Pos::poll () override
Called by PanelGroup::loop() during normal operation. No-op until forceReport() has been called at least once.
Implements OpenSkyhawk::InputBase::poll
The documentation for this class was generated from the following file Firmware/Libraries/PanelGroup/Inputs/Switch2Pos/Switch2Pos.h