diff --git a/README.md b/README.md index 95859540..5b852f2c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ [st:experimental]: https://img.shields.io/badge/experimental----black.svg?style=flat&colorA=dfb317&colorB=494e52 A common base for plugins that want to provide themes, or theme-related -capabilities, using a 15+1 color palette. In other words, this is for plugin +capabilities, using a 16 color palette. In other words, this is for plugin authors primarily. The primary aim of the plugin is to provide not only a common palette, but tools that make it easier to use it too. @@ -112,17 +112,6 @@ The plugin provides the `LEDPaletteTheme` object, which has the following method > The palette can be set via the `palette` focus command, implemented by the > `FOCUS_HOOK_LEDPALETTETHEME` hook explained below. -### `.transparent_index` - -> The plugin supports transparent colors too: by default, the last color (index -> 15) is treated as transparent. If a pixel is found to be transparent, -> `.updateHandler` will not change its color, but leave it as is. This way one -> can create layers of themes, if so desired. -> -> This property can be set to a number between 0 and 15 to make that index -> transparent, or to a number higher than 15 to disable transparency support, -> and gain another color on the palette. - ## Focus commands The plugin provides a single `Focus` hook, `FOCUS_HOOK_LEDPALETTETHEME`, diff --git a/src/Kaleidoscope/LED-Palette-Theme.cpp b/src/Kaleidoscope/LED-Palette-Theme.cpp index 01fb82c1..d2275a07 100644 --- a/src/Kaleidoscope/LED-Palette-Theme.cpp +++ b/src/Kaleidoscope/LED-Palette-Theme.cpp @@ -24,10 +24,6 @@ namespace kaleidoscope { uint16_t LEDPaletteTheme::palette_base_; -uint8_t LEDPaletteTheme::transparent_index = 15; - -LEDPaletteTheme::LEDPaletteTheme(void) { -} void LEDPaletteTheme::begin(void) { Kaleidoscope.use(&::EEPROMSettings); @@ -44,11 +40,7 @@ void LEDPaletteTheme::updateHandler(uint16_t theme_base, uint8_t theme) { uint16_t map_base = theme_base + (theme * ROWS * COLS / 2); for (uint16_t pos = 0; pos < ROWS * COLS; pos++) { - cRGB color; - - if (!lookupColorAtPosition(map_base, pos, &color)) - continue; - + cRGB color = lookupColorAtPosition(map_base, pos); ::LEDControl.setCrgbAt(pos, color); } } @@ -57,11 +49,7 @@ void LEDPaletteTheme::refreshAt(uint16_t theme_base, uint8_t theme, byte row, by 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; - + cRGB color = lookupColorAtPosition(map_base, pos); ::LEDControl.setCrgbAt(pos, color); } @@ -78,15 +66,10 @@ const uint8_t LEDPaletteTheme::lookupColorIndexAtPosition(uint16_t map_base, uin return color_index; } -const bool LEDPaletteTheme::lookupColorAtPosition(uint16_t map_base, uint16_t position, cRGB *color) { +const cRGB LEDPaletteTheme::lookupColorAtPosition(uint16_t map_base, uint16_t position) { uint8_t color_index = lookupColorIndexAtPosition(map_base, position); - if (color_index == transparent_index) - return false; - - *color = lookupPaletteColor(color_index); - - return true; + return lookupPaletteColor(color_index); } const cRGB LEDPaletteTheme::lookupPaletteColor(uint8_t color_index) { diff --git a/src/Kaleidoscope/LED-Palette-Theme.h b/src/Kaleidoscope/LED-Palette-Theme.h index fa106ade..d878e6d9 100644 --- a/src/Kaleidoscope/LED-Palette-Theme.h +++ b/src/Kaleidoscope/LED-Palette-Theme.h @@ -25,7 +25,7 @@ namespace kaleidoscope { class LEDPaletteTheme : public KaleidoscopePlugin { public: - LEDPaletteTheme(void); + LEDPaletteTheme(void) {}; void begin(void) final; @@ -34,7 +34,7 @@ class LEDPaletteTheme : public KaleidoscopePlugin { 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); + static const cRGB lookupColorAtPosition(uint16_t theme_base, uint16_t position); static void updateColorIndexAtPosition(uint16_t theme_base, uint16_t position, uint8_t color_index); static const cRGB lookupPaletteColor(uint8_t palette_index); @@ -43,8 +43,6 @@ class LEDPaletteTheme : public KaleidoscopePlugin { static bool themeFocusHandler(const char *command, const char *expected_command, uint16_t theme_base, uint8_t max_themes); - static uint8_t transparent_index; - private: static uint16_t palette_base_; };