Giter Site home page Giter Site logo

khoih-prog / esp_doubleresetdetector Goto Github PK

View Code? Open in Web Editor NEW
48.0 3.0 16.0 147 KB

ESP_DoubleResetDetector is a library for the ESP32/ESP8266 Arduino platform to enable trigger configure mode by resetting twice.

License: MIT License

C++ 98.23% Shell 1.77%
spiffs eeprom arduino-platform spiffs-support esp-doubleresetdetector rtc-memory configuration config-portal esp8266 esp32-arduino

esp_doubleresetdetector's People

Contributors

khoih-prog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

esp_doubleresetdetector's Issues

Strange Incompatibility when DRD is in a xTask

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

Double reset detected when powering up

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?

Feature Request: Ability to clear timeout with a call, instead of time

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

'LittleFS' was not declared in this scope

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 example Not working on ESP32

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

Sign compare warning

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.

library.json has a missing comma

last lines of library.json should be:

...
"frameworks": "arduino",
"platforms": "espressif",
"examples": "examples/*/*/*.ino"
}

with a comma after "expressif"

Error compilation for ESP32

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;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.