From 5444b25e11bce6139a58c8a641dccd266f90a0f1 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Mon, 13 Oct 2008 15:03:20 +0000 Subject: 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 --- cores/arduino/WMath.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'cores/arduino/WMath.cpp') 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; -- cgit v1.2.3-18-g5258