Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 6027a01

Browse files
authored
Update README.md
1 parent da782ba commit 6027a01

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ It is tested and working with
1313
1. The `ESP8266` Arduino platform with a recent stable release [`ESP8266 Core 2.6.2 or newer`] (https://github.com/esp8266/Arduino)
1414
2. The `ESP32` Arduino platform with a recent stable release [`ESP32 Core 1.0.4 or newer`] (https://github.com/espressif/arduino-esp32)
1515

16+
### Quick Start
17+
18+
#### Installing
19+
20+
The easiest way is to use `Arduino Library Manager`. Search for `ESP_DoubleResetDetector`, then select / install the latest version.
21+
1622
### Releases
1723
#### New in v1.0.1
1824

@@ -24,3 +30,77 @@ It is tested and working with
2430

2531
Detects a double reset so that an alternative start-up mode can be used. One example use is to allow re-configuration of a device's wifi credentials.
2632

33+
### Usage
34+
35+
How to use
36+
37+
```cpp
38+
// These defines must be put before #include <ESP_DoubleResetDetector.h>
39+
// to select where to store DoubleResetDetector's variable.
40+
// For ESP32, You must select one to be true (EEPROM or SPIFFS)
41+
// For ESP8266, You must select one to be true (RTC, EEPROM or SPIFFS)
42+
// Otherwise, library will use default EEPROM storage
43+
#define ESP_DRD_USE_EEPROM false
44+
#define ESP_DRD_USE_SPIFFS true //false
45+
46+
#ifdef ESP8266
47+
#define ESP8266_DRD_USE_RTC false //true
48+
#endif
49+
50+
#define DOUBLERESETDETECTOR_DEBUG true //false
51+
52+
#include <ESP_DoubleResetDetector.h> //https://github.com/khoih-prog/ESP_DoubleResetDetector
53+
54+
// Number of seconds after reset during which a
55+
// subseqent reset will be considered a double reset.
56+
#define DRD_TIMEOUT 10
57+
58+
// RTC Memory Address for the DoubleResetDetector to use
59+
#define DRD_ADDRESS 0
60+
61+
DoubleResetDetector* drd;
62+
63+
void setup()
64+
{
65+
pinMode(LED_BUILTIN, OUTPUT);
66+
67+
Serial.begin(115200);
68+
Serial.println("\Starting");
69+
70+
drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);
71+
72+
if (drd->detectDoubleReset())
73+
{
74+
Serial.println("Double Reset Detected");
75+
digitalWrite(LED_BUILTIN, LOW);
76+
}
77+
else
78+
{
79+
Serial.println("No Double Reset Detected");
80+
digitalWrite(LED_BUILTIN, HIGH);
81+
}
82+
}
83+
84+
void loop()
85+
{
86+
// Call the double reset detector loop method every so often,
87+
// so that it can recognise when the timeout expires.
88+
// You can also call drd.stop() when you wish to no longer
89+
// consider the next reset as a double reset.
90+
drd->loop();
91+
}
92+
```
93+
### TO DO
94+
95+
1. Search for bug and improvement.
96+
2. Similar features for Arduino (UNO, Mega, etc...)
97+
98+
### Contributing
99+
If you want to contribute to this project:
100+
- Report bugs and errors
101+
- Ask for enhancements
102+
- Create issues and pull requests
103+
- Tell other people about this library
104+
105+
### Copyright
106+
Copyright 2019- Khoi Hoang

0 commit comments

Comments
 (0)