1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-30 11:24:12 +01:00

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
This commit is contained in:
David A. Mellis 2008-10-13 15:03:20 +00:00
parent 30dc672dff
commit 2ba54d2cbf
5 changed files with 34 additions and 22 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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))

View File

@ -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);

View File

@ -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.