khoih-prog / esp_doubleresetdetector Goto Github PK
View Code? Open in Web Editor NEWESP_DoubleResetDetector is a library for the ESP32/ESP8266 Arduino platform to enable trigger configure mode by resetting twice.
License: MIT License
ESP_DoubleResetDetector is a library for the ESP32/ESP8266 Arduino platform to enable trigger configure mode by resetting twice.
License: MIT License
Is that possible to configure the library to detect more than two resets ?
Thanks for the library.
It may be worth noting in the Readme that the first 127 bytes (32 blocks) of RTC memory on the ESP8266 are overwritten by OTA.
https://arduino-esp8266.readthedocs.io/en/latest/libraries.html?highlight=rtc#esp-specific-apis
Hi, to start thanks for your good good lib.
I need to delegate the DRD in a task to completly separate from loop(),
I tried with a xTask but when DEBUG is enabled, the board crash:
Connecting.......Stop doubleResetDetecting
Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception)
Debug exception reason: Stack canary watchpoint triggered (DbleRstCheckr)
Core 0 register dump:
PC : 0x400893b3 PS : 0x00060e36 A0 : 0x80089558 A1 : 0x3ffb2080
A2 : 0x3ffbac0c A3 : 0x00000000 A4 : 0xffffffff A5 : 0x00000000
A6 : 0x000000ff A7 : 0x3ffb22bc A8 : 0x8008a565 A9 : 0x3ffb2090
A10 : 0x00000003 A11 : 0x00060e23 A12 : 0x00060e20 A13 : 0x0000007e
A14 : 0x00000002 A15 : 0x3ffb22bc SAR : 0x00000010 EXCCAUSE: 0x00000001
EXCVADDR: 0x00000000 LBEG : 0x40001609 LEND : 0x4000160d LCOUNT : 0x00000000
Backtrace: 0x400893b3:0x3ffb2080 0x40089555:0x3ffb20c0 0x4014c9e1:0x3ffb20e0 0x40087622:0x3ffb2100 0x40087bea:0x3ffb2120 0x400ffffd:0x3ffb2190 0x400fe8c5:0x3ffb21b0 0x400fed13:0x3ffb21d0 0x400fd659:0x3ffb2240 0x400fdc3d:0x3ffb2290 0x400fd0e9:0x3ffb2300 0x400e63d6:0x3ffb2340 0x400d29c3:0x3ffb2360 0x400d2a94:0x3ffb23a0 0x400896e5:0x3ffb23c0
If you want to keep debug mode enabled: Just add more space for it with 1500 byte of stack size to the default stack size of a new task.
here is my code if you want to publish an example:
Define:
//------------------------------------------------------------Double Reset Detector
#define ESP_DRD_USE_EEPROM 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 5
// RTC Memory Address for the DoubleResetDetector to use
#define DRD_ADDRESS 0
DoubleResetDetector* drd;
// For ESP32 LED Builtin
#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
//------------------------------------------------------------Double Reset Detector
Func to declare before setup:
void DoubleResetCheck(void * parameter){
for(;;){ // infinite loop
drd->loop(); // Double Reset Detector
// Pause the task for 5ms
vTaskDelay(5 / portTICK_PERIOD_MS);
}
}
In Setup():
//------------------------------------------------------------Double Reset Detector
drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);
if (drd->detectDoubleReset())
{
Serial.println("");Serial.println("Double Reset Detected");Serial.println("");
digitalWrite(LED_BUILTIN, LED_ON);
}
else
{
Serial.println("");Serial.println("No Double Reset Detected");Serial.println("");
digitalWrite(LED_BUILTIN, LED_OFF);
}
xTaskCreate(DoubleResetCheck, // Function that should be called
"DbleRstCheckr", // Name of the task (for debugging)
1500, // Stack size (bytes)
NULL, // Parameter to pass
1, // Task priority
NULL // Task handle
);
//------------------------------------------------------------Double Reset Detector
This is more a question than a clear bug report.
Im using Lolin wemos d1 mini pro. I upload the example sketch minimum for esp8266. It works nicely otherwise but when I disconnect power supply and then reconnect it, double reset is detected. Im wondering can this be avoided somehow or why does this happen. I wouldn't want eg my wifi credentials to be erased if there is power outage. Any idea?
There seems to be a typo in ESP_DoubleResetDetector/examples/minimal/minimal.ino
it refers to #include <DoubleResetDetector.h> instead of #include <ESP_DoubleResetDetector.h>
In my application, there is a process indicated on the LCD.
I want to allow something along the lines of "You can press reset twice, while the logo is on screen, to enter the ... mode"
That logo is displayed for a variable amount of time - so would like to be able to do something like
setup() {
drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);
if (drd->detectDoubleReset()) {
enterConfigMode()
}
doOneThing()
doAnotherThing()
doThirdThing()
drd->clearFlag(); // if you press reset after this, it resets, doesnt count as a doublereset anymore
}
ie instead of the loop counting down the timeout and clearing it when time is over
ESP_DoubleResetDetector.h
#define FileFS LittleFS
Error: 'LittleFS' was not declared in this scope C/C++(20)...
Espressif 32 framework v.4.0.0 / 4.4.0 / 5.0.0 / 5.1.1
Minimal from examples does nothing on ESP32
Using the sketch from Readme works
Not sure whats different, but might have to add that as Example (:
With minimal, these lines arent present in debug
Saving config file...
Saving config file OK
ESP_DoubleResetDetector 1.1.0
PlatformIO version 5.0.3
Espressif 8266 2.6.2
In file included from include/reset.h:16:0,
from src/reset.cpp:1:
.pio/libdeps/d1_mini/ESP_DoubleResetDetector/src/ESP_DoubleResetDetector.h: In member function 'void DoubleResetDetector::loop()':
.pio/libdeps/d1_mini/ESP_DoubleResetDetector/src/ESP_DoubleResetDetector.h:184:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (waitingForDoubleReset && millis() > timeout)
^
Changing the private int timeout
in ESP_DoubleResetDetector.h
to e.g. an uint
solves the warning.
last lines of library.json should be:
...
"frameworks": "arduino",
"platforms": "espressif",
"examples": "examples/*/*/*.ino"
}
with a comma after "expressif"
Hello!
I get an Error compilation for ESP32. Arduino IDE 1.8.12, ESP32 core 1.0.4. Many redifinitions errors. How to fix it?
Log of compilator:
In file included from C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:19:0:
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.h:35:2: warning: #warning Neither EEPROM nor SPIFFS selected. Default to EEPROM [-Wcpp]
#warning Neither EEPROM nor SPIFFS selected. Default to EEPROM
^
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:44:1: error: redefinition of 'DoubleResetDetector::DoubleResetDetector(int, int)'
DoubleResetDetector::DoubleResetDetector(int timeout, int address)
^
In file included from C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:19:0:
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.h:88:5: note: 'DoubleResetDetector::DoubleResetDetector(int, int)' previously defined here
DoubleResetDetector(int timeout, int address)
^
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:60:6: error: redefinition of 'bool DoubleResetDetector::detectDoubleReset()'
bool DoubleResetDetector::detectDoubleReset()
^
In file included from C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:19:0:
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.h:116:10: note: 'bool DoubleResetDetector::detectDoubleReset()' previously defined here
bool detectDoubleReset()
^
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:84:6: error: redefinition of 'void DoubleResetDetector::loop()'
void DoubleResetDetector::loop()
^
In file included from C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:19:0:
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.h:142:10: note: 'void DoubleResetDetector::loop()' previously defined here
void loop()
^
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:96:6: error: redefinition of 'void DoubleResetDetector::stop()'
void DoubleResetDetector::stop()
^
In file included from C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:19:0:
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.h:154:10: note: 'void DoubleResetDetector::stop()' previously defined here
void stop()
^
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:102:6: error: redefinition of 'bool DoubleResetDetector::detectRecentlyResetFlag()'
bool DoubleResetDetector::detectRecentlyResetFlag()
^
In file included from C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:19:0:
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.h:169:10: note: 'bool DoubleResetDetector::detectRecentlyResetFlag()' previously defined here
bool detectRecentlyResetFlag()
^
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:121:6: error: redefinition of 'void DoubleResetDetector::setRecentlyResetFlag()'
void DoubleResetDetector::setRecentlyResetFlag() {
^
In file included from C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:19:0:
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.h:212:10: note: 'void DoubleResetDetector::setRecentlyResetFlag()' previously defined here
void setRecentlyResetFlag()
^
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:139:6: error: redefinition of 'void DoubleResetDetector::clearRecentlyResetFlag()'
void DoubleResetDetector::clearRecentlyResetFlag() {
^
In file included from C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:19:0:
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.h:257:10: note: 'void DoubleResetDetector::clearRecentlyResetFlag()' previously defined here
void clearRecentlyResetFlag()
^
C:\Users\User\Documents\Arduino\libraries\ESP_DoubleResetDetector-master\src\ESP_DoubleResetDetector.cpp:23:17: warning: 'DOUBLERESETDETECTOR_FLAG' defined but not used [-Wunused-variable]
static uint32_t DOUBLERESETDETECTOR_FLAG;
Hello,
I am writing .ino code compatible with both ESP32 and ESP8266 and I am using Arduino IDE.
When I try to compile the code on ESP32 everything is ok, but if I try to compile the code with ESP8266 I get this error:
I know it's not a bug but it's probably my development environment is bad configured :(
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.