mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 14:42:18 +03:00
Добавляем Bh1750 и Dwini
This commit is contained in:
56
src/modules/display/DwinI/DwinI.cpp
Normal file
56
src/modules/display/DwinI/DwinI.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
|
||||
#ifdef ESP8266
|
||||
#include <SoftwareSerial.h>
|
||||
#else
|
||||
#include <HardwareSerial.h>
|
||||
#endif
|
||||
|
||||
class DwinI : public IoTItem {
|
||||
private:
|
||||
#ifdef ESP8266
|
||||
SoftwareSerial* _myUART;
|
||||
#else
|
||||
HardwareSerial* _myUART;
|
||||
#endif
|
||||
|
||||
public:
|
||||
DwinI(String parameters) : IoTItem(parameters) {
|
||||
int _tx, _rx, _speed, _line;
|
||||
jsonRead(parameters, "RX", _rx);
|
||||
jsonRead(parameters, "TX", _tx);
|
||||
jsonRead(parameters, "speed", _speed);
|
||||
jsonRead(parameters, "line", _line);
|
||||
|
||||
#ifdef ESP8266
|
||||
_myUART = new SoftwareSerial(_rx, _tx);
|
||||
_myUART->begin(_speed);
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
_myUART = new HardwareSerial(_line);
|
||||
_myUART->begin(_speed, SERIAL_8N1, _rx, _tx);
|
||||
#endif
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
Serial.println("ddddddddddddd");
|
||||
}
|
||||
|
||||
IoTValue execute(String command, std::vector<IoTValue> ¶m) { // будет возможным использовать, когда сценарии запустятся
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
~DwinI(){
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
void *getAPI_DwinI(String subtype, String param) {
|
||||
if (subtype == F("DwinI")) {
|
||||
return new DwinI(param);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
61
src/modules/display/DwinI/modinfo.json
Normal file
61
src/modules/display/DwinI/modinfo.json
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"menuSection": "Экраны",
|
||||
|
||||
"configItem": [{
|
||||
"global": 0,
|
||||
"name": "LCD Dwin экран",
|
||||
"type": "Reading",
|
||||
"subtype": "DwinI",
|
||||
"id": "dwin",
|
||||
"widget": "",
|
||||
"page": "",
|
||||
"descr": "",
|
||||
|
||||
"int": 15,
|
||||
"TX": 17,
|
||||
"RX": 16,
|
||||
"line": 2,
|
||||
"speed": 115200
|
||||
}],
|
||||
|
||||
"about": {
|
||||
"authorName": "Ilya Belyakov",
|
||||
"authorContact": "https://t.me/Biveraxe",
|
||||
"authorGit": "https://github.com/biveraxe",
|
||||
"specialThanks": "",
|
||||
"moduleName": "DwinI",
|
||||
"moduleVersion": "1.0",
|
||||
"usedRam": {
|
||||
"esp32_4mb": 15,
|
||||
"esp8266_4mb": 15
|
||||
},
|
||||
"moduleDesc": "Позволяет выводить на графические экраны фирмы Dwin информацию от элементов конфигурации в автоматическом режиме.",
|
||||
"propInfo": {
|
||||
"int": ""
|
||||
},
|
||||
"funcInfo": [
|
||||
{
|
||||
"name": "rrrr",
|
||||
"descr": "rrrr",
|
||||
"params": []
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"defActive": false,
|
||||
|
||||
"usedLibs": {
|
||||
"esp32_4mb": [
|
||||
],
|
||||
"esp8266_4mb": [
|
||||
],
|
||||
"esp8266_1mb": [
|
||||
],
|
||||
"esp8266_1mb_ota": [
|
||||
],
|
||||
"esp8285_1mb": [
|
||||
],
|
||||
"esp8285_1mb_ota": [
|
||||
]
|
||||
}
|
||||
}
|
||||
32
src/modules/sensors/BH_1750/Bh1750.cpp
Normal file
32
src/modules/sensors/BH_1750/Bh1750.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "Global.h"
|
||||
#include "classes/IoTItem.h"
|
||||
|
||||
#include "BH1750.h"
|
||||
|
||||
|
||||
class Bh1750 : public IoTItem {
|
||||
BH1750 _lightMeter;
|
||||
|
||||
public:
|
||||
Bh1750(String parameters): IoTItem(parameters){
|
||||
_lightMeter.begin();
|
||||
}
|
||||
|
||||
void doByInterval() {
|
||||
value.valD = _lightMeter.readLightLevel();
|
||||
if (value.valD < 70000)
|
||||
regEvent(value.valD, "BH1750");
|
||||
else
|
||||
SerialPrint("E", "Sensor BH1750", "Error");
|
||||
}
|
||||
|
||||
~Bh1750() {};
|
||||
};
|
||||
|
||||
void* getAPI_Bh1750(String subtype, String param) {
|
||||
if (subtype == F("Bh1750")) {
|
||||
return new Bh1750(param);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
44
src/modules/sensors/BH_1750/modinfo.json
Normal file
44
src/modules/sensors/BH_1750/modinfo.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"menuSection": "Сенсоры",
|
||||
|
||||
"configItem": [{
|
||||
"global": 0,
|
||||
"name": "Cенсор освещенность Bh1750",
|
||||
"type": "Reading",
|
||||
"subtype": "Bh1750",
|
||||
"id": "Bh1750",
|
||||
"widget": "anydata",
|
||||
"page": "Сенсоры",
|
||||
"descr": "Освещённость",
|
||||
"round": 1,
|
||||
"int": 15
|
||||
}],
|
||||
|
||||
"about": {
|
||||
"authorName": "Ilya Belyakov",
|
||||
"authorContact": "https://t.me/Biveraxe",
|
||||
"authorGit": "https://github.com/biveraxe",
|
||||
"exampleURL": "https://iotmanager.org/wiki",
|
||||
"specialThanks": "",
|
||||
"moduleName": "Bh1750",
|
||||
"moduleVersion": "1.0",
|
||||
"usedRam": {
|
||||
"esp32_4mb": 15,
|
||||
"esp8266_4mb": 15
|
||||
},
|
||||
"title": "Cенсор освещённости",
|
||||
"moduleDesc": "Позволяет получить текущее значение освещённости в LUX.",
|
||||
"propInfo": {
|
||||
"int": "Количество секунд между опросами датчика."
|
||||
}
|
||||
},
|
||||
"defActive": false,
|
||||
"usedLibs": {
|
||||
"esp32_4mb": [
|
||||
"BH1750"
|
||||
],
|
||||
"esp8266_4mb": [
|
||||
"BH1750"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user