From 57815cb3bf07a6ab04c2bbc599bc4293de52e55f Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Wed, 5 Jun 2019 06:27:07 +0200 Subject: [PATCH] Joined SingleDynamicEffect and MultiDynamicEffect into one file and finally got different timings for both classes to work. --- ...fect_single_dynamic.h => effect_dynamic.h} | 13 ++++--- include/effect_multi_dynamic.h | 12 ------ src/effect_dynamic.cpp | 36 ++++++++++++++++++ src/effect_multi_dynamic.cpp | 12 ------ src/effect_single_dynamic.cpp | 38 ------------------- src/effects.cpp | 12 +++--- 6 files changed, 50 insertions(+), 73 deletions(-) rename include/{effect_single_dynamic.h => effect_dynamic.h} (76%) delete mode 100644 include/effect_multi_dynamic.h create mode 100644 src/effect_dynamic.cpp delete mode 100644 src/effect_multi_dynamic.cpp delete mode 100644 src/effect_single_dynamic.cpp diff --git a/include/effect_single_dynamic.h b/include/effect_dynamic.h similarity index 76% rename from include/effect_single_dynamic.h rename to include/effect_dynamic.h index 8356c84..b663419 100644 --- a/include/effect_single_dynamic.h +++ b/include/effect_dynamic.h @@ -1,6 +1,4 @@ -#ifndef effect_single_dynamic_H -#define effect_single_dynamic_H - +#pragma once #include "Effect.h" #include "config.h" @@ -8,15 +6,18 @@ class SingleDynamicEffect : public Effect { protected: static const int factor = 2; static const int tile_count = LED_WIDTH/factor * LED_HEIGHT/factor; - int loopTime = 200; CRGB tiles[tile_count]; CRGB old_tiles[tile_count]; uint8_t blend = 0; public: SingleDynamicEffect(); void init(); - virtual void update(); boolean can_be_shown_with_clock(); virtual void loop(); + void draw(); +}; + +class MultiDynamicEffect : public SingleDynamicEffect { + public: + void loop(); }; -#endif diff --git a/include/effect_multi_dynamic.h b/include/effect_multi_dynamic.h deleted file mode 100644 index 92d247d..0000000 --- a/include/effect_multi_dynamic.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef effect_multi_dynamic_H -#define effect_multi_dynamic_H - -#include "effect_single_dynamic.h" - -class MultiDynamicEffect : public SingleDynamicEffect { - public: - MultiDynamicEffect(); - void update(); -}; - -#endif diff --git a/src/effect_dynamic.cpp b/src/effect_dynamic.cpp new file mode 100644 index 0000000..66901f0 --- /dev/null +++ b/src/effect_dynamic.cpp @@ -0,0 +1,36 @@ +#include "effect_dynamic.h" +#include "functions.h" +#include "config.h" + +SingleDynamicEffect::SingleDynamicEffect() { + init(); +} + +void SingleDynamicEffect::init() { + for (int i=0; idraw(); +} + +void SingleDynamicEffect::draw() { + for (int x=0; xdraw(); +} diff --git a/src/effect_multi_dynamic.cpp b/src/effect_multi_dynamic.cpp deleted file mode 100644 index 3c93a93..0000000 --- a/src/effect_multi_dynamic.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "effect_multi_dynamic.h" -#include "effect_single_dynamic.h" -#include "config.h" - -MultiDynamicEffect::MultiDynamicEffect() { - init(); - loopTime = EFFECT_MULTI_DYNAMIC_LOOP_TIME; -} - -void MultiDynamicEffect::update() { - for (int i=0; i* effects; SimpleList* cycle_effects; @@ -26,9 +26,9 @@ BigClockEffect effect_big_clock; //ClockEffect effect_clock; <-- generated as global variable in effects.h BellEffect effect_bell; StaticEffect effect_off(CRGB(0x000000)); -AnimationEffect effect_anim_koopa(&animation_koopa, CRGB(0x000000), 0, 0); -AnimationEffect effect_anim_couple_rain(&animation_couple_rain, CRGB(0x000000), -8, -16); -AnimationEffect effect_anim_heart(&animation_heart, CRGB(0x000000), 0, 0); +AnimationEffect effect_anim_koopa(&animation_koopa, new CRGB(0x000000), 0, 0); +AnimationEffect effect_anim_couple_rain(&animation_couple_rain, new CRGB(0x000000), -8, -16); +AnimationEffect effect_anim_heart(&animation_heart, new CRGB(0x000000), 0, 0); SingleDynamicEffect effect_single_dynamic; MultiDynamicEffect effect_multi_dynamic; MatrixEffect effect_matrix; @@ -37,6 +37,7 @@ TwirlEffect effect_twirl; ConfettiEffect effect_confetti; SnakeEffect effect_snake; FireEffect effect_fire; +FireworkEffect effect_firework; Effect* current_effect; @@ -60,6 +61,7 @@ void setup_effects() { effects->add((EffectEntry){"confetti", (Effect *)&effect_confetti}); effects->add((EffectEntry){"snake", (Effect *)&effect_snake}); effects->add((EffectEntry){"fire", (Effect *)&effect_fire}); + effects->add((EffectEntry){"firework", (Effect *)&effect_firework}); cycle_effects->add(&effect_sinematrix3); cycle_effects->add(&effect_single_dynamic);