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

Commit fc8be81

Browse files
authored
v1.0.3
### Releases v1.0.3 1. Update to use the new LittleFS for ESP8266 core 2.7.1+ 2. Update [minimal example](examples/minimal)
1 parent 518aaca commit fc8be81

File tree

6 files changed

+180
-54
lines changed

6 files changed

+180
-54
lines changed

README.md

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
## ESP_DoubleResetDetector
22

33
[![arduino-library-badge](https://www.ardu-badge.com/badge/ESP_DoubleResetDetector.svg?)](https://www.ardu-badge.com/ESP_DoubleResetDetector)
4+
[![GitHub release](https://img.shields.io/github/release/khoih-prog/ESP_DoubleResetDetector.svg)](https://github.com/khoih-prog/ESP_DoubleResetDetector/releases)
5+
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/ESP_DoubleResetDetector/blob/master/LICENSE)
6+
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
7+
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/ESP_DoubleResetDetector.svg)](http://github.com/khoih-prog/ESP_DoubleResetDetector/issues)
8+
9+
### Releases v1.0.3
10+
11+
1. Update to use the new LittleFS for ESP8266 core 2.7.1+
12+
2. Update [minimal example](examples/minimal)
413

514
### Releases v1.0.2
615

@@ -12,13 +21,13 @@ This library is based on, modified, bug-fixed and improved from [`DataCute`](htt
1221

1322
Using this library to detect a double reset, using
1423

15-
1. RTC Memory, EEPROM or SPIFFS for ESP8266
24+
1. RTC Memory, EEPROM, LittleFS or SPIFFS for ESP8266
1625
2. EEPROM and SPIFFS for ESP32.
1726

1827
## Prerequisite
1928
1. [`Arduino IDE 1.8.12 or later` for Arduino](https://www.arduino.cc/en/Main/Software)
2029
2. [`ESP32 core 1.0.4 or later`](https://github.com/espressif/arduino-esp32/releases) for ESP32 (Use Arduino Board Manager)
21-
3. [`ESP8266 core 2.6.3 or later`](https://github.com/esp8266/Arduino/releases) for ES82662 (Use Arduino Board Manager)
30+
3. [`ESP8266 core 2.7.1 or later`](https://github.com/esp8266/Arduino/releases) for ES82662 (Use Arduino Board Manager) to use LittleFS or SPIFFS. SPIFFS is deprecated from ESP8266 core 2.7.1.
2231

2332
### Quick Start
2433

@@ -37,6 +46,11 @@ Using this library to detect a double reset, using
3746

3847
### Releases
3948

49+
### Releases v1.0.3
50+
51+
1. Update to use the new LittleFS for ESP8266 core 2.7.1+
52+
2. Update [minimal example](examples/minimal)
53+
4054
#### Releases v1.0.2
4155

4256
1. Fix bug by left-over cpp file.
@@ -60,15 +74,18 @@ How to use
6074
// These defines must be put before #include <ESP_DoubleResetDetector.h>
6175
// to select where to store DoubleResetDetector's variable.
6276
// For ESP32, You must select one to be true (EEPROM or SPIFFS)
63-
// For ESP8266, You must select one to be true (RTC, EEPROM or SPIFFS)
77+
// For ESP8266, You must select one to be true (RTC, EEPROM, LITTLEFS or SPIFFS)
6478
// Otherwise, library will use default EEPROM storage
65-
#define ESP_DRD_USE_EEPROM false
66-
#define ESP_DRD_USE_SPIFFS true //false
79+
6780

6881
#ifdef ESP8266
69-
#define ESP8266_DRD_USE_RTC false //true
82+
#define ESP8266_DRD_USE_RTC false //true
83+
#define ESP_DRD_USE_LITTLEFS true //false
7084
#endif
7185

86+
#define ESP_DRD_USE_EEPROM false
87+
#define ESP_DRD_USE_SPIFFS true
88+
7289
#define DOUBLERESETDETECTOR_DEBUG true //false
7390

7491
#include <ESP_DoubleResetDetector.h> //https://github.com/khoih-prog/ESP_DoubleResetDetector
@@ -82,24 +99,42 @@ How to use
8299

83100
DoubleResetDetector* drd;
84101

102+
#ifdef ESP32
103+
104+
// For ESP32
105+
#ifndef LED_BUILTIN
106+
#define LED_BUILTIN 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
107+
#endif
108+
109+
#define LED_OFF LOW
110+
#define LED_ON HIGH
111+
112+
#else
113+
114+
// For ESP8266
115+
#define LED_ON LOW
116+
#define LED_OFF HIGH
117+
118+
#endif
119+
85120
void setup()
86121
{
87122
pinMode(LED_BUILTIN, OUTPUT);
88123

89124
Serial.begin(115200);
90-
Serial.println("\Starting");
125+
Serial.println("\nStarting minimal example for ESP_DoubleResetDetector");
91126

92127
drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);
93128

94129
if (drd->detectDoubleReset())
95130
{
96131
Serial.println("Double Reset Detected");
97-
digitalWrite(LED_BUILTIN, LOW);
132+
digitalWrite(LED_BUILTIN, LED_ON);
98133
}
99134
else
100135
{
101136
Serial.println("No Double Reset Detected");
102-
digitalWrite(LED_BUILTIN, HIGH);
137+
digitalWrite(LED_BUILTIN, LED_OFF);
103138
}
104139
}
105140

examples/ConfigOnDoubleReset/ConfigOnDoubleReset.ino

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,28 @@
99
1010
Built by Khoi Hoang https://github.com/khoih-prog/ESP_DoubleResetDetector
1111
Licensed under MIT license
12-
Version: 1.0.2
12+
Version: 1.0.3
1313
1414
Version Modified By Date Comments
1515
------- ----------- ---------- -----------
1616
1.0.0 K Hoang 15/12/2019 Initial coding
1717
1.0.1 K Hoang 30/12/2019 Now can use EEPROM or SPIFFS for both ESP8266 and ESP32. RTC still OK for ESP8266
1818
1.0.2 K Hoang 10/04/2020 Fix bug by left-over cpp file and in example.
19+
1.0.3 K Hoang 13/05/2020 Update to use LittleFS for ESP8266 core 2.7.1+
1920
*****************************************************************************************************************************/
2021
/****************************************************************************************************************************
2122
This example will open a configuration portal when the reset button is pressed twice.
2223
This method works well on Wemos boards which have a single reset button on board. It avoids using a pin for launching the configuration portal.
2324
2425
How It Works
2526
1) ESP8266
26-
Save data in RTC memory, EPPROM or SPIFFS
27+
Save data in RTC memory, EPPROM, LittleFS or SPIFFS
2728
2) ESP32
2829
Save data in
2930
a) EEPROM from address 256, size 512 bytes (both configurable)
30-
b) SPIFFS, file name "/drd.dat"
31+
b) SPIFFS
32+
33+
For LittleFS or SPIFFS, file name is "/drd.dat"
3134
3235
So when the device starts up it checks this region of ram for a flag to see if it has been recently reset.
3336
If so it launches a configuration portal, if not it sets the reset flag. After running for a while this flag is cleared so that
@@ -78,15 +81,18 @@ String Router_Pass;
7881
// These defines must be put before #include <ESP_DoubleResetDetector.h>
7982
// to select where to store DoubleResetDetector's variable.
8083
// For ESP32, You must select one to be true (EEPROM or SPIFFS)
81-
// For ESP8266, You must select one to be true (RTC, EEPROM or SPIFFS)
84+
// For ESP8266, You must select one to be true (RTC, EEPROM, LITTLEFS or SPIFFS)
8285
// Otherwise, library will use default EEPROM storage
83-
#define ESP_DRD_USE_EEPROM false
84-
#define ESP_DRD_USE_SPIFFS true //false
86+
8587

8688
#ifdef ESP8266
8789
#define ESP8266_DRD_USE_RTC false //true
90+
#define ESP_DRD_USE_LITTLEFS true //false
8891
#endif
8992

93+
#define ESP_DRD_USE_EEPROM false
94+
#define ESP_DRD_USE_SPIFFS true
95+
9096
#define DOUBLERESETDETECTOR_DEBUG true //false
9197

9298
#include <ESP_DoubleResetDetector.h> //https://github.com/khoih-prog/ESP_DoubleResetDetector
@@ -184,7 +190,9 @@ void setup()
184190

185191
if (initialConfig)
186192
{
187-
Serial.println("Starting configuration portal.");
193+
Serial.println("Starting configuration portal @ 192.168.4.1");
194+
Serial.println("Using SSID = " + ssid + " and password = " + String(password) );
195+
188196
digitalWrite(PIN_LED, LED_ON); // turn the LED on by making the voltage LOW to tell us we are in configuration mode.
189197

190198
//sets timeout in seconds until configuration portal gets turned off.

examples/minimal/minimal.ino

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,80 @@
99
1010
Built by Khoi Hoang https://github.com/khoih-prog/ESP_DoubleResetDetector
1111
Licensed under MIT license
12-
Version: 1.0.2
12+
Version: 1.0.3
1313
1414
Version Modified By Date Comments
1515
------- ----------- ---------- -----------
1616
1.0.0 K Hoang 15/12/2019 Initial coding
1717
1.0.1 K Hoang 30/12/2019 Now can use EEPROM or SPIFFS for both ESP8266 and ESP32. RTC still OK for ESP8266
1818
1.0.2 K Hoang 10/04/2020 Fix bug by left-over cpp file and in example.
19+
1.0.3 K Hoang 13/05/2020 Update to use LittleFS for ESP8266 core 2.7.1+
1920
*****************************************************************************************************************************/
2021

21-
#include <ESP_DoubleResetDetector.h>
22+
// These defines must be put before #include <ESP_DoubleResetDetector.h>
23+
// to select where to store DoubleResetDetector's variable.
24+
// For ESP32, You must select one to be true (EEPROM or SPIFFS)
25+
// For ESP8266, You must select one to be true (RTC, EEPROM, LITTLEFS or SPIFFS)
26+
// Otherwise, library will use default EEPROM storage
2227

23-
// Number of seconds after reset during which a
28+
29+
#ifdef ESP8266
30+
#define ESP8266_DRD_USE_RTC false //true
31+
#define ESP_DRD_USE_LITTLEFS true //false
32+
#endif
33+
34+
#define ESP_DRD_USE_EEPROM false
35+
#define ESP_DRD_USE_SPIFFS true
36+
37+
#define DOUBLERESETDETECTOR_DEBUG true //false
38+
39+
#include <ESP_DoubleResetDetector.h> //https://github.com/khoih-prog/ESP_DoubleResetDetector
40+
41+
// Number of seconds after reset during which a
2442
// subseqent reset will be considered a double reset.
2543
#define DRD_TIMEOUT 10
2644

2745
// RTC Memory Address for the DoubleResetDetector to use
2846
#define DRD_ADDRESS 0
2947

30-
DoubleResetDetector drd(DRD_TIMEOUT, DRD_ADDRESS);
48+
DoubleResetDetector* drd;
49+
50+
#ifdef ESP32
3151

52+
// For ESP32
3253
#ifndef LED_BUILTIN
3354
#define LED_BUILTIN 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
3455
#endif
3556

57+
#define LED_OFF LOW
58+
#define LED_ON HIGH
59+
60+
#else
61+
62+
// For ESP8266
63+
#define LED_ON LOW
64+
#define LED_OFF HIGH
65+
66+
#endif
67+
3668
void setup()
3769
{
3870
pinMode(LED_BUILTIN, OUTPUT);
39-
71+
4072
Serial.begin(115200);
41-
Serial.println();
42-
Serial.println("DoubleResetDetector Example Program");
43-
Serial.println("-----------------------------------");
73+
Serial.println("\nStarting minimal example for ESP_DoubleResetDetector");
74+
75+
drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);
4476

45-
if (drd.detectDoubleReset()) {
77+
if (drd->detectDoubleReset())
78+
{
4679
Serial.println("Double Reset Detected");
47-
digitalWrite(LED_BUILTIN, LOW);
48-
} else {
80+
digitalWrite(LED_BUILTIN, LED_ON);
81+
}
82+
else
83+
{
4984
Serial.println("No Double Reset Detected");
50-
digitalWrite(LED_BUILTIN, HIGH);
85+
digitalWrite(LED_BUILTIN, LED_OFF);
5186
}
5287
}
5388

@@ -57,5 +92,5 @@ void loop()
5792
// so that it can recognise when the timeout expires.
5893
// You can also call drd.stop() when you wish to no longer
5994
// consider the next reset as a double reset.
60-
drd.loop();
95+
drd->loop();
6196
}

library.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
{
22
"name": "ESP_DoubleResetDetector",
3-
"keywords": "rtc,eeprom,spiffs,reset,data,esp32,esp8266",
4-
"description": "Library to detect a double reset, using RTC Memory, EEPROM or SPIFFS for ESP8266 and EEPROM and SPIFFS for ESP32",
3+
"version": "1.0.3",
4+
"keywords": "rtc,eeprom,littlefs,spiffs,reset,data,esp32,esp8266",
5+
"description": "Library to detect a double reset, using RTC Memory, EEPROM, LittleFS or SPIFFS for ESP8266 and EEPROM and SPIFFS for ESP32",
6+
"authors":
7+
{
8+
"name": "Khoi Hoang",
9+
"url": "https://github.com/khoih-prog",
10+
"maintainer": true
11+
},
512
"repository":
613
{
714
"type": "git",
815
"url": "https://github.com/khoih-prog/ESP_DoubleResetDetector"
916
},
10-
"version": "1.0.2",
17+
"homepage": "https://github.com/khoih-prog/ESP_DoubleResetDetector",
18+
"export": {
19+
"exclude": [
20+
"linux",
21+
"extras",
22+
"tests"
23+
]
24+
},
1125
"frameworks": "arduino",
1226
"platforms": "espressif"
27+
"examples": "examples/*/*/*.ino"
1328
}

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=ESP_DoubleResetDetector
2-
version=1.0.2
2+
version=1.0.3
33
author=Khoi Hoang
44
maintainer=Khoi Hoang <khoih.prog@gmail.com>
55
license=MIT
6-
sentence=Library to detect a double reset, using RTC Memory, EEPROM or SPIFFS for ESP8266 and EEPROM and SPIFFS for ESP32
6+
sentence=Library to detect a double reset, using RTC Memory, EEPROM, LittleFS or SPIFFS for ESP8266 and EEPROM and SPIFFS for ESP32
77
paragraph=An alternative start-up mode can be used. One example use is to allow re-configuration of device's wifi credentials.
88
category=Device Control
99
url=https://github.com/khoih-prog/ESP_DoubleResetDetector

0 commit comments

Comments
 (0)