некоторые изменения

This commit is contained in:
Dmitry Borisenko
2022-08-31 17:32:40 +02:00
parent df95f8bae2
commit a2d5a6f5e1
5 changed files with 28 additions and 45 deletions

View File

@@ -443,38 +443,25 @@
"num": 33 "num": 33
}, },
{ {
"name": "34. PWM ESP32", "name": "34. PWM ESP8266",
"type": "Writing", "type": "Writing",
"subtype": "Pwm32", "subtype": "Pwm8266",
"id": "pwm", "id": "pwm",
"widget": "range", "widget": "range",
"page": "Кнопки", "page": "Кнопки",
"descr": "PWM", "descr": "PWM",
"int": 0, "int": 0,
"pin": 2, "pin": 15,
"freq": 5000, "freq": 5000,
"ledChannel": 2,
"PWM_resolution": 10,
"val": 0, "val": 0,
"apin": -1, "apin": -1,
"num": 34 "num": 34
}, },
{
"name": "35. Доп. функции системы",
"type": "Reading",
"subtype": "SysExt",
"id": "SysExt",
"widget": "",
"page": "",
"descr": "",
"int": 15,
"num": 35
},
{ {
"header": "Экраны" "header": "Экраны"
}, },
{ {
"name": "36. LCD экран 2004", "name": "35. LCD экран 2004",
"type": "Reading", "type": "Reading",
"subtype": "Lcd2004", "subtype": "Lcd2004",
"id": "Lcd", "id": "Lcd",
@@ -486,10 +473,10 @@
"size": "20,4", "size": "20,4",
"coord": "0,0", "coord": "0,0",
"id2show": "id датчика", "id2show": "id датчика",
"num": 36 "num": 35
}, },
{ {
"name": "37. LCD экран 1602", "name": "36. LCD экран 1602",
"type": "Reading", "type": "Reading",
"subtype": "Lcd2004", "subtype": "Lcd2004",
"id": "Lcd", "id": "Lcd",
@@ -501,6 +488,6 @@
"size": "16,2", "size": "16,2",
"coord": "0,0", "coord": "0,0",
"id2show": "id датчика", "id2show": "id датчика",
"num": 37 "num": 36
} }
] ]

View File

@@ -21,7 +21,7 @@
}, },
"projectProp": { "projectProp": {
"platformio": { "platformio": {
"default_envs": "esp32_4mb", "default_envs": "esp8266_4mb",
"data_dir": "data_svelte" "data_dir": "data_svelte"
} }
}, },
@@ -157,7 +157,7 @@
}, },
{ {
"path": "src\\modules\\exec\\SysExt", "path": "src\\modules\\exec\\SysExt",
"active": true "active": false
}, },
{ {
"path": "src\\modules\\exec\\Telegram", "path": "src\\modules\\exec\\Telegram",

View File

@@ -39,7 +39,7 @@ build_src_filter =
${env:esp32_4mb_fromitems.build_src_filter} ${env:esp32_4mb_fromitems.build_src_filter}
[platformio] [platformio]
default_envs = esp32_4mb default_envs = esp8266_4mb
data_dir = data_svelte data_dir = data_svelte
[common_env_data] [common_env_data]
@@ -89,7 +89,6 @@ build_src_filter =
+<modules\exec\Mcp23017> +<modules\exec\Mcp23017>
+<modules\exec\Mp3> +<modules\exec\Mp3>
+<modules\exec\Pwm8266> +<modules\exec\Pwm8266>
+<modules\exec\SysExt>
+<modules\display\Lcd2004> +<modules\display\Lcd2004>
[env:esp32_4mb_fromitems] [env:esp32_4mb_fromitems]

View File

@@ -22,8 +22,7 @@ void* getAPI_ButtonOut(String subtype, String params);
void* getAPI_IoTServo(String subtype, String params); void* getAPI_IoTServo(String subtype, String params);
void* getAPI_Mcp23017(String subtype, String params); void* getAPI_Mcp23017(String subtype, String params);
void* getAPI_Mp3(String subtype, String params); void* getAPI_Mp3(String subtype, String params);
void* getAPI_Pwm32(String subtype, String params); void* getAPI_Pwm8266(String subtype, String params);
void* getAPI_SysExt(String subtype, String params);
void* getAPI_Lcd2004(String subtype, String params); void* getAPI_Lcd2004(String subtype, String params);
void* getAPI(String subtype, String params) { void* getAPI(String subtype, String params) {
@@ -50,8 +49,7 @@ if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_IoTServo(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_IoTServo(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Mp3(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Mp3(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Pwm32(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Pwm8266(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_SysExt(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Lcd2004(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Lcd2004(subtype, params)) != nullptr) return tmpAPI;
return nullptr; return nullptr;
} }

View File

@@ -4,57 +4,56 @@
https://github.com/adafruit/Adafruit_BMP280_Library https://github.com/adafruit/Adafruit_BMP280_Library
******************************************************************/ ******************************************************************/
#include "Global.h" #include "Global.h"
#include "classes/IoTItem.h" #include "classes/IoTItem.h"
#include <Adafruit_BMP280.h> #include <Adafruit_BMP280.h>
#include <map> #include <map>
std::map<String, Adafruit_BMP280*> bmps; std::map<String, Adafruit_BMP280*> bmps;
class Bmp280t : public IoTItem { class Bmp280t : public IoTItem {
private: private:
Adafruit_BMP280* _bmp; Adafruit_BMP280* _bmp;
public: public:
Bmp280t(Adafruit_BMP280* bmp, String parameters): IoTItem(parameters) { Bmp280t(Adafruit_BMP280* bmp, String parameters) : IoTItem(parameters) {
_bmp = bmp; _bmp = bmp;
} }
void doByInterval() { void doByInterval() {
value.valD = _bmp->readTemperature(); value.valD = _bmp->readTemperature();
if (String(value.valD) != "nan") regEvent(value.valD, "Bmp280t"); if (String(value.valD) != "nan")
else SerialPrint("E", "Sensor DHTt", "Error"); regEvent(value.valD, "Bmp280t");
else
SerialPrint("E", "Sensor Bmp280t", "Error");
} }
~Bmp280t() {}; ~Bmp280t(){};
}; };
class Bmp280p : public IoTItem { class Bmp280p : public IoTItem {
private: private:
Adafruit_BMP280* _bmp; Adafruit_BMP280* _bmp;
public: public:
Bmp280p(Adafruit_BMP280* bmp, String parameters): IoTItem(parameters) { Bmp280p(Adafruit_BMP280* bmp, String parameters) : IoTItem(parameters) {
_bmp = bmp; _bmp = bmp;
} }
void doByInterval() { void doByInterval() {
value.valD = _bmp->readPressure(); value.valD = _bmp->readPressure();
if (String(value.valD) != "nan") { if (String(value.valD) != "nan") {
value.valD = value.valD / 1.333224 / 100; value.valD = value.valD / 1.333224 / 100;
regEvent(value.valD, "Bmp280p"); regEvent(value.valD, "Bmp280p");
} else SerialPrint("E", "Sensor DHTh", "Error"); } else
SerialPrint("E", "Sensor Bmp280p", "Error");
} }
~Bmp280p() {}; ~Bmp280p(){};
}; };
void* getAPI_Bmp280(String subtype, String param) {
void* getAPI_Bmp280(String subtype, String param) {
if (subtype == F("Bmp280t") || subtype == F("Bmp280p")) { if (subtype == F("Bmp280t") || subtype == F("Bmp280p")) {
String addr; String addr;
jsonRead(param, "addr", addr); jsonRead(param, "addr", addr);