Noiasca Tool Kit
Several helper functions and classes to make life with Arduino easier
Public Member Functions | List of all members
LittleTimer Class Reference

a simple timer More...

#include <Noiasca_timer.h>

Public Member Functions

void attachOnStart (const CallBack cbOnStart)
 attach callback for on start event
 
void attachOnInterval (const CallBack cbOnInterval)
 attach callback for on interval event
 
void attachOnStop (const CallBack cbOnStop)
 attach callback for on stop event
 
byte getState ()
 get the state of the timer More...
 
void setLimit (uint32_t limit)
 set limit More...
 
void setIteration (uint32_t iteration)
 set the iteration More...
 
void setInterval (uint32_t interval)
 set the interval More...
 
void start ()
 start timer More...
 
void stop ()
 stop timer More...
 
uint32_t getIteration ()
 get the iteration More...
 
uint16_t hasTriggered ()
 indicate if timer has been triggered More...
 
bool hasEnded ()
 indicate if timer has been ended More...
 
void update (uint32_t currentMillis=millis())
 run More...
 

Detailed Description

a simple timer

The LittleTimer can be used to fire in a specific interval. Additionally you can limit the timer by a specific amount of intervals. If necessary you can define callback functions.

Todo:
tbd methods for pause and restart

Member Function Documentation

◆ getState()

byte LittleTimer::getState ( )
inline

get the state of the timer

Returns
the current state of the timer

◆ setLimit()

void LittleTimer::setLimit ( uint32_t  limit)
inline

set limit

Set a new limit for the timer.

Parameters
limithow often should the timer fire

◆ setIteration()

void LittleTimer::setIteration ( uint32_t  iteration)
inline

set the iteration

Modify the counter of iterations.

Parameters
iterationhow often has the timer fired

◆ setInterval()

void LittleTimer::setInterval ( uint32_t  interval)
inline

set the interval

Modify the interval of the timer.

Parameters
intervalinterval in milliseconds

◆ start()

void LittleTimer::start ( )
inline

start timer

starts the timer.

◆ stop()

void LittleTimer::stop ( )
inline

stop timer

Stops the timer.

◆ getIteration()

uint32_t LittleTimer::getIteration ( )
inline

get the iteration

Returns the current number of ioterations.

Returns
interations of how often the timer has fired.

◆ hasTriggered()

uint16_t LittleTimer::hasTriggered ( )
inline

indicate if timer has been triggered

Returns
> 0 if interval time is passed since last call. Returns the number of "missed" intervals.

◆ hasEnded()

bool LittleTimer::hasEnded ( )
inline

indicate if timer has been ended

Returns
true if interval time is over.

◆ update()

void LittleTimer::update ( uint32_t  currentMillis = millis())
inline

run

call this member function in your loop()