kitesurfer1404 / WS2812FX

WS2812 FX Library for Arduino and ESP8266
MIT License
1.58k stars 344 forks source link

Allow to set random seed #288

Closed schumar closed 3 years ago

schumar commented 3 years ago

_rand16seed always starts at 0, so any patterns using random8() or random16() look the same after a reset.

I've worked around this doing

for (uint16_t i = analogRead(A0)+analogRead(A1); i--; i>0)
    ws2812fx.random8();

(i.e. calling random8() manually, a somewhat random amount of times), but that is.. hacky :)

Would be great if there was a void setRandomSeed(uint16_t seed), and maybe even a void setRandomSeed() which sets the seed based on micros() and some analogRead(...)s.

moose4lord commented 3 years ago

A setRandomSeed() function has been added to WS2812FX in the latest release (v1.3.4). Thanks for the suggestion.