diff --git a/cores/esp32/Arduino.h b/cores/esp32/Arduino.h index e915d678..192aa7e5 100644 --- a/cores/esp32/Arduino.h +++ b/cores/esp32/Arduino.h @@ -115,10 +115,6 @@ typedef bool boolean; typedef uint8_t byte; typedef unsigned int word; -#ifdef __cplusplus -long random(long, long); -#endif -void randomSeed(unsigned long); long map(long, long, long, long, long); #ifdef __cplusplus @@ -155,8 +151,6 @@ uint16_t makeWord(byte h, byte l); unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); -// WMath prototypes -long random(long); #endif /* __cplusplus */ #define _min(a,b) ((a)<(b)?(a):(b)) diff --git a/cores/esp32/WMath.cpp b/cores/esp32/WMath.cpp index d351b194..ebbd20c1 100644 --- a/cores/esp32/WMath.cpp +++ b/cores/esp32/WMath.cpp @@ -24,47 +24,9 @@ */ extern "C" { -#include #include "esp_system.h" } -void randomSeed(unsigned long seed) -{ - if(seed != 0) { - srand(seed); - } -} - -long random(long howbig) -{ - uint32_t x = esp_random(); - uint64_t m = uint64_t(x) * uint64_t(howbig); - uint32_t l = uint32_t(m); - if (l < howbig) { - uint32_t t = -howbig; - if (t >= howbig) { - t -= howbig; - if (t >= howbig) - t %= howbig; - } - while (l < t) { - x = esp_random(); - m = uint64_t(x) * uint64_t(howbig); - l = uint32_t(m); - } - } - return m >> 32; -} - -long random(long howsmall, long howbig) -{ - if(howsmall >= howbig) { - return howsmall; - } - long diff = howbig - howsmall; - return random(diff) + howsmall; -} - long map(long x, long in_min, long in_max, long out_min, long out_max) { const long dividend = out_max - out_min; const long divisor = in_max - in_min;