From 77fdba213a32e243004df973728c867f94bd3b16 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Wed, 19 Jun 2019 22:29:11 +0200 Subject: [PATCH] I'm tired and forgot to add two files to previous commits. :-/ --- include/effect_dynamic.h | 8 ++++++++ src/Window.cpp | 21 +++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/include/effect_dynamic.h b/include/effect_dynamic.h index 0983479..8fdaebd 100644 --- a/include/effect_dynamic.h +++ b/include/effect_dynamic.h @@ -21,3 +21,11 @@ class MultiDynamicEffect : public SingleDynamicEffect { public: void loop(); }; + +class BigDynamicEffect : public Effect { +private: + Window* window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6); +public: + void loop(); + ~BigDynamicEffect(); +}; diff --git a/src/Window.cpp b/src/Window.cpp index 92b19c7..b85d0f7 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -11,6 +11,11 @@ void Window::setPixel(uint8_t x, uint8_t y, CRGB* color) { leds[this->coordsToGlobalIndex(x, y)] = *color; } +void Window::raisePixel(uint8_t x, uint8_t y, CRGB* color) { + if (x>=this->width || y>=this->height) return; + leds[this->coordsToGlobalIndex(x, y)] |= *color; +} + void Window::setPixelByIndex(uint16_t index, CRGB* color) { uint8_t x = index % this->width; uint8_t y = index / this->width; @@ -69,7 +74,7 @@ void Window::line(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, CRGB* color) { int8_t sy = y1= 0) { y--; @@ -101,12 +106,12 @@ void Window::circle(uint8_t x0, uint8_t y0, uint8_t radius, CRGB* color) { x++; ddF_x += 2; f += ddF_x + 1; - + setPixel(x0 + x, y0 + y, color); setPixel(x0 - x, y0 + y, color); setPixel(x0 + x, y0 - y, color); setPixel(x0 - x, y0 - y, color); - + setPixel(x0 + y, y0 + x, color); setPixel(x0 - y, y0 + x, color); setPixel(x0 + y, y0 - x, color); @@ -121,14 +126,14 @@ void Window::lineWithAngle(uint8_t x, uint8_t y, uint8_t angle, uint8_t length, void Window::lineWithAngle(uint8_t x, uint8_t y, uint8_t angle, uint8_t startdist, uint8_t length, CRGB* color) { int16_t x1 = x; int16_t y1 = y; - + if (startdist > 0) { x1 = x + scale8(startdist, cos8(angle)); y1 = y + scale8(startdist, sin8(angle)); } - + int16_t x2 = x + scale8(startdist + length, cos8(angle)); int16_t y2 = y + scale8(startdist + length, sin8(angle)); - + line(x1, y1, x2, y2, color); }