DoubleResetDetector_Generic is a library for the Arduino AVR, Teensy, SAM-DUE, SAMD, STM32, etc. boards to enable trigger configure mode by resetting the boards twice within configurable timeout seconds.
Releases v1.0.0
- Support boards such as AVR, Teensy, SAM DUE, SAMD and STM32, etc.
- AVR Mega, Teensy, STM32 to save data in EPPROM
- SAMD to sve data in EEPROM-simulated FlashStorage
- SAM DUE to save data in DueFlashStorage
This library will help detect a double reset
within a configurable time, so that an alternative start-up mode / function
can be used. For example:
- To allow re-configuration of a device’s
WiFi / Blynk credentials
. - To do some
out-of-schedule work
, such asclearing data, loading defaults, etc.
The 4-byte flag data is stored in EEPROM, FlashStorage or DueFlashStorage.
See example how to use this library in minimal example
#define DRD_GENERIC_DEBUG true //false
#include <DoubleResetDetector_Generic.h>
// Number of seconds after reset during which a
// subseqent reset will be considered a double reset.
#define DRD_TIMEOUT 10
// RTC Memory Address for the DoubleResetDetector to use
#define DRD_ADDRESS 0
DoubleResetDetector_Generic* drd;
#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#endif
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
while (!Serial);
Serial.println();
Serial.println("DoubleResetDetector Example Program");
Serial.println("-----------------------------------");
drd = new DoubleResetDetector_Generic(DRD_TIMEOUT, DRD_ADDRESS);
if (drd->detectDoubleReset()) {
Serial.println("Double Reset Detected");
digitalWrite(LED_BUILTIN, LOW);
} else {
Serial.println("No Double Reset Detected");
digitalWrite(LED_BUILTIN, HIGH);
}
}
void loop()
{
// Call the double reset detector loop method every so often,
// so that it can recognise when the timeout expires.
// You can also call drd.stop() when you wish to no longer
// consider the next reset as a double reset.
drd->loop();
}