Skip to content

Commit

Permalink
Have the plugin use the LED palette
Browse files Browse the repository at this point in the history
  • Loading branch information
EvyBongers committed Nov 18, 2023
1 parent 14e8920 commit 49c90b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "kaleidoscope/key_defs.h" // for Key, KEY_FLAGS, Key_NoKey, LockLayer
#include "kaleidoscope/layers.h" // for Layer, Layer_
#include "kaleidoscope/plugin/LEDControl.h" // for LEDControl
#include <Kaleidoscope-LED-Palette-Theme.h> // for LEDPaletteTheme

namespace kaleidoscope {
namespace plugin {
Expand All @@ -35,7 +36,7 @@ bool ColormapOverlay::hasOverlay(KeyAddr k) {
if (overlay.addr == k) {
if ((overlay.layer == layer_index) ||
(overlay.layer == layer_wildcard)) {
selectedColor = &overlay.color;
selectedColor = ::LEDPaletteTheme.lookupPaletteColor(overlay.palette_index);
return true;
}
}
Expand All @@ -51,7 +52,7 @@ EventHandlerResult ColormapOverlay::onSetup() {
void ColormapOverlay::setKeyboardLEDColors() {
for (auto key_addr : KeyAddr::all()) {
if (ColormapOverlay::hasOverlay(key_addr)) {
::LEDControl.setCrgbAt(KeyAddr(key_addr), *selectedColor);
::LEDControl.setCrgbAt(KeyAddr(key_addr), selectedColor);
} else {
::LEDControl.refreshAt(KeyAddr(key_addr));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,14 @@ namespace plugin {

// Data structure for an individual qukey
struct Overlay {
// The layer this qukey is mapped on.
int8_t layer;
// The keyswitch address of the qukey.
KeyAddr addr;
// The alternake Key value this qukey should use (when held).
cRGB color;
uint8_t palette_index;

// This is the constructor that should be used when creating a Overlay that
// will be used by ColormapOverlay
constexpr Overlay(int8_t layer, KeyAddr k, cRGB color)
: layer(layer), addr(k), color(color) {}
constexpr Overlay(int8_t layer, KeyAddr k, uint8_t palette_index)
: layer(layer), addr(k), palette_index(palette_index) {}
};

class ColormapOverlay : public kaleidoscope::Plugin {
Expand All @@ -64,7 +61,7 @@ class ColormapOverlay : public kaleidoscope::Plugin {
private:
Overlay const *overlays_;
uint8_t overlay_count_;
cRGB *selectedColor;
cRGB selectedColor;

bool hasOverlay(KeyAddr k);
void setKeyboardLEDColors();
Expand Down

0 comments on commit 49c90b9

Please sign in to comment.