mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-31 20:39:14 +03:00
Структурируем модули как надо
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
|
||||
#include "Wire.h"
|
||||
#include "SHT2x.h"
|
||||
|
||||
|
||||
SHT2x* sht = nullptr;
|
||||
|
||||
class Sht20t : public IoTItem {
|
||||
public:
|
||||
Sht20t(String parameters): IoTItem(parameters) { }
|
||||
|
||||
void doByInterval() {
|
||||
sht->read();
|
||||
value.valD = sht->getTemperature();
|
||||
if (value.valD > -46.85F) regEvent(value.valD, "Sht20t");
|
||||
else SerialPrint("E", "Sensor Sht20t", "Error");
|
||||
}
|
||||
|
||||
~Sht20t() {};
|
||||
};
|
||||
|
||||
class Sht20h : public IoTItem {
|
||||
public:
|
||||
Sht20h(String parameters): IoTItem(parameters) { }
|
||||
|
||||
void doByInterval() {
|
||||
sht->read();
|
||||
value.valD = sht->getHumidity();
|
||||
if (value.valD != -6) regEvent(value.valD, "Sht20h");
|
||||
else SerialPrint("E", "Sensor Sht20h", "Error");
|
||||
}
|
||||
|
||||
~Sht20h() {};
|
||||
};
|
||||
|
||||
|
||||
void* getAPI_Sht20(String subtype, String param) {
|
||||
if (subtype == F("Sht20t") || subtype == F("Sht20h")) {
|
||||
if (!sht) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
{
|
||||
"menuSection": "Сенсоры",
|
||||
|
||||
"configItem": [{
|
||||
"name": "Cенсор температуры Sht20",
|
||||
"type": "Reading",
|
||||
"subtype": "Sht20t",
|
||||
"id": "tmp2",
|
||||
"widget": "anydataTmp",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Температура",
|
||||
"int": 15,
|
||||
"round": 1
|
||||
},
|
||||
{
|
||||
"name": "Cенсор влажности Sht20",
|
||||
"type": "Reading",
|
||||
"subtype": "Sht20h",
|
||||
"id": "Hum2",
|
||||
"widget": "anydataHum",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Влажность",
|
||||
"int": 15,
|
||||
"round": 1
|
||||
}],
|
||||
|
||||
"about": {
|
||||
"authorName": "Ilya Belyakov",
|
||||
"authorContact": "https://t.me/Biveraxe",
|
||||
"authorGit": "https://github.com/biveraxe",
|
||||
"specialThanks": "",
|
||||
"moduleName": "Sht20",
|
||||
"moduleVersion": "1.0",
|
||||
"moduleDesc": "Позволяет получить значения температуры и влажности с Sht20.",
|
||||
"propInfo": {
|
||||
"int": "Количество секунд между опросами датчика."
|
||||
}
|
||||
},
|
||||
|
||||
"defActive": true,
|
||||
|
||||
"devices": {
|
||||
"esp32_4mb": [
|
||||
"robtillaart/SHT2x@^0.1.1"
|
||||
],
|
||||
"esp8266_4mb": [
|
||||
"robtillaart/SHT2x@^0.1.1"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user