Skip to content

Class OpenSkyhawk::SwitchWithCover2Pos

ClassList > OpenSkyhawk > SwitchWithCover2Pos

Guarded switch — the DcsBios::SwitchWithCover2Pos equivalent. One physical switch pin drives two sim controls: the guard cover and the switch it protects. More...

  • #include <SwitchWithCover2Pos.h>

Inherits the following classes: OpenSkyhawk::Switch2Pos

Public Static Attributes

Type Name
constexpr uint16_t COVER_DELAY_MS = 200
Minimum gap between the cover frame and the switch frame, ms.

Public Static Attributes inherited from OpenSkyhawk::Switch2Pos

See OpenSkyhawk::Switch2Pos

Type Name
constexpr uint16_t DEBOUNCE_MS = 20

Public Functions

Type Name
SwitchWithCover2Pos (uint16_t switchId, uint16_t coverId, PinRef pin, bool reverse=false)
Construct a guarded 2-position switch.
virtual void poll () override
Debounce through Switch2Pos , then advance the cover/switch sequence.

Public Functions inherited from OpenSkyhawk::Switch2Pos

See OpenSkyhawk::Switch2Pos

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

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 Attributes inherited from OpenSkyhawk::Switch2Pos

See OpenSkyhawk::Switch2Pos

Type Name
uint16_t _controlId
bool _lastConfirmed
PinRef _pin
bool _reverse

Protected Functions

Type Name
virtual void emit (bool active, bool init) override
Set the sequence target instead of sending. Called by Switch2Pos on a confirmed change, and with init = true for the boot / SYNC_REQ baseline.

Protected Functions inherited from OpenSkyhawk::Switch2Pos

See OpenSkyhawk::Switch2Pos

Type Name
virtual void emit (bool active, bool init)
Send the debounced state. The one hook a family member overrides.

Protected Functions inherited from OpenSkyhawk::InputBase

See OpenSkyhawk::InputBase

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

Detailed Description

The cover is not sensed. There is one switch on the panel, and this class sequences the pair so the sim's cover animates and any sim logic gated on the cover is satisfied:

Physical switch Frames, each COVER_DELAY_MS apart End state
flips on cover 1 (open) → switch 1 cover open, switch on
flips off switch 0 → cover 0 (close) cover closed, switch off

States mirror DCS-BIOS — OFF_CLOSED → OFF_OPEN → ON_OPEN and back — and the 20 ms debounce comes from Switch2Pos. The sequencer steps from poll(), one frame at a time, and never calls delay(): a node blocking for 200 ms would stall every other control and the CAN drain with it. Flipping back mid-sequence simply retargets the machine, so it walks back the way it came.

On boot and SYNC_REQ the settled pair is re-asserted in the same order (cover first when on, switch first when off). That is deliberately more than DCS-BIOS does — its reset re-sends nothing — because FirmwarePlan D5 requires every absolute input to be re-sent on sync: a missed input otherwise leaves DCS wrong until the control is next touched.

Does not read a cover microswitch: a builder with a sensed cover wires it as its own Switch2Pos on the cover's control. Does not cover 3-position guarded switches — the DCS-BIOS class is 2-position only, and the A-4E-C's one cover guards a 3-position switch the mod does not gate, so the A-4 build uses Switch3Pos there. This class is for DCS-BIOS parity and other aircraft.

Public Static Attributes Documentation

variable COVER_DELAY_MS

Minimum gap between the cover frame and the switch frame, ms.

constexpr uint16_t OpenSkyhawk::SwitchWithCover2Pos::COVER_DELAY_MS;


Public Functions Documentation

function SwitchWithCover2Pos

Construct a guarded 2-position switch.

OpenSkyhawk::SwitchWithCover2Pos::SwitchWithCover2Pos (
    uint16_t switchId,
    uint16_t coverId,
    PinRef pin,
    bool reverse=false
) 

Parameters:

  • switchId DCSIN_* constant for the switch under the cover.
  • coverId DCSIN_* constant for the cover itself (the generator already emits covers as their own control, e.g. AFCS_1N2_COVER).
  • pin PinRef for the one physical switch (GPIO or MCP23017).
  • reverse false (default): active-LOW, as Switch2Pos. true: active-HIGH.

function poll

Debounce through Switch2Pos , then advance the cover/switch sequence.

virtual void OpenSkyhawk::SwitchWithCover2Pos::poll () override

Implements OpenSkyhawk::Switch2Pos::poll


Protected Functions Documentation

function emit

Set the sequence target instead of sending. Called by Switch2Pos on a confirmed change, and with init = true for the boot / SYNC_REQ baseline.

virtual void OpenSkyhawk::SwitchWithCover2Pos::emit (
    bool active,
    bool init
) override

On init the machine is seeded at the opposite end of the travel so the sequencer re-asserts both frames in the correct order rather than only the one that changed.

Implements OpenSkyhawk::Switch2Pos::emit



The documentation for this class was generated from the following file Firmware/Libraries/PanelGroup/Inputs/SwitchWithCover2Pos/SwitchWithCover2Pos.h