Added effects SingleDynamic and MultiDynamic.
This commit is contained in:
30
effects.h
30
effects.h
@ -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);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user