Added additional comments

This commit is contained in:
David Madison 2017-05-05 09:16:01 -04:00
parent e9092c39fe
commit 203abb8740
1 changed files with 6 additions and 3 deletions

View File

@ -127,10 +127,9 @@ void loop(){
} }
void adalight(){ void adalight(){
// Implementation is a simple finite-state machine. t = millis(); // Save current time
// Regardless of mode, check for serial input each time:
t = millis();
// If there is new serial data
if((c = Serial.read()) >= 0){ if((c = Serial.read()) >= 0){
lastByteTime = lastAckTime = t; // Reset timeout counters lastByteTime = lastAckTime = t; // Reset timeout counters
@ -144,6 +143,7 @@ void adalight(){
} }
} }
else { else {
// No new data
timeouts(); timeouts();
} }
} }
@ -154,10 +154,12 @@ void headerMode(){
hi, lo, chk; hi, lo, chk;
if(headPos < MAGICSIZE){ if(headPos < MAGICSIZE){
// Check if magic word matches
if(c == magic[headPos]) {headPos++;} if(c == magic[headPos]) {headPos++;}
else {headPos = 0;} else {headPos = 0;}
} }
else{ else{
// Magic word matches! Now verify checksum
switch(headPos){ switch(headPos){
case HICHECK: case HICHECK:
hi = c; hi = c;
@ -185,6 +187,7 @@ void headerMode(){
} }
void dataMode(){ void dataMode(){
// If LED data is not full
if (outPos < sizeof(leds)){ if (outPos < sizeof(leds)){
dataSet(); dataSet();
} }