diff --git a/doc/plugin/LEDEffects.md b/doc/plugin/LEDEffects.md new file mode 100644 index 00000000..b6e358c2 --- /dev/null +++ b/doc/plugin/LEDEffects.md @@ -0,0 +1,71 @@ +# Kaleidoscope-LEDEffects + +The `LEDEffects` plugin provides a selection of LED effects, each of them fairly +simple, simple enough to not need a plugin of their own. + +## Using the plugin + +There are a number of different effects included in the package, all of them are +available once including the header, and one's free to choose any number of +them. + +```c++ +#include +#include + +KALEIDOSCOPE_INIT_PLUGINS(LEDControl, JukeBoxEffect); + +void setup(void) { + Kaleidoscope.setup(); +} +``` + +## Included effects + +All of these effects will scan the active layers, and apply effects based on +what keys are active on each position, thus, it needs no hints or configuration +to figure out our layout! + +### `MiamiEffect` + +Applies a color effect to the keyboard, inspired by the popular Miami keyset: + +![Miami](extras/MiamiEffect.png) + +Alphas, punctuation, numbers, the space bar, the numbers and the dot on the +keypad, and half the function keys will be in a cyan-ish color, the rest in +magenta. + +### `JukeboxEffect` + +Applies a color effect to the keyboard, inspired by the JukeBox keyset: + +![Jukebox](extras/JukeboxEffect.png) + +Alphas, punctuation, numbers, the space bar, the numbers and the dot on the +keypad, and half the function keys will be in a beige-ish color, the rest in +light green, except for the `Esc` key, which will be in red. + +An alternative color scheme exists under the `JukeboxAlternateEffect` name, +where the light green and red colors are swapped. + +## Plugin methods + +The plugin provides a single method on each of the included effect objects: + +### `.activate()` + +> When called, immediately activates the effect. Mostly useful in the `setup()` +> method of the Sketch, or in macros that are meant to switch to the selected +> effect, no matter where we are in the list. + +## Dependencies + +* [Kaleidoscope-LEDControl](LEDControl.md) + +## Further reading + +Starting from the [example][plugin:example] is the recommended way of getting +started with the plugin. + + [plugin:example]: ../../examples/LEDEffects/LEDEffects.ino diff --git a/doc/plugin/TriColor.md b/doc/plugin/TriColor.md new file mode 100644 index 00000000..d653e36e --- /dev/null +++ b/doc/plugin/TriColor.md @@ -0,0 +1,35 @@ +# Kaleidoscope-TriColor + +The `TriColor` effect extension is a part of +the [`LEDEffects`][plugin:ledeffects] library, not a stand-alone base library of +its own. It is used to implement the effects in that library. + + [plugin:ledeffects]: LEDEffects.md + +It is a class that can be used to create LED effects that all follow a similar +pattern: alphas and similar in one color; modifiers, special keys, and half the +function keys in another, and `Esc` in a third (this latter being optional). If +we have a color scheme that follows this pattern, the `TriColor` extension can +make it a lot easier to implement it. + +## Using the extension + +Because the extension is part of the [`LEDEffects`][plugin:ledeffects] library, +we need to include that header: + +```c++ +#include +``` + +Then, we simply create a new instance of the `TriColor` class, with appropriate +colors set for the constructor: + +```c++ +kaleidoscope::TriColor BlackAndWhiteEffect (CRGB(0x00, 0x00, 0x00), + CRGB(0xff, 0xff, 0xff), + CRGB(0x80, 0x80, 0x80)); +``` + +The first argument is the base color, the second is for modifiers and special +keys, the last one is for the `Esc` key. If the last one is omitted, the +extension will use the modifier color for it. diff --git a/examples/LEDEffects/LEDEffects.ino b/examples/LEDEffects/LEDEffects.ino new file mode 100644 index 00000000..0c88da2e --- /dev/null +++ b/examples/LEDEffects/LEDEffects.ino @@ -0,0 +1,59 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-LEDEffects -- An assorted collection of LED effects for Kaleidoscope + * Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc + * + * This program is free software: you can redistribute it and/or modify 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 + * 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 + * this program. If not, see . + */ + +#include +#include + +#include "LED-Off.h" + +// *INDENT-OFF* +const Key keymaps[][ROWS][COLS] PROGMEM = { + [0] = KEYMAP_STACKED + ( + Key_LEDEffectNext, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, + Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab, + Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G, + Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape, + + Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift, + Key_NoKey, + + Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip, + Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals, + Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote, + Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus, + + Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, + Key_NoKey), +}; +// *INDENT-ON* + +KALEIDOSCOPE_INIT_PLUGINS(LEDControl, + LEDOff, + MiamiEffect, + JukeboxEffect, + JukeboxAlternateEffect); + +void setup() { + Kaleidoscope.setup(); + + MiamiEffect.activate(); +} + +void loop() { + Kaleidoscope.loop(); +} diff --git a/extras/JukeboxEffect.png b/extras/JukeboxEffect.png new file mode 100644 index 00000000..647b89bf Binary files /dev/null and b/extras/JukeboxEffect.png differ diff --git a/extras/MiamiEffect.png b/extras/MiamiEffect.png new file mode 100644 index 00000000..b6615fce Binary files /dev/null and b/extras/MiamiEffect.png differ diff --git a/src/Kaleidoscope-LEDEffects.h b/src/Kaleidoscope-LEDEffects.h new file mode 100644 index 00000000..b4a7ba2c --- /dev/null +++ b/src/Kaleidoscope-LEDEffects.h @@ -0,0 +1,22 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-LEDEffects -- An assorted collection of LED effects for Kaleidoscope + * Copyright (C) 2016, 2017 Keyboard.io, Inc + * + * This program is free software: you can redistribute it and/or modify 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 + * 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 + * this program. If not, see . + */ + +#pragma once + +#include +#include +#include diff --git a/src/kaleidoscope/plugin/Jukebox.cpp b/src/kaleidoscope/plugin/Jukebox.cpp new file mode 100644 index 00000000..dc0f3eb8 --- /dev/null +++ b/src/kaleidoscope/plugin/Jukebox.cpp @@ -0,0 +1,26 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-LEDEffects -- An assorted collection of LED effects for Kaleidoscope + * Copyright (C) 2016 Keyboard.io, Inc + * + * This program is free software: you can redistribute it and/or modify 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 + * 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 + * this program. If not, see . + */ + +#include + +kaleidoscope::plugin::TriColor JukeboxEffect(CRGB(0xc8, 0xe8, 0xee), /* TM */ + CRGB(0xc3, 0xee, 0x8c), /* VCO */ + CRGB(0x21, 0x38, 0xd7)); /* RN */ + +kaleidoscope::plugin::TriColor JukeboxAlternateEffect(CRGB(0xc8, 0xe8, 0xee), /* TM */ + CRGB(0x21, 0x38, 0xd7), /* RN */ + CRGB(0xc3, 0xee, 0x8c)); /* VCO */ diff --git a/src/kaleidoscope/plugin/Jukebox.h b/src/kaleidoscope/plugin/Jukebox.h new file mode 100644 index 00000000..4b250088 --- /dev/null +++ b/src/kaleidoscope/plugin/Jukebox.h @@ -0,0 +1,23 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-LEDEffects -- An assorted collection of LED effects for Kaleidoscope + * Copyright (C) 2016, 2017 Keyboard.io, Inc + * + * This program is free software: you can redistribute it and/or modify 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 + * 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 + * this program. If not, see . + */ + +#pragma once + +#include + +extern kaleidoscope::plugin::TriColor JukeboxEffect; +extern kaleidoscope::plugin::TriColor JukeboxAlternateEffect; diff --git a/src/kaleidoscope/plugin/Miami.cpp b/src/kaleidoscope/plugin/Miami.cpp new file mode 100644 index 00000000..c23d63d5 --- /dev/null +++ b/src/kaleidoscope/plugin/Miami.cpp @@ -0,0 +1,21 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-LEDEffects -- An assorted collection of LED effects for Kaleidoscope + * Copyright (C) 2016, 2017 Keyboard.io, Inc + * + * This program is free software: you can redistribute it and/or modify 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 + * 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 + * this program. If not, see . + */ + +#include + +kaleidoscope::plugin::TriColor MiamiEffect(CRGB(0x4e, 0xd6, 0xd6), /* Cyan */ + CRGB(0xaf, 0x67, 0xfa)); /* Magenta */ diff --git a/src/kaleidoscope/plugin/Miami.h b/src/kaleidoscope/plugin/Miami.h new file mode 100644 index 00000000..08e6b342 --- /dev/null +++ b/src/kaleidoscope/plugin/Miami.h @@ -0,0 +1,22 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-LEDEffects -- An assorted collection of LED effects for Kaleidoscope + * Copyright (C) 2016, 2017 Keyboard.io, Inc + * + * This program is free software: you can redistribute it and/or modify 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 + * 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 + * this program. If not, see . + */ + +#pragma once + +#include + +extern kaleidoscope::plugin::TriColor MiamiEffect; diff --git a/src/kaleidoscope/plugin/TriColor.cpp b/src/kaleidoscope/plugin/TriColor.cpp new file mode 100644 index 00000000..c13eb626 --- /dev/null +++ b/src/kaleidoscope/plugin/TriColor.cpp @@ -0,0 +1,62 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-LEDEffects -- An assorted collection of LED effects for Kaleidoscope + * Copyright (C) 2016, 2017 Keyboard.io, Inc + * + * This program is free software: you can redistribute it and/or modify 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 + * 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 + * this program. If not, see . + */ + +#include + +namespace kaleidoscope { +namespace plugin { + +TriColor::TriColor(cRGB base_color, cRGB mod_color, cRGB esc_color) { + base_color_ = base_color; + mod_color_ = mod_color; + esc_color_ = esc_color; +} + +void TriColor::update(void) { + for (uint8_t r = 0; r < ROWS; r++) { + for (uint8_t c = 0; c < COLS; c++) { + Key k = Layer.lookup(r, c); + + // Special keys are always mod_color + if (k.flags != 0) { + ::LEDControl.setCrgbAt(r, c, mod_color_); + continue; + } + + cRGB color = mod_color_; + + switch (k.keyCode) { + case Key_A.keyCode ... Key_0.keyCode: + case Key_Spacebar.keyCode: + case Key_KeypadDivide.keyCode ... Key_KeypadSubtract.keyCode: + case Key_Keypad1.keyCode ... Key_KeypadDot.keyCode: + case Key_F1.keyCode ... Key_F4.keyCode: + case Key_F9.keyCode ... Key_F12.keyCode: + color = base_color_; + break; + case Key_Escape.keyCode: + color = esc_color_; + break; + } + + ::LEDControl.setCrgbAt(r, c, color); + } + } +} + +} +} diff --git a/src/kaleidoscope/plugin/TriColor.h b/src/kaleidoscope/plugin/TriColor.h new file mode 100644 index 00000000..b4d62ef9 --- /dev/null +++ b/src/kaleidoscope/plugin/TriColor.h @@ -0,0 +1,39 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-LEDEffects -- An assorted collection of LED effects for Kaleidoscope + * Copyright (C) 2016, 2017 Keyboard.io, Inc + * + * This program is free software: you can redistribute it and/or modify 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 + * 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 + * this program. If not, see . + */ + +#pragma once + +#include +#include + +namespace kaleidoscope { +namespace plugin { +class TriColor : public LEDMode { + public: + TriColor(cRGB base_color, cRGB mod_color, cRGB esc_color); + TriColor(cRGB base_color, cRGB mod_color) : TriColor(base_color, mod_color, mod_color) {} + + protected: + void update(void) final; + + private: + cRGB base_color_; + cRGB mod_color_; + cRGB esc_color_; +}; +} +}