New Effect: RandomConfettiEffect

This commit is contained in:
Fabian Schlenz 2019-06-19 22:17:10 +02:00
parent 41af01ee0b
commit f1821b0b85
2 changed files with 17 additions and 1 deletions

View File

@ -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

View File

@ -6,9 +6,17 @@
void ConfettiEffect::loop() {
window->fadeToBlackBy(3);
for (int i=0; i<EFFECT_CONFETTI_PIXELS_PER_LOOP; i++) {
CRGB color(CHSV(baseHue + random8(64), 200, 255));
CRGB color = _getColor();
window->addPixelColor(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; };