Compare commits
No commits in common. "377ccc477f91444ea08bbcbe2f4eec77d4e03e80" and "359b7a7826b128f626c04468773d6242f991e0ea" have entirely different histories.
377ccc477f
...
359b7a7826
@ -48,40 +48,24 @@ public:
|
||||
RandomMatrixEffectColumn(Window* win, uint8_t dir, bool rnd=false) : MatrixEffectColumn(win, dir, rnd) {};
|
||||
};
|
||||
|
||||
class MatrixEffectBase : public Effect {
|
||||
class MatrixEffect : public Effect {
|
||||
protected:
|
||||
MatrixEffectColumn** _columns;
|
||||
uint8_t _count;
|
||||
virtual uint8_t _get_count();
|
||||
virtual void _delete();
|
||||
void _init();
|
||||
virtual void _create() = 0;
|
||||
public:
|
||||
boolean can_be_shown_with_clock();
|
||||
virtual ~MatrixEffectBase();
|
||||
void loop(uint16_t ms);
|
||||
};
|
||||
|
||||
class MatrixEffect : public MatrixEffectBase {
|
||||
protected:
|
||||
void _create() override;
|
||||
public:
|
||||
MatrixEffect();
|
||||
virtual ~MatrixEffect();
|
||||
void loop(uint16_t ms);
|
||||
String get_name() override { return "matrix"; }
|
||||
};
|
||||
|
||||
class RainbowMatrixEffect : public MatrixEffectBase {
|
||||
protected:
|
||||
void _create() override;
|
||||
class RainbowMatrixEffect : public MatrixEffect {
|
||||
public:
|
||||
RainbowMatrixEffect();
|
||||
String get_name() override { return "rainbow_matrix"; }
|
||||
};
|
||||
|
||||
class RandomMatrixEffect : public MatrixEffectBase {
|
||||
protected:
|
||||
uint8_t _get_count() override;
|
||||
void _create() override;
|
||||
class RandomMatrixEffect : public MatrixEffect {
|
||||
public:
|
||||
RandomMatrixEffect();
|
||||
String get_name() override { return "random_matrix"; }
|
||||
|
@ -28,8 +28,6 @@ struct Settings {
|
||||
uint16_t length_max = 20;
|
||||
uint16_t speed_min = 3;
|
||||
uint16_t speed_max = 7;
|
||||
uint16_t count = 16;
|
||||
uint16_t random_count = 32;
|
||||
} matrix;
|
||||
|
||||
struct /* confetti */ {
|
||||
|
@ -136,61 +136,37 @@ void RandomMatrixEffectColumn::restart(bool completely_random) {
|
||||
|
||||
|
||||
|
||||
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; }
|
||||
boolean MatrixEffect::can_be_shown_with_clock() { return true; };
|
||||
|
||||
MatrixEffect::MatrixEffect() {
|
||||
_init();
|
||||
_create();
|
||||
}
|
||||
|
||||
void MatrixEffect::_create() {
|
||||
for (int i=0; i<_count; i++) _columns[i] = new MatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
|
||||
_columns = new MatrixEffectColumn* [window->width];
|
||||
for (int i=0; i<window->width; i++) _columns[i] = new MatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
|
||||
}
|
||||
|
||||
RandomMatrixEffect::RandomMatrixEffect() {
|
||||
_init();
|
||||
_create();
|
||||
// No need to initialize _columns, because that will have been done by ctor of MatrixEffect.
|
||||
for (int i=0; i<window->width; i++) {
|
||||
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() {
|
||||
_init();
|
||||
_create();
|
||||
// No need to initialize _columns, because that will have been done by ctor of MatrixEffect.
|
||||
for (int i=0; i<window->width; i++) {
|
||||
delete _columns[i];
|
||||
_columns[i] = new RainbowMatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
|
||||
}
|
||||
}
|
||||
|
||||
void RainbowMatrixEffect::_create() {
|
||||
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++) {
|
||||
MatrixEffect::~MatrixEffect() {
|
||||
for (int i=0; i<window->width; i++) {
|
||||
delete _columns[i];
|
||||
}
|
||||
delete[] _columns;
|
||||
}
|
||||
|
||||
void MatrixEffectBase::loop(uint16_t ms) {
|
||||
if (_count != _get_count()) {
|
||||
_delete();
|
||||
_init();
|
||||
_create();
|
||||
}
|
||||
void MatrixEffect::loop(uint16_t ms) {
|
||||
window->clear();
|
||||
for (int i=0; i<_count; i++) _columns[i]->loop(ms);
|
||||
for (int i=0; i<window->width; i++) _columns[i]->loop(ms);
|
||||
}
|
||||
|
@ -37,8 +37,6 @@ Setting all_settings[] = {
|
||||
{"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_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},
|
||||
|
||||
@ -47,15 +45,14 @@ Setting all_settings[] = {
|
||||
{"effects.tv_static.black_bar_speed", &settings.effects.tv_static.black_bar_speed, TYPE_UINT16},
|
||||
};
|
||||
|
||||
const uint8_t all_settings_size = 29;
|
||||
const uint8_t all_settings_size = 26;
|
||||
|
||||
bool change_setting(const char* key, uint16_t new_value) {
|
||||
LOGln("Settings * Setting %s to new value %d.", key, new_value);
|
||||
Setting* s = NULL;
|
||||
for (uint8_t i=0; i<all_settings_size; i++) {
|
||||
s = &(all_settings[i]);
|
||||
|
||||
if (strcmp(key, s->name)==0) {
|
||||
if (strcmp(key, all_settings[i].name)==0) {
|
||||
s = &all_settings[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -100,14 +97,13 @@ bool save_settings() {
|
||||
return false;
|
||||
}
|
||||
|
||||
Setting* s;
|
||||
for (uint8_t i=0; i<all_settings_size; i++) {
|
||||
s = &(all_settings[i]);
|
||||
uint16_t value = *(s->value);
|
||||
uint16_t default_value = setting_default(s);
|
||||
for (int i=0; i<all_settings_size; i++) {
|
||||
Setting s = all_settings[i];
|
||||
uint16_t value = *(s.value);
|
||||
uint16_t default_value = setting_default(&s);
|
||||
if (default_value != value) {
|
||||
char buf[50];
|
||||
snprintf(buf, 50, "%s=%d", s->name, value);
|
||||
snprintf(buf, 50, "%s=%d", s.name, value);
|
||||
LOGln("Saving: %s", buf);
|
||||
f.println(buf);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user