Skip to content

Class OpenSkyhawk::ActionButton

ClassList > OpenSkyhawk > ActionButton

Momentary push button driving a control that latches in the sim. Self-registers into PanelGroup 'sInputBase list.More...

  • #include <ActionButton.h>

Inherits the following classes: OpenSkyhawk::InputBase

Public Static Attributes

Type Name
constexpr uint32_t DEBOUNCE_MS = 20

Public Functions

Type Name
ActionButton (uint16_t controlId, PinRef pin, bool reverse=false)
Construct a momentary action button.
virtual void configure () override
Configure the input pin. Called by PanelGroup::setup() after chip.begin().
virtual void forceReport () override
Establish the current pin state as the baseline. Emits nothing. __
virtual void poll () override
Read the pin and emit one EVT_ACTION on a debounced press edge.

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.
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

See OpenSkyhawk::InputBase

Type Name
InputBase * head ()
Head of the self-registered linked list.

Protected Functions inherited from OpenSkyhawk::InputBase

See OpenSkyhawk::InputBase

Type Name
InputBase ()
Registers this instance into the linked list.

Detailed Description

Emits one EVT_ACTION frame on the press edge and nothing on release. The payload value is a selector, not a magnitude: 0 means TOGGLE, which PanelBridge renders as the DCS-BIOS action argument. The DCS-BIOS string never appears on this side of the bus.

What it is for. Switch2Pos sends absolute 0/1, so it needs a physical switch that latches. This class lets a momentary part drive a control that latches in the sim: DCS-BIOS reads the control's current value, flips it, and writes it back, so each press toggles and the state persists. Because the sim supplies the current value, the panel cannot desync from it — unlike a physical latching switch, whose position can disagree with the sim after a cold start, a keyboard binding, or a mission script. The trade-off is that a momentary button shows no state at a glance.

Only for controls that latch in the sim — DCS-BIOS defineToggleSwitch. Pointing this at a definePushButton control is wrong: those are momentary_last_position, and a TOGGLE latches them on until the next press. Use Switch2Pos for those.

VALUE semantics (reverse = false, default): press (pin LOW — button closed, pulling pin to GND via board pull-up) — emit TOGGLE release (pin HIGH) — emit nothing

Holding the button emits exactly once: the press edge is consumed and the state does not change again until release, so there is no interval at which it could begin repeating.

Debounce: 20 ms of post-fire suppression, not a stability window. An action's first edge is the event, so waiting for the level to settle would only add latency. Suppressing after the send costs nothing and stops contact chatter — which matters here more than for a level-tracking switch, because every TOGGLE flips sim state: an even number of bounces cancels and an odd number flips, so the final position would otherwise depend on bounce parity.

forceReport() deliberately emits nothing — see its documentation.

Public Static Attributes Documentation

variable DEBOUNCE_MS

constexpr uint32_t OpenSkyhawk::ActionButton::DEBOUNCE_MS;

Public Functions Documentation

function ActionButton

Construct a momentary action button.

OpenSkyhawk::ActionButton::ActionButton (
    uint16_t controlId,
    PinRef pin,
    bool reverse=false
) 

Parameters:

  • controlId DCSIN_* constant. Determines PanelBridge routing.
  • pin PinRef for the button input pin (GPIO, MCP23017, or ShiftBus '165).
  • reverse false (default): active-LOW — board wiring holds HIGH, button pulls LOW. true: active-HIGH — board wiring holds LOW, button 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::ActionButton::configure () override

Does not enable internal pull-ups; board wiring supplies the input bias.

Note:

Must not be called from the constructor — MCP23017 register writes require the chip to be initialised first.

Implements OpenSkyhawk::InputBase::configure


function forceReport

Establish the current pin state as the baseline. Emits nothing. __

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

Called by PanelGroup during the boot EVT burst and on every SYNC_REQ. Every other input class emits its current position here, which is idempotent for a switch — re-sending position 1 leaves the sim at 1. An action is not idempotent: emitting a TOGGLE would flip the sim switch on every resync, so this method is silent by design.

It is not a no-op, though. Seeding the baseline is what stops a button that is physically held at boot from reading as a press edge on the first poll() and firing an unwanted TOGGLE.

Implements OpenSkyhawk::InputBase::forceReport


function poll

Read the pin and emit one EVT_ACTION on a debounced press edge.

virtual void OpenSkyhawk::ActionButton::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/ActionButton/ActionButton.h