There are now global instances of Window which don't have to be created and deleted all the time.
This commit is contained in:
parent
9de77349e8
commit
10be8ef7cc
@ -6,7 +6,7 @@
|
||||
|
||||
class Effect {
|
||||
protected:
|
||||
Window* window = Window::getFullWindow(); // Use a full screen window per default.
|
||||
Window* window = &Window::window_full; // Use a full screen window per default.
|
||||
public:
|
||||
virtual ~Effect() {};
|
||||
virtual void loop(uint16_t ms) = 0;
|
||||
|
@ -14,10 +14,13 @@ private:
|
||||
void _circle_point(int x0, int y0, int x1, int y1, CRGB* color);
|
||||
void _subpixel_render(uint8_t x, uint8_t y, CRGB* color, SubpixelRenderingMode m);
|
||||
public:
|
||||
static Window window_full;
|
||||
static Window window_with_clock;
|
||||
static Window window_clock;
|
||||
|
||||
const uint8_t x, y;
|
||||
const uint8_t width, height;
|
||||
uint16_t count;
|
||||
static Window* getFullWindow();
|
||||
|
||||
Window(): Window(0, 0, LED_WIDTH, LED_HEIGHT) {};
|
||||
Window(uint8_t x, uint8_t y) : Window(x, y, LED_WIDTH-x, LED_HEIGHT-y) {};
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
|
||||
class Blur2DEffect : public Effect {
|
||||
private:
|
||||
Window* window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||
Window* window = &Window::window_with_clock;
|
||||
uint8_t _count;
|
||||
Blur2DBlob* _blobs;
|
||||
public:
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
class ClockEffect : public Effect {
|
||||
protected:
|
||||
Window* window = new Window(0, LED_HEIGHT - 6, LED_WIDTH, 6);
|
||||
Window* window = &Window::window_clock;
|
||||
|
||||
public:
|
||||
virtual ~ClockEffect();
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
class DvdEffect : public Effect {
|
||||
private:
|
||||
Window* window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||
Window* window = &Window::window_with_clock;
|
||||
saccum78 _x = 0;
|
||||
saccum78 _y = 0;
|
||||
int8_t _x_dir = 1;
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
|
||||
class BigDynamicEffect : public Effect {
|
||||
private:
|
||||
Window* window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||
Window* window = &Window::window_with_clock;
|
||||
public:
|
||||
void loop(uint16_t ms);
|
||||
~BigDynamicEffect();
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
|
||||
class FireworkEffect : public Effect {
|
||||
private:
|
||||
Window* window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||
Window* window = &Window::window_with_clock;
|
||||
bool _skyburst = 0;
|
||||
|
||||
accum88 _burst_x;
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
class MarqueeEffect : public Effect {
|
||||
private:
|
||||
Window* window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||
Window* window = &Window::window_with_clock;
|
||||
String _text = String("No text set +++ ");
|
||||
saccum78 _position = (window->width<<8);
|
||||
public:
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
class TvStaticEffect : public Effect {
|
||||
private:
|
||||
Window* _window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||
Window* _window = &Window::window_with_clock;
|
||||
public:
|
||||
~TvStaticEffect();
|
||||
void loop(uint16_t ms) override;
|
||||
|
@ -1,10 +1,9 @@
|
||||
#include "Window.h"
|
||||
#include "functions.h"
|
||||
|
||||
Window* Window::getFullWindow() {
|
||||
static Window win;
|
||||
return &win;
|
||||
}
|
||||
Window Window::window_full = Window();
|
||||
Window Window::window_with_clock = Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||
Window Window::window_clock = Window(0, LED_HEIGHT-6, LED_WIDTH, 6);
|
||||
|
||||
void Window::setPixel(uint8_t x, uint8_t y, CRGB* color) {
|
||||
if (x>=this->width || y>=this->height) return;
|
||||
|
@ -45,5 +45,4 @@ void Blur2DEffect::_delete() {
|
||||
|
||||
Blur2DEffect::~Blur2DEffect() {
|
||||
_delete();
|
||||
delete window;
|
||||
}
|
||||
|
@ -52,5 +52,4 @@ void ClockEffect::loop(boolean invert, CRGB fg_color, CRGB bg_color, uint8_t yPo
|
||||
}
|
||||
|
||||
ClockEffect::~ClockEffect() {
|
||||
delete window;
|
||||
}
|
||||
|
@ -47,5 +47,4 @@ DvdEffect::DvdEffect() {
|
||||
}
|
||||
|
||||
DvdEffect::~DvdEffect() {
|
||||
delete window;
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ void MultiDynamicEffect::loop(uint16_t ms) {
|
||||
}
|
||||
|
||||
BigDynamicEffect::~BigDynamicEffect() {
|
||||
delete window;
|
||||
}
|
||||
|
||||
void BigDynamicEffect::loop(uint16_t ms) {
|
||||
|
@ -176,7 +176,6 @@ FireworkEffect::FireworkEffect() {
|
||||
}
|
||||
|
||||
FireworkEffect::~FireworkEffect() {
|
||||
delete window;
|
||||
for (int i=0; i<settings.effects.firework.sparks; i++) {
|
||||
delete _sparks[i];
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "my_fastled.h"
|
||||
|
||||
GolEffect::GolEffect() {
|
||||
this->window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||
this->window = &Window::window_with_clock;
|
||||
|
||||
_data = new uint8_t[this->window->count];
|
||||
_old = new uint8_t[this->window->count];
|
||||
@ -26,7 +26,6 @@ void GolEffect::_initialize() {
|
||||
GolEffect::~GolEffect() {
|
||||
delete[] _data;
|
||||
delete[] _old;
|
||||
delete window;
|
||||
}
|
||||
|
||||
void GolEffect::loop(uint16_t ms) {
|
||||
|
@ -4,12 +4,11 @@
|
||||
#include "prototypes.h"
|
||||
|
||||
LightspeedEffect::LightspeedEffect() {
|
||||
window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||
window = &Window::window_with_clock;
|
||||
_init();
|
||||
}
|
||||
|
||||
LightspeedEffect::~LightspeedEffect() {
|
||||
delete window;
|
||||
_delete();
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "ntp.h"
|
||||
|
||||
PixelClockEffect::PixelClockEffect() {
|
||||
window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||
window = &Window::window_with_clock;
|
||||
_color_seconds = new CRGB(0x00FF00);
|
||||
_color_minutes = new CRGB(0xFFFF00);
|
||||
}
|
||||
@ -10,7 +10,6 @@ PixelClockEffect::PixelClockEffect() {
|
||||
PixelClockEffect::~PixelClockEffect() {
|
||||
delete _color_seconds;
|
||||
delete _color_minutes;
|
||||
delete window;
|
||||
}
|
||||
|
||||
void PixelClockEffect::loop(uint16_t ms) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "functions.h"
|
||||
|
||||
SnakeEffect::SnakeEffect() {
|
||||
window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||
window = &Window::window_with_clock;
|
||||
_pixels = window->width * window->height;
|
||||
_map = new uint8_t[_pixels];
|
||||
_init();
|
||||
@ -25,7 +25,6 @@ void SnakeEffect::_init() {
|
||||
}
|
||||
|
||||
SnakeEffect::~SnakeEffect() {
|
||||
delete window;
|
||||
delete _map;
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ void loop() {
|
||||
EVERY_N_SECONDS(1) {
|
||||
Serial.print("Core * Waiting for OTA... "); Serial.println(starting_up);
|
||||
starting_up--;
|
||||
Window* w = Window::getFullWindow();
|
||||
Window* w = &Window::window_full;
|
||||
CRGB color(0xFF0000);
|
||||
w->clear();
|
||||
for (int i=0; i<starting_up; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user