diff --git a/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/DefaultPalette.cpp b/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/DefaultPalette.cpp index 02ab271fff..0f43874b0f 100644 --- a/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/DefaultPalette.cpp +++ b/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/DefaultPalette.cpp @@ -31,7 +31,7 @@ __attribute__((weak)) extern bool palette_defined = false; void DefaultPalette::setup() { if (!ledpalette::palette_defined) return; - for (uint8_t i = 0; i < 16; i++) { + for (uint8_t i = 0; i < LEDPaletteTheme::getPaletteSize(); i++) { cRGB color; color.r = pgm_read_byte(&(ledpalette::palette[i].r)); diff --git a/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/DefaultPalette.h b/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/DefaultPalette.h index 622b713d11..7a25c48c1d 100644 --- a/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/DefaultPalette.h +++ b/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/DefaultPalette.h @@ -41,13 +41,13 @@ class DefaultPalette : public Plugin { // clang-format off #define PALETTE(p0, p1, p2, p3, p4, p5, p6, p7, \ - p8, p9, pa, pb, pc, pd, pe, pf) \ + p8, p9, pa, pb, pc, pd, pe, ...) \ namespace kaleidoscope { \ namespace plugin { \ namespace ledpalette { \ const cRGB palette[] PROGMEM = { \ p0, p1, p2, p3, p4, p5, p6, p7, \ - p8, p9, pa, pb, pc, pd, pe, pf \ + p8, p9, pa, pb, pc, pd, pe, ##__VA_ARGS__ \ }; \ bool palette_defined = true; \ } /* defaultcolormap */ \ diff --git a/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/LED-Palette-Theme.cpp b/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/LED-Palette-Theme.cpp index 1f64451f31..2df03f8e8f 100644 --- a/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/LED-Palette-Theme.cpp +++ b/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/LED-Palette-Theme.cpp @@ -32,10 +32,11 @@ namespace kaleidoscope { namespace plugin { uint16_t LEDPaletteTheme::palette_base_; +uint8_t LEDPaletteTheme::palette_size_ = 24; uint16_t LEDPaletteTheme::reserveThemes(uint8_t max_themes) { if (!palette_base_) - palette_base_ = ::EEPROMSettings.requestSlice(16 * sizeof(cRGB)); + palette_base_ = ::EEPROMSettings.requestSlice(palette_size_ * sizeof(cRGB)); return ::EEPROMSettings.requestSlice(max_themes * Runtime.device().led_count / 2); } @@ -116,12 +117,16 @@ void LEDPaletteTheme::updatePaletteColor(uint8_t palette_index, cRGB color) { } bool LEDPaletteTheme::isThemeUninitialized(uint16_t theme_base, uint8_t max_themes) { - bool paletteEmpty = Runtime.storage().isSliceUninitialized(palette_base_, 16 * sizeof(cRGB)); + bool paletteEmpty = Runtime.storage().isSliceUninitialized(palette_base_, palette_size_ * sizeof(cRGB)); bool themeEmpty = Runtime.storage().isSliceUninitialized(theme_base, max_themes * Runtime.device().led_count / 2); return paletteEmpty && themeEmpty; } +uint8_t LEDPaletteTheme::getPaletteSize() { + return LEDPaletteTheme::palette_size_; +} + EventHandlerResult LEDPaletteTheme::onFocusEvent(const char *input) { if (!Runtime.has_leds) return EventHandlerResult::OK; @@ -135,7 +140,7 @@ EventHandlerResult LEDPaletteTheme::onFocusEvent(const char *input) { return EventHandlerResult::OK; if (::Focus.isEOL()) { - for (uint8_t i = 0; i < 16; i++) { + for (uint8_t i = 0; i < palette_size_; i++) { cRGB color; color = lookupPaletteColor(i); @@ -145,7 +150,7 @@ EventHandlerResult LEDPaletteTheme::onFocusEvent(const char *input) { } uint8_t i = 0; - while (i < 16 && !::Focus.isEOL()) { + while (i < palette_size_ && !::Focus.isEOL()) { cRGB color; ::Focus.read(color); diff --git a/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/LED-Palette-Theme.h b/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/LED-Palette-Theme.h index 8612e2904c..18793fb7ac 100644 --- a/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/LED-Palette-Theme.h +++ b/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/LED-Palette-Theme.h @@ -47,8 +47,11 @@ class LEDPaletteTheme : public kaleidoscope::Plugin { uint8_t max_themes); static bool isThemeUninitialized(uint16_t theme_base, uint8_t max_themes); + static uint8_t getPaletteSize(); + private: static uint16_t palette_base_; + static uint8_t palette_size_; }; } // namespace plugin