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

Commit

Permalink
v1.0.3
Browse files Browse the repository at this point in the history
### Releases v1.0.3

1. Update to use the new LittleFS for ESP8266 core 2.7.1+
2. Update [minimal example](examples/minimal)
  • Loading branch information
khoih-prog committed May 12, 2020
1 parent 518aaca commit fc8be81
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 54 deletions.
53 changes: 44 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
## ESP_DoubleResetDetector

[![arduino-library-badge](https://www.ardu-badge.com/badge/ESP_DoubleResetDetector.svg?)](https://www.ardu-badge.com/ESP_DoubleResetDetector)
[![GitHub release](https://img.shields.io/github/release/khoih-prog/ESP_DoubleResetDetector.svg)](https://github.com/khoih-prog/ESP_DoubleResetDetector/releases)
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/ESP_DoubleResetDetector/blob/master/LICENSE)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/ESP_DoubleResetDetector.svg)](http://github.com/khoih-prog/ESP_DoubleResetDetector/issues)

### Releases v1.0.3

1. Update to use the new LittleFS for ESP8266 core 2.7.1+
2. Update [minimal example](examples/minimal)

### Releases v1.0.2

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

Using this library to detect a double reset, using

1. RTC Memory, EEPROM or SPIFFS for ESP8266
1. RTC Memory, EEPROM, LittleFS or SPIFFS for ESP8266
2. EEPROM and SPIFFS for ESP32.

## Prerequisite
1. [`Arduino IDE 1.8.12 or later` for Arduino](https://www.arduino.cc/en/Main/Software)
2. [`ESP32 core 1.0.4 or later`](https://github.com/espressif/arduino-esp32/releases) for ESP32 (Use Arduino Board Manager)
3. [`ESP8266 core 2.6.3 or later`](https://github.com/esp8266/Arduino/releases) for ES82662 (Use Arduino Board Manager)
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.

### Quick Start

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

### Releases

### Releases v1.0.3

1. Update to use the new LittleFS for ESP8266 core 2.7.1+
2. Update [minimal example](examples/minimal)

#### Releases v1.0.2

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


#ifdef ESP8266
#define ESP8266_DRD_USE_RTC false //true
#define ESP8266_DRD_USE_RTC false //true
#define ESP_DRD_USE_LITTLEFS true //false
#endif

#define ESP_DRD_USE_EEPROM false
#define ESP_DRD_USE_SPIFFS true

#define DOUBLERESETDETECTOR_DEBUG true //false

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

DoubleResetDetector* drd;

#ifdef ESP32

// For ESP32
#ifndef LED_BUILTIN
#define LED_BUILTIN 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
#endif

#define LED_OFF LOW
#define LED_ON HIGH

#else

// For ESP8266
#define LED_ON LOW
#define LED_OFF HIGH

#endif

void setup()
{
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
Serial.println("\Starting");
Serial.println("\nStarting minimal example for ESP_DoubleResetDetector");

drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);

if (drd->detectDoubleReset())
{
Serial.println("Double Reset Detected");
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(LED_BUILTIN, LED_ON);
}
else
{
Serial.println("No Double Reset Detected");
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(LED_BUILTIN, LED_OFF);
}
}

Expand Down
22 changes: 15 additions & 7 deletions examples/ConfigOnDoubleReset/ConfigOnDoubleReset.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,28 @@
Built by Khoi Hoang https://github.com/khoih-prog/ESP_DoubleResetDetector
Licensed under MIT license
Version: 1.0.2
Version: 1.0.3
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 15/12/2019 Initial coding
1.0.1 K Hoang 30/12/2019 Now can use EEPROM or SPIFFS for both ESP8266 and ESP32. RTC still OK for ESP8266
1.0.2 K Hoang 10/04/2020 Fix bug by left-over cpp file and in example.
1.0.3 K Hoang 13/05/2020 Update to use LittleFS for ESP8266 core 2.7.1+
*****************************************************************************************************************************/
/****************************************************************************************************************************
This example will open a configuration portal when the reset button is pressed twice.
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.
How It Works
1) ESP8266
Save data in RTC memory, EPPROM or SPIFFS
Save data in RTC memory, EPPROM, LittleFS or SPIFFS
2) ESP32
Save data in
a) EEPROM from address 256, size 512 bytes (both configurable)
b) SPIFFS, file name "/drd.dat"
b) SPIFFS
For LittleFS or SPIFFS, file name is "/drd.dat"
So when the device starts up it checks this region of ram for a flag to see if it has been recently reset.
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
Expand Down Expand Up @@ -78,15 +81,18 @@ String Router_Pass;
// These defines must be put before #include <ESP_DoubleResetDetector.h>
// to select where to store DoubleResetDetector's variable.
// For ESP32, You must select one to be true (EEPROM or SPIFFS)
// For ESP8266, You must select one to be true (RTC, EEPROM or SPIFFS)
// For ESP8266, You must select one to be true (RTC, EEPROM, LITTLEFS or SPIFFS)
// Otherwise, library will use default EEPROM storage
#define ESP_DRD_USE_EEPROM false
#define ESP_DRD_USE_SPIFFS true //false


#ifdef ESP8266
#define ESP8266_DRD_USE_RTC false //true
#define ESP_DRD_USE_LITTLEFS true //false
#endif

#define ESP_DRD_USE_EEPROM false
#define ESP_DRD_USE_SPIFFS true

#define DOUBLERESETDETECTOR_DEBUG true //false

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

if (initialConfig)
{
Serial.println("Starting configuration portal.");
Serial.println("Starting configuration portal @ 192.168.4.1");
Serial.println("Using SSID = " + ssid + " and password = " + String(password) );

digitalWrite(PIN_LED, LED_ON); // turn the LED on by making the voltage LOW to tell us we are in configuration mode.

//sets timeout in seconds until configuration portal gets turned off.
Expand Down
61 changes: 48 additions & 13 deletions examples/minimal/minimal.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,80 @@
Built by Khoi Hoang https://github.com/khoih-prog/ESP_DoubleResetDetector
Licensed under MIT license
Version: 1.0.2
Version: 1.0.3
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 15/12/2019 Initial coding
1.0.1 K Hoang 30/12/2019 Now can use EEPROM or SPIFFS for both ESP8266 and ESP32. RTC still OK for ESP8266
1.0.2 K Hoang 10/04/2020 Fix bug by left-over cpp file and in example.
1.0.3 K Hoang 13/05/2020 Update to use LittleFS for ESP8266 core 2.7.1+
*****************************************************************************************************************************/

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

// Number of seconds after reset during which a

#ifdef ESP8266
#define ESP8266_DRD_USE_RTC false //true
#define ESP_DRD_USE_LITTLEFS true //false
#endif

#define ESP_DRD_USE_EEPROM false
#define ESP_DRD_USE_SPIFFS true

#define DOUBLERESETDETECTOR_DEBUG true //false

#include <ESP_DoubleResetDetector.h> //https://github.com/khoih-prog/ESP_DoubleResetDetector

// 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 drd(DRD_TIMEOUT, DRD_ADDRESS);
DoubleResetDetector* drd;

#ifdef ESP32

// For ESP32
#ifndef LED_BUILTIN
#define LED_BUILTIN 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
#endif

#define LED_OFF LOW
#define LED_ON HIGH

#else

// For ESP8266
#define LED_ON LOW
#define LED_OFF HIGH

#endif

void setup()
{
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
Serial.println();
Serial.println("DoubleResetDetector Example Program");
Serial.println("-----------------------------------");
Serial.println("\nStarting minimal example for ESP_DoubleResetDetector");

drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);

if (drd.detectDoubleReset()) {
if (drd->detectDoubleReset())
{
Serial.println("Double Reset Detected");
digitalWrite(LED_BUILTIN, LOW);
} else {
digitalWrite(LED_BUILTIN, LED_ON);
}
else
{
Serial.println("No Double Reset Detected");
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(LED_BUILTIN, LED_OFF);
}
}

Expand All @@ -57,5 +92,5 @@ void loop()
// 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();
drd->loop();
}
21 changes: 18 additions & 3 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
{
"name": "ESP_DoubleResetDetector",
"keywords": "rtc,eeprom,spiffs,reset,data,esp32,esp8266",
"description": "Library to detect a double reset, using RTC Memory, EEPROM or SPIFFS for ESP8266 and EEPROM and SPIFFS for ESP32",
"version": "1.0.3",
"keywords": "rtc,eeprom,littlefs,spiffs,reset,data,esp32,esp8266",
"description": "Library to detect a double reset, using RTC Memory, EEPROM, LittleFS or SPIFFS for ESP8266 and EEPROM and SPIFFS for ESP32",
"authors":
{
"name": "Khoi Hoang",
"url": "https://github.com/khoih-prog",
"maintainer": true
},
"repository":
{
"type": "git",
"url": "https://github.com/khoih-prog/ESP_DoubleResetDetector"
},
"version": "1.0.2",
"homepage": "https://github.com/khoih-prog/ESP_DoubleResetDetector",
"export": {
"exclude": [
"linux",
"extras",
"tests"
]
},
"frameworks": "arduino",
"platforms": "espressif"
"examples": "examples/*/*/*.ino"
}
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=ESP_DoubleResetDetector
version=1.0.2
version=1.0.3
author=Khoi Hoang
maintainer=Khoi Hoang <khoih.prog@gmail.com>
license=MIT
sentence=Library to detect a double reset, using RTC Memory, EEPROM or SPIFFS for ESP8266 and EEPROM and SPIFFS for ESP32
sentence=Library to detect a double reset, using RTC Memory, EEPROM, LittleFS or SPIFFS for ESP8266 and EEPROM and SPIFFS for ESP32
paragraph=An alternative start-up mode can be used. One example use is to allow re-configuration of device's wifi credentials.
category=Device Control
url=https://github.com/khoih-prog/ESP_DoubleResetDetector
Expand Down

0 comments on commit fc8be81

Please sign in to comment.