From fa5f1c8816af46eb12d242f5e03fc0fd3d2ec637 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Wed, 25 Sep 2019 06:26:27 +0200 Subject: [PATCH] Added effect blur2d --- include/effect_blur2d.h | 16 ++++++++++++++++ src/effect_blur2d.cpp | 31 +++++++++++++++++++++++++++++++ src/effects.cpp | 2 ++ 3 files changed, 49 insertions(+) create mode 100644 include/effect_blur2d.h create mode 100644 src/effect_blur2d.cpp diff --git a/include/effect_blur2d.h b/include/effect_blur2d.h new file mode 100644 index 0000000..3ca1895 --- /dev/null +++ b/include/effect_blur2d.h @@ -0,0 +1,16 @@ +#pragma once + +#include "prototypes.h" +#include "functions.h" +#include "Effect.h" + +class Blur2DEffect : public Effect { +private: + Window* window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6); +public: + ~Blur2DEffect(); + boolean supports_window = true; + boolean can_be_shown_with_clock(); + void loop(); +}; + diff --git a/src/effect_blur2d.cpp b/src/effect_blur2d.cpp new file mode 100644 index 0000000..6e756f1 --- /dev/null +++ b/src/effect_blur2d.cpp @@ -0,0 +1,31 @@ +#include "effect_blur2d.h" + +boolean Blur2DEffect::can_be_shown_with_clock() { + return true; +} + +void Blur2DEffect::loop() { + uint8_t blur_amount = dim8_raw(beatsin8(3, 64, 192)); + window->blur(blur_amount); + + uint8_t x1 = beatsin8(5, 0, window->width-1); + uint8_t y1 = beatsin8(8, 0, window->height-1); + + uint8_t x2 = beatsin8(8, 0, window->width-1); + uint8_t y2 = beatsin8(3, 0, window->height-1); + + uint8_t x3 = beatsin8(4, 0, window->width-1); + uint8_t y3 = beatsin8(7, 0, window->height-1); + + uint16_t ms = millis(); + CRGB c1 = CHSV(ms / 29, 200, 255); + CRGB c2 = CHSV(ms / 41, 200, 255); + CRGB c3 = CHSV(ms / 73, 200, 255); + window->addPixelColor(x1, y1, &c1); + window->addPixelColor(x2, y2, &c2); + window->addPixelColor(x3, y3, &c3); +} + +Blur2DEffect::~Blur2DEffect() { + delete window; +} diff --git a/src/effects.cpp b/src/effects.cpp index b6ed067..a471d0e 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -20,6 +20,7 @@ #include "effect_dvd.h" #include "effect_analogclock.h" #include "effect_sines.h" +#include "effect_blur2d.h" Effect* current_effect; @@ -55,6 +56,7 @@ Effect* select_effect(uint32_t code) { case 24: case 0x8325C1DF /* dvd */ : return new DvdEffect(); case 25: case 0x8CA97519 /* analog_clock */ : return new AnalogClockEffect(); case 26: case 0xADB18CC5 /* sines */ : return new SinesEffect(); + case 27: case 0x0407881E /* blur2d */ : return new Blur2DEffect(); default : return NULL; }; }