Removed 'loop' avoidance
Cleans up the code slightly. If the compiler is smart, the functions are inlined regardless.
This commit is contained in:
parent
0e16794589
commit
e9092c39fe
|
@ -117,39 +117,35 @@ void setup(){
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Serial.begin(SerialSpeed);
|
Serial.begin(SerialSpeed);
|
||||||
|
Serial.print("Ada\n"); // Send ACK string to host
|
||||||
|
|
||||||
|
lastByteTime = lastAckTime = millis(); // Set initial counters
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop(){
|
||||||
adalight();
|
adalight();
|
||||||
}
|
}
|
||||||
|
|
||||||
void adalight(){
|
void adalight(){
|
||||||
Serial.print("Ada\n"); // Send ACK string to host
|
// Implementation is a simple finite-state machine.
|
||||||
|
// Regardless of mode, check for serial input each time:
|
||||||
|
t = millis();
|
||||||
|
|
||||||
lastByteTime = lastAckTime = millis();
|
if((c = Serial.read()) >= 0){
|
||||||
|
lastByteTime = lastAckTime = t; // Reset timeout counters
|
||||||
|
|
||||||
// loop() is avoided as even that small bit of function overhead
|
switch(mode) {
|
||||||
// has a measurable impact on this code's overall throughput.
|
case MODE_HEADER:
|
||||||
|
headerMode();
|
||||||
for(;;) {
|
break;
|
||||||
// Implementation is a simple finite-state machine.
|
case MODE_DATA:
|
||||||
// Regardless of mode, check for serial input each time:
|
dataMode();
|
||||||
t = millis();
|
break;
|
||||||
|
|
||||||
if((c = Serial.read()) >= 0){
|
|
||||||
lastByteTime = lastAckTime = t; // Reset timeout counters
|
|
||||||
|
|
||||||
switch(mode) {
|
|
||||||
case MODE_HEADER:
|
|
||||||
headerMode();
|
|
||||||
break;
|
|
||||||
case MODE_DATA:
|
|
||||||
dataMode();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
timeouts();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
timeouts();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void headerMode(){
|
void headerMode(){
|
||||||
|
@ -231,8 +227,3 @@ void timeouts(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(){
|
|
||||||
// loop() is avoided as even that small bit of function overhead
|
|
||||||
// has a measurable impact on this code's overall throughput.
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue