From 92e65abde71c7b53797e3dd5550ef42ca58889b7 Mon Sep 17 00:00:00 2001 From: David Madison Date: Fri, 5 May 2017 08:07:35 -0400 Subject: [PATCH] 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. --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index 177ca7d..f5a3e6d 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -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 + } } }