supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
sensor
particle_meter.h
1
/*
2
Copyright (C) malarz
3
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; either version 2
7
of the License, or (at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
*/
18
19
#ifndef SRC_SUPLA_SENSOR_PARTICLE_METER_H_
20
#define SRC_SUPLA_SENSOR_PARTICLE_METER_H_
21
22
#include <supla/sensor/general_purpose_measurement.h>
23
24
namespace
Supla {
25
namespace
Sensor {
26
class
ParticleMeter :
public
Supla::Element
{
27
public
:
28
ParticleMeter() {
29
lastReadTime = millis();
30
}
31
32
double
getPM1() {
33
return
pm1value;
34
}
35
double
getPM2_5() {
36
return
pm2_5value;
37
}
38
double
getPM4() {
39
return
pm4value;
40
}
41
double
getPM10() {
42
return
pm10value;
43
}
44
45
GeneralPurposeMeasurement
* getPM1channel() {
46
return
pm1channel;
47
}
48
GeneralPurposeMeasurement
* getPM2_5channel() {
49
return
pm2_5channel;
50
}
51
GeneralPurposeMeasurement
* getPM4channel() {
52
return
pm4channel;
53
}
54
GeneralPurposeMeasurement
* getPM10channel() {
55
return
pm10channel;
56
}
57
58
void
createPM1Channel() {
59
if
(pm1channel ==
nullptr
) {
60
// create GPM channel for PM1.0
61
pm1channel =
new
GeneralPurposeMeasurement
();
62
pm1channel->setDefaultUnitAfterValue(
"μg/m³"
);
63
pm1channel->setInitialCaption(
"PM 1.0"
);
64
pm1channel->getChannel()->setDefaultIcon(8);
65
}
66
}
67
68
void
createPM2_5Channel() {
69
if
(pm2_5channel ==
nullptr
) {
70
// create GPM channel for PM2.5
71
pm2_5channel =
new
GeneralPurposeMeasurement
();
72
pm2_5channel->setDefaultUnitAfterValue(
"μg/m³"
);
73
pm2_5channel->setInitialCaption(
"PM 2.5"
);
74
pm2_5channel->getChannel()->setDefaultIcon(8);
75
}
76
}
77
78
void
createPM4Channel() {
79
if
(pm4channel ==
nullptr
) {
80
// create GPM channel for PM4
81
pm4channel =
new
GeneralPurposeMeasurement
();
82
pm4channel->setDefaultUnitAfterValue(
"μg/m³"
);
83
pm4channel->setInitialCaption(
"PM 4"
);
84
pm4channel->getChannel()->setDefaultIcon(8);
85
}
86
}
87
88
void
createPM10Channel() {
89
if
(pm10channel ==
nullptr
) {
90
// create GPM channel for PM10
91
pm10channel =
new
GeneralPurposeMeasurement
();
92
pm10channel->setDefaultUnitAfterValue(
"μg/m³"
);
93
pm10channel->setInitialCaption(
"PM 10"
);
94
pm10channel->getChannel()->setDefaultIcon(8);
95
}
96
}
97
98
protected
:
99
uint32_t refreshIntervalMs = 600000;
100
uint32_t lastReadTime = 0;
101
102
double
pm1value = NAN;
103
double
pm2_5value = NAN;
104
double
pm4value = NAN;
105
double
pm10value = NAN;
106
107
GeneralPurposeMeasurement
*pm1channel =
nullptr
;
108
GeneralPurposeMeasurement
*pm2_5channel =
nullptr
;
109
GeneralPurposeMeasurement
*pm4channel =
nullptr
;
110
GeneralPurposeMeasurement
*pm10channel =
nullptr
;
111
};
112
113
}
// namespace Sensor
114
}
// namespace Supla
115
116
#endif
// SRC_SUPLA_SENSOR_PARTICLE_METER_H_
Supla::Element
Base class for all elements of SuplaDevice.
Definition
element.h:42
Supla::Sensor::GeneralPurposeMeasurement
Definition
general_purpose_measurement.h:26
Generated by
1.17.0