Software timer object. More...
#include <SoftTimer.h>
Public Member Functions | |
bool | is_expired () |
Return true if the timer has expired. More... | |
void | start (uint16_t delay_ms) |
Start timer with up to 65535 ms. More... | |
void | startW (unsigned long delay_ms) |
Start timer. More... | |
void | startN (uint8_t delay_ms) |
Start timer with up to 255 ms. More... | |
bool | interval (uint16_t delay_ms) |
Return true when timer expires, and restart. 65535 ms max. More... | |
bool | intervalW (unsigned long delay_ms) |
Return true when timer expires, and restart. More... | |
bool | intervalN (uint8_t delay_ms) |
Return true when timer expires, and restart. 255 ms max. More... | |
Protected Attributes | |
unsigned long | _finish_ms |
Expiry time, in milliseconds. | |
Software timer object.
Simple timer that does not use interrupts. It's easier to use and produces shorter code than using 4-byte comparisons with millis() everywhere.
bool SoftTimer::interval | ( | uint16_t | delay_ms | ) |
Return true when timer expires, and restart. 65535 ms max.
is_expired() and start() combined. Because the timer is restarted, true is returned only once (unless the timer has again expired before the next call).
delay_ms | uint16_t Timer delay in milliseconds. |
bool SoftTimer::intervalN | ( | uint8_t | delay_ms | ) |
Return true when timer expires, and restart. 255 ms max.
is_expired() and startN() combined. See interval().
delay_ms | uint8_t Timer delay in milliseconds. |
bool SoftTimer::intervalW | ( | unsigned long | delay_ms | ) |
Return true when timer expires, and restart.
is_expired() and startW() combined. See interval().
Uses unsigned long instead of uint32_t because that is what millis() uses.
delay_ms | unsigned long Timer delay in milliseconds. |
bool SoftTimer::is_expired | ( | ) |
Return true if the timer has expired.
Compares with the current value of millis().
void SoftTimer::start | ( | uint16_t | delay_ms | ) |
Start timer with up to 65535 ms.
Start the timer with a 16 bit (65535 ms max) delay from now.
delay_ms | uint16_t Timer delay in milliseconds. |
void SoftTimer::startN | ( | uint8_t | delay_ms | ) |
Start timer with up to 255 ms.
Start the timer with an 8 bit (narrow, 255 ms max) delay from now.
delay_ms | uint8_t Timer delay in milliseconds. |
void SoftTimer::startW | ( | unsigned long | delay_ms | ) |
Start timer.
Start the timer with a 32 bit (wide) delay from now.
Uses unsigned long instead of uint32_t because that is what millis() uses.
delay_ms | unsigned long Timer delay in milliseconds. |