-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seed FastLED's RNG #3552
Seed FastLED's RNG #3552
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this "else" branch needed? We only support esp32 variants (ARDUINO_ARCH_ESP32) and 8266 (ARDUINO_ARCH_ESP8266). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, but it doesn't hurt, does it? If someone were to come along and try to port WLED to a different architecture, this would be one less thing to worry about. I don't have strong feelings about this though, and can remove it if you There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer if you remove it - its unused code and we don't have any plans for supporting non-esp architectures. |
||
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: please check if the header file for esp_random is already included.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I also include something for the esp8266?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure ... is there a header on 8266 that defines
RANDOM_REG32
?