Merge pull request #13 from dmadison/timeouts

Updated Timeouts
This commit is contained in:
David Madison 2017-12-04 20:05:22 -05:00 committed by GitHub
commit 9a66ac9d61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -36,7 +36,7 @@ static const uint8_t
static const unsigned long static const unsigned long
SerialSpeed = 115200; // serial port speed SerialSpeed = 115200; // serial port speed
static const uint16_t static const uint16_t
SerialTimeout = 150; // time before LEDs are shut off if no data (in seconds) SerialTimeout = 60; // time before LEDs are shut off if no data (in seconds), 0 to disable
// --- Optional Settings (uncomment to add) // --- Optional Settings (uncomment to add)
#define SERIAL_FLUSH // Serial buffer cleared on LED latch #define SERIAL_FLUSH // Serial buffer cleared on LED latch
@ -234,12 +234,12 @@ void dataSet(){
void timeouts(){ void timeouts(){
// No data received. If this persists, send an ACK packet // No data received. If this persists, send an ACK packet
// to host once every second to alert it to our presence. // 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 Serial.print("Ada\n"); // Send ACK string to host
lastAckTime = t; // Reset counter lastAckTime = t; // Reset counter
// If no data received for an extended time, turn off all LEDs. // If no data received for an extended time, turn off all LEDs.
if((t - lastByteTime) > SerialTimeout * 1000) { if(SerialTimeout != 0 && (t - lastByteTime) >= (uint32_t) SerialTimeout * 1000) {
memset(leds, 0, Num_Leds * sizeof(struct CRGB)); //filling Led array by zeroes memset(leds, 0, Num_Leds * sizeof(struct CRGB)); //filling Led array by zeroes
FastLED.show(); FastLED.show();
mode = Header; mode = Header;