1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-15 12:29:26 +01:00

Avoid delay in heartbeat. That way we can also set the baudrate back to the value used in the IDE. In fact, with this fix, baud rates of up to 115200 work also.

This commit is contained in:
Peter Van Hoyweghen 2015-02-13 20:48:40 +01:00
parent aeaed27e13
commit ad2a32fd24

View File

@ -67,7 +67,7 @@
void pulse(int pin, int times); void pulse(int pin, int times);
void setup() { void setup() {
Serial.begin(9600); Serial.begin(19200);
SPI.setDataMode(0); SPI.setDataMode(0);
SPI.setBitOrder(MSBFIRST); SPI.setBitOrder(MSBFIRST);
// Clock Div can be 2,4,8,16,32,64, or 128 // Clock Div can be 2,4,8,16,32,64, or 128
@ -111,18 +111,17 @@ parameter param;
uint8_t hbval = 128; uint8_t hbval = 128;
int8_t hbdelta = 8; int8_t hbdelta = 8;
void heartbeat() { void heartbeat() {
if (hbval > 192) { static unsigned long last_time = 0;
hbdelta = -hbdelta; unsigned long now = millis();
} if ((now - last_time) < 40)
if (hbval < 32) { return;
hbdelta = -hbdelta; last_time = now;
} if (hbval > 192) hbdelta = -hbdelta;
if (hbval < 32) hbdelta = -hbdelta;
hbval += hbdelta; hbval += hbdelta;
analogWrite(LED_HB, hbval); analogWrite(LED_HB, hbval);
delay(20);
} }
void loop(void) { void loop(void) {
// is pmode active? // is pmode active?
if (pmode) { if (pmode) {