From 203abb87408e5926719fc4e262e7b03b1760be54 Mon Sep 17 00:00:00 2001 From: David Madison Date: Fri, 5 May 2017 09:16:01 -0400 Subject: [PATCH] Added additional comments --- Arduino/LEDstream_FastLED/LEDstream_FastLED.ino | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino index 6036076..0e31f8a 100644 --- a/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino +++ b/Arduino/LEDstream_FastLED/LEDstream_FastLED.ino @@ -127,10 +127,9 @@ void loop(){ } void adalight(){ - // Implementation is a simple finite-state machine. - // Regardless of mode, check for serial input each time: - t = millis(); + t = millis(); // Save current time + // If there is new serial data if((c = Serial.read()) >= 0){ lastByteTime = lastAckTime = t; // Reset timeout counters @@ -144,6 +143,7 @@ void adalight(){ } } else { + // No new data timeouts(); } } @@ -154,10 +154,12 @@ void headerMode(){ hi, lo, chk; if(headPos < MAGICSIZE){ + // Check if magic word matches if(c == magic[headPos]) {headPos++;} else {headPos = 0;} } else{ + // Magic word matches! Now verify checksum switch(headPos){ case HICHECK: hi = c; @@ -185,6 +187,7 @@ void headerMode(){ } void dataMode(){ + // If LED data is not full if (outPos < sizeof(leds)){ dataSet(); }