diff --git a/examples/BasicUsage/.esp8266.test.skip b/examples/BasicUsage/.esp8266.test.skip deleted file mode 100644 index e69de29..0000000 diff --git a/examples/BasicUsage/BasicUsage.ino b/examples/BasicUsage/BasicUsage.ino index 06df4b3..edc48de 100644 --- a/examples/BasicUsage/BasicUsage.ino +++ b/examples/BasicUsage/BasicUsage.ino @@ -8,7 +8,8 @@ void setup() { Serial.begin(115200); - while(!Serial) delay(10); + while (!Serial) + delay(10); // wait for Arduino Serial Monitor (native USB boards) Serial.println("Adafruit Watchdog Library Demo!"); @@ -29,8 +30,9 @@ void setup() { // Now loop a few times and periodically reset the watchdog. Serial.println("Looping ten times while resetting the watchdog..."); - for(int i = 1; i <= 10; ++i) { - Serial.print("Loop #"); Serial.println(i, DEC); + for (int i = 1; i <= 10; ++i) { + Serial.print("Loop #"); + Serial.println(i, DEC); delay(1000); // Reset watchdog with every loop to make sure the sketch keeps running. // If you comment out this call watch what happens in about 4 iterations! @@ -41,7 +43,7 @@ void setup() { #ifndef NRF52_SERIES // cannot disable nRF's WDT // Disable the watchdog entirely by calling Watchdog.disable(); Watchdog.disable(); -#endif +#endif // Finally demonstrate the watchdog resetting by enabling it for a shorter // period of time and waiting a long time without a reset. Notice you can @@ -54,7 +56,13 @@ void setup() { Serial.print(countdownMS, DEC); Serial.println(" milliseconds!"); Serial.println(); - delay(countdownMS+1000); +#ifndef ARDUINO_ARCH_ESP8266 + delay(countdownMS + 1000); +#else + // Calls to delay() and yield() feed the ESP8266's + // hardware and software watchdog timers, delayMicroseconds does not. + delayMicroseconds(countdownMS * 1000); +#endif // Execution will never get here because the watchdog resets the Arduino! } diff --git a/examples/Sleep/.esp32.test.skip b/examples/Sleep/.esp32.test.skip deleted file mode 100644 index e69de29..0000000 diff --git a/examples/Sleep/.esp8266.test.skip b/examples/Sleep/.esp8266.test.skip deleted file mode 100644 index e69de29..0000000 diff --git a/examples/Sleep/.nrf52840.test.skip b/examples/Sleep/.nrf52840.test.skip deleted file mode 100644 index e69de29..0000000 diff --git a/utility/WatchdogESP8266.cpp b/utility/WatchdogESP8266.cpp index f9e1dc2..8f937e4 100644 --- a/utility/WatchdogESP8266.cpp +++ b/utility/WatchdogESP8266.cpp @@ -17,7 +17,6 @@ */ /**********************************************************************************************/ int WatchdogESP8266::enable(int maxPeriodMS) { - ESP.wdtDisable(); if (maxPeriodMS < 0) return 0; @@ -30,7 +29,9 @@ int WatchdogESP8266::enable(int maxPeriodMS) { /**************************************************************************/ /*! - @brief Feeds the Watchdog Timer. + @brief Feeds the Watchdog timer. + NOTE: Calling yield() or delay() also feeds the hardware and software + watchdog timers. */ /**************************************************************************/ void WatchdogESP8266::reset() { ESP.wdtFeed(); } @@ -38,9 +39,9 @@ void WatchdogESP8266::reset() { ESP.wdtFeed(); } /**************************************************************************/ /*! @brief Disables the Watchdog Timer. - NOTE: Please don't stop software watchdog too long - (less than 6 seconds), otherwise it will trigger the hardware - watchdog reset. + NOTE: Please don't stop the software WDT too long + (less than 6 seconds), otherwise it will trigger a hardware + watchdog reset! */ /**************************************************************************/ void WatchdogESP8266::disable() { ESP.wdtDisable(); }