mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Поддержка нескольких DHT
This commit is contained in:
@@ -5,8 +5,6 @@
|
||||
#include "Global.h"
|
||||
#include "GyverFilters.h"
|
||||
|
||||
extern DHTesp* dht;
|
||||
|
||||
class SensorDht;
|
||||
|
||||
typedef std::vector<SensorDht> MySensorDhtVector;
|
||||
@@ -24,13 +22,15 @@ class SensorDht {
|
||||
SensorDht(const paramsDht& paramsTmp, const paramsDht& paramsHum);
|
||||
~SensorDht();
|
||||
|
||||
DHTesp* dht;
|
||||
|
||||
void loop();
|
||||
void readTmpHum();
|
||||
|
||||
private:
|
||||
paramsDht _paramsTmp;
|
||||
paramsDht _paramsHum;
|
||||
|
||||
|
||||
unsigned long prevMillis;
|
||||
unsigned long difference;
|
||||
};
|
||||
|
||||
@@ -6,15 +6,11 @@
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
|
||||
DHTesp* dht = nullptr;
|
||||
|
||||
SensorDht::SensorDht(const paramsDht& paramsTmp, const paramsDht& paramsHum) {
|
||||
_paramsTmp = paramsDht(paramsTmp);
|
||||
_paramsHum = paramsDht(paramsHum);
|
||||
|
||||
if (!dht) {
|
||||
dht = new DHTesp();
|
||||
}
|
||||
dht = new DHTesp();
|
||||
|
||||
if (_paramsHum.type == "dht11") {
|
||||
dht->setup(_paramsHum.pin, DHTesp::DHT11);
|
||||
@@ -92,5 +88,7 @@ void dhtSensor() {
|
||||
if (firstTime) mySensorDht = new MySensorDhtVector();
|
||||
firstTime = false;
|
||||
mySensorDht->push_back(SensorDht(paramsTmp, paramsHum));
|
||||
|
||||
enterCnt = -1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user