mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-18 12:54:25 +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:
parent
30dc672dff
commit
2ba54d2cbf
@ -210,6 +210,9 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
List commandObjcopy;
|
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 = new ArrayList(baseCommandObjcopy);
|
||||||
commandObjcopy.add(2, "ihex");
|
commandObjcopy.add(2, "ihex");
|
||||||
commandObjcopy.set(3, "-j");
|
commandObjcopy.set(3, "-j");
|
||||||
@ -221,10 +224,11 @@ public class Compiler implements MessageConsumer {
|
|||||||
commandObjcopy.add(buildPath + File.separator + sketch.name + ".eep");
|
commandObjcopy.add(buildPath + File.separator + sketch.name + ".eep");
|
||||||
if (execAsynchronously(commandObjcopy) != 0)
|
if (execAsynchronously(commandObjcopy) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
*/
|
||||||
|
|
||||||
commandObjcopy = new ArrayList(baseCommandObjcopy);
|
commandObjcopy = new ArrayList(baseCommandObjcopy);
|
||||||
commandObjcopy.add(2, "ihex");
|
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 + ".elf");
|
||||||
commandObjcopy.add(buildPath + File.separator + sketch.name + ".hex");
|
commandObjcopy.add(buildPath + File.separator + sketch.name + ".hex");
|
||||||
if (execAsynchronously(commandObjcopy) != 0)
|
if (execAsynchronously(commandObjcopy) != 0)
|
||||||
|
@ -30,17 +30,16 @@ extern "C" {
|
|||||||
void randomSeed(unsigned int seed)
|
void randomSeed(unsigned int seed)
|
||||||
{
|
{
|
||||||
if (seed != 0) {
|
if (seed != 0) {
|
||||||
srand(seed);
|
srandom(seed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long random(long howbig)
|
long random(long howbig)
|
||||||
{
|
{
|
||||||
long value;
|
|
||||||
if (howbig == 0) {
|
if (howbig == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return (rand() * 0x10000L + rand()) % howbig;
|
return random() % howbig;
|
||||||
}
|
}
|
||||||
|
|
||||||
long random(long howsmall, long howbig)
|
long random(long howsmall, long howbig)
|
||||||
|
@ -66,12 +66,12 @@ extern "C"{
|
|||||||
#undef abs
|
#undef abs
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define int(x) ((int)(x))
|
//#define int(x) ((int)(x))
|
||||||
#define char(x) ((char)(x))
|
//#define char(x) ((char)(x))
|
||||||
#define long(x) ((long)(x))
|
//#define long(x) ((long)(x))
|
||||||
#define byte(x) ((uint8_t)(x))
|
//#define byte(x) ((uint8_t)(x))
|
||||||
#define float(x) ((float)(x))
|
//#define float(x) ((float)(x))
|
||||||
#define boolean(x) ((uint8_t)((x)==0?0:1))
|
//#define boolean(x) ((uint8_t)((x)==0?0:1))
|
||||||
|
|
||||||
#define min(a,b) ((a)<(b)?(a):(b))
|
#define min(a,b) ((a)<(b)?(a):(b))
|
||||||
#define max(a,b) ((a)>(b)?(a):(b))
|
#define max(a,b) ((a)>(b)?(a):(b))
|
||||||
|
@ -89,15 +89,23 @@ void analogWrite(uint8_t pin, int val)
|
|||||||
OCR1B = val;
|
OCR1B = val;
|
||||||
#if defined(__AVR_ATmega168__)
|
#if defined(__AVR_ATmega168__)
|
||||||
} else if (digitalPinToTimer(pin) == TIMER0A) {
|
} else if (digitalPinToTimer(pin) == TIMER0A) {
|
||||||
|
if (val == 0) {
|
||||||
|
digitalWrite(pin, LOW);
|
||||||
|
} else {
|
||||||
// connect pwm to pin on timer 0, channel A
|
// connect pwm to pin on timer 0, channel A
|
||||||
sbi(TCCR0A, COM0A1);
|
sbi(TCCR0A, COM0A1);
|
||||||
// set pwm duty
|
// set pwm duty
|
||||||
OCR0A = val;
|
OCR0A = val;
|
||||||
|
}
|
||||||
} else if (digitalPinToTimer(pin) == TIMER0B) {
|
} else if (digitalPinToTimer(pin) == TIMER0B) {
|
||||||
|
if (val == 0) {
|
||||||
|
digitalWrite(pin, LOW);
|
||||||
|
} else {
|
||||||
// connect pwm to pin on timer 0, channel B
|
// connect pwm to pin on timer 0, channel B
|
||||||
sbi(TCCR0A, COM0B1);
|
sbi(TCCR0A, COM0B1);
|
||||||
// set pwm duty
|
// set pwm duty
|
||||||
OCR0B = val;
|
OCR0B = val;
|
||||||
|
}
|
||||||
} else if (digitalPinToTimer(pin) == TIMER2A) {
|
} else if (digitalPinToTimer(pin) == TIMER2A) {
|
||||||
// connect pwm to pin on timer 2, channel A
|
// connect pwm to pin on timer 2, channel A
|
||||||
sbi(TCCR2A, COM2A1);
|
sbi(TCCR2A, COM2A1);
|
||||||
|
1
todo.txt
1
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.
|
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).
|
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)
|
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 uploading of .hex files.
|
||||||
Allow for arbitrary compilation command line arguments.
|
Allow for arbitrary compilation command line arguments.
|
||||||
Find in reference should give same message for missing page as for missing page association.
|
Find in reference should give same message for missing page as for missing page association.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user