Compare commits
2 Commits
359b7a7826
...
377ccc477f
Author | SHA1 | Date | |
---|---|---|---|
377ccc477f | |||
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,14 +47,15 @@ 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 = 29;
|
||||||
|
|
||||||
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);
|
||||||
Setting* s = NULL;
|
Setting* s = NULL;
|
||||||
for (uint8_t i=0; i<all_settings_size; i++) {
|
for (uint8_t i=0; i<all_settings_size; i++) {
|
||||||
if (strcmp(key, all_settings[i].name)==0) {
|
s = &(all_settings[i]);
|
||||||
s = &all_settings[i];
|
|
||||||
|
if (strcmp(key, s->name)==0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,13 +100,14 @@ bool save_settings() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<all_settings_size; i++) {
|
Setting* s;
|
||||||
Setting s = all_settings[i];
|
for (uint8_t i=0; i<all_settings_size; i++) {
|
||||||
uint16_t value = *(s.value);
|
s = &(all_settings[i]);
|
||||||
uint16_t default_value = setting_default(&s);
|
uint16_t value = *(s->value);
|
||||||
|
uint16_t default_value = setting_default(s);
|
||||||
if (default_value != value) {
|
if (default_value != value) {
|
||||||
char buf[50];
|
char buf[50];
|
||||||
snprintf(buf, 50, "%s=%d", s.name, value);
|
snprintf(buf, 50, "%s=%d", s->name, value);
|
||||||
LOGln("Saving: %s", buf);
|
LOGln("Saving: %s", buf);
|
||||||
f.println(buf);
|
f.println(buf);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user