SingleDynamic and MultiDynamic: Now with fading between the frames, better timing and a bit more saturation.

This commit is contained in:
Fabian Schlenz 2019-05-26 00:30:47 +02:00
parent 7bcb911fec
commit 21c0f1fdf7
1 changed files with 16 additions and 6 deletions

View File

@ -272,29 +272,39 @@ class SingleDynamic : public Effect {
protected:
static const int factor = 2;
static const int tile_count = LED_WIDTH/factor * LED_HEIGHT/factor;
virtual int getLoopTime() { return 200; }
CRGB tiles[tile_count];
CRGB old_tiles[tile_count];
uint8_t blend = 0;
public:
SingleDynamic() {
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(random8(), 120, 255);
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(random8(), 180, 255);
}
virtual void update() {
tiles[random8() % tile_count] = CHSV(random8(), 120, 255);
tiles[random8() % tile_count] = CHSV(random8(), 180, 255);
}
boolean can_be_shown_with_clock() { return true; }
void loop() {
EVERY_N_MILLISECONDS(400) { update(); }
virtual void loop() {
EVERY_N_MILLISECONDS(getLoopTime()) {
memcpy(old_tiles, tiles, tile_count*sizeof(CRGB));
blend = 0;
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]);
setPixel(window, x, y, nblend(old_tiles[index], tiles[index], blend));
}
if (blend < 255) blend+=20;
}
};
class MultiDynamic : public SingleDynamic {
protected:
virtual int getLoopTime() { return 1400; }
public:
void update() {
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(random8(), 120, 255);
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(random8(), 180, 255);
}
};