diff --git a/README.md b/README.md index ef117e63..6e5c3cdc 100644 --- a/README.md +++ b/README.md @@ -5,85 +5,4 @@ [travis:image]: https://travis-ci.org/keyboardio/Kaleidoscope-LED-Stalker.svg?branch=master [travis:status]: https://travis-ci.org/keyboardio/Kaleidoscope-LED-Stalker -The `StalkerEffect` plugin provides an interesting new typing experience: the -LEDs light up as you tap keys and play one of the selected effects: a haunting -trail of ghostly white lights, or a blazing trail of fire. - -## Using the plugin - -To use the plugin, one needs to include the header and select the effect. - -```c++ -#include -#include -#include - -KALEIDOSCOPE_INIT_PLUGINS(LEDControl, StalkerEffect); - -void setup (){ - Kaleidoscope.setup(); - - StalkerEffect.variant = STALKER(Haunt, (CRGB(0, 128, 0))); - StalkerEffect.activate(); -} -``` - -It is recommended to place the activation of the plugin (the `Kaleidoscope.use` -call) as early as possible, so the plugin can catch all relevant key presses. -The configuration can happen at any time and should use the `STALKER` macro to -do so. - -## Plugin methods - -The plugin provides the `StalkerEffect` object, which has the following -properties: - -### `.variant` - -> Set the effect to use with the plugin. See below for a list. -> -> It is recommended to use the `STALKER` macro to declare the effect itself. - -### `.step_length` - -> The length - in milliseconds - of each step of the animation. An animation -> lasts 256 steps. -> -> Defaults to 50. - -## Plugin helpers - -### `STALKER(effect, params)` - -> Returns an effect, to be used to assign a value the `.variant` property of the -> `StalkerEffect` object. Any arguments given to the macro are passed on -> to the effect. If the effect takes no arguments, use an empty `params` list. - -## Plugin effects - -The plugin provides the following effects: - -### `Haunt([color])` - -> A ghostly haunt effect, that trails the key taps with a ghostly white color -> (or any other color, if specified). Use the `CRGB(r,g,b)` macro to specify the -> color, if you want something else than the ghostly white. - -### `BlazingTrail()` - -> A blazing trail of fire will follow our fingers! - -### `Rainbow()` - -> Leave a rainbow behind, where your fingers has been! - -## Dependencies - -* [Kaleidoscope-LEDControl](https://github.com/keyboardio/Kaleidoscope-LEDControl) - -## Further reading - -Starting from the [example][plugin:example] is the recommended way of getting -started with the plugin. - - [plugin:example]: https://github.com/keyboardio/Kaleidoscope-LED-Stalker/blob/master/examples/LED-Stalker/LED-Stalker.ino +See [doc/plugin/LED-Stalker.md](doc/plugin/LED-Stalker.md) for documentation. diff --git a/doc/plugin/LED-Stalker.md b/doc/plugin/LED-Stalker.md new file mode 100644 index 00000000..20b9eda5 --- /dev/null +++ b/doc/plugin/LED-Stalker.md @@ -0,0 +1,84 @@ +# Kaleidoscope-LED-Stalker + +The `StalkerEffect` plugin provides an interesting new typing experience: the +LEDs light up as you tap keys and play one of the selected effects: a haunting +trail of ghostly white lights, or a blazing trail of fire. + +## Using the plugin + +To use the plugin, one needs to include the header and select the effect. + +```c++ +#include +#include +#include + +KALEIDOSCOPE_INIT_PLUGINS(LEDControl, StalkerEffect); + +void setup (){ + Kaleidoscope.setup(); + + StalkerEffect.variant = STALKER(Haunt, (CRGB(0, 128, 0))); + StalkerEffect.activate(); +} +``` + +It is recommended to place the activation of the plugin (the `Kaleidoscope.use` +call) as early as possible, so the plugin can catch all relevant key presses. +The configuration can happen at any time and should use the `STALKER` macro to +do so. + +## Plugin methods + +The plugin provides the `StalkerEffect` object, which has the following +properties: + +### `.variant` + +> Set the effect to use with the plugin. See below for a list. +> +> It is recommended to use the `STALKER` macro to declare the effect itself. + +### `.step_length` + +> The length - in milliseconds - of each step of the animation. An animation +> lasts 256 steps. +> +> Defaults to 50. + +## Plugin helpers + +### `STALKER(effect, params)` + +> Returns an effect, to be used to assign a value the `.variant` property of the +> `StalkerEffect` object. Any arguments given to the macro are passed on +> to the effect. If the effect takes no arguments, use an empty `params` list. + +## Plugin effects + +The plugin provides the following effects: + +### `Haunt([color])` + +> A ghostly haunt effect, that trails the key taps with a ghostly white color +> (or any other color, if specified). Use the `CRGB(r,g,b)` macro to specify the +> color, if you want something else than the ghostly white. + +### `BlazingTrail()` + +> A blazing trail of fire will follow our fingers! + +### `Rainbow()` + +> Leave a rainbow behind, where your fingers has been! + +## Dependencies + +* [Kaleidoscope-LEDControl](https://github.com/keyboardio/Kaleidoscope-LEDControl) + +## Further reading + +Starting from the [example][plugin:example] is the recommended way of getting +started with the plugin. + + [plugin:example]: https://github.com/keyboardio/Kaleidoscope-LED-Stalker/blob/master/examples/LED-Stalker/LED-Stalker.ino diff --git a/examples/LED-Stalker/LED-Stalker.ino b/examples/LED-Stalker/LED-Stalker.ino index 5362e971..050fcfe8 100644 --- a/examples/LED-Stalker/LED-Stalker.ino +++ b/examples/LED-Stalker/LED-Stalker.ino @@ -18,7 +18,6 @@ #include #include #include -#include "LED-Off.h" // *INDENT-OFF* const Key keymaps[][ROWS][COLS] PROGMEM = { diff --git a/src/Kaleidoscope-LED-Stalker.h b/src/Kaleidoscope-LED-Stalker.h index 042d66b0..5eabcc3f 100644 --- a/src/Kaleidoscope-LED-Stalker.h +++ b/src/Kaleidoscope-LED-Stalker.h @@ -17,4 +17,4 @@ #pragma once -#include +#include diff --git a/src/Kaleidoscope/LED-Stalker.cpp b/src/kaleidoscope/plugin/LED-Stalker.cpp similarity index 97% rename from src/Kaleidoscope/LED-Stalker.cpp rename to src/kaleidoscope/plugin/LED-Stalker.cpp index 22681a4f..4f64913c 100644 --- a/src/Kaleidoscope/LED-Stalker.cpp +++ b/src/kaleidoscope/plugin/LED-Stalker.cpp @@ -16,9 +16,9 @@ */ #include -#include namespace kaleidoscope { +namespace plugin { uint8_t StalkerEffect::map_[ROWS][COLS]; StalkerEffect::ColorComputer *StalkerEffect::variant; @@ -136,8 +136,9 @@ cRGB Rainbow::compute(uint8_t *step) { return hsvToRgb(255 - *step, 255, *step); } +} } } -kaleidoscope::StalkerEffect StalkerEffect; +kaleidoscope::plugin::StalkerEffect StalkerEffect; diff --git a/src/Kaleidoscope/LED-Stalker.h b/src/kaleidoscope/plugin/LED-Stalker.h similarity index 91% rename from src/Kaleidoscope/LED-Stalker.h rename to src/kaleidoscope/plugin/LED-Stalker.h index e43d6354..029895fa 100644 --- a/src/Kaleidoscope/LED-Stalker.h +++ b/src/kaleidoscope/plugin/LED-Stalker.h @@ -20,9 +20,10 @@ #include #include -#define STALKER(v, ...) ({static kaleidoscope::stalker::v _effect __VA_ARGS__; &_effect;}) +#define STALKER(v, ...) ({static kaleidoscope::plugin::stalker::v _effect __VA_ARGS__; &_effect;}) namespace kaleidoscope { +namespace plugin { class StalkerEffect : public LEDMode { public: class ColorComputer { @@ -72,7 +73,8 @@ class Rainbow : public StalkerEffect::ColorComputer { cRGB compute(uint8_t *step) final; }; +} } } -extern kaleidoscope::StalkerEffect StalkerEffect; +extern kaleidoscope::plugin::StalkerEffect StalkerEffect;