Nested serial timeout check

Should give a significant performance improvement, reducing the delay
before a received byte is processed. Limits timeout periods to
increments of 1000, though.
This commit is contained in:
David Madison 2017-05-05 08:07:35 -04:00
parent 92362303b8
commit 92e65abde7
1 changed files with 7 additions and 6 deletions

View File

@ -222,12 +222,13 @@ void timeouts(){
if((t - lastAckTime) > 1000) {
Serial.print("Ada\n"); // Send ACK string to host
lastAckTime = t; // Reset counter
}
// If no data received for an extended time, turn off all LEDs.
if((t - lastByteTime) > SerialTimeout) {
memset(leds, 0, Num_Leds * sizeof(struct CRGB)); //filling Led array by zeroes
FastLED.show();
lastByteTime = t; // Reset counter
// If no data received for an extended time, turn off all LEDs.
if((t - lastByteTime) > SerialTimeout) {
memset(leds, 0, Num_Leds * sizeof(struct CRGB)); //filling Led array by zeroes
FastLED.show();
lastByteTime = t; // Reset counter
}
}
}