supla-device
Loading...
Searching...
No Matches
src
supla
sensor
particle_meter.h
1
// SPDX-FileCopyrightText: malarz
2
// SPDX-License-Identifier: GPL-2.0-or-later
3
4
#ifndef SRC_SUPLA_SENSOR_PARTICLE_METER_H_
5
#define SRC_SUPLA_SENSOR_PARTICLE_METER_H_
6
7
#include <supla/sensor/general_purpose_measurement.h>
8
9
namespace
Supla {
10
namespace
Sensor {
11
class
ParticleMeter
:
public
Supla::Element
{
12
public
:
13
ParticleMeter
() {
14
lastReadTime = millis();
15
}
16
17
double
getPM1() {
18
return
pm1value;
19
}
20
double
getPM2_5() {
21
return
pm2_5value;
22
}
23
double
getPM4() {
24
return
pm4value;
25
}
26
double
getPM10() {
27
return
pm10value;
28
}
29
30
GeneralPurposeMeasurement
* getPM1channel() {
31
return
pm1channel;
32
}
33
GeneralPurposeMeasurement
* getPM2_5channel() {
34
return
pm2_5channel;
35
}
36
GeneralPurposeMeasurement
* getPM4channel() {
37
return
pm4channel;
38
}
39
GeneralPurposeMeasurement
* getPM10channel() {
40
return
pm10channel;
41
}
42
43
void
createPM1Channel() {
44
if
(pm1channel ==
nullptr
) {
45
// create GPM channel for PM1.0
46
pm1channel =
new
GeneralPurposeMeasurement
();
47
pm1channel->
setDefaultUnitAfterValue
(
"μg/m³"
);
48
pm1channel->
setInitialCaption
(
"PM 1.0"
);
49
pm1channel->getChannel()->
setDefaultIcon
(8);
50
}
51
}
52
53
void
createPM2_5Channel() {
54
if
(pm2_5channel ==
nullptr
) {
55
// create GPM channel for PM2.5
56
pm2_5channel =
new
GeneralPurposeMeasurement
();
57
pm2_5channel->
setDefaultUnitAfterValue
(
"μg/m³"
);
58
pm2_5channel->
setInitialCaption
(
"PM 2.5"
);
59
pm2_5channel->getChannel()->
setDefaultIcon
(8);
60
}
61
}
62
63
void
createPM4Channel() {
64
if
(pm4channel ==
nullptr
) {
65
// create GPM channel for PM4
66
pm4channel =
new
GeneralPurposeMeasurement
();
67
pm4channel->
setDefaultUnitAfterValue
(
"μg/m³"
);
68
pm4channel->
setInitialCaption
(
"PM 4"
);
69
pm4channel->getChannel()->
setDefaultIcon
(8);
70
}
71
}
72
73
void
createPM10Channel() {
74
if
(pm10channel ==
nullptr
) {
75
// create GPM channel for PM10
76
pm10channel =
new
GeneralPurposeMeasurement
();
77
pm10channel->
setDefaultUnitAfterValue
(
"μg/m³"
);
78
pm10channel->
setInitialCaption
(
"PM 10"
);
79
pm10channel->getChannel()->
setDefaultIcon
(8);
80
}
81
}
82
83
protected
:
84
uint32_t refreshIntervalMs = 600000;
85
uint32_t lastReadTime = 0;
86
87
double
pm1value = NAN;
88
double
pm2_5value = NAN;
89
double
pm4value = NAN;
90
double
pm10value = NAN;
91
92
GeneralPurposeMeasurement
*pm1channel =
nullptr
;
93
GeneralPurposeMeasurement
*pm2_5channel =
nullptr
;
94
GeneralPurposeMeasurement
*pm4channel =
nullptr
;
95
GeneralPurposeMeasurement
*pm10channel =
nullptr
;
96
};
97
98
}
// namespace Sensor
99
}
// namespace Supla
100
101
#endif
// SRC_SUPLA_SENSOR_PARTICLE_METER_H_
Supla::Channel::setDefaultIcon
void setDefaultIcon(uint8_t iconId)
Sets default icon.
Definition
channel.cpp:1529
Supla::Element
Base class for all elements of SuplaDevice.
Definition
element.h:27
Supla::Element::setInitialCaption
void setInitialCaption(const char *caption, bool secondaryChannel=false)
Sets initial caption.
Definition
element.cpp:372
Supla::Sensor::GeneralPurposeChannelBase::setDefaultUnitAfterValue
void setDefaultUnitAfterValue(const char *unit)
Sets default unit which is displayed after value.
Definition
general_purpose_channel_base.cpp:197
Supla::Sensor::GeneralPurposeMeasurement
Definition
general_purpose_measurement.h:11
Supla::Sensor::ParticleMeter
Definition
particle_meter.h:11
Generated by
1.12.0