MatrixEffect now uses dynamically allocated memory.

This commit is contained in:
Fabian Schlenz 2019-06-15 14:17:06 +02:00
parent 02b3bbcea8
commit b65afde142
2 changed files with 13 additions and 3 deletions

View File

@ -30,9 +30,11 @@ public:
class MatrixEffect : public Effect {
private:
MatrixEffectColumn columns[LED_WIDTH];
MatrixEffectColumn* _columns;
public:
boolean can_be_shown_with_clock();
void start();
void stop();
MatrixEffect();
void loop();
};

View File

@ -55,10 +55,18 @@ void MatrixEffectColumn::loop() {
boolean MatrixEffect::can_be_shown_with_clock() { return true; };
MatrixEffect::MatrixEffect() {
for (int i=0; i<LED_WIDTH; i++) columns[i] = MatrixEffectColumn(window, i);
}
void MatrixEffect::start() {
_columns = new MatrixEffectColumn[LED_WIDTH];
for (int i=0; i<LED_WIDTH; i++) _columns[i] = MatrixEffectColumn(window, i);
}
void MatrixEffect::stop() {
delete[] _columns;
}
void MatrixEffect::loop() {
window->clear();
for (int i=0; i<window->width; i++) columns[i].loop();
for (int i=0; i<window->width; i++) _columns[i].loop();
}