Skip to content

Commit

Permalink
Expand palette to 24 colors
Browse files Browse the repository at this point in the history
Signed-off-by: Evy Bongers <[email protected]>
  • Loading branch information
EvyBongers committed Apr 19, 2024
1 parent fd7f5f9 commit 7aef9b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 < 24; i++) {
cRGB color;

color.r = pgm_read_byte(&(ledpalette::palette[i].r));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ 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) \
#define PALETTE(p00, p01, p02, p03, p04, p05, p06, p07, \
p08, p09, p0a, p0b, p0c, p0d, p0e, p0f, \
p10, p11, p12, p13, p14, p15, p16, p17) \
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 \
p00, p01, p02, p03, p04, p05, p06, p07, \
p08, p09, p0a, p0b, p0c, p0d, p0e, p0f, \
p10, p11, p12, p13, p14, p15, p16, p17 \
}; \
bool palette_defined = true; \
} /* defaultcolormap */ \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ uint16_t LEDPaletteTheme::palette_base_;

uint16_t LEDPaletteTheme::reserveThemes(uint8_t max_themes) {
if (!palette_base_)
palette_base_ = ::EEPROMSettings.requestSlice(16 * sizeof(cRGB));
palette_base_ = ::EEPROMSettings.requestSlice(24 * sizeof(cRGB));

return ::EEPROMSettings.requestSlice(max_themes * Runtime.device().led_count / 2);
}
Expand Down Expand Up @@ -116,7 +116,7 @@ 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_, 24 * sizeof(cRGB));
bool themeEmpty = Runtime.storage().isSliceUninitialized(theme_base, max_themes * Runtime.device().led_count / 2);

return paletteEmpty && themeEmpty;
Expand All @@ -135,7 +135,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 < 24; i++) {
cRGB color;

color = lookupPaletteColor(i);
Expand All @@ -145,7 +145,7 @@ EventHandlerResult LEDPaletteTheme::onFocusEvent(const char *input) {
}

uint8_t i = 0;
while (i < 16 && !::Focus.isEOL()) {
while (i < 24 && !::Focus.isEOL()) {
cRGB color;

::Focus.read(color);
Expand Down

0 comments on commit 7aef9b7

Please sign in to comment.