From c974039771135aae120365dc551670b9d7773dcb Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 14 Oct 2018 11:49:24 +0200 Subject: [PATCH] Rearrange the file layout in preparation of becoming a monorepo Move the documentation to `doc/plugin/LEDEffect-BootGreeting.md`, sources under `src/kaleidoscope/plugin/` (appropriately namespaced). This is in preparation of merging plugins into a single monorepo. Signed-off-by: Gergely Nagy --- README.md | 145 +---------------- doc/plugin/LEDEffect-BootGreeting.md | 146 ++++++++++++++++++ .../LEDEffect-BootGreeting.ino | 3 +- src/Kaleidoscope-LEDEffect-BootGreeting.h | 27 +--- .../plugin/LEDEffect-BootGreeting.cpp} | 5 +- .../plugin/LEDEffect-BootGreeting.h | 47 ++++++ 6 files changed, 199 insertions(+), 174 deletions(-) create mode 100644 doc/plugin/LEDEffect-BootGreeting.md rename src/{Kaleidoscope-LEDEffect-BootGreeting.cpp => kaleidoscope/plugin/LEDEffect-BootGreeting.cpp} (96%) create mode 100644 src/kaleidoscope/plugin/LEDEffect-BootGreeting.h diff --git a/README.md b/README.md index 61f261ce..2d57b177 100644 --- a/README.md +++ b/README.md @@ -5,147 +5,4 @@ [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-LEDEffect-BootGreeting.svg?branch=master [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-LEDEffect-BootGreeting -If you want to have your keyboard signal when it turns on, but you don't want to -use any more complicated LED modes, this plugin is for you. It will make the -`LEDEffectNext` key on your keymap slowly breathe for about ten seconds after -plugging the keyboard in (without blocking the normal functionality of the -keyboard, of course). - -## Using the plugin - -To use the plugin, include the header, and tell `Kaleidoscope` to use the plugin: - -```c++ -#include -#include -#include - -KALEIDOSCOPE_INIT_PLUGINS(LEDControl, - BootGreetingEffect - LEDOff); - -void setup() { - Kaleidoscope.setup(); -} -``` - -You may also set optional parameters. - -### Specify by search key -```c++ -#include -#include -#include - -KALEIDOSCOPE_INIT_PLUGINS(LEDControl, - BootGreetingEffect - LEDOff); - -void setup() { - Kaleidoscope.setup(); - - BootGreetingEffect.search_key = Key_M; -} -``` - -### Specify by position -```c++ -#include -#include -#include - -KALEIDOSCOPE_INIT_PLUGINS(LEDControl, - BootGreetingEffect - LEDOff); - -void setup() { - Kaleidoscope.setup(); - - //Butterfly key - BootGreetingEffect.key_col = 7; - BootGreetingEffect.key_row = 3; -} -``` - -### Specify longer timeout -```c++ -#include -#include -#include - -KALEIDOSCOPE_INIT_PLUGINS(LEDControl, - BootGreetingEffect - LEDOff); - -void setup() { - Kaleidoscope.setup(); - - //Butterfly key - BootGreetingEffect.timeout = 15000; -} -``` - -### Specify different color -```c++ -#include -#include -#include - -KALEIDOSCOPE_INIT_PLUGINS(LEDControl, - BootGreetingEffect - LEDOff); - -void setup() { - Kaleidoscope.setup(); - - //Butterfly key - BootGreetingEffect.hue = 90; - - Kaleidoscope.setup(); -} -``` - -## Plugin methods - -The plugin provides the `BootGreetingEffect` object, with the following methods and -properties: - -### `.search_key` - -> Set the key in the current keymap that should be activated with the pulsing -> LED on startup. The plugin will search from the top left to the bottom right -> of the keyboard, row by row, to find this key. The first matching key will -> be selected. -> -> Defaults to `Key_LEDEffectNext` - -### `.key_row` - -> This is an optional override to explicitly set the selected key by exact row -> and column. This number is 0-indexed, so the top row is 0, the second row is -> 1, etc. Must set `.key_col` property for this feature to be enabled. - -### `.key_col` - -> This is an optional override to explicitly set the selected key by exact row -> and column. This number is 0-indexed, so the left-most column is 0, the -> second column is 1, etc. Must set `.key_row` property for this feature to -> be enabled. - -### `.timeout` - -> This property specifies the timeout (in milliseconds) for the effect to last. -> When the keyboard is first connected, the pulsing LED effect will last for -> this duration before turning off. -> -> Defaults to `9200` ms. - -### `.hue` - -> This property sets the color hue that the LED pulsing effect. -> -> The default is `170`, which is a blue color. - -## Dependencies - -* [Kaleidoscope-LEDControl](https://github.com/keyboardio/Kaleidoscope-LEDControl) +See [doc/plugin/LEDEffect-BootGreeting.md](doc/plugin/LEDEffect-BootGreeting.md) for documentation. diff --git a/doc/plugin/LEDEffect-BootGreeting.md b/doc/plugin/LEDEffect-BootGreeting.md new file mode 100644 index 00000000..29c8e5a2 --- /dev/null +++ b/doc/plugin/LEDEffect-BootGreeting.md @@ -0,0 +1,146 @@ +# Kaleidoscope-LEDEffect-BootGreeting + +If you want to have your keyboard signal when it turns on, but you don't want to +use any more complicated LED modes, this plugin is for you. It will make the +`LEDEffectNext` key on your keymap slowly breathe for about ten seconds after +plugging the keyboard in (without blocking the normal functionality of the +keyboard, of course). + +## Using the plugin + +To use the plugin, include the header, and tell `Kaleidoscope` to use the plugin: + +```c++ +#include +#include +#include + +KALEIDOSCOPE_INIT_PLUGINS(LEDControl, + BootGreetingEffect + LEDOff); + +void setup() { + Kaleidoscope.setup(); +} +``` + +You may also set optional parameters. + +### Specify by search key +```c++ +#include +#include +#include + +KALEIDOSCOPE_INIT_PLUGINS(LEDControl, + BootGreetingEffect + LEDOff); + +void setup() { + Kaleidoscope.setup(); + + BootGreetingEffect.search_key = Key_M; +} +``` + +### Specify by position +```c++ +#include +#include +#include + +KALEIDOSCOPE_INIT_PLUGINS(LEDControl, + BootGreetingEffect + LEDOff); + +void setup() { + Kaleidoscope.setup(); + + //Butterfly key + BootGreetingEffect.key_col = 7; + BootGreetingEffect.key_row = 3; +} +``` + +### Specify longer timeout +```c++ +#include +#include +#include + +KALEIDOSCOPE_INIT_PLUGINS(LEDControl, + BootGreetingEffect + LEDOff); + +void setup() { + Kaleidoscope.setup(); + + //Butterfly key + BootGreetingEffect.timeout = 15000; +} +``` + +### Specify different color +```c++ +#include +#include +#include + +KALEIDOSCOPE_INIT_PLUGINS(LEDControl, + BootGreetingEffect + LEDOff); + +void setup() { + Kaleidoscope.setup(); + + //Butterfly key + BootGreetingEffect.hue = 90; + + Kaleidoscope.setup(); +} +``` + +## Plugin methods + +The plugin provides the `BootGreetingEffect` object, with the following methods and +properties: + +### `.search_key` + +> Set the key in the current keymap that should be activated with the pulsing +> LED on startup. The plugin will search from the top left to the bottom right +> of the keyboard, row by row, to find this key. The first matching key will +> be selected. +> +> Defaults to `Key_LEDEffectNext` + +### `.key_row` + +> This is an optional override to explicitly set the selected key by exact row +> and column. This number is 0-indexed, so the top row is 0, the second row is +> 1, etc. Must set `.key_col` property for this feature to be enabled. + +### `.key_col` + +> This is an optional override to explicitly set the selected key by exact row +> and column. This number is 0-indexed, so the left-most column is 0, the +> second column is 1, etc. Must set `.key_row` property for this feature to +> be enabled. + +### `.timeout` + +> This property specifies the timeout (in milliseconds) for the effect to last. +> When the keyboard is first connected, the pulsing LED effect will last for +> this duration before turning off. +> +> Defaults to `9200` ms. + +### `.hue` + +> This property sets the color hue that the LED pulsing effect. +> +> The default is `170`, which is a blue color. + +## Dependencies + +* [Kaleidoscope-LEDControl](https://github.com/keyboardio/Kaleidoscope-LEDControl) diff --git a/examples/LEDEffect-BootGreeting/LEDEffect-BootGreeting.ino b/examples/LEDEffect-BootGreeting/LEDEffect-BootGreeting.ino index a539a3c0..a7ad3224 100644 --- a/examples/LEDEffect-BootGreeting/LEDEffect-BootGreeting.ino +++ b/examples/LEDEffect-BootGreeting/LEDEffect-BootGreeting.ino @@ -16,10 +16,9 @@ */ #include +#include #include -#include "LED-Off.h" - // *INDENT-OFF* const Key keymaps[][ROWS][COLS] PROGMEM = { [0] = KEYMAP_STACKED diff --git a/src/Kaleidoscope-LEDEffect-BootGreeting.h b/src/Kaleidoscope-LEDEffect-BootGreeting.h index ebf9facb..a08ef1c9 100644 --- a/src/Kaleidoscope-LEDEffect-BootGreeting.h +++ b/src/Kaleidoscope-LEDEffect-BootGreeting.h @@ -17,29 +17,4 @@ #pragma once -#include "Kaleidoscope-LEDControl.h" - -namespace kaleidoscope { -class BootGreetingEffect : public kaleidoscope::Plugin { - public: - BootGreetingEffect(void) {} - BootGreetingEffect(byte, byte); - - static byte key_row; - static byte key_col; - static Key search_key; - static uint8_t hue; - static uint16_t timeout; - - EventHandlerResult afterEachCycle(); - - private: - static void findLed(void); - static bool done_; - static byte row_; - static byte col_; - static uint16_t start_time; -}; -} - -extern kaleidoscope::BootGreetingEffect BootGreetingEffect; +#include "kaleidoscope/plugin/LEDEffect-BootGreeting.h" diff --git a/src/Kaleidoscope-LEDEffect-BootGreeting.cpp b/src/kaleidoscope/plugin/LEDEffect-BootGreeting.cpp similarity index 96% rename from src/Kaleidoscope-LEDEffect-BootGreeting.cpp rename to src/kaleidoscope/plugin/LEDEffect-BootGreeting.cpp index 6a6ccf19..ac435c0f 100644 --- a/src/Kaleidoscope-LEDEffect-BootGreeting.cpp +++ b/src/kaleidoscope/plugin/LEDEffect-BootGreeting.cpp @@ -16,9 +16,9 @@ */ #include "Kaleidoscope-LEDEffect-BootGreeting.h" -#include "LEDUtils.h" namespace kaleidoscope { +namespace plugin { bool BootGreetingEffect::done_ = false; byte BootGreetingEffect::row_; @@ -88,6 +88,7 @@ EventHandlerResult BootGreetingEffect::afterEachCycle() { return EventHandlerResult::OK; } +} } -kaleidoscope::BootGreetingEffect BootGreetingEffect; +kaleidoscope::plugin::BootGreetingEffect BootGreetingEffect; diff --git a/src/kaleidoscope/plugin/LEDEffect-BootGreeting.h b/src/kaleidoscope/plugin/LEDEffect-BootGreeting.h new file mode 100644 index 00000000..aeeae501 --- /dev/null +++ b/src/kaleidoscope/plugin/LEDEffect-BootGreeting.h @@ -0,0 +1,47 @@ +/* -*- mode: c++ -*- + * Kaleidoscope-LEDEffect-BootGreeting -- Small greeting at boot time + * Copyright (C) 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 . + */ + +#pragma once + +#include "Kaleidoscope-LEDControl.h" + +namespace kaleidoscope { +namespace plugin { +class BootGreetingEffect : public kaleidoscope::Plugin { + public: + BootGreetingEffect(void) {} + BootGreetingEffect(byte, byte); + + static byte key_row; + static byte key_col; + static Key search_key; + static uint8_t hue; + static uint16_t timeout; + + EventHandlerResult afterEachCycle(); + + private: + static void findLed(void); + static bool done_; + static byte row_; + static byte col_; + static uint16_t start_time; +}; +} +} + +extern kaleidoscope::plugin::BootGreetingEffect BootGreetingEffect;