From 0a39cc6c4caa19d8f51b5b3a2cbab950eadf1617 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Sun, 21 Apr 2024 12:31:44 +0200 Subject: [PATCH] Prepare support for dynamic palette size Signed-off-by: Evy Bongers --- .../src/kaleidoscope/plugin/DefaultPalette.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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 998b65802..b443a579e 100644 --- a/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/DefaultPalette.h +++ b/plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/DefaultPalette.h @@ -19,8 +19,9 @@ #include // for PROGMEM -#include "kaleidoscope/device/device.h" // for cRGB -#include "kaleidoscope/plugin.h" // for Plugin +#include "kaleidoscope/device/device.h" // for cRGB, CRGB +#include "kaleidoscope/plugin.h" // for Plugin +#include "kaleidoscope/plugin/LED-Palette-Theme.h" // for LEDPaletteTheme namespace kaleidoscope { namespace plugin { @@ -28,6 +29,18 @@ namespace plugin { namespace ledpalette { extern bool palette_defined; extern const cRGB palette[]; + +template +void configurePalette(cRGB const (&colors)[_color_count]) { + for (uint8_t i = 0; i < LEDPaletteTheme::getPaletteSize(); i++) { + if (i < _color_count) { + palette[i] = colors[i]; + } else { + palette[i] = CRGB(0x00, 0x00, 0x00); + } + } + bool palette_defined = true; +} } // namespace ledpalette class DefaultPalette : public Plugin {