From f1821b0b856fbf4c140b3eec525795517b83d799 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Wed, 19 Jun 2019 22:17:10 +0200 Subject: [PATCH] New Effect: RandomConfettiEffect --- include/effect_confetti.h | 8 ++++++++ src/effect_confetti.cpp | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/effect_confetti.h b/include/effect_confetti.h index 4009e73..cff7210 100644 --- a/include/effect_confetti.h +++ b/include/effect_confetti.h @@ -5,8 +5,16 @@ #include "my_fastled.h" class ConfettiEffect : public Effect { +protected: + virtual CRGB _getColor(); +public: void loop(); boolean can_be_shown_with_clock(); }; +class RandomConfettiEffect : public ConfettiEffect { +protected: + CRGB _getColor() override; +}; + #endif diff --git a/src/effect_confetti.cpp b/src/effect_confetti.cpp index 7c9128a..e48cebf 100644 --- a/src/effect_confetti.cpp +++ b/src/effect_confetti.cpp @@ -6,9 +6,17 @@ void ConfettiEffect::loop() { window->fadeToBlackBy(3); for (int i=0; iaddPixelColor(random16(LED_COUNT), &color); } } +CRGB ConfettiEffect::_getColor() { + return CHSV(baseHue + random8(64), 255, 255); +} + +CRGB RandomConfettiEffect::_getColor() { + return CHSV(random8(), 255, 255); +} + boolean ConfettiEffect::can_be_shown_with_clock() { return true; };