From e6f7aef63ba29f282354a33ab4df8271e8531be7 Mon Sep 17 00:00:00 2001 From: Aaron Christianson Date: Wed, 30 May 2018 13:53:07 +0200 Subject: [PATCH 1/3] added methods to control delay time and updated the README --- README.md | 10 +++++++--- src/Kaleidoscope-LEDEffect-Rainbow.cpp | 8 ++++++++ src/Kaleidoscope-LEDEffect-Rainbow.h | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 652f986e..8a92239e 100644 --- a/README.md +++ b/README.md @@ -25,18 +25,22 @@ both!) of the effects: #include #include -KALEIDOSCOPE_INIT_PLUGINS(LEDRainbowEffect, LEDRainbowWaveEffect); void setup() { Kaleidoscope.setup(); + Kaleidoscope.use(&LEDRainbowWaveEffect, &LEDDigitalRainEffect); + + LEDRainbowEffect.brightness(150); + LEDRainbowWaveEffect.brightness(150); + LEDRainbowWaveEffect.delay(50); } ``` ## Plugin methods The plugin provides two objects: `LEDRainbowEffect`, and `LEDRainbowWaveEffect`, -neither of which have any public methods or properties, outside of those -provided by all LED modes. +both of which provide methods to set the delay time (animation speed) +and effect brightness, called `delay` and `brightness` respectively. ## Dependencies diff --git a/src/Kaleidoscope-LEDEffect-Rainbow.cpp b/src/Kaleidoscope-LEDEffect-Rainbow.cpp index 5fdbcc5f..320dbe67 100644 --- a/src/Kaleidoscope-LEDEffect-Rainbow.cpp +++ b/src/Kaleidoscope-LEDEffect-Rainbow.cpp @@ -23,6 +23,10 @@ void LEDRainbowEffect::brightness(byte brightness) { rainbow_value = brightness; } +void LEDRainbowEffect::delay(byte delay) { + rainbow_update_delay = delay; +} + // --------- @@ -51,6 +55,10 @@ void LEDRainbowWaveEffect::update(void) { void LEDRainbowWaveEffect::brightness(byte brightness) { rainbow_value = brightness; } + +void LEDRainbowWaveEffect::delay(byte delay) { + rainbow_update_delay = delay; +} } kaleidoscope::LEDRainbowEffect LEDRainbowEffect; diff --git a/src/Kaleidoscope-LEDEffect-Rainbow.h b/src/Kaleidoscope-LEDEffect-Rainbow.h index e3a66210..0c01c5a8 100644 --- a/src/Kaleidoscope-LEDEffect-Rainbow.h +++ b/src/Kaleidoscope-LEDEffect-Rainbow.h @@ -9,6 +9,7 @@ class LEDRainbowEffect : public LEDMode { LEDRainbowEffect(void) {} void brightness(byte); + void delay(byte); void update(void) final; private: @@ -28,6 +29,7 @@ class LEDRainbowWaveEffect : public LEDMode { LEDRainbowWaveEffect(void) {} void brightness(byte); + void delay(byte); void update(void) final; private: From 834d75fc7d594042ad1f588410cae8271e3f6019 Mon Sep 17 00:00:00 2001 From: Aaron Christianson Date: Wed, 30 May 2018 14:05:41 +0200 Subject: [PATCH 2/3] added methods to control delay time and updated the README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a92239e..13c00172 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,10 @@ both!) of the effects: #include #include +KALEIDOSCOPE_INIT_PLUGINS(LEDRainbowEffect, LEDRainbowWaveEffect); void setup() { Kaleidoscope.setup(); - Kaleidoscope.use(&LEDRainbowWaveEffect, &LEDDigitalRainEffect); LEDRainbowEffect.brightness(150); LEDRainbowWaveEffect.brightness(150); From a1fadd9f752f82d726bc467bacfa38504670b8ef Mon Sep 17 00:00:00 2001 From: Aaron Christianson Date: Wed, 30 May 2018 16:05:32 +0200 Subject: [PATCH 3/3] added changes suggested in the PR discussion. --- README.md | 12 ++++++++++-- src/Kaleidoscope-LEDEffect-Rainbow.cpp | 4 ++-- src/Kaleidoscope-LEDEffect-Rainbow.h | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 13c00172..3afdbfd7 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,16 @@ void setup() { ## Plugin methods The plugin provides two objects: `LEDRainbowEffect`, and `LEDRainbowWaveEffect`, -both of which provide methods to set the delay time (animation speed) -and effect brightness, called `delay` and `brightness` respectively. +both of which provide the following methods: + +### `.brightness(brightness)` + +Sets the LED brightness for the effect. + +### `.update_delay(delay)` + +Sets the number of miliseconds between effect updates. +Smaller number = faster rainbows. ## Dependencies diff --git a/src/Kaleidoscope-LEDEffect-Rainbow.cpp b/src/Kaleidoscope-LEDEffect-Rainbow.cpp index 320dbe67..a8a4f21e 100644 --- a/src/Kaleidoscope-LEDEffect-Rainbow.cpp +++ b/src/Kaleidoscope-LEDEffect-Rainbow.cpp @@ -23,7 +23,7 @@ void LEDRainbowEffect::brightness(byte brightness) { rainbow_value = brightness; } -void LEDRainbowEffect::delay(byte delay) { +void LEDRainbowEffect::update_delay(byte delay) { rainbow_update_delay = delay; } @@ -56,7 +56,7 @@ void LEDRainbowWaveEffect::brightness(byte brightness) { rainbow_value = brightness; } -void LEDRainbowWaveEffect::delay(byte delay) { +void LEDRainbowWaveEffect::updat_delay(byte delay) { rainbow_update_delay = delay; } } diff --git a/src/Kaleidoscope-LEDEffect-Rainbow.h b/src/Kaleidoscope-LEDEffect-Rainbow.h index 0c01c5a8..bd87d998 100644 --- a/src/Kaleidoscope-LEDEffect-Rainbow.h +++ b/src/Kaleidoscope-LEDEffect-Rainbow.h @@ -9,7 +9,7 @@ class LEDRainbowEffect : public LEDMode { LEDRainbowEffect(void) {} void brightness(byte); - void delay(byte); + void update_delay(byte); void update(void) final; private: @@ -29,7 +29,7 @@ class LEDRainbowWaveEffect : public LEDMode { LEDRainbowWaveEffect(void) {} void brightness(byte); - void delay(byte); + void update_delay(byte); void update(void) final; private: