Added effect "confetti". Closes #16.
This commit is contained in:
parent
b452fff812
commit
711d028e90
12
include/effect_confetti.h
Normal file
12
include/effect_confetti.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef effect_confetti_H
|
||||
#define effect_confetti_H
|
||||
|
||||
#include "Effect.h"
|
||||
#include "my_fastled.h"
|
||||
|
||||
class ConfettiEffect : public Effect {
|
||||
void loop();
|
||||
boolean can_be_shown_with_clock();
|
||||
};
|
||||
|
||||
#endif
|
@ -13,6 +13,8 @@ void setPixel(int i, CRGB color);
|
||||
|
||||
void setPixel(Window win, int x, int y, CRGB color);
|
||||
|
||||
void addPixelColor(int i, CRGB color);
|
||||
|
||||
void clear(Window window, CRGB color);
|
||||
|
||||
void clear(Window window);
|
||||
|
10
src/effect_confetti.cpp
Normal file
10
src/effect_confetti.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "effect_confetti.h"
|
||||
#include "config.h"
|
||||
#include "functions.h"
|
||||
|
||||
void ConfettiEffect::loop() {
|
||||
fadeToBlackBy(leds, LED_COUNT, 1);
|
||||
addPixelColor(random16(LED_COUNT), CHSV(random8(), 200, 255));
|
||||
}
|
||||
|
||||
boolean ConfettiEffect::can_be_shown_with_clock() { return true; };
|
@ -13,6 +13,7 @@
|
||||
#include "effect_matrix.h"
|
||||
#include "effect_twirl.h"
|
||||
#include "effect_cycle.h"
|
||||
#include "effect_confetti.h"
|
||||
|
||||
SimpleList<EffectEntry>* effects;
|
||||
SimpleList<Effect*>* cycle_effects;
|
||||
@ -31,6 +32,7 @@ MultiDynamicEffect effect_multi_dynamic;
|
||||
MatrixEffect effect_matrix;
|
||||
CycleEffect effect_cycle;
|
||||
TwirlEffect effect_twirl;
|
||||
ConfettiEffect effect_confetti;
|
||||
|
||||
Effect* current_effect;
|
||||
|
||||
@ -51,11 +53,13 @@ void setup_effects() {
|
||||
effects->add((EffectEntry){"cycle", (Effect *)&effect_cycle});
|
||||
effects->add((EffectEntry){"twirl", (Effect *)&effect_twirl});
|
||||
effects->add((EffectEntry){"heart", (Effect*)&effect_anim_heart});
|
||||
effects->add((EffectEntry){"confetti", (Effect *)&effect_confetti});
|
||||
|
||||
cycle_effects->add(&effect_sinematrix3);
|
||||
cycle_effects->add(&effect_single_dynamic);
|
||||
cycle_effects->add(&effect_multi_dynamic);
|
||||
cycle_effects->add(&effect_matrix);
|
||||
cycle_effects->add(&effect_confetti);
|
||||
|
||||
current_effect = &effect_cycle;
|
||||
}
|
||||
|
@ -19,8 +19,6 @@ int XYsafe(int x, int y) {
|
||||
return y*LED_WIDTH+x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setPixel(int x, int y, CRGB color) {
|
||||
if ( x >= LED_WIDTH) return;
|
||||
if ( y >= LED_HEIGHT) return;
|
||||
@ -49,6 +47,10 @@ void setPixel(Window win, int x, int y, CRGB color) {
|
||||
setPixel(win.x + x, win.y + y, color);
|
||||
}
|
||||
|
||||
void addPixelColor(int i, CRGB color) {
|
||||
leds[i] += color;
|
||||
}
|
||||
|
||||
void clear(Window window, CRGB color) {
|
||||
for ( byte y = 0; y < window.h; y++) {
|
||||
for ( byte x = 0; x < window.w; x++) {
|
||||
|
@ -22,14 +22,14 @@ long loop_started_at = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(74880);
|
||||
Serial.println("Core * Starting");
|
||||
LOGln("Core * Starting");
|
||||
setup_effects();
|
||||
wifi_setup();
|
||||
ota_setup();
|
||||
fastled_setup();
|
||||
ntpClient.begin();
|
||||
mqtt_setup();
|
||||
Serial.println("Core * Setup complete");
|
||||
LOGln("Core * Setup complete");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
Loading…
Reference in New Issue
Block a user