HomeWaterLeaksDetection
PulseCounter.h
Go to the documentation of this file.
1
#ifndef PULSE_COUNTER_H
2
#define PULSE_COUNTER_H
3
4
#include "Arduino.h"
5
#include "
Setup.h
"
6
#include "
DateTime.h
"
7
8
//====================web server========================
9
10
// if the webserver is enabled,
11
// include these files as well
12
#ifdef WEB_SERVER
13
# include <map>
14
# include <
HTMLDataSource.h
>
15
#endif
16
17
//=================PulseCounter class===================
18
25
class
PulseCounter
26
#ifdef
WEB_SERVER
27
:
public
HTMLDataSource
28
#endif
29
{
30
//====================private data======================
31
private
:
32
int
inputPin
;
33
time_t
lastPulseTime
;
34
int
previousInputValue
;
35
int
pulseDown
;
36
37
//==================public methods======================
38
public
:
41
PulseCounter
(
int
inputPin
);
42
50
void
update
();
51
54
int
isActive
()
const
;
55
58
time_t
getLastPulseTime
()
const
;
59
60
//====================web server========================
61
#ifdef WEB_SERVER
62
private
:
65
std::map<int, String (*)(
const
PulseCounter
&
pulseCounter
)>
htmlData
;
66
67
public
:
75
const
String
getHTMLData
(
const
int
id
)
const
;
76
77
private
:
81
friend
String
HTML_lastPulseTime
(
const
PulseCounter
&
pulseCounter
);
82
86
friend
String
HTML_currentTime
(
const
PulseCounter
&
pulseCounter
);
87
91
friend
String
HTML_currentDate
(
const
PulseCounter
&
pulseCounter
);
92
#endif
93
};
94
95
#endif
PulseCounter::PulseCounter
PulseCounter(int inputPin)
Constructor of the class.
Definition:
PulseCounter.cpp:9
pulseCounter
PulseCounter pulseCounter(SENSOR_PIN)
PulseCounter::getLastPulseTime
time_t getLastPulseTime() const
Return the time when the last pulse was detected.
Definition:
PulseCounter.cpp:44
DateTime.h
PulseCounter::inputPin
int inputPin
number of the input pin
Definition:
PulseCounter.h:32
PulseCounter::previousInputValue
int previousInputValue
previous state of the input pin
Definition:
PulseCounter.h:34
WEB_SERVER
#define WEB_SERVER
enable the webserver
Definition:
Setup.h:13
PulseCounter::update
void update()
Updates the class.
Definition:
PulseCounter.cpp:25
HTMLDataSource.h
Setup.h
PulseCounter::HTML_lastPulseTime
friend String HTML_lastPulseTime(const PulseCounter &pulseCounter)
Associated function for returing the last pulse time.
PulseCounter::HTML_currentDate
friend String HTML_currentDate(const PulseCounter &pulseCounter)
Associated function for returing the current date.
time_t
unsigned long time_t
Referring to the data type unsigned long as time_t.
Definition:
DateTime.h:20
PulseCounter::lastPulseTime
time_t lastPulseTime
time when the last pulse was detected
Definition:
PulseCounter.h:33
PulseCounter::HTML_currentTime
friend String HTML_currentTime(const PulseCounter &pulseCounter)
Associated function for returing the current time.
PulseCounter
Definition:
PulseCounter.h:29
PulseCounter::isActive
int isActive() const
Returns information if a pulse has been detected.
Definition:
PulseCounter.cpp:40
HTMLDataSource
Definition:
HTMLDataSource.h:15
PulseCounter::pulseDown
int pulseDown
flag if a pulse just occurred
Definition:
PulseCounter.h:35
PulseCounter::getHTMLData
const String getHTMLData(const int id) const
Since this class is registered as a source of data for the HTML content, it needs return the appropri...
PulseCounter::htmlData
std::map< int, String(*)(const PulseCounter &pulseCounter)> htmlData
A map of different values (keys) and their associated functions which returns the appropriate values.
Definition:
PulseCounter.h:65
include
PulseCounter.h
Generated on Thu May 13 2021 08:42:38 for HomeWaterLeaksDetection by
1.8.18