From 075823220a757ecb523b7760157d093cc01e54e7 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Thu, 30 Apr 2020 06:51:02 +0200 Subject: [PATCH] Added effect diamond. --- include/effect_diamond.h | 11 +++++++++++ src/effect_diamond.cpp | 14 ++++++++++++++ src/effects.cpp | 4 +++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 include/effect_diamond.h create mode 100644 src/effect_diamond.cpp diff --git a/include/effect_diamond.h b/include/effect_diamond.h new file mode 100644 index 0000000..f24ac0a --- /dev/null +++ b/include/effect_diamond.h @@ -0,0 +1,11 @@ +#pragma once +#include "Effect.h" + +class DiamondEffect : public Effect { +private: + Window* window = &Window::window_with_clock; +public: + void loop(uint16_t ms) override; + bool can_be_shown_with_clock() override; + String get_name() override { return "diamond"; } +}; diff --git a/src/effect_diamond.cpp b/src/effect_diamond.cpp new file mode 100644 index 0000000..eff96f9 --- /dev/null +++ b/src/effect_diamond.cpp @@ -0,0 +1,14 @@ +#include "effect_diamond.h" +#include "my_fastled.h" + +void DiamondEffect::loop(uint16_t ms) { + for (int x=0; xwidth; x++) { + for (int y=0; yheight; y++) { + uint8_t distance = abs(window->height/2 - y) + abs(window->width/2 - x); + CRGB col = CHSV(distance*8 - (millis()>>5)%255, 255, 255); + window->setPixel(x, y, &col); + } + } +} + +bool DiamondEffect::can_be_shown_with_clock() { return true; } diff --git a/src/effects.cpp b/src/effects.cpp index 2299031..08837ad 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -24,6 +24,7 @@ #include "effect_blur2d.h" #include "effect_tv_static.h" #include "effect_lightspeed.h" +#include "effect_diamond.h" Effect* current_effect; @@ -64,8 +65,9 @@ EffectEntry effects[] = { /* 29 */ {"koopa", 0, [](){ return new AnimationEffect("/koopa.pia"); }}, /* 30 */ {"cake", 0, [](){ return new AnimationEffect("/cake.pia"); }}, /* 31 */ {"kid", 0, [](){ return new AnimationEffect("/kid.pia"); }}, + /* 32 */ {"diamond", true, [](){ return new DiamondEffect(); }}, }; -const uint8_t effects_size = 32; +const uint8_t effects_size = 33; Effect* select_effect(const char* name) {