Arduino Helpers master
Utility library for Arduino
Public Member Functions | Private Attributes | List of all members
Timer< time > Class Template Reference

#include <AH/Timing/MillisMicrosTimer.hpp>

Detailed Description

template<timefunction time = micros>
class Timer< time >

A class for easily managing timed events.

A wrapper for "Blink Without Delay".

Template Parameters
timeThe time function to use.
Examples
1.FilteredAnalog-Advanced.ino, 1.FilteredAnalog.ino, Blink-Frequency-Buttons.ino, and BlinkWithoutDelay-Timer.ino.

Definition at line 23 of file MillisMicrosTimer.hpp.

+ Collaboration diagram for Timer< time >:

Public Member Functions

 Timer (unsigned long interval)
 Constructor. More...
 
void begin ()
 Initialize or reset the timer. The timer will fire immediately. More...
 
void beginNextPeriod ()
 Initialize or reset the timer. The timer will fire after one period. More...
 
 operator bool ()
 Update the timer and return true if the event should fire. More...
 
unsigned long getInterval () const
 Get the interval of the timer. More...
 
void setInterval (unsigned long interval)
 Set the interval of the timer. More...
 

Private Attributes

unsigned long interval
 
unsigned long previous = 0
 

Constructor & Destructor Documentation

◆ Timer()

Timer ( unsigned long  interval)
inline

Constructor.

Parameters
intervalThe interval between two events.

Definition at line 30 of file MillisMicrosTimer.hpp.

Member Function Documentation

◆ begin()

void begin ( )
inline

Initialize or reset the timer. The timer will fire immediately.

Definition at line 36 of file MillisMicrosTimer.hpp.

◆ beginNextPeriod()

void beginNextPeriod ( )
inline

Initialize or reset the timer. The timer will fire after one period.

Definition at line 38 of file MillisMicrosTimer.hpp.

◆ operator bool()

operator bool ( )
inlineexplicit

Update the timer and return true if the event should fire.

Definition at line 40 of file MillisMicrosTimer.hpp.

◆ getInterval()

unsigned long getInterval ( ) const
inline

Get the interval of the timer.

Examples
Blink-Frequency-Buttons.ino.

Definition at line 50 of file MillisMicrosTimer.hpp.

◆ setInterval()

void setInterval ( unsigned long  interval)
inline

Set the interval of the timer.

Examples
Blink-Frequency-Buttons.ino.

Definition at line 52 of file MillisMicrosTimer.hpp.

Member Data Documentation

◆ interval

unsigned long interval
private

Definition at line 55 of file MillisMicrosTimer.hpp.

◆ previous

unsigned long previous = 0
private

Definition at line 56 of file MillisMicrosTimer.hpp.


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