Browse Source

garland: update anim_spread

pull/2600/head
Dmitry Blinov 5 months ago
parent
commit
55ac3bf265
1 changed files with 11 additions and 6 deletions
  1. +11
    -6
      code/espurna/garland/animations/anim_spread.h

+ 11
- 6
code/espurna/garland/animations/anim_spread.h View File

@ -9,7 +9,7 @@ class AnimSpread : public Anim {
const byte minWidth = 10;
const byte maxWidth = 15;
const byte numTries = 5;
const byte fade_ind = 255 / minWidth;
byte fade_ind = 10;
int GeneratePos() {
int pos = -1;
@ -32,8 +32,9 @@ class AnimSpread : public Anim {
}
void SetupImpl() override {
fade_ind = secureRandom(1, 20);
inc = secureRandom(2, 4);
// DEBUG_MSG_P(PSTR("[GARLAND] AnimSpread inc = %d\n"), inc);
// DEBUG_MSG_P(PSTR("[GARLAND] AnimSpread inc = %d, fade_inc = %d\n"), inc, fade_ind);
for (int i = 0; i < numLeds; ++i)
seq[i] = 0;
}
@ -43,18 +44,22 @@ class AnimSpread : public Anim {
leds[i] = 0;
for (int i = 0; i < numLeds; ++i) {
if (seq[i] > 0) {
if (!ledstmp[i].empty()) {
byte width = maxWidth - seq[i];
for (int j = i - width; j <= (i + width); j++) {
Color c = ledstmp[i];
if (j >= 0 && j < numLeds) {
leds[j].r += c.r;
leds[j].g += c.g;
leds[j].b += c.b;
if (leds[j].empty()) {
leds[j] = c;
} else {
leds[j] = leds[j].interpolate(c, 0.5);
}
}
}
ledstmp[i].fade(fade_ind);
seq[i]--;
} else {
seq[i] = 0;
}
}


Loading…
Cancel
Save