1#ifndef SBL_PATTERNS_TIMING_NON_BLOCKING_DELAY_HPP_
2#define SBL_PATTERNS_TIMING_NON_BLOCKING_DELAY_HPP_
31template<
typename SystemTimeImpl>
39 : period_(delay_ms), last_trigger_(0), active_(false) {}
45 last_trigger_ = SystemTimeImpl::millis();
54 if (!active_)
return false;
55 return (SystemTimeImpl::millis() - last_trigger_) >= period_;
62 last_trigger_ = SystemTimeImpl::millis();
97 uint32_t last_trigger_;
111template<
typename SystemTimeImpl>
119 : interval_(interval_ms), last_trigger_(0), active_(false) {}
125 last_trigger_ = SystemTimeImpl::millis();
134 if (!active_)
return false;
136 uint32_t now = SystemTimeImpl::millis();
137 if ((now - last_trigger_) >= interval_) {
156 interval_ = interval_ms;
169 uint32_t last_trigger_;
Interval timer for periodic tasks.
void stop()
Stop the interval timer.
void start()
Start the interval timer.
uint32_t getInterval() const
Get current interval.
void setInterval(uint32_t interval_ms)
Update interval period.
bool tick()
Check if interval has elapsed and auto-reset.
IntervalTimer(uint32_t interval_ms)
Constructor with interval period.
Simple non-blocking delay using system time.
NonBlockingDelay(uint32_t delay_ms)
Constructor with delay period.
uint32_t getPeriod() const
Get current delay period.
bool isActive() const
Check if timer is active.
void stop()
Stop the delay timer.
void start()
Start the delay timer.
bool ready() const
Check if delay period has elapsed.
void setPeriod(uint32_t delay_ms)
Update delay period.
void reset()
Reset the delay timer for next period.
Root namespace for all Sound Byte Libs functionality.
System timing functions for cooperative scheduling.