supla-device
Loading...
Searching...
No Matches
therm_hygro_meter.h
1/*
2 Copyright (C) AC SOFTWARE SP. Z O.O.
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_THERM_HYGRO_METER_H_
20#define SRC_SUPLA_SENSOR_THERM_HYGRO_METER_H_
21
22#include <supla/channel_element.h>
23#include <supla/sensor/thermometer_driver.h>
24
25#define HUMIDITY_NOT_AVAILABLE -1
26
27namespace Supla {
28namespace Sensor {
29class ThermHygroMeter : public ChannelElement {
30 public:
31 ThermHygroMeter();
32
33 void setRefreshIntervalMs(int intervalMs);
34
35 void onInit() override;
36 void onLoadConfig(SuplaDeviceClass *) override;
37 void iterateAlways() override;
38 void fillChannelConfig(void *channelConfig,
39 int *size,
40 uint8_t configType) override;
41 void purgeConfig() override;
42
43 virtual double getTemp();
44 virtual double getHumi();
45
46 int16_t getTempInt16();
47 int16_t getHumiInt16();
48
49 Supla::ApplyConfigResult applyChannelConfig(TSD_ChannelConfig *result,
50 bool local) override;
51
52 int16_t getConfiguredTemperatureCorrection();
53 int16_t getConfiguredHumidityCorrection();
54
63 void applyCorrectionsAndStoreIt(int32_t temperatureCorrection,
64 int32_t humidityCorrection,
65 bool local = false);
66
79
88 void setMinMaxAllowedTemperatureAdjustment(int32_t minMax);
89
98 void setMinMaxAllowedHumidityAdjustment(int32_t minMax);
99
100 protected:
101 int16_t readCorrectionFromIndex(int index);
102 void setCorrectionAtIndex(int32_t correction, int index);
103 virtual void setTemperatureCorrection(int32_t correction);
104 virtual void setHumidityCorrection(int32_t correction);
105
106 uint32_t lastReadTime = 0;
107 uint16_t refreshIntervalMs = 10000;
108
114
120
124 bool applyCorrections = true;
125};
126
127}; // namespace Sensor
128}; // namespace Supla
129
130#endif // SRC_SUPLA_SENSOR_THERM_HYGRO_METER_H_
Definition SuplaDevice.h:93
void onLoadConfig(SuplaDeviceClass *) override
First method called on element in SuplaDevice.begin().
Definition therm_hygro_meter.cpp:88
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition therm_hygro_meter.cpp:81
bool applyCorrections
Whether correction should be applied by SD.
Definition therm_hygro_meter.h:124
void applyCorrectionsAndStoreIt(int32_t temperatureCorrection, int32_t humidityCorrection, bool local=false)
Apply temperature and humidity corrections and store them to Config.
Definition therm_hygro_meter.cpp:250
void setApplyCorrections(bool applyCorrections)
Set whether correction should be applied or not.
Definition therm_hygro_meter.cpp:303
int16_t minMaxAllowedTemperatureAdjustment
Minimum and maximum allowed temperature adjustment in 0.1 degree C.
Definition therm_hygro_meter.h:113
void setMinMaxAllowedHumidityAdjustment(int32_t minMax)
Set minimum and maximum allowed humidity adjustment.
Definition therm_hygro_meter.cpp:319
void setMinMaxAllowedTemperatureAdjustment(int32_t minMax)
Set minimum and maximum allowed temperature adjustment.
Definition therm_hygro_meter.cpp:308
int16_t minMaxAllowedHumidityAdjustment
Minimum and maximum allowed humidity adjustment in 0.1 RH.
Definition therm_hygro_meter.h:119
void onInit() override
Third method called on element in SuplaDevice.begin()
Definition therm_hygro_meter.cpp:33
void purgeConfig() override
Removes all configration data related to the element from Storage::Config.
Definition therm_hygro_meter.cpp:120
Definition proto.h:2987