app/led_assist.h

policy layer that turns game events into LED highlights.

LedAssist is a GameSessionListener: it translates last-move / check / error events into per-square (color, category) highlights and pushes them to a LedController, honoring a per-user “how much help” config. It knows chess; LedController knows the wire. Legal-move highlighting (the piece-lift path and the shared 16-square budget arbitration) arrives in L3 — this L2 layer covers the passive highlights that come free from state already in hand.

Fully off-Pi testable: drive it with MoveEvents/FENs and inspect the LedController (SimLedDriver). See docs/led-docs/PLAN.md §7, §9.

namespace kirin

Enums

enum class AssistPreset

Values:

enumerator Off
enumerator LastMoveOnly
enumerator LegalMoves
enumerator LegalPlusHints
class IHintSource
#include <led_assist.h>

Subclassed by kirin::EngineHintSource

Public Functions

virtual ~IHintSource() = default
virtual bool recommendedMove(int &from, int &to) = 0
class ILegalMoveSource
#include <led_assist.h>

Subclassed by kirin::EngineLegalMoveSource

Public Functions

virtual ~ILegalMoveSource() = default
virtual std::vector<LegalTarget> legalTargetsFrom(int square) = 0
inline virtual int bestTargetFrom(int square)
class LedAssist : public kirin::GameSessionListener
#include <led_assist.h>

Public Functions

explicit LedAssist(LedController &leds, const LedAssistConfig &config = {})
void setConfig(const LedAssistConfig &config)
inline void setPreset(AssistPreset preset)
inline const LedAssistConfig &config() const
inline void setMoveSource(ILegalMoveSource *source)
inline void setHintSource(IHintSource *source)
inline void setRenderListener(std::function<void()> onRendered)
virtual void onStateChanged(SessionState state) override
virtual void onMovePlayed(const MoveEvent &move) override
virtual void onHumanTurn(char sideToMove) override
virtual void onGameOver(const GameOverInfo &info) override
virtual void onBoardMismatch(const BoardMismatchInfo &info) override
void onPieceLifted(int square)
void onBoardSettled()
ScannerObserver scannerObserver()

Private Functions

void render()
void clearHighlights()
void renderLift()
void pushFrame()

Private Members

std::mutex mtx_
LedController &leds_
LedAssistConfig cfg_
ILegalMoveSource *moves_ = nullptr
IHintSource *hints_ = nullptr
std::function<void()> onRendered_
int lastFrom_ = -1
int lastTo_ = -1
int checkSquare_ = -1
int liftedSquare_ = -1
int recFrom_ = -1
int recTo_ = -1
bool errorActive_ = false
std::vector<int> errorSquares_
struct LedAssistConfig
#include <led_assist.h>

Public Members

bool enabled = true
bool showLegalMoves = true
bool showRecommended = false
bool showLastMove = true
bool showCheck = true
bool showErrors = true
bool keepCheckOnLift = true
uint8_t brightness = 64
Rgb legalColor = {40, 255, 120}
Rgb captureColor = {255, 130, 20}
Rgb recommendedColor = {40, 160, 255}
Rgb lastMoveColor = {245, 245, 255}
Rgb checkColor = {255, 60, 50}
Rgb errorColor = {255, 40, 130}
struct LegalTarget
#include <led_assist.h>

Public Members

int square
bool isCapture