I'm tired and forgot to add two files to previous commits. :-/

This commit is contained in:
Fabian Schlenz 2019-06-19 22:29:11 +02:00
parent ead076f9a3
commit 77fdba213a
2 changed files with 21 additions and 8 deletions

View File

@ -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();
};

View File

@ -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<y2 ? 1 : -1;
int16_t err = dx + dy;
int16_t e2;
while (1) {
setPixel(x1, y1, color);
if (x1==x2 && y1==y2) break;
@ -86,12 +91,12 @@ void Window::circle(uint8_t x0, uint8_t y0, uint8_t radius, CRGB* color) {
int16_t ddF_y = -2 * radius;
uint8_t x = 0;
uint8_t y = radius;
setPixel(x0, y0 + radius, color);
setPixel(x0, y0 - radius, color);
setPixel(x0 + radius, y0, color);
setPixel(x0 - radius, y0, color);
while (x < y) {
if (f >= 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);
}