Optimized code

- Removed unneccesary variable changes
- Redesigned IF clauses to improve binary code size after compile

Current binary size: 2092 bytes
This commit is contained in:
DarkSpir 2018-01-06 16:03:51 +01:00 committed by GitHub
parent d224488f2b
commit be4a1b0488
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 8 deletions

View File

@ -52,12 +52,10 @@ void loop() {
case 0:
digitalWrite(PINLIGHT, HIGH);
effLight = 1;
sleepBool = false;
break;
case 1:
effLight = 2;
sleepBool = false;
effStrobo = geninterval();
stroboMillis = millis();
break;
@ -65,8 +63,6 @@ void loop() {
case 2:
digitalWrite(PINLIGHT, LOW);
effLight = 0;
effStrobo = 0;
sleepBool = false;
break;
}
}
@ -79,10 +75,10 @@ void loop() {
}
}
if((effLight == 0) && (effLaser == 0) && (!sleepBool)) {
sleepBool = true;
sleepMillis = millis();
}
// if((effLight == 0) && (effLaser == 0) && (!sleepBool)) {
// sleepBool = true;
// sleepMillis = millis();
// }
if(sleepBool) {
if(millis() - sleepMillis > 200) {
@ -101,6 +97,11 @@ void loop() {
PCMSK = 0; // We disabled PCINT so we don't need to know what kind of PCINT we should listen to
sei(); // Cleanup done, enable interrupt handling again.
}
} else {
if((effLight == 0) && (effLaser == 0)) {
sleepBool = true;
sleepMillis = millis();
}
}
}