diff options
author | David A. Mellis <d.mellis@arduino.cc> | 2008-10-13 15:03:20 +0000 |
---|---|---|
committer | David A. Mellis <d.mellis@arduino.cc> | 2008-10-13 15:03:20 +0000 |
commit | 5444b25e11bce6139a58c8a641dccd266f90a0f1 (patch) | |
tree | 8da36e16ca20fbb31fdcd4314dd108452bda3253 /cores/arduino/WMath.cpp | |
parent | b7ec38e61a4f92ade80e38744d00311538671179 (diff) |
Little fixes:
- changing random(max) to use stdlib.h random()
- not generating .eep files to avoid warning when EEMEM isn't used
- removing cast macros (since they are automatically defined in C++)
- writing a digital LOW for PWM value of 0 on pins 5 or 6
Diffstat (limited to 'cores/arduino/WMath.cpp')
-rw-r--r-- | cores/arduino/WMath.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/cores/arduino/WMath.cpp b/cores/arduino/WMath.cpp index 78667f3..294d0dd 100644 --- a/cores/arduino/WMath.cpp +++ b/cores/arduino/WMath.cpp @@ -29,23 +29,22 @@ extern "C" { void randomSeed(unsigned int seed) { - if(seed != 0){ - srand(seed); + if (seed != 0) { + srandom(seed); } } long random(long howbig) { - long value; - if (howbig == 0){ + if (howbig == 0) { return 0; } - return (rand() * 0x10000L + rand()) % howbig; + return random() % howbig; } long random(long howsmall, long howbig) { - if(howsmall >= howbig){ + if (howsmall >= howbig) { return howsmall; } long diff = howbig - howsmall; |