Fixed rainbow_matrix and random_matrix.

This commit is contained in:
Fabian Schlenz 2019-09-04 06:00:18 +02:00
parent 2ddd77eb5c
commit a6cd94e416
2 changed files with 10 additions and 13 deletions

View File

@ -51,7 +51,6 @@ public:
class MatrixEffect : public Effect {
protected:
MatrixEffectColumn** _columns;
virtual void _init();
public:
boolean can_be_shown_with_clock();
MatrixEffect();
@ -60,11 +59,11 @@ public:
};
class RainbowMatrixEffect : public MatrixEffect {
private:
void _init() override;
public:
RainbowMatrixEffect();
};
class RandomMatrixEffect : public MatrixEffect {
private:
void _init() override;
public:
RandomMatrixEffect();
};

View File

@ -69,9 +69,9 @@ void MatrixEffectColumn::draw() {
int8_t ydir = 0;
switch (_direction) {
case DIR_NORTH: ydir = 1; break;
case DIR_EAST: xdir = 1; break;
case DIR_EAST: xdir = -1; break;
case DIR_SOUTH: ydir = -1; break;
case DIR_WEST: xdir = -1; break;
case DIR_WEST: xdir = 1; break;
}
for(int i=0; i<length; i++) {
CRGB color = _getColor(i);
@ -144,18 +144,16 @@ boolean MatrixEffect::can_be_shown_with_clock() { return true; };
MatrixEffect::MatrixEffect() {
_columns = new MatrixEffectColumn* [window->width];
_init();
}
void MatrixEffect::_init() {
for (int i=0; i<window->width; i++) _columns[i] = new MatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
}
void RandomMatrixEffect::_init() {
RandomMatrixEffect::RandomMatrixEffect() {
_columns = new MatrixEffectColumn* [window->width];
for (int i=0; i<window->width; i++) _columns[i] = new RandomMatrixEffectColumn(window, random8(4), true);
}
void RainbowMatrixEffect::_init() {
RainbowMatrixEffect::RainbowMatrixEffect() {
_columns = new MatrixEffectColumn* [window->width];
for (int i=0; i<window->width; i++) _columns[i] = new RainbowMatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
}