Skip to content

Commit bf067f7

Browse files
committed
make random more random
1 parent b39146d commit bf067f7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cores/esp8266/WMath.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@
2626
extern "C" {
2727
#include <stdlib.h>
2828
}
29+
#include "esp8266_peri.h"
2930

3031
void randomSeed(unsigned long seed) {
3132
if(seed != 0) {
32-
srand(seed);
33+
srand((seed ^ RANDOM_REG32));
3334
}
3435
}
3536

3637
long random(long howbig) {
3738
if(howbig == 0) {
3839
return 0;
3940
}
40-
return rand() % howbig;
41+
return (rand() ^ RANDOM_REG32) % howbig;
4142
}
4243

4344
long random(long howsmall, long howbig) {

0 commit comments

Comments
 (0)