pitrix/include/effects/matrix.h

105 lines
2.7 KiB
C
Raw Normal View History

#pragma once
#include "prototypes.h"
#include "Effect.h"
#include "config.h"
#include "my_fastled.h"
#include "my_color_palettes.h"
class MatrixEffectColumn {
protected:
Window* window;
2019-10-10 04:43:01 +00:00
saccum78 x, y;
uint8_t length = 1;
uint8_t _direction = 2;
bool _random_direction = false;
virtual CRGB _getColor(uint8_t height);
virtual void restart(bool completely_random);
private:
uint16_t speed;
boolean running;
unsigned long last_move = 0;
2019-06-07 04:24:16 +00:00
public:
static const uint8_t DIR_NORTH = 0;
static const uint8_t DIR_EAST = 1;
static const uint8_t DIR_SOUTH = 2;
static const uint8_t DIR_WEST = 3;
MatrixEffectColumn(Window* win, uint8_t direction=0, bool random_direction=false);
virtual ~MatrixEffectColumn() {};
void advance(uint16_t ms);
void draw();
void loop(uint16_t ms);
};
class RainbowMatrixEffectColumn : public MatrixEffectColumn {
protected:
CRGB _getColor(uint8_t height) override;
public:
RainbowMatrixEffectColumn(Window* win, uint8_t dir, bool rnd=false) : MatrixEffectColumn(win, dir, rnd) {};
};
class RandomMatrixEffectColumn : public MatrixEffectColumn {
protected:
uint8_t _hue = 42;
CRGB _getColor(uint8_t height) override;
void restart(bool completely_random) override;
public:
RandomMatrixEffectColumn(Window* win, uint8_t dir, bool rnd=false) : MatrixEffectColumn(win, dir, rnd) {};
};
2020-04-28 15:46:23 +00:00
class ColumnMatrixEffectColumn : public MatrixEffectColumn {
protected:
uint8_t _hue;
CRGB _getColor(uint8_t height) override;
void restart(bool completely_random) override;
public:
ColumnMatrixEffectColumn(Window* win, uint8_t dir, bool rnd=false) : MatrixEffectColumn(win, dir, rnd) {};
};
class MatrixEffectBase : public Effect {
protected:
MatrixEffectColumn** _columns;
uint8_t _count;
virtual uint8_t _get_count();
virtual void _delete();
void _init();
virtual void _create() = 0;
2019-06-07 04:24:16 +00:00
public:
boolean can_be_shown_with_clock();
virtual ~MatrixEffectBase();
void loop(uint16_t ms);
};
class MatrixEffect : public MatrixEffectBase {
protected:
void _create() override;
public:
MatrixEffect();
String get_name() override { return "matrix"; }
};
class RainbowMatrixEffect : public MatrixEffectBase {
protected:
void _create() override;
public:
RainbowMatrixEffect();
String get_name() override { return "rainbow_matrix"; }
};
class RandomMatrixEffect : public MatrixEffectBase {
protected:
uint8_t _get_count() override;
void _create() override;
public:
RandomMatrixEffect();
String get_name() override { return "random_matrix"; }
};
2020-04-28 15:46:23 +00:00
class ColumnMatrixEffect : public MatrixEffectBase {
protected:
void _create() override;
public:
ColumnMatrixEffect();
String get_name() override { return "column_matrix"; }
};