More (unseccessful) experiments with FireworksEffect.

This commit is contained in:
Fabian Schlenz 2019-06-06 06:44:52 +02:00
parent f7275cc086
commit 026ed27d8e
2 changed files with 12 additions and 21 deletions

View File

@ -4,8 +4,10 @@
#include "config.h" #include "config.h"
void FireworkEffect::loop() { void FireworkEffect::loop() {
blur(EFFECT_FIREWORK_BLUR);
fadeToBlackBy(leds, LED_COUNT, EFFECT_FIREWORK_FADEOUT_SPEED);
if (random8(EFFECT_FIREWORK_SHOT_CHANCE)==0) { if (random8(EFFECT_FIREWORK_SHOT_CHANCE)==0) {
leds[random16(LED_COUNT)] = CHSV(random8(), 255, 255); leds[random16(LED_COUNT)] = CHSV(random8(), 255, 255);
} }
blur(EFFECT_FIREWORK_BLUR);
} }

View File

@ -70,34 +70,23 @@ void blur(fract8 blur_amount) {
void blur_row(uint8_t row_index, fract8 blur_amount) { void blur_row(uint8_t row_index, fract8 blur_amount) {
CRGB* row = &leds[row_index * LED_WIDTH]; CRGB* row = &leds[row_index * LED_WIDTH];
uint8_t keep = 255 - blur_amount;
uint8_t seep = 17; // 15 is zu wenig
CRGB carryover = CRGB::Black; CRGB carryover = CRGB::Black;
for (uint8_t x=0; x<LED_WIDTH; x++) { for (uint8_t x=0; x<LED_WIDTH; x++) {
CRGB currentColor = row[x]; CRGB seep = row[x].nscale8(blur_amount);
CRGB part = currentColor; row[x] += carryover;
part.nscale8(seep); if (x>0) row[x-1] += seep;
currentColor.nscale8(keep); carryover = seep;
currentColor += carryover;
if (x>0) row[x-1]+=part;
row[x]=currentColor;
carryover = part;
} }
} }
void blur_column(uint8_t col_index, fract8 blur_amount) { void blur_column(uint8_t col_index, fract8 blur_amount) {
uint8_t keep = 255 - blur_amount;
uint8_t seep = 17;
CRGB carryover = CRGB::Black; CRGB carryover = CRGB::Black;
for (uint8_t y=0; y<LED_HEIGHT; y++) { for (uint8_t y=0; y<LED_HEIGHT; y++) {
CRGB currentColor = leds[XYsafe(col_index, y)]; uint16_t led_index = XYsafe(col_index, y);
CRGB part = currentColor; CRGB seep = leds[led_index].nscale8(blur_amount);
part.nscale8(seep); leds[led_index] += carryover;
currentColor.nscale8(keep); if (y>0) leds[XYsafe(col_index, y-1)] += seep;
currentColor += carryover; carryover = seep;
if (y>0) leds[XYsafe(col_index, y-1)]+=part;
leds[XYsafe(col_index, y)]=currentColor;
carryover = part;
} }
} }