Skip to content

Class OpenSkyhawk::Dimmer

ClassList > OpenSkyhawk > Dimmer

PWM dimmer output — the DcsBios::Dimmer equivalent. Maps a 16-bit DCS-BIOS value to PWM duty on a direct GPIO timer pin. More...

  • #include <Dimmer.h>

Inherits the following classes: OpenSkyhawk::AnalogOutput

Public Types

Type Name
typedef uint16_t(*)(uint16_t value) ScaleFn
Scale function: raw 16-bit DCS value → 16-bit value handed to writeAnalog().

Public Functions

Type Name
Dimmer (uint16_t controlId, PinRef pin, ScaleFn scale=nullptr)
Construct and register a dimmer.
virtual void configure () override
Configure the output pin and drive duty to 0.

Public Functions inherited from OpenSkyhawk::AnalogOutput

See OpenSkyhawk::AnalogOutput

Type Name
virtual void onControlPacket (uint16_t controlId, uint16_t value)
Match, decode, dedup, then apply() . Called byPanelGroup for every CTRL_BCAST packet.

Public Functions inherited from OpenSkyhawk::OutputBase

See OpenSkyhawk::OutputBase

Type Name
virtual void configure ()
Configure hardware pins for this output.
OutputBase * next () const
Next output in the list; nullptr at end.
virtual void onControlPacket (uint16_t controlId, uint16_t value) = 0
Called for every non-null ControlPacket in a CTRL_BCAST frame.
virtual void update ()
Called every PanelGroup::loop() iteration.

Public Static Functions inherited from OpenSkyhawk::OutputBase

See OpenSkyhawk::OutputBase

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

Protected Functions

Type Name
virtual void apply (uint16_t value) override
Write the value as PWM duty. Called by the base when the decoded value changed.

Protected Functions inherited from OpenSkyhawk::AnalogOutput

See OpenSkyhawk::AnalogOutput

Type Name
AnalogOutput (uint16_t controlId, uint16_t mask=0xFFFF, uint8_t shift=0)
Construct the base. Registration into PanelGroup 's output list isOutputBase 's.
virtual void apply (uint16_t value) = 0
Sink hook — called with the decoded value, only when it changed.

Protected Functions inherited from OpenSkyhawk::OutputBase

See OpenSkyhawk::OutputBase

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

Detailed Description

Primary use is backlight zone dimming: the low-side MOSFET gate of an LED zone, one Dimmer per zone (PA6 / PA7 on the PanelGroup base). The A-4E-C drives five such values — LIGHTS_CONSOLE, LIGHTS_INSTRUMENTS, LIGHTS_FLOOD_RED, LIGHTS_FLOOD_WHITE, APG53A_GLOW — and any other PWM-proportional load works the same way.

The AnalogOutput base owns matching, decoding and change dedup; this class is the sink: apply() writes through PinRef::writeAnalog() (16-bit in; the GPIO path outputs value >> 8 as 8-bit duty). An optional scale function reshapes the value first — perceptual dimming curves, inversion.

Takes a PinRef like every control class and checks its type: brightness comes from an STM32 timer channel, so configure() requires a direct GPIO that has one. Anything else (MCP23017, ShiftBus, a GPIO with no timer) is logged and leaves the output disabled rather than degrading silently — writeAnalog() is a no-op through an expander, and analogWrite() on a non-timer GPIO collapses to an on/off threshold. Software PWM through an expander is deliberately not offered: those bits change once per loop or bus transfer, so a duty cycle there would flicker and keep the bus busy, where timer PWM costs no CPU.

On/off threshold behaviour is LED's job, not this class's. Polarity is not invertible — the zone-switch hardware standard is fixed (higher duty = brighter); an inverted drive is a scale function, not a constructor flag.

Duty is driven to 0 during configure() and stays there (zone dark) until a CTRL_BCAST packet with a matching controlId arrives.

Public Types Documentation

typedef ScaleFn

Scale function: raw 16-bit DCS value → 16-bit value handed to writeAnalog().

using OpenSkyhawk::Dimmer::ScaleFn =  uint16_t (*)(uint16_t value);


Public Functions Documentation

function Dimmer

Construct and register a dimmer.

OpenSkyhawk::Dimmer::Dimmer (
    uint16_t controlId,
    PinRef pin,
    ScaleFn scale=nullptr
) 

Parameters:

  • controlId DCS-BIOS output address (A_4E_C_* from A4EC_OutputIds.h — the full 16-bit word; the matching *_AM mask is 0xffff for these outputs).
  • pin PinRef for the PWM output: a direct STM32 GPIO on a timer channel (the zone-switch MOSFET gate) — PinRef(PA6) / PinRef(PA7) on the base.
  • scale Optional reshaping of the 16-bit value before it is written. nullptr (default) = identity.

function configure

Configure the output pin and drive duty to 0.

virtual void OpenSkyhawk::Dimmer::configure () override

Called by PanelGroup::setup() after chip.init(). Requires a direct GPIO on a timer channel; otherwise disables the output (no writes at all) and logs on DiagSerial when STM32Board::setDebug(true) is set. On success the pin becomes an output at duty 0, so the zone stays dark until the first matching CTRL_BCAST.

Implements OpenSkyhawk::OutputBase::configure


Protected Functions Documentation

function apply

Write the value as PWM duty. Called by the base when the decoded value changed.

virtual void OpenSkyhawk::Dimmer::apply (
    uint16_t value
) override

Applies the scale function, then skips the write when the resulting 8-bit duty equals the last one written — different 16-bit values map to the same duty. No-op while the output is disabled.

Implements OpenSkyhawk::AnalogOutput::apply



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