Effect tv_static now also uses subpixel rendering.

This commit is contained in:
Fabian Schlenz 2019-10-18 17:03:21 +02:00
parent 7b8dabee43
commit efe9b924ec
2 changed files with 8 additions and 8 deletions

View File

@ -81,7 +81,7 @@ struct Settings {
} snake;
struct /* tv_static */ {
uint16_t black_bar_speed = 3500;
uint16_t black_bar_speed = 12;
} tv_static;
} effects;
};

View File

@ -1,17 +1,17 @@
#include "effect_tv_static.h"
void TvStaticEffect::loop(uint16_t ms) {
uint8_t dark_position = (millis() % settings.effects.tv_static.black_bar_speed) * _window->width / settings.effects.tv_static.black_bar_speed;
//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;
for (uint8_t y=0; y<_window->height; y++) {
uint8_t row_dark_position = (dark_position + y/3) % _window->width;
accum88 row_dark_position = (dark_position + (y<<8)/3) % (_window->width<<8);
for (uint8_t x=0; x<_window->width; x++) {
uint8_t brightness = random8();
uint8_t darkening = 0;
uint8_t distance = x - row_dark_position;
if (distance == 0) darkening = random8(192, 255);
else if (distance == 1) darkening = random8(128, 255);
else if (distance == 2) darkening = random8(92, 192);
else if (distance == 3) darkening = random8(32, 128);
accum88 distance = (x<<8) - row_dark_position;
if (distance < 256) darkening = random8(distance, 255);
else if (distance < (4<<8)) darkening = random8(distance >> 2, 255);
if (darkening > brightness) brightness = 0;
else brightness -= darkening;
CRGB color(brightness, brightness, brightness);