Effects now use Constructor and Destructor to initialize or delete their data, instead of using start() and stop().

This commit is contained in:
2019-06-18 18:09:05 +02:00
parent 72cdb46451
commit 1912772da3
13 changed files with 58 additions and 60 deletions

View File

@ -9,6 +9,7 @@ class Effect {
protected:
Window* window = Window::getFullWindow(); // Use a full screen window per default.
public:
virtual ~Effect() {};
virtual void loop() = 0;
boolean supports_window = false;
virtual boolean can_be_shown_with_clock() { return false; };
@ -16,8 +17,6 @@ public:
void setWindow(Window* win) {
window = win;
};
virtual void start() {}
virtual void stop() {}
};
#endif

View File

@ -6,13 +6,13 @@
class CycleEffect : public Effect {
private:
Effect* effect;
Effect* effect = NULL;
uint16_t effect_id = -1;
unsigned long effectSince = 0;
public:
CycleEffect();
~CycleEffect();
void changeEffect();
void start();
void stop();
boolean can_be_shown_with_clock();
boolean clock_as_mask();

View File

@ -13,7 +13,7 @@ private:
static CRGBPalette16 palette;
public:
void start();
void stop();
FireEffect();
~FireEffect();
void loop();
};

View File

@ -16,8 +16,7 @@ private:
public:
GolEffect();
void start();
void stop();
~GolEffect();
void loop();
bool can_be_shown_with_clock();
};

View File

@ -12,15 +12,14 @@ protected:
int x, y;
int length = 1;
virtual CRGB _getColor(uint8_t height);
virtual void restart();
private:
uint16_t speed;
boolean running;
unsigned long last_move = 0;
public:
MatrixEffectColumn();
MatrixEffectColumn(Window* win, int xPos);
virtual void start();
virtual ~MatrixEffectColumn() {};
void advance();
void draw();
void loop();
@ -30,7 +29,6 @@ class RainbowMatrixEffectColumn : public MatrixEffectColumn {
protected:
CRGB _getColor(uint8_t height) override;
public:
RainbowMatrixEffectColumn() : MatrixEffectColumn() {};
RainbowMatrixEffectColumn(Window* win, int xPos) : MatrixEffectColumn(win, xPos) {};
};
@ -38,29 +36,28 @@ class RandomMatrixEffectColumn : public MatrixEffectColumn {
protected:
uint8_t _hue = 42;
CRGB _getColor(uint8_t height) override;
void restart() override;
public:
void start() override;
RandomMatrixEffectColumn() : MatrixEffectColumn() {};
RandomMatrixEffectColumn(Window* win, int xPos) : MatrixEffectColumn(win, xPos) {};
};
class MatrixEffect : public Effect {
protected:
MatrixEffectColumn** _columns;
virtual void _init();
public:
boolean can_be_shown_with_clock();
virtual void start();
void stop();
MatrixEffect();
virtual ~MatrixEffect();
void loop();
};
class RainbowMatrixEffect : public MatrixEffect {
public:
void start() override;
private:
void _init() override;
};
class RandomMatrixEffect : public MatrixEffect {
public:
void start() override;
private:
void _init() override;
};

View File

@ -9,8 +9,7 @@ private:
CRGB* _color_minutes;
public:
PixelClockEffect();
void start();
void stop();
~PixelClockEffect();
void loop();
bool can_be_shown_with_clock();
};