From 3398d6b55b32d10119666523b1bc14063f8cfcf4 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Sat, 4 May 2024 23:26:04 +0200 Subject: [PATCH 1/6] Define a default palette to use with ColormapOverlay Signed-off-by: Evy Bongers --- .../Devices/Keyboardio/Model100/Model100.ino | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/examples/Devices/Keyboardio/Model100/Model100.ino b/examples/Devices/Keyboardio/Model100/Model100.ino index 247fe330d0..212ed5a3cc 100644 --- a/examples/Devices/Keyboardio/Model100/Model100.ino +++ b/examples/Devices/Keyboardio/Model100/Model100.ino @@ -306,6 +306,33 @@ KEYMAPS( ___) ) // KEYMAPS( +PALETTE( + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0x00, 0x00, 0x00), + CRGB(0xff, 0x00, 0x00) +) // PALETTE( + /* Re-enable astyle's indent enforcement */ // clang-format on @@ -657,6 +684,7 @@ void setup() { // maps for. To make things simple, we set it to eight layers, which is how // many editable layers we have (see above). ColormapEffect.max_layers(8); + DefaultColormap.setup(); // For Dynamic Macros, we need to reserve storage space for the editable // macros. A kilobyte is a reasonable default. From dac82bfecb2de22ae298e848efce6b2560e6b119 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Sat, 4 May 2024 23:26:51 +0200 Subject: [PATCH 2/6] Replace the NumPad plugin with ColormapOverlay Signed-off-by: Evy Bongers --- .../Devices/Keyboardio/Model100/Model100.ino | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/examples/Devices/Keyboardio/Model100/Model100.ino b/examples/Devices/Keyboardio/Model100/Model100.ino index 212ed5a3cc..119aa6da16 100644 --- a/examples/Devices/Keyboardio/Model100/Model100.ino +++ b/examples/Devices/Keyboardio/Model100/Model100.ino @@ -29,9 +29,6 @@ // Support for controlling the keyboard's LEDs #include "Kaleidoscope-LEDControl.h" -// Support for "Numpad" mode, which is mostly just the Numpad specific LED mode -#include "Kaleidoscope-NumPad.h" - // Support for the "Boot greeting" effect, which pulses the 'LED' button for 10s // when the keyboard is connected to a computer (or that computer is powered on) #include "Kaleidoscope-LEDEffect-BootGreeting.h" @@ -63,6 +60,9 @@ // Support for turning the LEDs off after a certain amount of time #include "Kaleidoscope-IdleLEDs.h" +// Support for overlaying colors +#include "Kaleidoscope-Colormap-Overlay.h" + // Support for setting and saving the default LED mode #include "Kaleidoscope-DefaultLEDModeConfig.h" @@ -615,9 +615,9 @@ KALEIDOSCOPE_INIT_PLUGINS( // The Colormap effect makes it possible to set up per-layer colormaps ColormapEffect, - // The numpad plugin is responsible for lighting up the 'numpad' mode - // with a custom LED effect - NumPad, + // The colormap overlay plugin is responsible for lighting up the keys assigned + // in the factory 'numpad' mode + ColormapOverlay, // The HostPowerManagement plugin allows us to turn LEDs off when then host // goes to sleep, and resume them when it wakes up. @@ -649,14 +649,30 @@ void setup() { // First, call Kaleidoscope's internal setup function Kaleidoscope.setup(); + COLORMAP_OVERLAYS( + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(0, 11), 23), // 7 + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(1, 11), 23), // 4 + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(2, 11), 23), // 1 + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(3, 11), 23), // 0 + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(0, 12), 23), // 8 + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(1, 12), 23), // 5 + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(2, 12), 23), // 2 + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(3, 12), 23), // period + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(0, 13), 23), // 9 + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(1, 13), 23), // 6 + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(2, 13), 23), // 3 + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(3, 13), 23), // multiply + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(0, 14), 23), // substract + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(1, 14), 23), // add + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(2, 14), 23), // equals + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(3, 14), 23), // divide + kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(3, 15), 23), // enter + ) // COLORMAP_OVERLAYS( + // Set the hue of the boot greeting effect to something that will result in a // nice green color. BootGreetingEffect.hue = 85; - // While we hope to improve this in the future, the NumPad plugin - // needs to be explicitly told which keymap layer is your numpad layer - NumPad.numPadLayer = NUMPAD; - // We configure the AlphaSquare effect to use RED letters AlphaSquare.color = CRGB(255, 0, 0); From 8f1c05c4001aed630012abd2b48ee47abb71c833 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Tue, 7 May 2024 22:40:51 +0200 Subject: [PATCH 3/6] Use constants for setting led palette Signed-off-by: Evy Bongers --- .../Devices/Keyboardio/Model100/Model100.ino | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/examples/Devices/Keyboardio/Model100/Model100.ino b/examples/Devices/Keyboardio/Model100/Model100.ino index 119aa6da16..b53b258045 100644 --- a/examples/Devices/Keyboardio/Model100/Model100.ino +++ b/examples/Devices/Keyboardio/Model100/Model100.ino @@ -306,31 +306,34 @@ KEYMAPS( ___) ) // KEYMAPS( +#define RGB_UNSET CRGB(0x00, 0x00, 0x00) +#define RGB_RED CRGB(0xff, 0x00, 0x00) + PALETTE( - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0x00, 0x00, 0x00), - CRGB(0xff, 0x00, 0x00) + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_UNSET, + RGB_RED ) // PALETTE( /* Re-enable astyle's indent enforcement */ From f86eec0e5457451a4fe27210c7a6c51e8e2ac593 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Tue, 7 May 2024 22:55:20 +0200 Subject: [PATCH 4/6] Satisfy code style Signed-off-by: Evy Bongers --- examples/Devices/Keyboardio/Model100/Model100.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/Devices/Keyboardio/Model100/Model100.ino b/examples/Devices/Keyboardio/Model100/Model100.ino index b53b258045..0a06fc6e2a 100644 --- a/examples/Devices/Keyboardio/Model100/Model100.ino +++ b/examples/Devices/Keyboardio/Model100/Model100.ino @@ -652,6 +652,7 @@ void setup() { // First, call Kaleidoscope's internal setup function Kaleidoscope.setup(); + // clang-format off COLORMAP_OVERLAYS( kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(0, 11), 23), // 7 kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(1, 11), 23), // 4 @@ -671,6 +672,7 @@ void setup() { kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(3, 14), 23), // divide kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(3, 15), 23), // enter ) // COLORMAP_OVERLAYS( + // clang-format on // Set the hue of the boot greeting effect to something that will result in a // nice green color. From d16c94a59a85a5c7baac72ebd4d37b4190e66046 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Sat, 11 May 2024 09:54:29 +0200 Subject: [PATCH 5/6] Allow clang to format the PALETTE Signed-off-by: Evy Bongers --- .../Devices/Keyboardio/Model100/Model100.ino | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/examples/Devices/Keyboardio/Model100/Model100.ino b/examples/Devices/Keyboardio/Model100/Model100.ino index 0a06fc6e2a..12c8aea1db 100644 --- a/examples/Devices/Keyboardio/Model100/Model100.ino +++ b/examples/Devices/Keyboardio/Model100/Model100.ino @@ -306,8 +306,11 @@ KEYMAPS( ___) ) // KEYMAPS( -#define RGB_UNSET CRGB(0x00, 0x00, 0x00) -#define RGB_RED CRGB(0xff, 0x00, 0x00) +/* Re-enable astyle's indent enforcement */ +// clang-format on + +#define RGB_UNSET CRGB(0x00, 0x00, 0x00) +#define RGB_RED CRGB(0xff, 0x00, 0x00) PALETTE( RGB_UNSET, @@ -333,11 +336,7 @@ PALETTE( RGB_UNSET, RGB_UNSET, RGB_UNSET, - RGB_RED -) // PALETTE( - -/* Re-enable astyle's indent enforcement */ -// clang-format on + RGB_RED) // PALETTE( /** versionInfoMacro handles the 'firmware version info' macro * When a key bound to the macro is pressed, this macro @@ -652,7 +651,6 @@ void setup() { // First, call Kaleidoscope's internal setup function Kaleidoscope.setup(); - // clang-format off COLORMAP_OVERLAYS( kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(0, 11), 23), // 7 kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(1, 11), 23), // 4 @@ -671,8 +669,7 @@ void setup() { kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(2, 14), 23), // equals kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(3, 14), 23), // divide kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(3, 15), 23), // enter - ) // COLORMAP_OVERLAYS( - // clang-format on + ) // COLORMAP_OVERLAYS( // Set the hue of the boot greeting effect to something that will result in a // nice green color. From 9ce4bda99e40fa4c0d7cde958d23558519406625 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Sat, 11 May 2024 10:27:17 +0200 Subject: [PATCH 6/6] Add a bunch of additional comments Signed-off-by: Evy Bongers --- .../Devices/Keyboardio/Model100/Model100.ino | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/examples/Devices/Keyboardio/Model100/Model100.ino b/examples/Devices/Keyboardio/Model100/Model100.ino index 12c8aea1db..8aad4ebfda 100644 --- a/examples/Devices/Keyboardio/Model100/Model100.ino +++ b/examples/Devices/Keyboardio/Model100/Model100.ino @@ -312,6 +312,8 @@ KEYMAPS( #define RGB_UNSET CRGB(0x00, 0x00, 0x00) #define RGB_RED CRGB(0xff, 0x00, 0x00) +// Set up a default palette to be use for the Colormap and Colormap-Overlay +// plugins PALETTE( RGB_UNSET, RGB_UNSET, @@ -617,8 +619,9 @@ KALEIDOSCOPE_INIT_PLUGINS( // The Colormap effect makes it possible to set up per-layer colormaps ColormapEffect, - // The colormap overlay plugin is responsible for lighting up the keys assigned - // in the factory 'numpad' mode + // The colormap overlay plugin provides a way to set LED colors regardless of + // the active LED effect. This is used for lighting up the keys assigned in + // the factory 'numpad' mode ColormapOverlay, // The HostPowerManagement plugin allows us to turn LEDs off when then host @@ -651,6 +654,20 @@ void setup() { // First, call Kaleidoscope's internal setup function Kaleidoscope.setup(); + // Add colormap overlays for all keys of the numpad. This makes sure that + // all keys of the numpad light up once the numpad layer is active. + // + // The call signature is: + // kaleidoscope::plugin::Overlay(, , ) + // + // Key address matrix: https://github.com/keyboardio/Kaleidoscope/blob/master/plugins/Kaleidoscope-Hardware-Keyboardio-Model100/src/kaleidoscope/device/keyboardio/Model100.h#L175-L205 + // + // (0, 0) (0, 1) (0, 2) (0, 3) (0, 4) (0, 5) (0, 6) | (0, 9) (0, 10) (0, 11) (0, 12) (0, 13) (0, 14) (0, 15) + // (1, 0) (1, 1) (1, 2) (1, 3) (1, 4) (1, 5) (1, 6) | (1, 9) (1, 10) (1, 11) (1, 12) (1, 13) (1, 14) (1, 15) + // (2, 0) (2, 1) (2, 2) (2, 3) (2, 4) (2, 5) | (2, 10) (2, 11) (2, 12) (2, 13) (2, 14) (2, 15) + // (3, 0) (3, 1) (3, 2) (3, 3) (3, 4) (3, 5) (2, 6) | (2, 9) (3, 10) (3, 11) (3, 12) (3, 13) (3, 14) (3, 15) + // (0, 7) (1, 7) (2, 7) (3, 7) | (3, 8) (2, 8) (1, 8) (0, 8) + // (3, 6) | (3, 9) COLORMAP_OVERLAYS( kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(0, 11), 23), // 7 kaleidoscope::plugin::Overlay(NUMPAD, KeyAddr(1, 11), 23), // 4