2019-10-10 04:50:09 +00:00
|
|
|
#include "effect_tv_static.h"
|
|
|
|
|
|
|
|
void TvStaticEffect::loop(uint16_t ms) {
|
2019-10-18 15:03:21 +00:00
|
|
|
//uint8_t dark_position = (millis() % settings.effects.tv_static.black_bar_speed) * _window->width / settings.effects.tv_static.black_bar_speed;
|
|
|
|
accum88 dark_position = (beat16(settings.effects.tv_static.black_bar_speed) * _window->width) >> 8;
|
2019-10-10 04:50:09 +00:00
|
|
|
for (uint8_t y=0; y<_window->height; y++) {
|
2019-10-18 15:03:21 +00:00
|
|
|
accum88 row_dark_position = (dark_position + (y<<8)/3) % (_window->width<<8);
|
2019-10-10 04:50:09 +00:00
|
|
|
for (uint8_t x=0; x<_window->width; x++) {
|
|
|
|
uint8_t brightness = random8();
|
|
|
|
uint8_t darkening = 0;
|
2019-10-18 15:03:21 +00:00
|
|
|
accum88 distance = (x<<8) - row_dark_position;
|
|
|
|
if (distance < 256) darkening = random8(distance, 255);
|
|
|
|
else if (distance < (4<<8)) darkening = random8(distance >> 2, 255);
|
|
|
|
|
2019-10-10 04:50:09 +00:00
|
|
|
if (darkening > brightness) brightness = 0;
|
|
|
|
else brightness -= darkening;
|
|
|
|
CRGB color(brightness, brightness, brightness);
|
|
|
|
_window->setPixel(x, y, &color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TvStaticEffect::can_be_shown_with_clock() { return true; }
|
|
|
|
|
|
|
|
TvStaticEffect::~TvStaticEffect() {
|
|
|
|
delete _window;
|
|
|
|
}
|