Created
March 12, 2018 11:26
-
-
Save msraynsford/fd9416512434f7748587927f86741d35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(115200); Serial.println(); | |
pinMode(LED_BUILTIN, OUTPUT); | |
digitalWrite(LED_BUILTIN, HIGH); | |
//Activate the EEPROM before attempting to use it | |
EEPROM.begin(sizeof(flag)); | |
//Check to see if the flag is still set from the previous boot | |
if(checkFlag()) { | |
//Clear the flag now it has been detected | |
writeFlag(FLAGCLEAR); | |
//Do the firmware reset here | |
Serial.println("Flag Detected"); | |
digitalWrite(LED_BUILTIN, LOW); | |
} | |
else { | |
//Set the flag for detection with the next boot | |
writeFlag(FLAGSET); | |
} | |
// After setup, while away the end of the reset period | |
while (millis() < FLAGTIMEOUT); | |
writeFlag(FLAGCLEAR); | |
Serial.println("Flag Checking Stopped"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment