57 lines
1.6 KiB
C++
57 lines
1.6 KiB
C++
#include "effects/dynamic.h"
|
|
#include "functions.h"
|
|
#include "config.h"
|
|
|
|
SingleDynamicEffect::SingleDynamicEffect() {
|
|
init();
|
|
}
|
|
|
|
void SingleDynamicEffect::init() {
|
|
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(baseHue + random8(64), 180, 255);
|
|
}
|
|
|
|
void SingleDynamicEffect::loop(uint16_t ms) {
|
|
EVERY_N_MILLISECONDS( settings.effects.dynamic.single_loop_time ) {
|
|
tiles[random8(tile_count)] = CHSV(baseHue + random8(64), 180, 255);
|
|
}
|
|
this->draw();
|
|
}
|
|
|
|
void SingleDynamicEffect::draw() {
|
|
for (int x=0; x<window->width; x++) for (int y=0; y<window->height; y++) {
|
|
int index = y/2 * window->width/2 + x/2;
|
|
window->setPixel(x, y, &tiles[index]);
|
|
}
|
|
}
|
|
|
|
boolean SingleDynamicEffect::can_be_shown_with_clock() {
|
|
return true;
|
|
}
|
|
|
|
void MultiDynamicEffect::loop(uint16_t ms) {
|
|
EVERY_N_MILLISECONDS( settings.effects.dynamic.multi_loop_time ) {
|
|
for (int i=0; i<tile_count; i++) tiles[i] = CHSV(baseHue + random8(64), 180, 255);
|
|
}
|
|
this->draw();
|
|
}
|
|
|
|
BigDynamicEffect::~BigDynamicEffect() {
|
|
}
|
|
|
|
void BigDynamicEffect::loop(uint16_t ms) {
|
|
EVERY_N_MILLISECONDS( settings.effects.dynamic.big_loop_time ) {
|
|
uint8_t x = random8(0, window->width - settings.effects.dynamic.big_size + 1);
|
|
uint8_t y = random8(0, window->height - settings.effects.dynamic.big_size + 1);
|
|
CRGB color = CHSV(random8(), 255, 255);
|
|
CRGB black(0x000000);
|
|
|
|
for (uint8_t ix=0; ix<settings.effects.dynamic.big_size; ix++) for (uint8_t iy=0; iy<settings.effects.dynamic.big_size; iy++) {
|
|
window->setPixel(x+ix, y+iy, &color);
|
|
}
|
|
}
|
|
}
|
|
|
|
boolean BigDynamicEffect::can_be_shown_with_clock() {
|
|
return true;
|
|
}
|