HomeWaterLeaksDetection
TimePeriod Class Reference

#include <TimePeriod.h>

Public Member Functions

 TimePeriod (time_t period)
 Constructor of the class. More...
 
int isActive ()
 Returns information if the period of time has passed. More...
 

Private Attributes

time_t period
 the period of tme, e.g. 2s More...
 
time_t lastActive
 last time stamp from which the period of time is being measured More...
 

Detailed Description

Author
silhavyj A17B0362P

This class is used for counting down a certail period of time, for example, 2s. This class is used, for example, in the LCD controller

Definition at line 14 of file TimePeriod.h.

Constructor & Destructor Documentation

◆ TimePeriod()

TimePeriod::TimePeriod ( time_t  period)

Constructor of the class.

Parameters
periodperiod of time that will be counted down

Definition at line 3 of file TimePeriod.cpp.

3  {
4  this->period = period;
5 }

References period.

Member Function Documentation

◆ isActive()

int TimePeriod::isActive ( )

Returns information if the period of time has passed.

Returns
true if the amount of time has passed, false otherwise

Definition at line 7 of file TimePeriod.cpp.

7  {
8  time_t currentTime = millis();
9  if ((time_t)(currentTime - lastActive) >= period) {
10  lastActive = currentTime;
11  return true;
12  }
13  return false;
14 }

References lastActive, and period.

Referenced by Logger::update(), and LCDController::update().

Member Data Documentation

◆ lastActive

time_t TimePeriod::lastActive
private

last time stamp from which the period of time is being measured

Definition at line 19 of file TimePeriod.h.

Referenced by isActive().

◆ period

time_t TimePeriod::period
private

the period of tme, e.g. 2s

Definition at line 18 of file TimePeriod.h.

Referenced by isActive(), and TimePeriod().


The documentation for this class was generated from the following files:
TimePeriod::period
time_t period
the period of tme, e.g. 2s
Definition: TimePeriod.h:18
time_t
unsigned long time_t
Referring to the data type unsigned long as time_t.
Definition: DateTime.h:20
TimePeriod::lastActive
time_t lastActive
last time stamp from which the period of time is being measured
Definition: TimePeriod.h:19