Merge branch 'ver4dev'

This commit is contained in:
2022-02-22 21:21:48 +03:00
parent a4648fd075
commit bd4753f2c9
7 changed files with 62 additions and 52 deletions

View File

@@ -22,7 +22,7 @@ class Aht20t : public IoTItem {
void doByInterval() {
value.valD = temp.temperature;
if (value.valD != -200) regEvent(value.valD, "Aht20t"); // todo: найти способ понимания ошибки получения данных
if (value.valD != -200) regEvent(value.valD, "Aht20t"); // TODO: найти способ понимания ошибки получения данных
else SerialPrint("E", "Sensor AHTt", "Error");
}
@@ -36,7 +36,7 @@ class Aht20h : public IoTItem {
void doByInterval() {
value.valD = humidity.relative_humidity;
if (value.valD != -200) regEvent(value.valD, "Aht20h"); // todo: найти способ понимания ошибки получения данных
if (value.valD != -200) regEvent(value.valD, "Aht20h"); // TODO: найти способ понимания ошибки получения данных
else SerialPrint("E", "Sensor AHTt", "Error");
}

View File

@@ -73,21 +73,24 @@ class Bme280p : public IoTItem {
~Bme280p();
};
void* getAPI_Bme280(String subtype, String param) {
String addr;
jsonRead(param, "addr", addr);
if (bmes.find(addr) == bmes.end()) {
bmes[addr] = new Adafruit_BME280();
bmes[addr]->begin(hexStringToUint8(addr));
}
void* getAPI_Bme280(String subtype, String param) {
if (subtype == F("Bme280t") || subtype == F("Bme280h") || subtype == F("Bme280p")) {
String addr;
jsonRead(param, "addr", addr);
if (subtype == F("Bme280t")) {
return new Bme280t(bmes[addr], param);
} else if (subtype == F("Bme280h")) {
return new Bme280h(bmes[addr], param);
} else if (subtype == F("Bme280p")) {
return new Bme280p(bmes[addr], param);
if (bmes.find(addr) == bmes.end()) {
bmes[addr] = new Adafruit_BME280();
bmes[addr]->begin(hexStringToUint8(addr));
}
if (subtype == F("Bme280t")) {
return new Bme280t(bmes[addr], param);
} else if (subtype == F("Bme280h")) {
return new Bme280h(bmes[addr], param);
} else if (subtype == F("Bme280p")) {
return new Bme280p(bmes[addr], param);
}
} else {
return nullptr;
}

View File

@@ -55,18 +55,20 @@ class Bmp280p : public IoTItem {
void* getAPI_Bmp280(String subtype, String param) {
String addr;
jsonRead(param, "addr", addr);
if (subtype == F("Bmp280t") || subtype == F("Bmp280p")) {
String addr;
jsonRead(param, "addr", addr);
if (bmps.find(addr) == bmps.end()) {
bmps[addr] = new Adafruit_BMP280();
bmps[addr]->begin(hexStringToUint8(addr));
}
if (bmps.find(addr) == bmps.end()) {
bmps[addr] = new Adafruit_BMP280();
bmps[addr]->begin(hexStringToUint8(addr));
}
if (subtype == F("Bmp280t")) {
return new Bmp280t(bmps[addr], param);
} else if (subtype == F("Bmp280p")) {
return new Bmp280p(bmps[addr], param);
if (subtype == F("Bmp280t")) {
return new Bmp280t(bmps[addr], param);
} else if (subtype == F("Bmp280p")) {
return new Bmp280p(bmps[addr], param);
}
} else {
return nullptr;
}

View File

@@ -53,25 +53,27 @@ class Dht1122h : public IoTItem {
void* getAPI_Dht1122(String subtype, String param) {
int pin;
String senstype;
jsonRead(param, "pin", pin);
jsonRead(param, "senstype", senstype);
if (subtype == F("Dht1122t") || subtype == F("Dht1122h")) {
int pin;
String senstype;
jsonRead(param, "pin", pin);
jsonRead(param, "senstype", senstype);
if (dhts.find(pin) == dhts.end()) {
dhts[pin] = new DHTesp();
if (senstype == "dht11") {
dhts[pin]->setup(pin, DHTesp::DHT11);
} else if (senstype == "dht22") {
dhts[pin]->setup(pin, DHTesp::DHT22);
if (dhts.find(pin) == dhts.end()) {
dhts[pin] = new DHTesp();
if (senstype == "dht11") {
dhts[pin]->setup(pin, DHTesp::DHT11);
} else if (senstype == "dht22") {
dhts[pin]->setup(pin, DHTesp::DHT22);
}
}
}
if (subtype == F("Dht1122t")) {
return new Dht1122t(dhts[pin], param);
} else if (subtype == F("Dht1122h")) {
return new Dht1122h(dhts[pin], param);
if (subtype == F("Dht1122t")) {
return new Dht1122t(dhts[pin], param);
} else if (subtype == F("Dht1122h")) {
return new Dht1122h(dhts[pin], param);
}
} else {
return nullptr;
}

View File

@@ -20,7 +20,7 @@ class GY21t : public IoTItem {
void doByInterval() {
//wire->read();
value.valD = sensor->GY21_Temperature();
if (value.valD < 300) regEvent(value.valD, "GY21"); // todo: найти способ понимания ошибки получения данных
if (value.valD < 300) regEvent(value.valD, "GY21"); // TODO: найти способ понимания ошибки получения данных
else SerialPrint("E", "Sensor GY21t", "Error");
}
@@ -34,7 +34,7 @@ class GY21h : public IoTItem {
void doByInterval() {
//sht->read();
value.valD = sensor->GY21_Humidity();
if (value.valD != 0) regEvent(value.valD, "GY21h"); // todo: найти способ понимания ошибки получения данных
if (value.valD != 0) regEvent(value.valD, "GY21h"); // TODO: найти способ понимания ошибки получения данных
else SerialPrint("E", "Sensor GY21h", "Error");
}
@@ -42,16 +42,18 @@ class GY21h : public IoTItem {
};
void* getAPI_GY21(String subtype, String param) {
if (subtype == F("GY21t") || subtype == F("GY21h")) {
if (!sensor) {
sensor = new GY21;
if (sensor) Wire.begin(SDA, SCL);
sensor = new GY21;
if (sensor) Wire.begin(SDA, SCL);
}
if (subtype == F("GY21t")) {
return new GY21t(param);
} else if (subtype == F("GY21h")) {
return new GY21h(param);
} else {
return nullptr;
}
} else {
return nullptr;
}
}

View File

@@ -43,7 +43,6 @@ class Mcp23017 : public IoTItem, IoTGpio {
void* getAPI_Mcp23017(String subtype, String param) {
if (subtype == F("Mcp23017")) {
String addr;
uint8_t deviceAddress[1];
jsonRead(param, "addr", addr);
Serial.printf("deviceAddress %s = %02x \n", addr.c_str(), hexStringToUint8(addr));

View File

@@ -37,16 +37,18 @@ class Sht20h : public IoTItem {
void* getAPI_Sht20(String subtype, String param) {
if (subtype == F("Sht20t") || subtype == F("Sht20h")) {
if (!sht) {
sht = new SHT2x;
if (sht) sht->begin();
sht = new SHT2x;
if (sht) sht->begin();
}
if (subtype == F("Sht20t")) {
return new Sht20t(param);
} else if (subtype == F("Sht20h")) {
return new Sht20h(param);
} else {
return nullptr;
}
} else {
return nullptr;
}
}