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,7 +222,7 @@ 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
@ -230,6 +230,7 @@ void timeouts(){
lastByteTime = t; // Reset counter
}
}
}
void loop(){
// loop() is avoided as even that small bit of function overhead