wip: testing
This commit is contained in:
@@ -12,43 +12,43 @@ void setup() {
|
||||
pinMode(PIN_BOOT, OUTPUT);
|
||||
//NOTE might want to replace this initialization with a check in the first loop, so we dont instantly reboot
|
||||
startTimeMillis = millis();
|
||||
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (Serial.available() > 0) { // if something has been written to the serial port
|
||||
// Serial Connection has received data? Reset Timer
|
||||
if (Serial.available() > 0) {
|
||||
startTimeMillis = millis();
|
||||
clearSerial();
|
||||
rebooted = false;
|
||||
Serial.println("read serial");
|
||||
}
|
||||
unsigned long timeElapsed = millis() - startTimeMillis;
|
||||
|
||||
// TODO fix instant reboot
|
||||
// reboot?
|
||||
if (timeElapsed > HEARTBEAT_REBOOT_DELAY_MILLIS && not rebooted){
|
||||
pin_switch(PIN_REBOOT);
|
||||
startTimeMillis = millis();
|
||||
rebooted = true;
|
||||
Serial.println("reboot");
|
||||
|
||||
}
|
||||
|
||||
// boot?
|
||||
if (timeElapsed > HEARTBEAT_BOOT_DELAY_MILLIS){
|
||||
pin_switch(PIN_BOOT);
|
||||
startTimeMillis = millis();
|
||||
Serial.println("boot");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pin_switch(int pin){
|
||||
//TODO connect the RST pins on the motherboard
|
||||
digitalWrite(pin, LOW);
|
||||
delay(500);
|
||||
digitalWrite(pin, HIGH);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void clearSerial(){
|
||||
while (Serial.available()>0){
|
||||
char t = Serial.read();
|
||||
|
||||
Reference in New Issue
Block a user