From cc4d86a98d68a5eb4ac83320c97090bdae3b7ae6 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 4 Jun 2017 19:52:49 +0200 Subject: [PATCH] Kaleidoscope Style Guide conformance Signed-off-by: Gergely Nagy --- README.md | 26 ++++++++++++++------------ TriColor.md | 12 ++++++------ examples/LEDEffects/LEDEffects.ino | 8 ++++---- src/Kaleidoscope/Jukebox.cpp | 24 ++++++------------------ src/Kaleidoscope/Jukebox.h | 4 ++-- src/Kaleidoscope/Miami.cpp | 8 ++------ src/Kaleidoscope/Miami.h | 2 +- src/Kaleidoscope/TriColor.cpp | 25 ++++++++++++------------- src/Kaleidoscope/TriColor.h | 16 +++++++--------- 9 files changed, 54 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index f69efda1..2110ac3d 100644 --- a/README.md +++ b/README.md @@ -5,27 +5,29 @@ [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-LEDEffects.svg?branch=master [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-LEDEffects - [st:stable]: https://img.shields.io/badge/stable-✔-black.png?style=flat&colorA=44cc11&colorB=494e52 - [st:broken]: https://img.shields.io/badge/broken-X-black.png?style=flat&colorA=e05d44&colorB=494e52 - [st:experimental]: https://img.shields.io/badge/experimental----black.png?style=flat&colorA=dfb317&colorB=494e52 + [st:stable]: https://img.shields.io/badge/stable-✔-black.svg?style=flat&colorA=44cc11&colorB=494e52 + [st:broken]: https://img.shields.io/badge/broken-X-black.svg?style=flat&colorA=e05d44&colorB=494e52 + [st:experimental]: https://img.shields.io/badge/experimental----black.svg?style=flat&colorA=dfb317&colorB=494e52 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 -Because of containing a number of different effects, and not wanting to force -all of them on the user, the plugin behaves differently than most others: it -does not enable anything by default, and we will have to selectively enable the -effects we are interested in. +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 -``` -Then, in the `setup()` method of our Sketch, we will call `Kaleidoscope.use()`, -with the selected effect objects. +void setup(void) { + USE_PLUGINS(&JukeBoxEffect); + + Kaleidoscope.setup(); +} +``` ## Included effects @@ -43,7 +45,7 @@ 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` +### `JukeboxEffect` Applies a color effect to the keyboard, inspired by the JukeBox keyset: @@ -53,7 +55,7 @@ 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, +An alternative color scheme exists under the `JukeboxAlternateEffect` name, where the light green and red colors are swapped. ## Plugin methods diff --git a/TriColor.md b/TriColor.md index 3d79fd7c..1b428f44 100644 --- a/TriColor.md +++ b/TriColor.md @@ -2,9 +2,9 @@ ![status][st:stable] - [st:stable]: https://img.shields.io/badge/stable-✔-black.png?style=flat&colorA=44cc11&colorB=494e52 - [st:broken]: https://img.shields.io/badge/broken-X-black.png?style=flat&colorA=e05d44&colorB=494e52 - [st:experimental]: https://img.shields.io/badge/experimental----black.png?style=flat&colorA=dfb317&colorB=494e52 + [st:stable]: https://img.shields.io/badge/stable-✔-black.svg?style=flat&colorA=44cc11&colorB=494e52 + [st:broken]: https://img.shields.io/badge/broken-X-black.svg?style=flat&colorA=e05d44&colorB=494e52 + [st:experimental]: https://img.shields.io/badge/experimental----black.svg?style=flat&colorA=dfb317&colorB=494e52 The `TriColor` effect extension is a part of the [`LEDEffects`][plugin:ledeffects] library, not a stand-alone base library of @@ -31,9 +31,9 @@ Then, we simply create a new instance of the `TriColor` class, with appropriate colors set for the constructor: ```c++ -KaleidoscopePlugins::LEDEffects::TriColor BlackAndWhiteEffect ((cRGB){0x00, 0x00, 0x00}, - (cRGB){0xff, 0xff, 0xff}, - (cRGB){0x80, 0x80, 0x80}); +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 diff --git a/examples/LEDEffects/LEDEffects.ino b/examples/LEDEffects/LEDEffects.ino index 41a1e765..3d2c8fb0 100644 --- a/examples/LEDEffects/LEDEffects.ino +++ b/examples/LEDEffects/LEDEffects.ino @@ -39,14 +39,14 @@ const Key keymaps[][ROWS][COLS] PROGMEM = { Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus, Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, - Key_NoKey - ), + Key_NoKey), }; void setup() { - Kaleidoscope.setup(KEYMAP_SIZE); - Kaleidoscope.use(&LEDControl, &LEDOff, &MiamiEffect, &JukeboxEffect, &JukeboxAlternateEffect, NULL); + USE_PLUGINS(&LEDOff, &MiamiEffect, &JukeboxEffect, &JukeboxAlternateEffect); + + Kaleidoscope.setup(); MiamiEffect.activate(); } diff --git a/src/Kaleidoscope/Jukebox.cpp b/src/Kaleidoscope/Jukebox.cpp index d6b1a101..27ea9fe7 100644 --- a/src/Kaleidoscope/Jukebox.cpp +++ b/src/Kaleidoscope/Jukebox.cpp @@ -18,22 +18,10 @@ #include -KaleidoscopePlugins::LEDEffects::TriColor JukeboxEffect((cRGB) { - 0xc8, 0xe8, 0xee -} /* TM */, -(cRGB) { - 0xc3, 0xee, 0x8c -} /* VCO */, -(cRGB) { - 0x21, 0x38, 0xd7 -} /* RN */); +kaleidoscope::TriColor JukeboxEffect(CRGB(0xc8, 0xe8, 0xee), /* TM */ + CRGB(0xc3, 0xee, 0x8c), /* VCO */ + CRGB(0x21, 0x38, 0xd7)); /* RN */ -KaleidoscopePlugins::LEDEffects::TriColor JukeboxAlternateEffect((cRGB) { - 0xc8, 0xe8, 0xee -} /* TM */, -(cRGB) { - 0x21, 0x38, 0xd7 -} /* RN */, -(cRGB) { - 0xc3, 0xee, 0x8c -} /* VCO */); +kaleidoscope::TriColor JukeboxAlternateEffect(CRGB(0xc8, 0xe8, 0xee), /* TM */ + CRGB(0x21, 0x38, 0xd7), /* RN */ + CRGB(0xc3, 0xee, 0x8c)); /* VCO */ diff --git a/src/Kaleidoscope/Jukebox.h b/src/Kaleidoscope/Jukebox.h index d1aee9a9..3a50252c 100644 --- a/src/Kaleidoscope/Jukebox.h +++ b/src/Kaleidoscope/Jukebox.h @@ -20,5 +20,5 @@ #include -extern KaleidoscopePlugins::LEDEffects::TriColor JukeboxEffect; -extern KaleidoscopePlugins::LEDEffects::TriColor JukeboxAlternateEffect; +extern kaleidoscope::TriColor JukeboxEffect; +extern kaleidoscope::TriColor JukeboxAlternateEffect; diff --git a/src/Kaleidoscope/Miami.cpp b/src/Kaleidoscope/Miami.cpp index 217500ad..206821f9 100644 --- a/src/Kaleidoscope/Miami.cpp +++ b/src/Kaleidoscope/Miami.cpp @@ -18,9 +18,5 @@ #include -KaleidoscopePlugins::LEDEffects::TriColor MiamiEffect((cRGB) { - 0xd6, 0xd6, 0x4e -} /* Cyan */, -(cRGB) { - 0xaf, 0x67, 0xfa -} /* Magenta */); +kaleidoscope::TriColor MiamiEffect(CRGB(0xd6, 0xd6, 0x4e), /* Cyan */ + CRGB(0xaf, 0x67, 0xfa)); /* Magenta */ diff --git a/src/Kaleidoscope/Miami.h b/src/Kaleidoscope/Miami.h index 9682a87c..0dcead0c 100644 --- a/src/Kaleidoscope/Miami.h +++ b/src/Kaleidoscope/Miami.h @@ -20,4 +20,4 @@ #include -extern KaleidoscopePlugins::LEDEffects::TriColor MiamiEffect; +extern kaleidoscope::TriColor MiamiEffect; diff --git a/src/Kaleidoscope/TriColor.cpp b/src/Kaleidoscope/TriColor.cpp index 5bc7a1de..ca81a537 100644 --- a/src/Kaleidoscope/TriColor.cpp +++ b/src/Kaleidoscope/TriColor.cpp @@ -18,13 +18,12 @@ #include -namespace KaleidoscopePlugins { -namespace LEDEffects { +namespace kaleidoscope { -TriColor::TriColor(cRGB baseColor, cRGB modColor, cRGB escColor) { - this->baseColor = baseColor; - this->modColor = modColor; - this->escColor = escColor; +TriColor::TriColor(cRGB base_color, cRGB mod_color, cRGB esc_color) { + base_color_ = base_color; + mod_color_ = mod_color; + esc_color_ = esc_color; } void @@ -33,13 +32,13 @@ TriColor::update(void) { for (uint8_t c = 0; c < COLS; c++) { Key k = Layer.lookup(r, c); - // Special keys are always modColor + // Special keys are always mod_color if (k.flags != 0) { - LEDControl.led_set_crgb_at(r, c, modColor); + LEDControl.led_set_crgb_at(r, c, mod_color_); continue; } - cRGB color = modColor; + cRGB color = mod_color_; switch (k.keyCode) { case Key_A.keyCode ... Key_0.keyCode: @@ -48,10 +47,10 @@ TriColor::update(void) { case Key_Keypad1.keyCode ... Key_KeypadDot.keyCode: case Key_F1.keyCode ... Key_F4.keyCode: case Key_F9.keyCode ... Key_F12.keyCode: - color = baseColor; + color = base_color_; break; case Key_Escape.keyCode: - color = escColor; + color = esc_color_; break; } @@ -59,5 +58,5 @@ TriColor::update(void) { } } } -}; -}; + +} diff --git a/src/Kaleidoscope/TriColor.h b/src/Kaleidoscope/TriColor.h index b7cc0774..5a19fb26 100644 --- a/src/Kaleidoscope/TriColor.h +++ b/src/Kaleidoscope/TriColor.h @@ -21,19 +21,17 @@ #include #include -namespace KaleidoscopePlugins { -namespace LEDEffects { +namespace kaleidoscope { class TriColor : public LEDMode { public: - TriColor(cRGB baseColor, cRGB modColor, cRGB escColor); - TriColor(cRGB baseColor, cRGB modColor) : TriColor(baseColor, modColor, modColor) {}; + TriColor(cRGB base_color, cRGB mod_color, cRGB esc_color); + TriColor(cRGB base_color, cRGB mod_color) : TriColor(base_color, mod_color, mod_color) {}; virtual void update(void) final; private: - cRGB baseColor; - cRGB modColor; - cRGB escColor; -}; -}; + cRGB base_color_; + cRGB mod_color_; + cRGB esc_color_; }; +}