From e01c7106f63df6f63595eddf9fe7cacefd510017 Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Fri, 30 Mar 2018 15:44:18 +0200 Subject: [PATCH] Add Rainbow stalker effect There already exist 2 rainbow LED effects, this adds a third, using the LED-Stalker effect. When you press a key, the LED on that key will cycle through all the colors of the rainbow, independent of the colors of other keys. --- README.md | 4 ++++ src/Kaleidoscope/LED-Stalker.cpp | 13 +++++++++++++ src/Kaleidoscope/LED-Stalker.h | 7 +++++++ 3 files changed, 24 insertions(+) diff --git a/README.md b/README.md index dece8113..debffaa6 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,10 @@ The plugin provides the following effects: > 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) diff --git a/src/Kaleidoscope/LED-Stalker.cpp b/src/Kaleidoscope/LED-Stalker.cpp index 42c043d4..050fd28c 100644 --- a/src/Kaleidoscope/LED-Stalker.cpp +++ b/src/Kaleidoscope/LED-Stalker.cpp @@ -127,6 +127,19 @@ cRGB BlazingTrail::compute(uint8_t *step) { return color; } +// Rainbow +Rainbow::Rainbow(void) { +} + +cRGB Rainbow::compute(uint8_t *step) { + if (*step > 0) + *step -= 1; + else + *step = 0; + + return hsvToRgb(255 - *step, 255, *step); +} + } } diff --git a/src/Kaleidoscope/LED-Stalker.h b/src/Kaleidoscope/LED-Stalker.h index 99caed29..6cf9b464 100644 --- a/src/Kaleidoscope/LED-Stalker.h +++ b/src/Kaleidoscope/LED-Stalker.h @@ -67,6 +67,13 @@ class BlazingTrail : public StalkerEffect::ColorComputer { cRGB compute(uint8_t *step) final; }; +class Rainbow : public StalkerEffect::ColorComputer { + public: + Rainbow(void); + + cRGB compute(uint8_t *step) final; +}; + } }