FastLED 3.9.3
Loading...
Searching...
No Matches
CEveryNTime Class Reference

Detailed Description

Time interval checking class.

Keeps track of a time interval in order to limit how often code is executed.

Note
TIMETYPE is specific to the initialized class, and is in the units used by the time function. E.g. for EVERY_N_MILLIS it's uint32_t and milliseconds, for EVERY_N_HOURS it's uint8_t and hours, etc.
Warning
This specific class isn't actually part of the library! It's created using a preprocessor macro (INSTANTIATE_EVERY_N_TIME_PERIODS) as a new class for every different time unit. It has been recreated specifically for the documentation, so that the methods can be documented as usual.
See also
INSTANTIATE_EVERY_N_TIME_PERIODS

Definition at line 1125 of file lib8tion.h.

#include <lib8tion.h>

Public Member Functions

 CEveryNTime ()
 Default constructor.
 
 CEveryNTime (TIMETYPE period)
 Constructor.
 
void setPeriod (TIMETYPE period)
 Set the time interval between triggers.
 
TIMETYPE getTime ()
 Get the current time according to the class' timekeeper.
 
TIMETYPE getPeriod ()
 Get the time interval between triggers.
 
TIMETYPE getElapsed ()
 Get the time elapsed since the last trigger event.
 
TIMETYPE getRemaining ()
 Get the time until the next trigger event.
 
TIMETYPE getLastTriggerTime ()
 Get the timestamp of the most recent trigger event.
 
bool ready ()
 Check if the time interval has elapsed.
 
void reset ()
 Reset the timestamp to the current time.
 
void trigger ()
 Reset the timestamp so it is ready() on next call.
 
 operator bool ()
 Check if the time interval has elapsed.
 

Public Attributes

TIMETYPE mPrevTrigger
 Timestamp of the last time the class was "ready".
 
TIMETYPE mPeriod
 Timing interval to check.
 

Constructor & Destructor Documentation

◆ CEveryNTime() [1/2]

CEveryNTime::CEveryNTime ( )
inline

Default constructor.

Definition at line 1131 of file lib8tion.h.

◆ CEveryNTime() [2/2]

CEveryNTime::CEveryNTime ( TIMETYPE period)
inline

Constructor.

Parameters
periodthe time interval between triggers

Definition at line 1134 of file lib8tion.h.

Member Function Documentation

◆ getElapsed()

TIMETYPE CEveryNTime::getElapsed ( )
inline

Get the time elapsed since the last trigger event.

Definition at line 1146 of file lib8tion.h.

◆ getLastTriggerTime()

TIMETYPE CEveryNTime::getLastTriggerTime ( )
inline

Get the timestamp of the most recent trigger event.

Definition at line 1152 of file lib8tion.h.

◆ getPeriod()

TIMETYPE CEveryNTime::getPeriod ( )
inline

Get the time interval between triggers.

Definition at line 1143 of file lib8tion.h.

◆ getRemaining()

TIMETYPE CEveryNTime::getRemaining ( )
inline

Get the time until the next trigger event.

Definition at line 1149 of file lib8tion.h.

◆ getTime()

TIMETYPE CEveryNTime::getTime ( )
inline

Get the current time according to the class' timekeeper.

Definition at line 1140 of file lib8tion.h.

◆ operator bool()

CEveryNTime::operator bool ( )
inline

Check if the time interval has elapsed.

Definition at line 1168 of file lib8tion.h.

◆ ready()

bool CEveryNTime::ready ( )
inline

Check if the time interval has elapsed.

Definition at line 1155 of file lib8tion.h.

◆ reset()

void CEveryNTime::reset ( )
inline

Reset the timestamp to the current time.

Definition at line 1162 of file lib8tion.h.

◆ setPeriod()

void CEveryNTime::setPeriod ( TIMETYPE period)
inline

Set the time interval between triggers.

Definition at line 1137 of file lib8tion.h.

◆ trigger()

void CEveryNTime::trigger ( )
inline

Reset the timestamp so it is ready() on next call.

Definition at line 1165 of file lib8tion.h.

Member Data Documentation

◆ mPeriod

TIMETYPE CEveryNTime::mPeriod

Timing interval to check.

Definition at line 1128 of file lib8tion.h.

◆ mPrevTrigger

TIMETYPE CEveryNTime::mPrevTrigger

Timestamp of the last time the class was "ready".

Definition at line 1127 of file lib8tion.h.


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