|
FastLED 3.9.15
|
RAII watchdog guard for the canonical loop()-top use case.
First construction (per-process) lazily arms the watchdog with the supplied timeout (default 15 000 ms), prints any prior-boot reset/crash diagnostic through fl::println, and pauses for 3 s on a crash so the developer can read the message before loop() repaints serial output. Construction feeds the watchdog immediately so the current loop iteration starts with a fresh deadline; destruction feeds it again so the next iteration also starts fresh.
Single-instance rule. Only one ScopedWatchdog should be alive at a time. The class detects nested / overlapping live instances at runtime and prints a one-shot warning via fl::println (the WDT is still fed in both ctors and dtors so the program keeps running). Two guards on the same source line are a compile error (the FL_WATCHDOG_AUTO macro stamps the local variable name from __LINE__, so a duplicate would collide).
Prefer the FL_WATCHDOG_AUTO(...) macro below — it stamps a unique stack variable name and is the canonical entry point.
Definition at line 205 of file watchdog.h.
#include <watchdog.h>
Public Member Functions | |
| ScopedWatchdog () FL_NOEXCEPT | |
| Default construct with the library default timeout (15 000 ms). | |
| ScopedWatchdog (const ScopedWatchdog &) FL_NOEXCEPT=delete | |
| ScopedWatchdog (fl::u32 timeout_ms) FL_NOEXCEPT | |
| Construct with an explicit timeout. | |
| ~ScopedWatchdog () FL_NOEXCEPT | |
Feed the watchdog at end-of-scope so the next loop() iteration has a clean deadline window. | |
| ScopedWatchdog & | operator= (const ScopedWatchdog &) FL_NOEXCEPT=delete |
Static Public Member Functions | |
| static int | activeScopeCount () FL_NOEXCEPT |
| Observability: number of simultaneously-alive ScopedWatchdog instances. | |