|
FastLED 3.9.15
|
Generic timeout timer with rollover-safe arithmetic.
Tracks elapsed time using provided timestamps. Time units are determined by the caller (microseconds, milliseconds, clock ticks, etc.).
Handles uint32_t rollover correctly - works across 0xFFFFFFFF → 0x00000000 boundary.
Example with microseconds:
Example with milliseconds:
#include <timeout.h>
Public Member Functions | |
| Timeout () FL_NOEXCEPT | |
| Default constructor - creates an already-expired timeout. | |
| Timeout (u32 start_time, u32 duration) | |
| Construct a timeout with specified start time and duration. | |
| bool | done (u32 current_time) const |
| Check if the timeout has completed. | |
| u32 | elapsed (u32 current_time) const |
| Get elapsed time since timeout started. | |
| void | reset (u32 start_time) |
| Reset the timeout to start counting from specified time. | |
| void | reset (u32 start_time, u32 duration) |
| Reset with a new start time and duration. | |
Private Attributes | |
| u32 | mDuration |
| Timeout duration. | |
| u32 | mStartTime |
| Start timestamp. | |