Software Timers  1.4
Software timer library
 All Classes Files Functions Variables Pages
Public Member Functions | Protected Attributes | List of all members
SoftTimer Class Reference

Software timer object. More...

#include <SoftTimer.h>

Inheritance diagram for SoftTimer:
Inheritance graph
[legend]

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.
 

Detailed Description

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.

Member Function Documentation

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).

SoftTimer timer;
if (timer.interval(1000)) {
// Do something once per second
}
Parameters
delay_msuint16_t Timer delay in milliseconds.
Returns
bool True if timer has expired.

Here is the call graph for this function:

bool SoftTimer::intervalN ( uint8_t  delay_ms)

Return true when timer expires, and restart. 255 ms max.

is_expired() and startN() combined. See interval().

Parameters
delay_msuint8_t Timer delay in milliseconds.
Returns
bool True if timer has expired.

Here is the call graph for this function:

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.

Parameters
delay_msunsigned long Timer delay in milliseconds.
Returns
bool True if timer has expired.

Here is the call graph for this function:

Here is the caller graph for this function:

bool SoftTimer::is_expired ( )

Return true if the timer has expired.

Compares with the current value of millis().

Note
The Arduino millisecond counter overflows after 49.7 days. This function fails if the timer's start and finish times cross the overflow.
Returns
bool True if timer has expired. Return true for as long as the timer is in the expired state.

Here is the caller graph for this function:

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.

Parameters
delay_msuint16_t Timer delay in milliseconds.
Returns
void

Here is the caller graph for this function:

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.

Parameters
delay_msuint8_t Timer delay in milliseconds.
Returns
void

Here is the caller graph for this function:

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.

Parameters
delay_msunsigned long Timer delay in milliseconds.
Returns
void

Here is the caller graph for this function:


The documentation for this class was generated from the following files: