FastLED 3.9.15
Loading...
Searching...
No Matches
SketchHalt.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/ostream.h"
4#include "fl/stl/chrono.h"
5#include "fl/system/delay.h"
6#include "fl/stl/string.h"
7
26public:
32 bool check() {
33 if (!mHalted) {
34 return false;
35 }
36
37 fl::u32 current_time = fl::millis();
38 if (mLastPrintTime == 0 || (current_time - mLastPrintTime) >= 5000) {
39 fl::cout << "ERROR: HALT: " << mMessage.c_str() << "\n";
40 mLastPrintTime = current_time;
41 }
42 fl::delayMillis(100);
43 return true;
44 }
45
47 void error(const char* message) {
48 mHalted = true;
49 mMessage = message;
50 fl::cout << "ERROR: HALT: " << mMessage.c_str() << "\n";
52 }
53
54private:
55 bool mHalted = false;
57 fl::u32 mLastPrintTime = 0;
58};
FastLED chrono implementation - duration types for time measurements.
bool mHalted
Definition SketchHalt.h:55
fl::u32 mLastPrintTime
Definition SketchHalt.h:57
void error(const char *message)
Halt sketch execution with an error message.
Definition SketchHalt.h:47
bool check()
Check if sketch is halted and handle periodic message printing.
Definition SketchHalt.h:32
fl::string mMessage
Definition SketchHalt.h:56
Sketch halting mechanism that prevents watchdog timer resets.
Definition SketchHalt.h:25
Delay utilities for FastLED Includes nanosecond-precision delays, cycle counting, and microsecond del...
ostream cout
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
void delayMillis(u32 ms) FL_NOEXCEPT
Delay for a given number of milliseconds (legacy - no async pumping)