The *matrix effects now are all derived from MatrixEffectBase class. Also, you can now set the amount of columns for these effects.
This commit is contained in:
parent
359b7a7826
commit
efebe9adb4
@ -48,24 +48,40 @@ public:
|
|||||||
RandomMatrixEffectColumn(Window* win, uint8_t dir, bool rnd=false) : MatrixEffectColumn(win, dir, rnd) {};
|
RandomMatrixEffectColumn(Window* win, uint8_t dir, bool rnd=false) : MatrixEffectColumn(win, dir, rnd) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
class MatrixEffect : public Effect {
|
class MatrixEffectBase : public Effect {
|
||||||
protected:
|
protected:
|
||||||
MatrixEffectColumn** _columns;
|
MatrixEffectColumn** _columns;
|
||||||
|
uint8_t _count;
|
||||||
|
virtual uint8_t _get_count();
|
||||||
|
virtual void _delete();
|
||||||
|
void _init();
|
||||||
|
virtual void _create() = 0;
|
||||||
public:
|
public:
|
||||||
boolean can_be_shown_with_clock();
|
boolean can_be_shown_with_clock();
|
||||||
MatrixEffect();
|
virtual ~MatrixEffectBase();
|
||||||
virtual ~MatrixEffect();
|
|
||||||
void loop(uint16_t ms);
|
void loop(uint16_t ms);
|
||||||
String get_name() override { return "matrix"; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RainbowMatrixEffect : public MatrixEffect {
|
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:
|
public:
|
||||||
RainbowMatrixEffect();
|
RainbowMatrixEffect();
|
||||||
String get_name() override { return "rainbow_matrix"; }
|
String get_name() override { return "rainbow_matrix"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class RandomMatrixEffect : public MatrixEffect {
|
class RandomMatrixEffect : public MatrixEffectBase {
|
||||||
|
protected:
|
||||||
|
uint8_t _get_count() override;
|
||||||
|
void _create() override;
|
||||||
public:
|
public:
|
||||||
RandomMatrixEffect();
|
RandomMatrixEffect();
|
||||||
String get_name() override { return "random_matrix"; }
|
String get_name() override { return "random_matrix"; }
|
||||||
|
@ -28,6 +28,8 @@ struct Settings {
|
|||||||
uint16_t length_max = 20;
|
uint16_t length_max = 20;
|
||||||
uint16_t speed_min = 3;
|
uint16_t speed_min = 3;
|
||||||
uint16_t speed_max = 7;
|
uint16_t speed_max = 7;
|
||||||
|
uint16_t count = 16;
|
||||||
|
uint16_t random_count = 32;
|
||||||
} matrix;
|
} matrix;
|
||||||
|
|
||||||
struct /* confetti */ {
|
struct /* confetti */ {
|
||||||
|
@ -136,37 +136,61 @@ void RandomMatrixEffectColumn::restart(bool completely_random) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
boolean MatrixEffect::can_be_shown_with_clock() { return true; };
|
boolean MatrixEffectBase::can_be_shown_with_clock() { return true; };
|
||||||
|
|
||||||
|
void MatrixEffectBase::_init() {
|
||||||
|
_count = _get_count();
|
||||||
|
_columns = new MatrixEffectColumn* [_count];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t MatrixEffectBase::_get_count() { return settings.effects.matrix.count; }
|
||||||
|
|
||||||
MatrixEffect::MatrixEffect() {
|
MatrixEffect::MatrixEffect() {
|
||||||
_columns = new MatrixEffectColumn* [window->width];
|
_init();
|
||||||
for (int i=0; i<window->width; i++) _columns[i] = new MatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
|
_create();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MatrixEffect::_create() {
|
||||||
|
for (int i=0; i<_count; i++) _columns[i] = new MatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomMatrixEffect::RandomMatrixEffect() {
|
RandomMatrixEffect::RandomMatrixEffect() {
|
||||||
// No need to initialize _columns, because that will have been done by ctor of MatrixEffect.
|
_init();
|
||||||
for (int i=0; i<window->width; i++) {
|
_create();
|
||||||
delete _columns[i];
|
|
||||||
_columns[i] = new RandomMatrixEffectColumn(window, random8(4), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RandomMatrixEffect::_create() {
|
||||||
|
for (int i=0; i<_count; i++) _columns[i] = new RandomMatrixEffectColumn(window, random8(4), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t RandomMatrixEffect::_get_count() { return settings.effects.matrix.random_count; }
|
||||||
|
|
||||||
RainbowMatrixEffect::RainbowMatrixEffect() {
|
RainbowMatrixEffect::RainbowMatrixEffect() {
|
||||||
// No need to initialize _columns, because that will have been done by ctor of MatrixEffect.
|
_init();
|
||||||
for (int i=0; i<window->width; i++) {
|
_create();
|
||||||
delete _columns[i];
|
|
||||||
_columns[i] = new RainbowMatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixEffect::~MatrixEffect() {
|
void RainbowMatrixEffect::_create() {
|
||||||
for (int i=0; i<window->width; i++) {
|
for (int i=0; i<_count; i++) _columns[i] = new RainbowMatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
MatrixEffectBase::~MatrixEffectBase() {
|
||||||
|
_delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MatrixEffectBase::_delete() {
|
||||||
|
for (int i=0; i<_count; i++) {
|
||||||
delete _columns[i];
|
delete _columns[i];
|
||||||
}
|
}
|
||||||
delete[] _columns;
|
delete[] _columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatrixEffect::loop(uint16_t ms) {
|
void MatrixEffectBase::loop(uint16_t ms) {
|
||||||
|
if (_count != _get_count()) {
|
||||||
|
_delete();
|
||||||
|
_init();
|
||||||
|
_create();
|
||||||
|
}
|
||||||
window->clear();
|
window->clear();
|
||||||
for (int i=0; i<window->width; i++) _columns[i]->loop(ms);
|
for (int i=0; i<_count; i++) _columns[i]->loop(ms);
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,8 @@ Setting all_settings[] = {
|
|||||||
{"effects.matrix.length_max", &settings.effects.matrix.length_max, TYPE_UINT8},
|
{"effects.matrix.length_max", &settings.effects.matrix.length_max, TYPE_UINT8},
|
||||||
{"effects.matrix.speed_min", &settings.effects.matrix.speed_min, TYPE_UINT8},
|
{"effects.matrix.speed_min", &settings.effects.matrix.speed_min, TYPE_UINT8},
|
||||||
{"effects.matrix.speed_max", &settings.effects.matrix.speed_max, TYPE_UINT8},
|
{"effects.matrix.speed_max", &settings.effects.matrix.speed_max, TYPE_UINT8},
|
||||||
|
{"effects.matrix.count", &settings.effects.matrix.count, TYPE_UINT8},
|
||||||
|
{"effects.matrix.random_count", &settings.effects.matrix.random_count, TYPE_UINT8},
|
||||||
|
|
||||||
{"effects.sines.count", &settings.effects.sines.count, TYPE_UINT8},
|
{"effects.sines.count", &settings.effects.sines.count, TYPE_UINT8},
|
||||||
|
|
||||||
@ -45,7 +47,7 @@ Setting all_settings[] = {
|
|||||||
{"effects.tv_static.black_bar_speed", &settings.effects.tv_static.black_bar_speed, TYPE_UINT16},
|
{"effects.tv_static.black_bar_speed", &settings.effects.tv_static.black_bar_speed, TYPE_UINT16},
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t all_settings_size = 26;
|
const uint8_t all_settings_size = 28;
|
||||||
|
|
||||||
bool change_setting(const char* key, uint16_t new_value) {
|
bool change_setting(const char* key, uint16_t new_value) {
|
||||||
LOGln("Settings * Setting %s to new value %d.", key, new_value);
|
LOGln("Settings * Setting %s to new value %d.", key, new_value);
|
||||||
|
Loading…
Reference in New Issue
Block a user