-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1362 from EvyBongers/movedPalette
Drop Colormap dependency for using the color palette
- Loading branch information
Showing
5 changed files
with
115 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/DefaultPalette.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* -*- mode: c++ -*- | ||
* Kaleidoscope-Colormap -- Per-layer colormap effect | ||
* Copyright (C) 2022 Keyboard.io, Inc | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation, version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "kaleidoscope/plugin/DefaultPalette.h" | ||
#include "kaleidoscope/plugin/LED-Palette-Theme.h" // for LEDPaletteTheme | ||
|
||
#include <stdint.h> // for uint8_t | ||
|
||
namespace kaleidoscope { | ||
namespace plugin { | ||
|
||
namespace ledpalette { | ||
__attribute__((weak)) extern const cRGB palette[] = {}; | ||
__attribute__((weak)) extern bool palette_defined = false; | ||
} // namespace ledpalette | ||
|
||
void DefaultPalette::setup() { | ||
if (!ledpalette::palette_defined) return; | ||
|
||
for (uint8_t i = 0; i < 16; i++) { | ||
cRGB color; | ||
|
||
color.r = pgm_read_byte(&(ledpalette::palette[i].r)); | ||
color.g = pgm_read_byte(&(ledpalette::palette[i].g)); | ||
color.b = pgm_read_byte(&(ledpalette::palette[i].b)); | ||
|
||
::LEDPaletteTheme.updatePaletteColor(i, color); | ||
} | ||
} | ||
|
||
} // namespace plugin | ||
} // namespace kaleidoscope | ||
|
||
kaleidoscope::plugin::DefaultPalette DefaultPalette; |
59 changes: 59 additions & 0 deletions
59
plugins/Kaleidoscope-LED-Palette-Theme/src/kaleidoscope/plugin/DefaultPalette.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* -*- mode: c++ -*- | ||
* Kaleidoscope-Colormap -- Per-layer colormap effect | ||
* Copyright (C) 2022 Keyboard.io, Inc | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation, version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <Arduino.h> // for PROGMEM | ||
|
||
#include "kaleidoscope/device/device.h" // for cRGB | ||
#include "kaleidoscope/plugin.h" // for Plugin | ||
|
||
namespace kaleidoscope { | ||
namespace plugin { | ||
|
||
namespace ledpalette { | ||
extern bool palette_defined; | ||
extern const cRGB palette[]; | ||
} // namespace ledpalette | ||
|
||
class DefaultPalette : public Plugin { | ||
public: | ||
static void setup(); | ||
}; | ||
|
||
} // namespace plugin | ||
} // namespace kaleidoscope | ||
|
||
// clang-format off | ||
|
||
#define PALETTE(p0, p1, p2, p3, p4, p5, p6, p7, \ | ||
p8, p9, pa, pb, pc, pd, pe, pf) \ | ||
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 \ | ||
}; \ | ||
bool palette_defined = true; \ | ||
} /* defaultcolormap */ \ | ||
} /* plugin */ \ | ||
} /* kaleidoscope */ | ||
|
||
// clang-format on | ||
|
||
extern kaleidoscope::plugin::DefaultPalette DefaultPalette; |