From 7c67b22dff7c8394d5b090c7a8c1cb8c74aa7419 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 15 Aug 2017 22:49:09 +0200 Subject: [PATCH] Updated to use the new LEDMode/LEDControl API Signed-off-by: Gergely Nagy --- src/Kaleidoscope/LED-Palette-Theme.cpp | 17 +++++++++++++++-- src/Kaleidoscope/LED-Palette-Theme.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Kaleidoscope/LED-Palette-Theme.cpp b/src/Kaleidoscope/LED-Palette-Theme.cpp index 29c3ad6b..01fb82c1 100644 --- a/src/Kaleidoscope/LED-Palette-Theme.cpp +++ b/src/Kaleidoscope/LED-Palette-Theme.cpp @@ -30,7 +30,7 @@ LEDPaletteTheme::LEDPaletteTheme(void) { } void LEDPaletteTheme::begin(void) { - USE_PLUGINS(&::EEPROMSettings); + Kaleidoscope.use(&::EEPROMSettings); if (!palette_base_) palette_base_ = ::EEPROMSettings.requestSlice(16 * sizeof(cRGB)); @@ -49,10 +49,23 @@ void LEDPaletteTheme::updateHandler(uint16_t theme_base, uint8_t theme) { if (!lookupColorAtPosition(map_base, pos, &color)) continue; - LEDControl.setCrgbAt(pos, color); + ::LEDControl.setCrgbAt(pos, color); } } +void LEDPaletteTheme::refreshAt(uint16_t theme_base, uint8_t theme, byte row, byte col) { + uint16_t map_base = theme_base + (theme * ROWS * COLS / 2); + uint16_t pos = KeyboardHardware.getLedIndex(row, col); + + cRGB color; + + if (!lookupColorAtPosition(map_base, pos, &color)) + return; + + ::LEDControl.setCrgbAt(pos, color); +} + + const uint8_t LEDPaletteTheme::lookupColorIndexAtPosition(uint16_t map_base, uint16_t position) { uint8_t color_index; diff --git a/src/Kaleidoscope/LED-Palette-Theme.h b/src/Kaleidoscope/LED-Palette-Theme.h index f855a31f..fa106ade 100644 --- a/src/Kaleidoscope/LED-Palette-Theme.h +++ b/src/Kaleidoscope/LED-Palette-Theme.h @@ -31,6 +31,7 @@ class LEDPaletteTheme : public KaleidoscopePlugin { static uint16_t reserveThemes(uint8_t max_themes); static void updateHandler(uint16_t theme_base, uint8_t theme); + static void refreshAt(uint16_t theme_base, uint8_t theme, byte row, byte col); static const uint8_t lookupColorIndexAtPosition(uint16_t theme_base, uint16_t position); static const bool lookupColorAtPosition(uint16_t theme_base, uint16_t position, cRGB *color);