diff --git a/app/Compiler.java b/app/Compiler.java index 1ccfa1444..248b9266c 100644 --- a/app/Compiler.java +++ b/app/Compiler.java @@ -209,7 +209,10 @@ public class Compiler implements MessageConsumer { return false; List commandObjcopy; - + + /* + // Extract EEPROM data (from EEMEM directive) to .eep file. + // Commented out because it generates a warning if EEMEM isn't used. commandObjcopy = new ArrayList(baseCommandObjcopy); commandObjcopy.add(2, "ihex"); commandObjcopy.set(3, "-j"); @@ -221,10 +224,11 @@ public class Compiler implements MessageConsumer { commandObjcopy.add(buildPath + File.separator + sketch.name + ".eep"); if (execAsynchronously(commandObjcopy) != 0) return false; + */ commandObjcopy = new ArrayList(baseCommandObjcopy); commandObjcopy.add(2, "ihex"); - commandObjcopy.add(".eeprom"); + commandObjcopy.add(".eeprom"); // remove eeprom data commandObjcopy.add(buildPath + File.separator + sketch.name + ".elf"); commandObjcopy.add(buildPath + File.separator + sketch.name + ".hex"); if (execAsynchronously(commandObjcopy) != 0) diff --git a/hardware/cores/arduino/WMath.cpp b/hardware/cores/arduino/WMath.cpp index 78667f331..294d0dd19 100644 --- a/hardware/cores/arduino/WMath.cpp +++ b/hardware/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; diff --git a/hardware/cores/arduino/wiring.h b/hardware/cores/arduino/wiring.h index 26cba9ea4..3701f6dff 100755 --- a/hardware/cores/arduino/wiring.h +++ b/hardware/cores/arduino/wiring.h @@ -66,12 +66,12 @@ extern "C"{ #undef abs #endif -#define int(x) ((int)(x)) -#define char(x) ((char)(x)) -#define long(x) ((long)(x)) -#define byte(x) ((uint8_t)(x)) -#define float(x) ((float)(x)) -#define boolean(x) ((uint8_t)((x)==0?0:1)) +//#define int(x) ((int)(x)) +//#define char(x) ((char)(x)) +//#define long(x) ((long)(x)) +//#define byte(x) ((uint8_t)(x)) +//#define float(x) ((float)(x)) +//#define boolean(x) ((uint8_t)((x)==0?0:1)) #define min(a,b) ((a)<(b)?(a):(b)) #define max(a,b) ((a)>(b)?(a):(b)) diff --git a/hardware/cores/arduino/wiring_analog.c b/hardware/cores/arduino/wiring_analog.c index 30c5642cc..de0372e02 100755 --- a/hardware/cores/arduino/wiring_analog.c +++ b/hardware/cores/arduino/wiring_analog.c @@ -89,15 +89,23 @@ void analogWrite(uint8_t pin, int val) OCR1B = val; #if defined(__AVR_ATmega168__) } else if (digitalPinToTimer(pin) == TIMER0A) { - // connect pwm to pin on timer 0, channel A - sbi(TCCR0A, COM0A1); - // set pwm duty - OCR0A = val; + if (val == 0) { + digitalWrite(pin, LOW); + } else { + // connect pwm to pin on timer 0, channel A + sbi(TCCR0A, COM0A1); + // set pwm duty + OCR0A = val; + } } else if (digitalPinToTimer(pin) == TIMER0B) { - // connect pwm to pin on timer 0, channel B - sbi(TCCR0A, COM0B1); - // set pwm duty - OCR0B = val; + if (val == 0) { + digitalWrite(pin, LOW); + } else { + // connect pwm to pin on timer 0, channel B + sbi(TCCR0A, COM0B1); + // set pwm duty + OCR0B = val; + } } else if (digitalPinToTimer(pin) == TIMER2A) { // connect pwm to pin on timer 2, channel A sbi(TCCR2A, COM2A1); diff --git a/todo.txt b/todo.txt index 3c188a4a8..4b2a31aea 100644 --- a/todo.txt +++ b/todo.txt @@ -73,6 +73,7 @@ Investigate method for auto-detecting serial port on Windows (javax.usb?) Guess serial port on the Mac and Linux. Automatic detection of baud rate for serial monitor (based on the call to Serial.begin() in the current sketch). Improve, generally, the upload experience (e.g. faster program start after upload, keep-alive messages to bootloader from IDE, shorter bootloader timeout if possible, progress bar) +Generate .eep files for EEPROM variables (without warning when the EEMEM directive isn't used). Allow uploading of .hex files. Allow for arbitrary compilation command line arguments. Find in reference should give same message for missing page as for missing page association.