RBE1001Lib
Public Member Functions | Private Attributes
Timer Class Reference

A Timer that remembers a starting time and interval allow easy periodic events. More...

#include <Timer.h>

Public Member Functions

 Timer (unsigned long interval)
 Construct a new Timer object. More...
 
bool isExpired ()
 Checks to see if the timer has expired. More...
 
void reset ()
 Reset the timer to the current time + interval. More...
 
void reset (unsigned long newInterval)
 Reset the timer with a new interval. More...
 

Private Attributes

unsigned long expiredTime
 
unsigned long timeInterval
 

Detailed Description

A Timer that remembers a starting time and interval allow easy periodic events.

This class is for simple timing of things in the loop function where it will determine if some amount of time has elapsed. When it is checked after the time has elapsed then the timer is reset to simplify restarting the next interval. Think of printing periodically.

Definition at line 11 of file Timer.h.

Constructor & Destructor Documentation

◆ Timer()

Timer::Timer ( unsigned long  interval)

Construct a new Timer object.

Parameters
interval

Create a timer that will expire every "interval"

Definition at line 7 of file Timer.cpp.

References expiredTime, and timeInterval.

Member Function Documentation

◆ isExpired()

bool Timer::isExpired ( )

Checks to see if the timer has expired.

Returns
true If the timer has expired, and the timer is reset for another interval.
false If the timer has not expired.

Check if the timer is expired, that is the current time is past the expired time.

Definition at line 35 of file Timer.cpp.

References expiredTime, and timeInterval.

◆ reset() [1/2]

void Timer::reset ( )

Reset the timer to the current time + interval.

Reset the timer to that the expired time is the current time + interval

Definition at line 16 of file Timer.cpp.

References expiredTime, and timeInterval.

Referenced by reset(), setup(), and updateDashboard().

◆ reset() [2/2]

void Timer::reset ( unsigned long  newInterval)

Reset the timer with a new interval.

Parameters
newInterval

Change the timer interval to "NewInterval" then reset the timer to that the expired time is the current time + interval

Definition at line 25 of file Timer.cpp.

References reset(), and timeInterval.

Here is the call graph for this function:

Field Documentation

◆ expiredTime

unsigned long Timer::expiredTime
private

Definition at line 40 of file Timer.h.

Referenced by isExpired(), reset(), and Timer().

◆ timeInterval

unsigned long Timer::timeInterval
private

Definition at line 41 of file Timer.h.

Referenced by isExpired(), reset(), and Timer().


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