mirror of
https://github.com/wled/WLED.git
synced 2025-04-24 06:47:18 +00:00
Seed FastLED's random functions during startup
This allows effects or color palettes that use FastLED's RNG to be different each time the device is powered on.
This commit is contained in:
parent
528b8b1271
commit
25c5e823d9
@ -495,6 +495,16 @@ void WLED::setup()
|
||||
initServer();
|
||||
DEBUG_PRINT(F("heap ")); DEBUG_PRINTLN(ESP.getFreeHeap());
|
||||
|
||||
// Seed FastLED random functions with an esp random value, which already works properly at this point.
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
const uint32_t seed32 = esp_random();
|
||||
#elif defined(ARDUINO_ARCH_ESP8266)
|
||||
const uint32_t seed32 = RANDOM_REG32;
|
||||
#else
|
||||
const uint32_t seed32 = random(std::numeric_limits<long>::max());
|
||||
#endif
|
||||
random16_set_seed((uint16_t)((seed32 & 0xFFFF) ^ (seed32 >> 16)));
|
||||
|
||||
#if WLED_WATCHDOG_TIMEOUT > 0
|
||||
enableWatchdog();
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user