mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 03:49:13 +03:00
Структурируем модули как надо
This commit is contained in:
@@ -1,75 +0,0 @@
|
||||
/******************************************************************
|
||||
Used Adafruit BMP280 Driver (Barometric Pressure Sensor)
|
||||
Support for BMP280
|
||||
https://github.com/adafruit/Adafruit_BMP280_Library
|
||||
******************************************************************/
|
||||
|
||||
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
|
||||
#include <Adafruit_BMP280.h>
|
||||
#include <map>
|
||||
|
||||
|
||||
std::map<String, Adafruit_BMP280*> bmps;
|
||||
|
||||
class Bmp280t : public IoTItem {
|
||||
private:
|
||||
Adafruit_BMP280* _bmp;
|
||||
|
||||
public:
|
||||
Bmp280t(Adafruit_BMP280* bmp, String parameters): IoTItem(parameters) {
|
||||
_bmp = bmp;
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
value.valD = _bmp->readTemperature();
|
||||
if (String(value.valD) != "nan") regEvent(value.valD, "Bmp280t");
|
||||
else SerialPrint("E", "Sensor DHTt", "Error");
|
||||
}
|
||||
|
||||
~Bmp280t() {};
|
||||
};
|
||||
|
||||
|
||||
class Bmp280p : public IoTItem {
|
||||
private:
|
||||
Adafruit_BMP280* _bmp;
|
||||
|
||||
public:
|
||||
Bmp280p(Adafruit_BMP280* bmp, String parameters): IoTItem(parameters) {
|
||||
_bmp = bmp;
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
value.valD = _bmp->readPressure();
|
||||
if (String(value.valD) != "nan") {
|
||||
value.valD = value.valD / 1.333224 / 100;
|
||||
regEvent(value.valD, "Bmp280p");
|
||||
} else SerialPrint("E", "Sensor DHTh", "Error");
|
||||
}
|
||||
|
||||
~Bmp280p() {};
|
||||
};
|
||||
|
||||
|
||||
void* getAPI_Bmp280(String subtype, String param) {
|
||||
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 (subtype == F("Bmp280t")) {
|
||||
return new Bmp280t(bmps[addr], param);
|
||||
} else if (subtype == F("Bmp280p")) {
|
||||
return new Bmp280p(bmps[addr], param);
|
||||
}
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
{
|
||||
"menuSection": "Сенсоры",
|
||||
|
||||
"configItem": [{
|
||||
"name": "Cенсор температуры Bmp280",
|
||||
"type": "Reading",
|
||||
"subtype": "Bmp280t",
|
||||
"id": "tmp3",
|
||||
"widget": "anydataTmp",
|
||||
"page": "Сенсоры",
|
||||
"descr": "280 Температура",
|
||||
"int": 15,
|
||||
"addr": "0x77",
|
||||
"round": 1
|
||||
},
|
||||
{
|
||||
"name": "Cенсор давления Bmp280",
|
||||
"type": "Reading",
|
||||
"subtype": "Bmp280p",
|
||||
"id": "Press3",
|
||||
"widget": "anydataMm",
|
||||
"page": "Сенсоры",
|
||||
"descr": "280 Давление",
|
||||
"int": 15,
|
||||
"addr": "0x77",
|
||||
"round": 1
|
||||
}],
|
||||
|
||||
"about": {
|
||||
"authorName": "Ilya Belyakov",
|
||||
"authorContact": "https://t.me/Biveraxe",
|
||||
"authorGit": "https://github.com/biveraxe",
|
||||
"specialThanks": "Serghei Crasnicov @Serghei63",
|
||||
"moduleName": "Bmp280",
|
||||
"moduleVersion": "1.0",
|
||||
"moduleDesc": "Позволяет получить значения температуры и давления с Bmp280.",
|
||||
"propInfo": {
|
||||
"addr": "Адрес датчика на шине, обычно 0x77.",
|
||||
"int": "Количество секунд между опросами датчика."
|
||||
}
|
||||
},
|
||||
|
||||
"defActive": true,
|
||||
|
||||
"devices": {
|
||||
"esp32_4mb": [
|
||||
"adafruit/Adafruit BMP280 Library"
|
||||
],
|
||||
"esp8266_4mb": [
|
||||
"adafruit/Adafruit BMP280 Library"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user