Panic at end of bench()
This commit is contained in:
parent
3a95a80333
commit
6d342e4e0e
|
|
@ -28,6 +28,7 @@ void bench() {
|
||||||
int elapsed = micros() - startTime;
|
int elapsed = micros() - startTime;
|
||||||
Serial.print(elapsed);
|
Serial.print(elapsed);
|
||||||
Serial.println(F("microseconds for 5 moves"));
|
Serial.println(F("microseconds for 5 moves"));
|
||||||
|
panic(F("Bench finished!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
4
Config.h
4
Config.h
|
|
@ -1,3 +1,7 @@
|
||||||
// CLEAR_UNMOVE is a feature that clears the unmake stack when it is not used.
|
// CLEAR_UNMOVE is a feature that clears the unmake stack when it is not used.
|
||||||
// This is useful for making it more human readable
|
// This is useful for making it more human readable
|
||||||
//#define _ACF_CLEAR_UNMOVE
|
//#define _ACF_CLEAR_UNMOVE
|
||||||
|
|
||||||
|
// PANIC_BLINK makes the Arduino blink an error code when it panics.
|
||||||
|
// Costs a lot of flash though (around 700 bytes)
|
||||||
|
//#define _ACF_PANIC_BLINK
|
||||||
|
|
|
||||||
41
Panic.h
41
Panic.h
|
|
@ -1,12 +1,43 @@
|
||||||
#ifndef __PANIC_H_INC
|
#ifndef __PANIC_H_INC
|
||||||
#define __PANIC_H_INC
|
#define __PANIC_H_INC
|
||||||
|
|
||||||
void panic(const __FlashStringHelper* message) {
|
#pragma GCC push_options
|
||||||
|
#pragma GCC optimize("-Os")
|
||||||
|
|
||||||
|
#ifdef _ACF_PANIC_BLINK
|
||||||
|
void sos() {
|
||||||
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
while(true) {
|
while(true) {
|
||||||
Serial.println(F("PANIC!"));
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
Serial.println(message);
|
delay(500);
|
||||||
delay(1000);
|
digitalWrite(LED_BUILTIN, LOW);
|
||||||
|
delay(200);
|
||||||
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
|
delay(150);
|
||||||
|
digitalWrite(LED_BUILTIN, LOW);
|
||||||
|
delay(150);
|
||||||
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
|
delay(150);
|
||||||
|
digitalWrite(LED_BUILTIN, LOW);
|
||||||
|
delay(150);
|
||||||
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
|
delay(150);
|
||||||
|
digitalWrite(LED_BUILTIN, LOW);
|
||||||
|
delay(150);
|
||||||
|
delay(2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void panic(const __FlashStringHelper* message) {
|
||||||
|
Serial.println(F("PANIC!"));
|
||||||
|
Serial.println(message);
|
||||||
|
|
||||||
|
#ifdef _ACF_PANIC_BLINK
|
||||||
|
sos();
|
||||||
|
#endif
|
||||||
|
while(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma GCC pop_options
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue