Added effects SingleDynamic and MultiDynamic.

This commit is contained in:
2019-05-24 05:13:35 +02:00
parent 659181b25c
commit 08ac5c891c
2 changed files with 36 additions and 2 deletions

View File

@ -266,3 +266,33 @@ class Animation : public Effect {
return animation->delays[0];
}
};
class SingleDynamic : public Effect {
protected:
static const int factor = 2;
static const int tile_count = LED_WIDTH/factor * LED_HEIGHT/factor;
CRGB tiles[tile_count];
public:
SingleDynamic() {
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(random8(), 120, 255);
}
virtual void update() {
tiles[random8() % tile_count] = CHSV(random8(), 120, 255);
}
boolean can_be_shown_with_clock() { return true; }
void loop() {
EVERY_N_MILLISECONDS(400) { update(); }
for (int x=0; x<window.w; x++) for (int y=0; y<window.h; y++) {
int index = y/2 * window.w/2 + x/2;
setPixel(window, x, y, tiles[index]);
}
}
};
class MultiDynamic : public SingleDynamic {
public:
void update() {
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(random8(), 120, 255);
}
};