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) {