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

Software timer object with extended features. More...

#include <SoftTimer.h>

Inheritance diagram for SoftTimerExt:
Inheritance graph
[legend]
Collaboration diagram for SoftTimerExt:
Collaboration graph
[legend]

Public Member Functions

 SoftTimerExt ()
 Default constructor, does nothing. More...
 
 SoftTimerExt (unsigned long delay_ms)
 Save the timer interval without starting timer. More...
 
void restart ()
 Restart timer (that was previously started). More...
 
bool interval ()
 Return true when timer expires, and restart. More...
 
uint32_t remaining ()
 Return remaining timer milliseconds. More...
 
uint32_t remaining_s ()
 Return remaining timer seconds. More...
 
uint32_t elapsed ()
 Return elapsed milliseconds since (re-)start. More...
 
uint32_t elapsed_s ()
 Return elapsed seconds since (re-)start. More...
 
bool is_new_s ()
 Return true if a new second has started since last call. More...
 
void start (uint16_t delay_ms)
 Same as for SoftTimer. More...
 
void startW (unsigned long delay_ms)
 Same as for SoftTimer. More...
 
void startN (uint8_t delay_ms)
 Same as for SoftTimer. More...
 
- Public Member Functions inherited from SoftTimer
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 _length_ms
 Timer interval in milliseconds.
 
- Protected Attributes inherited from SoftTimer
unsigned long _finish_ms
 Expiry time, in milliseconds.
 

Private Attributes

uint8_t _last_s
 Hold the seconds when is_new_s() was last called.
 

Detailed Description

Software timer object with extended features.

The timer can be restarted without having to give the interval again. Elapsed and remaining times are availble. Uses more memory.

Constructor & Destructor Documentation

SoftTimerExt::SoftTimerExt ( )

Default constructor, does nothing.

Empty constructor, but required.

SoftTimerExt::SoftTimerExt ( unsigned long  delay_ms)

Save the timer interval without starting timer.

Constructor that stores the timer delay (in milliseconds). The timer is not started.

Parameters
delay_msunsigned long Timer delay in milliseconds.

Here is the call graph for this function:

Member Function Documentation

uint32_t SoftTimerExt::elapsed ( )

Return elapsed milliseconds since (re-)start.

Returns
uint32_t Number of milliseconds since the timer was started.

Here is the caller graph for this function:

uint32_t SoftTimerExt::elapsed_s ( )

Return elapsed seconds since (re-)start.

Uses integer division.

Returns
uint32_t Number of seconds since the timer was started.

Here is the call graph for this function:

bool SoftTimerExt::interval ( )

Return true when timer expires, and restart.

Check if the timer has expired, and restart it if it has. Similar to the SoftTimer interval functions, but start(), startW(), or startN() must have been called at least once before, as for restart().

Returns
bool True if timer has expired.

Here is the call graph for this function:

bool SoftTimerExt::is_new_s ( )

Return true if a new second has started since last call.

Returns true once for each second that has elapsed since the timer was started. This can be used e.g. to show elapsed time on a display, updating every second.

Returns
bool True if another second of the timer delay has elapsed.

Here is the call graph for this function:

uint32_t SoftTimerExt::remaining ( )

Return remaining timer milliseconds.

Returns
uint32_t Number of milliseconds before the timer expires.

Here is the caller graph for this function:

uint32_t SoftTimerExt::remaining_s ( )

Return remaining timer seconds.

This returns ceil() of the remaining seconds. I.e. 0s returns 0, 0.001 .. 1.000s returns 1, 1.001s .. 2.000s returns 2.

Uses integer division.

Returns
uint32_t Number of seconds before the timer expires.

Here is the call graph for this function:

Here is the caller graph for this function:

void SoftTimerExt::restart ( )

Restart timer (that was previously started).

This function only works correctly if the timer interval has been stored before, by calling start(), startW(), or startN() at least once before, or using the constructor with delay parameter. The start-functions can be called any time to change the timer delay for subsequent calls to restart().

Returns
void

Here is the call graph for this function:

void SoftTimerExt::start ( uint16_t  delay_ms)

Same as for SoftTimer.

Re-implementation, to also store the timer delay for use later.

Parameters
delay_msuint16_t Timer delay in milliseconds.
Returns
void

Here is the call graph for this function:

void SoftTimerExt::startN ( uint8_t  delay_ms)

Same as for SoftTimer.

Re-implementation, to also store the timer delay for use later.

Parameters
delay_msuint8_t Timer delay in milliseconds.
Returns
void

Here is the call graph for this function:

void SoftTimerExt::startW ( unsigned long  delay_ms)

Same as for SoftTimer.

Re-implementation, to also store the timer delay for use later.

Parameters
delay_msunsigned long Timer delay in milliseconds.
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:


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