From 8f0cfb753c92d3fa9541d263a984ec8fa561a290 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 4 Jun 2017 19:14:28 +0200 Subject: [PATCH] Kaleidoscope Style Guide conformance Signed-off-by: Gergely Nagy --- README.md | 27 ++++++++++--------- .../LED-ActiveModColor/LED-ActiveModColor.ino | 10 +++---- src/Kaleidoscope/LED-ActiveModColor.cpp | 26 +++++++----------- src/Kaleidoscope/LED-ActiveModColor.h | 16 +++++------ 4 files changed, 36 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index c2aa5720..dd894e7c 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,9 @@ [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-LED-ActiveModColor.svg?branch=master [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-LED-ActiveModColor - [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 With this plugin, any active modifier on the keyboard will have the LED under it highlighted. No matter how the modifier got activated (a key press, a macro, @@ -23,27 +23,28 @@ is also possible to use a custom color instead of the white default. #include void setup () { - Kaleidoscope.setup (KEYMAP_SIZE); - - Kaleidoscope.use (&ActiveModColorEffect, NULL); + USE_PLUGINS(&ActiveModColorEffect); + + Kaleidoscope.setup (); - ActiveModColorEffect.configure ({0x00, 0xff, 0xff}); + ActiveModColorEffect.highlight_color = CRGB(0x00, 0xff, 0xff); } ``` -It is recommended to place the activation (the `Kaleidoscope.use` call) of the -plugin last, so that it can reliably override any other plugins that may work -with the LEDs, and apply the highlight over those. +It is recommended to place the activation (the `USE_PLUGINS` call) of the plugin +last, so that it can reliably override any other plugins that may work with the +LEDs, and apply the highlight over those. ## Plugin methods The plugin provides the `ActiveModColorEffect` object, which has the following method: -### `.configure(color)` +### `.highlight_color` -> Set the color to use for highlighting the modifiers. If unset, will use the -> default white color. +> The color to use for highlighting the modifiers. Defaults to a white color. +> +> Not strictly a method, it is a variable one can assign a new value to. ## Dependencies diff --git a/examples/LED-ActiveModColor/LED-ActiveModColor.ino b/examples/LED-ActiveModColor/LED-ActiveModColor.ino index bd8f86b1..605a9c87 100644 --- a/examples/LED-ActiveModColor/LED-ActiveModColor.ino +++ b/examples/LED-ActiveModColor/LED-ActiveModColor.ino @@ -36,15 +36,15 @@ 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_skip - ), + Key_skip), }; void setup() { - Kaleidoscope.setup(KEYMAP_SIZE); - Kaleidoscope.use(&LEDControl, &ActiveModColorEffect, NULL); + USE_PLUGINS(&ActiveModColorEffect); - ActiveModColorEffect.configure({0x00, 0xff, 0xff}); + Kaleidoscope.setup(); + + ActiveModColorEffect.highlight_color = CRGB(0x00, 0xff, 0xff); } void loop() { diff --git a/src/Kaleidoscope/LED-ActiveModColor.cpp b/src/Kaleidoscope/LED-ActiveModColor.cpp index 24a8d0c8..c51810ba 100644 --- a/src/Kaleidoscope/LED-ActiveModColor.cpp +++ b/src/Kaleidoscope/LED-ActiveModColor.cpp @@ -19,28 +19,21 @@ #include #include -namespace KaleidoscopePlugins { -namespace LEDEffects { -cRGB ActiveModColorEffect::highlightColor = (cRGB) { +namespace kaleidoscope { + +cRGB ActiveModColorEffect::highlight_color = (cRGB) { 0xff, 0xff, 0xff }; ActiveModColorEffect::ActiveModColorEffect(void) { } -void -ActiveModColorEffect::begin(void) { +void ActiveModColorEffect::begin(void) { loop_hook_use(loopHook); } -void -ActiveModColorEffect::configure(const cRGB highlightColor_) { - highlightColor = highlightColor_; -} - -void -ActiveModColorEffect::loopHook(bool postClear) { - if (postClear) +void ActiveModColorEffect::loopHook(bool is_post_clear) { + if (is_post_clear) return; for (byte r = 0; r < ROWS; r++) { @@ -57,12 +50,11 @@ ActiveModColorEffect::loopHook(bool postClear) { continue; if (Keyboard.isModifierActive(k.keyCode)) - LEDControl.led_set_crgb_at(r, c, highlightColor); + LEDControl.led_set_crgb_at(r, c, highlight_color); } } } -}; -}; +} -KaleidoscopePlugins::LEDEffects::ActiveModColorEffect ActiveModColorEffect; +kaleidoscope::ActiveModColorEffect ActiveModColorEffect; diff --git a/src/Kaleidoscope/LED-ActiveModColor.h b/src/Kaleidoscope/LED-ActiveModColor.h index 47be5449..ef75aa1a 100644 --- a/src/Kaleidoscope/LED-ActiveModColor.h +++ b/src/Kaleidoscope/LED-ActiveModColor.h @@ -16,23 +16,23 @@ * along with this program. If not, see . */ +#pragma once + #include #include -namespace KaleidoscopePlugins { -namespace LEDEffects { +namespace kaleidoscope { class ActiveModColorEffect : public KaleidoscopePlugin { public: ActiveModColorEffect(void); - static void configure(const cRGB highlightColor); void begin(void) final; + static cRGB highlight_color; + private: - static cRGB highlightColor; - static void loopHook(bool postClear); -}; -}; + static void loopHook(bool is_post_clear); }; +} -extern KaleidoscopePlugins::LEDEffects::ActiveModColorEffect ActiveModColorEffect; +extern kaleidoscope::ActiveModColorEffect ActiveModColorEffect;