mirror of
https://github.com/brmlab/lasic.git
synced 2025-06-08 17:23:59 +02:00
Sketch: Clean up the reading loop slightly
This commit is contained in:
parent
40cbce606b
commit
360e7338b8
1 changed files with 6 additions and 7 deletions
|
@ -44,26 +44,25 @@ void loop() {
|
||||||
while(Serial.available()) {
|
while(Serial.available()) {
|
||||||
lastTime = millis();
|
lastTime = millis();
|
||||||
InByte = Serial.read();
|
InByte = Serial.read();
|
||||||
if (InCmdIndex >= sizeof(InCmd)){
|
|
||||||
InCmdIndex = 0;
|
|
||||||
Serial.println("INPUT COMMAND OVERFLOW");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (InByte == 10 || InByte == 13 ) {
|
if (InByte == 10 || InByte == 13 ) {
|
||||||
//Serial.println(sizeof(InCmd),DEC);
|
//Serial.println(sizeof(InCmd),DEC);
|
||||||
|
InCmd[InCmdIndex] = 0;
|
||||||
ExeCmd(InCmd);
|
ExeCmd(InCmd);
|
||||||
for (InCmdIndex++; InCmdIndex>0; InCmdIndex--) {
|
for (; InCmdIndex>0; InCmdIndex--) {
|
||||||
InCmd[InCmdIndex] = 0;
|
InCmd[InCmdIndex] = 0;
|
||||||
}
|
}
|
||||||
InCmdIndex = 0;
|
InCmdIndex = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
InCmd[InCmdIndex++] = InByte;
|
InCmd[InCmdIndex++] = InByte;
|
||||||
|
if (InCmdIndex >= sizeof(InCmd)){
|
||||||
|
InCmdIndex = 0;
|
||||||
|
Serial.println("INPUT COMMAND OVERFLOW");
|
||||||
|
}
|
||||||
}// Serial.println(InCmdIndex, DEC);
|
}// Serial.println(InCmdIndex, DEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( (lastTime + 15000) < millis() ) {
|
if ( (lastTime + 15000) < millis() ) {
|
||||||
digitalWrite(LaserPIN, LOW);
|
digitalWrite(LaserPIN, LOW);
|
||||||
digitalWrite(2, LOW);
|
digitalWrite(2, LOW);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue