39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
#include "effect_single_dynamic.h"
|
|
#include "functions.h"
|
|
|
|
SingleDynamicEffect::SingleDynamicEffect() {
|
|
init();
|
|
loopTime = EFFECT_SINGLE_DYNAMIC_LOOP_TIME;
|
|
}
|
|
|
|
void SingleDynamicEffect::init() {
|
|
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(baseHue + random8(64), 180, 255);
|
|
}
|
|
|
|
void SingleDynamicEffect::update() {
|
|
tiles[random8(tile_count)] = CHSV(baseHue + random8(64), 180, 255);
|
|
}
|
|
|
|
boolean SingleDynamicEffect::can_be_shown_with_clock() { return true; }
|
|
|
|
void SingleDynamicEffect::loop() {
|
|
/*EVERY_N_MILLISECONDS(loopTime) {
|
|
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, nblend(old_tiles[index], tiles[index], blend));
|
|
}
|
|
if (blend < 255) blend+=20;*/
|
|
EVERY_N_MILLISECONDS(loopTime) {
|
|
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]);
|
|
}
|
|
}
|