hardware/led_controller.h¶
Addressable-RGB square-highlight framebuffer + driver seam.
Under each of the 64 squares sits a ring of 8 SK6805 addressable RGB LEDs (512 LEDs total, one continuous data chain). This module owns the logical framebuffer, the square->LED “snake” (boustrophedon) mapping, and the hard <=16-lit-squares current-budget invariant. It knows nothing about chess.
The wire itself lives behind ILedDriver so the whole layer is off-Pi testable (SimLedDriver) and the Pi-5/RP1 PWM mechanism can be swapped in without touching anything above the driver. Mirrors the DisplayController / BoardScanner simulation-mode pattern.
See docs/led-docs/PLAN.md (§2-§5) for the design rationale.
-
class ILedDriver¶
- #include <led_controller.h>
Subclassed by SimLedDriver
-
class SimLedDriver : public ILedDriver¶
- #include <led_controller.h>
Public Functions
-
inline virtual bool init() override¶
-
virtual bool writeFrame(const uint8_t *grb, size_t ledCount) override¶
-
inline virtual bool isReady() const override¶
-
inline size_t lastLedCount() const¶
-
inline int frameCount() const¶
-
int grbByte(size_t index) const¶
Private Static Attributes
-
static constexpr size_t MAX_BYTES = 512 * 3¶
-
inline virtual bool init() override¶
-
class LedController¶
- #include <led_controller.h>
Public Functions
-
explicit LedController(ILedDriver &driver)¶
-
inline bool init()¶
-
inline bool isReady() const¶
-
bool clearSquare(int square)¶
-
void clear()¶
-
bool show()¶
-
inline void setBrightness(uint8_t b)¶
-
inline uint8_t getBrightness() const¶
-
bool isSquareLit(int square) const¶
-
int litSquareCount() const¶
Public Static Functions
-
static int ledBaseForSquare(int square)¶
Public Static Attributes
-
static constexpr int NUM_SQUARES = 64¶
-
static constexpr int LEDS_PER_SQUARE = 8¶
-
static constexpr int NUM_LEDS = NUM_SQUARES * LEDS_PER_SQUARE¶
-
static constexpr int MAX_LIT_SQUARES = 16¶
Private Static Functions
-
static uint8_t scale(uint8_t channel, uint8_t bright)¶
-
explicit LedController(ILedDriver &driver)¶