From 0b28f24b2e9587a628390c3c82dd711aa25f7db5 Mon Sep 17 00:00:00 2001 From: David Madison Date: Mon, 4 Dec 2017 19:11:30 -0500 Subject: [PATCH 1/4] Evaluate timeouts on the second --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index 01db0e1..a16ef66 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -234,12 +234,12 @@ void dataSet(){ void timeouts(){ // No data received. If this persists, send an ACK packet // to host once every second to alert it to our presence. - if((t - lastAckTime) > 1000) { + 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 * 1000) { + if((t - lastByteTime) >= SerialTimeout * 1000) { memset(leds, 0, Num_Leds * sizeof(struct CRGB)); //filling Led array by zeroes FastLED.show(); mode = Header; From 061ac5edfdaf39bc8fcb2c8e93b7860e7c03a088 Mon Sep 17 00:00:00 2001 From: David Madison Date: Mon, 4 Dec 2017 19:26:35 -0500 Subject: [PATCH 2/4] Fixed serial timeout overflow --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index a16ef66..4675c08 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -239,7 +239,7 @@ void timeouts(){ lastAckTime = t; // Reset counter // If no data received for an extended time, turn off all LEDs. - if((t - lastByteTime) >= SerialTimeout * 1000) { + if((t - lastByteTime) >= (uint32_t) SerialTimeout * 1000) { memset(leds, 0, Num_Leds * sizeof(struct CRGB)); //filling Led array by zeroes FastLED.show(); mode = Header; From 564637b1db16ca79894425f6dc25b5ad8d28afc9 Mon Sep 17 00:00:00 2001 From: David Madison Date: Mon, 4 Dec 2017 19:43:20 -0500 Subject: [PATCH 3/4] Added 'off' setting for serial timeout --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index 4675c08..0ae8787 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -36,7 +36,7 @@ static const uint8_t static const unsigned long SerialSpeed = 115200; // serial port speed static const uint16_t - SerialTimeout = 150; // time before LEDs are shut off if no data (in seconds) + SerialTimeout = 150; // time before LEDs are shut off if no data (in seconds), 0 to disable // --- Optional Settings (uncomment to add) #define SERIAL_FLUSH // Serial buffer cleared on LED latch @@ -239,7 +239,7 @@ void timeouts(){ lastAckTime = t; // Reset counter // If no data received for an extended time, turn off all LEDs. - if((t - lastByteTime) >= (uint32_t) SerialTimeout * 1000) { + if(SerialTimeout != 0 && (t - lastByteTime) >= (uint32_t) SerialTimeout * 1000) { memset(leds, 0, Num_Leds * sizeof(struct CRGB)); //filling Led array by zeroes FastLED.show(); mode = Header; From 79edc6911d89f3db4d28794eb09a8bd553b474c7 Mon Sep 17 00:00:00 2001 From: David Madison Date: Mon, 4 Dec 2017 19:51:02 -0500 Subject: [PATCH 4/4] Decreased default timeout 2:30 is a little long, don't you think? --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index 0ae8787..0a390b1 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -36,7 +36,7 @@ static const uint8_t static const unsigned long SerialSpeed = 115200; // serial port speed static const uint16_t - SerialTimeout = 150; // time before LEDs are shut off if no data (in seconds), 0 to disable + SerialTimeout = 60; // time before LEDs are shut off if no data (in seconds), 0 to disable // --- Optional Settings (uncomment to add) #define SERIAL_FLUSH // Serial buffer cleared on LED latch