Skip to content

Commit

Permalink
Remove re-seeding FastLED random8/random16 in FX
Browse files Browse the repository at this point in the history
  • Loading branch information
blazoncek authored and softhack007 committed Dec 12, 2023
1 parent 451243c commit fa6e217
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4087,6 +4087,7 @@ static const char _data_FX_MODE_PHASEDNOISE[] PROGMEM = "Phased Noise@!,!;!,!;!"


uint16_t mode_twinkleup(void) { // A very short twinkle routine with fade-in and dual controls. By Andrew Tuline.
uint16_t prevSeed = random16_get_seed(); // save seed so we can restore it at the end of the function
random16_set_seed(535); // The randomizer needs to be re-set each time through the loop in order for the same 'random' numbers to be the same each time through.

for (int i = 0; i < SEGLEN; i++) {
Expand All @@ -4096,6 +4097,7 @@ uint16_t mode_twinkleup(void) { // A very short twinkle routine
SEGMENT.setPixelColor(i, color_blend(SEGCOLOR(1), SEGMENT.color_from_palette(random8()+strip.now/100, false, PALETTE_SOLID_WRAP, 0), pixBri));
}

random16_set_seed(prevSeed); // restore original seed so other effects can use "random" PRNG
return FRAMETIME;
}
static const char _data_FX_MODE_TWINKLEUP[] PROGMEM = "Twinkleup@!,Intensity;!,!;!;;m12=0";
Expand Down

0 comments on commit fa6e217

Please sign in to comment.