Extended MatrixEffect to also get RainbowMatrixEffect and RandomMatrixEffect.
Side note: You know you understand C++ when you understand the meaning and reason for "MatrixEffect** _columns". ;-)
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
#ifndef effect_matrix_H
|
||||
#define effect_matrix_H
|
||||
#pragma once
|
||||
|
||||
#include "prototypes.h"
|
||||
#include "Effect.h"
|
||||
@ -8,10 +7,12 @@
|
||||
#include "my_color_palettes.h"
|
||||
|
||||
class MatrixEffectColumn {
|
||||
private:
|
||||
int x, y;
|
||||
int length;
|
||||
protected:
|
||||
Window* window;
|
||||
int x, y;
|
||||
int length = 1;
|
||||
virtual CRGB _getColor(uint8_t height);
|
||||
private:
|
||||
uint16_t speed;
|
||||
boolean running;
|
||||
unsigned long last_move = 0;
|
||||
@ -19,24 +20,47 @@ public:
|
||||
MatrixEffectColumn();
|
||||
MatrixEffectColumn(Window* win, int xPos);
|
||||
|
||||
void start();
|
||||
|
||||
virtual void start();
|
||||
void advance();
|
||||
|
||||
void draw();
|
||||
|
||||
void loop();
|
||||
};
|
||||
|
||||
class RainbowMatrixEffectColumn : public MatrixEffectColumn {
|
||||
protected:
|
||||
CRGB _getColor(uint8_t height) override;
|
||||
public:
|
||||
RainbowMatrixEffectColumn() : MatrixEffectColumn() {};
|
||||
RainbowMatrixEffectColumn(Window* win, int xPos) : MatrixEffectColumn(win, xPos) {};
|
||||
};
|
||||
|
||||
class RandomMatrixEffectColumn : public MatrixEffectColumn {
|
||||
protected:
|
||||
uint8_t _hue = 42;
|
||||
CRGB _getColor(uint8_t height) override;
|
||||
public:
|
||||
void start() override;
|
||||
RandomMatrixEffectColumn() : MatrixEffectColumn() {};
|
||||
RandomMatrixEffectColumn(Window* win, int xPos) : MatrixEffectColumn(win, xPos) {};
|
||||
};
|
||||
|
||||
class MatrixEffect : public Effect {
|
||||
private:
|
||||
MatrixEffectColumn* _columns;
|
||||
protected:
|
||||
MatrixEffectColumn** _columns;
|
||||
public:
|
||||
boolean can_be_shown_with_clock();
|
||||
void start();
|
||||
virtual void start();
|
||||
void stop();
|
||||
MatrixEffect();
|
||||
void loop();
|
||||
};
|
||||
|
||||
#endif
|
||||
class RainbowMatrixEffect : public MatrixEffect {
|
||||
public:
|
||||
void start() override;
|
||||
};
|
||||
|
||||
class RandomMatrixEffect : public MatrixEffect {
|
||||
public:
|
||||
void start() override;
|
||||
};
|
||||
|
Reference in New Issue
Block a user