From 67118f5c8f2c7232f83d40d63ba93494a28609b9 Mon Sep 17 00:00:00 2001 From: Ilya Belyakov Date: Sat, 23 Dec 2023 09:32:07 +0300 Subject: [PATCH 01/15] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D1=8F=D0=B5=D0=BC=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83?= =?UTF-8?q?=20=D0=B8=D0=BD=D0=B8=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20=D0=BF=D1=80=D0=B8=20=D1=87=D1=82=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/S8/S8.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modules/sensors/S8/S8.cpp b/src/modules/sensors/S8/S8.cpp index ce721103..c600809a 100644 --- a/src/modules/sensors/S8/S8.cpp +++ b/src/modules/sensors/S8/S8.cpp @@ -6,12 +6,14 @@ #define R_LEN 7 #define C_LEN 8 -byte cmd_s8[8] = {0xFE, 0x04, 0x00, 0x03, 0x00, 0x01, 0xD5, 0xC5}; -//byte abc_s8[8] = {0xFE, 0x03, 0x00, 0x1F, 0x00, 0x01, 0xA1, 0xC3}; + class S8co : public IoTItem { private: + byte cmd_s8[8] = {0xFE, 0x04, 0x00, 0x03, 0x00, 0x01, 0xD5, 0xC5}; + //byte abc_s8[8] = {0xFE, 0x03, 0x00, 0x1F, 0x00, 0x01, 0xA1, 0xC3}; + SoftwareSerial* s8Serial; unsigned int _s8_co2; @@ -24,6 +26,11 @@ class S8co : public IoTItem { byte _response_s8[7] = {0, 0, 0, 0, 0, 0, 0}; void s8Request(byte cmd[]) { + if (!s8Serial) { + SerialPrint("E", "Sensor S8_uart", "Serial not found!"); + return; + } + while(!s8Serial->available()) { s8Serial->write(cmd, C_LEN); delay(50); @@ -45,7 +52,7 @@ class S8co : public IoTItem { _response_s8[i] = s8Serial->read(); } - s8Serial->end(); + //s8Serial->end(); } void co2_measure() { From a751d36ddf19511faeeb92f5c06999fdc14232b4 Mon Sep 17 00:00:00 2001 From: Ilya Belyakov Date: Sat, 23 Dec 2023 19:13:54 +0300 Subject: [PATCH 02/15] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20"global":=200,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/S8/modinfo.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/sensors/S8/modinfo.json b/src/modules/sensors/S8/modinfo.json index c4ac2fe9..5874fca9 100644 --- a/src/modules/sensors/S8/modinfo.json +++ b/src/modules/sensors/S8/modinfo.json @@ -2,6 +2,7 @@ "menuSection": "sensors", "configItem": [ { + "global": 0, "name": "(S8) Cенсор качества воздуха", "num": 3, "type": "Reading", From 2f70055e4eb1b020f30c958211a2dbc253f7ce15 Mon Sep 17 00:00:00 2001 From: Mit4el Date: Sun, 24 Dec 2023 21:13:19 +0300 Subject: [PATCH 03/15] Telegram Button --- src/modules/exec/Telegram_v2/Telegram_v2.cpp | 408 ++++++++++++++++--- src/modules/exec/Telegram_v2/modinfo.json | 60 ++- 2 files changed, 408 insertions(+), 60 deletions(-) diff --git a/src/modules/exec/Telegram_v2/Telegram_v2.cpp b/src/modules/exec/Telegram_v2/Telegram_v2.cpp index ecaaaa4e..b7b5e170 100644 --- a/src/modules/exec/Telegram_v2/Telegram_v2.cpp +++ b/src/modules/exec/Telegram_v2/Telegram_v2.cpp @@ -9,7 +9,7 @@ // #include "esp_camera.h" #include -#include +#include // FastBot _myBot; FastBot *_myBot = nullptr; @@ -28,6 +28,17 @@ String _chatID; bool _autos; bool _initSD; +struct ButtonMenu +{ + String message = ""; + String getId = ""; + String setId = ""; + String value = ""; +}; + +std::map mapBtnMenu; // +std::map mapBtnInline; // + class Telegram_v2 : public IoTItem { private: @@ -43,6 +54,7 @@ public: jsonRead(parameters, "receiveMsg", _receiveMsg); jsonRead(parameters, "chatID", _chatID); instanceBot(); + // _myBot->setTextMode(FB_MARKDOWN); _myBot->attach(telegramMsgParse); #ifdef ESP32 @@ -69,9 +81,13 @@ public: { } + //============================================================================= + //=============++====== Обработка команд сценария ============================= + //============================================================================= IoTValue execute(String command, std::vector ¶m) { - if (!isNetworkActive()) return {}; + if (!isNetworkActive()) + return {}; if (command == "sendMsg") { if (param.size()) @@ -108,9 +124,14 @@ public: _myBot->sendMessage(strTmp, _chatID); _myBot->pinMessage(_myBot->lastBotMsg()); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ",pin msg: " + strTmp); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", pin msg: " + strTmp); } } + else if (command == "unpinAllMsg") + { + _myBot->unpinAll(_chatID); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", unpin all message"); + } else if (command == "editMsg") { if (param.size()) @@ -121,7 +142,7 @@ public: else strTmp = param[0].valS; _myBot->editMessage(_myBot->lastBotMsg(), strTmp); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ",edit msg: " + strTmp); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", edit msg: " + strTmp); } } else if (command == "sendFile") @@ -139,10 +160,9 @@ public: // selectToMarkerLast(msg.text, "_") uint8_t res = _myBot->sendFile(file, (FB_FileType)param[1].valD, selectToMarkerLast(param[0].valS, "/"), _chatID); file.close(); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", sendFile: " + param[0].valS + " res: " + String(res)); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", sendFile: " + param[0].valS + " res: " + String(res)); } } - else if (command == "editFile") { if (param.size() && !param[0].isDecimal) @@ -158,28 +178,297 @@ public: // selectToMarkerLast(msg.text, "_") uint8_t res = _myBot->editFile(file, (FB_FileType)param[1].valD, selectToMarkerLast(param[0].valS, "/"), _myBot->lastBotMsg(), _chatID); file.close(); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", editFile: " + param[0].valS + " res: " + String(res)); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", editFile: " + param[0].valS + " res: " + String(res)); } } + else if (command == "btnMenu") + { + mapBtnMenu[param[0].valS] = new ButtonMenu; + if (param.size() == 3) // btnMenu("Name", message, getId); + { + // if (IoTItems.find(param[2].valS) != IoTItems.end()) + // { + mapBtnMenu[param[0].valS]->message = param[1].valS; + mapBtnMenu[param[0].valS]->getId = param[2].valS; + // mapBtnMenu[param[0].valS] = btn; + SerialPrint("i", F("Telegram"), "add button menu: " + param[0].valS + ", get id: " + param[2].valS); + // } + } + else if (param.size() == 5) // btnMenu("Name", message, getId, setId, value); + { + // if (IoTItems.find(param[2].valS) != IoTItems.end()) + // { + mapBtnMenu[param[0].valS]->message = param[1].valS; + mapBtnMenu[param[0].valS]->getId = param[2].valS; + mapBtnMenu[param[0].valS]->setId = param[3].valS; + mapBtnMenu[param[0].valS]->value = param[4].valS; + // mapBtnMenu[param[0].valS] = btn; + SerialPrint("i", F("Telegram"), "add button menu: " + param[0].valS + ",get id: " + param[2].valS + ",set id: " + param[3].valS + "=" + param[4].valS); + // } + } + } + else if (command == "showMenu") + { + String out; + // перебирвем весь мап и строим меню + uint8_t cnt = 0; + for (auto it = mapBtnMenu.begin(); it != mapBtnMenu.end(); it++) + { + cnt++; + if (cnt % 2 == 0) + { + out += " \t " + it->first; + } + else + { + if (it == mapBtnMenu.begin()) + out = it->first; + else + out += " \n " + it->first; + } + } + _myBot->showMenuText("Menu", out, true); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", show menu: \n" + out); + } + else if (command == "btnInline") + { + mapBtnInline[param[0].valS] = new ButtonMenu; + if (param.size() == 3) // btnMenu("Name", message, getId); + { + // if (IoTItems.find(param[2].valS) != IoTItems.end()) + // { + mapBtnInline[param[0].valS]->message = param[1].valS; + mapBtnInline[param[0].valS]->getId = param[2].valS; + // mapBtnMenu[param[0].valS] = btn; + SerialPrint("i", "Telegram", "add button inline: " + param[0].valS + ", get id: " + param[2].valS); + // } + } + else if (param.size() == 5) // btnMenu("Name", message, getId, setId, value); + { + // if (IoTItems.find(param[2].valS) != IoTItems.end()) + // { + mapBtnInline[param[0].valS]->message = param[1].valS; + mapBtnInline[param[0].valS]->getId = param[2].valS; + mapBtnInline[param[0].valS]->setId = param[3].valS; + mapBtnInline[param[0].valS]->value = param[4].valS; + // mapBtnMenu[param[0].valS] = btn; + SerialPrint("i", "Telegram", "add button inline: " + param[0].valS + ",get id: " + param[2].valS + ",set id: " + param[3].valS + "=" + param[4].valS); + // } + } + } + else if (command == "showInline") + { + String out; + // перебирвем весь мап и строим меню + uint8_t cnt = 0; + for (auto it = mapBtnInline.begin(); it != mapBtnInline.end(); it++) + { + cnt++; + if (cnt % 2 == 0) + { + out += " \t " + it->first; + } + else + { + if (it == mapBtnInline.begin()) + out = it->first; + else + out += " \n " + it->first; + } + } + _myBot->inlineMenu("inline_menu", out); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", show inline: \n" + out); + } + else if (command == "clearInline") + { + clearMapMenuInline(); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", clear inline menu "); + } + else if (command == "clearMenu") + { + clearMapMenu(); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", clear menu "); + } + else if (command == "closeMenu") + { + _myBot->closeMenu(); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", closeMenu "); + } return {}; } + //============================================================================= + //=================== Обработка сообщений из чата ============================= + //============================================================================= void static telegramMsgParse(FB_msg &msg) { // FB_msg msg; - SerialPrint("->", F("Telegram"), "chat ID: " + msg.chatID + ", msg: " + msg.text); + SerialPrint("i", F("Telegram"), "chat ID: " + msg.chatID + ", msg: " + msg.text); // _myBot->setChatID(_chatID); if (_autos) { _chatID = msg.chatID; } - if (msg.text.indexOf("set") != -1) + // -------------- Обработка кнопок меню созданного в сценарии -------------- + // ------------------------------------------------------------------------- + if (auto search = mapBtnMenu.find(msg.text); search != mapBtnMenu.end()) + { + String outMsg; + outMsg = mapBtnMenu[msg.text]->message; + if (mapBtnMenu[msg.text]->getId != "") + { + IoTItem *item = findIoTItem(mapBtnMenu[msg.text]->getId); + if (item) + { + outMsg += ": " + item->getValue(); + } + } + if (mapBtnMenu[msg.text]->setId != "") + { + //outMsg += ", " + mapBtnMenu[msg.text]->setId + "=" + mapBtnMenu[msg.text]->value; + generateOrder(mapBtnMenu[msg.text]->setId, mapBtnMenu[msg.text]->value); + } + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(outMsg)); + _myBot->sendMessage(outMsg, _chatID); + } + + // -------------- Обработка нажатия на пользовательском инлайн меню -------------- + // ------------------------------------------------------------------------- + else if (msg.text.indexOf("inline_menu") != -1) + { + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", data: " + String(msg.data)); + if (auto search = mapBtnInline.find(msg.data); search != mapBtnInline.end()) + { + + String outMsg; + outMsg = mapBtnInline[msg.data]->message; + if (mapBtnInline[msg.data]->getId != "") + { + IoTItem *item = findIoTItem(mapBtnInline[msg.data]->getId); + if (item) + { + outMsg += ": " + item->getValue(); + //SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(msg.data)); + } + } + if (mapBtnInline[msg.data]->setId != "") + { + //outMsg += ", " + mapBtnInline[msg.data]->setId + "=" + mapBtnInline[msg.data]->value; + generateOrder(mapBtnInline[msg.data]->setId, mapBtnInline[msg.data]->value); + } + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(outMsg)); + _myBot->sendMessage(outMsg, _chatID); + } + } + // -------------- Вызов (повторный вызов) меню созданного в сценарии -------------- + // ------------------------------------------------------------------------- + else if (msg.text.indexOf("menu") != -1) + { + String out; + // перебирвем весь мап и строим меню + uint8_t cnt = 0; + for (auto it = mapBtnMenu.begin(); it != mapBtnMenu.end(); it++) + { + cnt++; + if (cnt % 2 == 0) + { + out += " \t " + it->first; + } + else + { + if (it == mapBtnMenu.begin()) + out = it->first; + else + out += " \n " + it->first; + } + } + _myBot->showMenuText("Menu", out, true); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", show menu: \n" + out); + } + // -------------- вывод нижнего меню всех юнитов -------------- + // ------------------------------------------------------------------------- + else if (msg.text.indexOf("allMenu") != -1) + { + // String list = returnListOfParams(); + String out; + // std::vector vctr; + uint8_t cnt = 0; + for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) + { + if ((*it)->iAmLocal) + { + cnt++; + if (cnt % 2 == 0) + { + out += " \t get_" + (*it)->getID(); + } + else + { + if (it == IoTItems.begin()) + out = "get_" + (*it)->getID(); + else + out += " \n get_" + (*it)->getID(); + } + } + } + _myBot->showMenuText("select Id", out, true); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + "\n" + out); + // _myBot->sendMessage(CharPlot(&vctr[0], vctr.size(), 5), _chatID); + // SerialPrint("<-", F("Telegram"), CharPlot(&vctr[0], vctr.size(), 10)); + } + + // -------------- Обработка нажатия в инлайн меню all (всех юнитов) -------------- + // ------------------------------------------------------------------------- + else if (msg.text.indexOf("all_inline") != -1 && msg.data.indexOf("get") != -1) + { + String out = deleteBeforeDelimiter(msg.data, "_"); + IoTItem *item = findIoTItem(out); + if (item) + { + _myBot->sendMessage(item->getID() + ": " + item->getValue(), _chatID); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + out); + } + } + // -------------- вывод инлайн меню всех юнитов -------------- + // ------------------------------------------------------------------------- + else if (msg.text.indexOf("all") != -1) + { + // String list = returnListOfParams(); + String out; + // std::vector vctr; + uint8_t cnt = 0; + for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) + { + if ((*it)->iAmLocal) + { + cnt++; + if (cnt % 2 == 0) + { + out += " \t get_" + (*it)->getID(); + } + else + { + if (it == IoTItems.begin()) + out = "get_" + (*it)->getID(); + else + out += " \n get_" + (*it)->getID(); + } + } + } + _myBot->inlineMenu("all_inline", out); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + "\n" + out); + } + // -------------- обработка команды /set_ID_VALUE -------------- + // ------------------------------------------------------------------------- + else if (msg.text.indexOf("set") != -1) { msg.text = deleteBeforeDelimiter(msg.text, "_"); generateOrder(selectToMarker(msg.text, "_"), selectToMarkerLast(msg.text, "_")); _myBot->replyMessage("order done", msg.messageID, _chatID); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(msg.text)); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(msg.text)); } + // -------------- обработка команды /get_ID -------------- + // ------------------------------------------------------------------------- else if (msg.text.indexOf("get") != -1) { msg.text = deleteBeforeDelimiter(msg.text, "_"); @@ -187,41 +476,15 @@ public: if (item) { _myBot->replyMessage(item->getValue(), msg.messageID, _chatID); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(msg.text)); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(msg.text)); } } - - else if (msg.text.indexOf("all") != -1) - { - // String list = returnListOfParams(); - String out; - std::vector vctr; - for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) - { - if ((*it)->iAmLocal) - { - if (it == IoTItems.begin()) - { - out = "get_" + (*it)->getID(); - } - else - { - out = out + " \n " + "get_" + (*it)->getID(); - } - vctr.push_back(atoff((*it)->getValue().c_str())); - // _myBot->sendMessage((*it)->getID() + ": " + (*it)->getValue(), _chatID); - } - } - _myBot->showMenuText("select Id", out, true); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + "\n" + out); - // _myBot->sendMessage(CharPlot(&vctr[0], vctr.size(), 5), _chatID); - // SerialPrint("<-", F("Telegram"), CharPlot(&vctr[0], vctr.size(), 10)); - } - + // -------------- обработка запроса пользователя на скачивание файла -------------- + // ------------------------------------------------------------------------- else if (msg.text.indexOf("file") != -1 && msg.chatID == _chatID) { msg.text = deleteBeforeDelimiter(msg.text, "_"); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", get file: " + String(msg.text)); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", get file: " + String(msg.text)); auto file = FileFS.open(selectToMarker(msg.text, "_"), FILE_READ); // /test.png if (!file) { @@ -232,6 +495,8 @@ public: _myBot->sendFile(file, (FB_FileType)type, selectToMarker(msg.text, "_"), _chatID); file.close(); } + // -------------- обработка файлов загруженных пользователем -------------- + // ------------------------------------------------------------------------- else if (msg.isFile) { if (msg.text.indexOf("download") != -1 && msg.chatID == _chatID) @@ -240,32 +505,41 @@ public: } else if (msg.text.indexOf("nextion") != -1 && msg.chatID == _chatID) { - for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) { - if ((*it)->getSubtype() == "NextionUpload") { - (*it)->uploadNextionTlgrm(msg.fileUrl); + for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) + { + if ((*it)->getSubtype() == "NextionUpload" || (*it)->getSubtype() == "Nextion") + { + (*it)->uploadNextionTlgrm(msg.fileUrl); + } } } - } } + // -------------- обработка остальных команд -------------- + // ------------------------------------------------------------------------- else if (msg.text.indexOf("help") != -1) { _myBot->sendMessage("ID: " + chipId, _chatID); _myBot->sendMessage("chatID: " + _chatID, _chatID); - _myBot->sendMessage(F("Wrong order, use /all to get all values, /get_id to get value, /set_id_value to set value, or /file_name_type or send file msg=download"), _chatID); + _myBot->sendMessage("Command: /help - this text \n /all - inline menu get all values \n /allMenu - bottom menu get all values \n /menu - bottom USER menu from scenario \n /get_id - get value by ID \n /set_id_value - set value in ID \n /file_name_type - take file from esp \n /file_type - support file type \n send file and write download - \"download\" file to esp \n send tft file and write \"nextion\" - flash file.tft to Nextion", _chatID); + } + else if (msg.text.indexOf("file_type") != -1) + { + _myBot->sendMessage("Support file type download: \n 0-foto \n 1-audio \n 2-doc \n 3-video \n 4-gif \n 5-voice", _chatID); } else { - // setValue(msg.text); + _myBot->sendMessage("Wrong order, use /help", _chatID); } } void sendTelegramMsg(bool often, String msg) { - if (!isNetworkActive()) return; + if (!isNetworkActive()) + return; if (often) { _myBot->sendMessage(msg, _chatID); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", msg: " + msg); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + msg); } else { @@ -273,23 +547,25 @@ public: { _prevMsg = msg; _myBot->sendMessage(msg, _chatID); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", msg: " + msg); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", msg: " + msg); } } } void sendFoto(uint8_t *buf, uint32_t length, const String &name) { - if (!isNetworkActive()) return; + if (!isNetworkActive()) + return; _myBot->sendFile(buf, length, FB_PHOTO, name, _chatID); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", send foto from esp-cam"); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", send foto from esp-cam"); } void editFoto(uint8_t *buf, uint32_t length, const String &name) { - if (!isNetworkActive()) return; + if (!isNetworkActive()) + return; _myBot->editFile(buf, length, FB_PHOTO, name, _myBot->lastBotMsg(), _chatID); - SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", edit foto from esp-cam"); + SerialPrint("i", F("Telegram"), "chat ID: " + _chatID + ", edit foto from esp-cam"); } int static downloadFile(FB_msg &msg) @@ -325,7 +601,7 @@ public: } else { - SerialPrint("<-", F("Telegram"), "download from: " + _chatID + ", file: " + msg.fileName + " size = " + String(_size) + " byte"); + SerialPrint("i", F("Telegram"), "download from: " + _chatID + ", file: " + msg.fileName + " size = " + String(_size) + " byte"); _myBot->sendMessage("Download Ok, size = " + String(_size) + " byte", _chatID); } } @@ -341,9 +617,31 @@ public: { return this; } - + void clearMapMenu() + { + for (auto it = mapBtnMenu.begin(); it != mapBtnMenu.end(); it++) + { + delete it->second; + } + mapBtnMenu.clear(); + for (auto it = mapBtnInline.begin(); it != mapBtnInline.end(); it++) + { + delete it->second; + } + mapBtnInline.clear(); + } + void clearMapMenuInline() + { + for (auto it = mapBtnInline.begin(); it != mapBtnInline.end(); it++) + { + delete it->second; + } + mapBtnInline.clear(); + } ~Telegram_v2() { + clearMapMenu(); + clearMapMenuInline(); tlgrmItem = nullptr; }; }; diff --git a/src/modules/exec/Telegram_v2/modinfo.json b/src/modules/exec/Telegram_v2/modinfo.json index a87f130b..c5633329 100644 --- a/src/modules/exec/Telegram_v2/modinfo.json +++ b/src/modules/exec/Telegram_v2/modinfo.json @@ -14,7 +14,7 @@ "token": "", "autos": 1, - "receiveMsg": 0, + "receiveMsg": 1, "chatID": "" }], @@ -24,7 +24,7 @@ "authorGit": "https://github.com/Mit4el", "specialThanks": "", "moduleName": "Telegram_v2", - "moduleVersion": "1.0", + "moduleVersion": "3.0", "usedRam": { "esp32_4mb": 37, "esp8266_4mb": 37 @@ -45,14 +45,19 @@ }, { "name": "sendOftenMsg", - "descr": "Отправить сообщение в любом случае, даж если отправляли такое ранее.", + "descr": "Отправить сообщение в любом случае, даже если отправляли такое ранее.", "params": ["Сообщение, может быть строкой, числом или ИД другого элемента для получения значения"] }, { "name": "sendPinMsg", - "descr": "Отправить закрепленное сообщение в любом случае, даж если отправляли такое ранее.", + "descr": "Отправить закрепленное сообщение в любом случае, даже если отправляли такое ранее.", "params": ["Сообщение, может быть строкой, числом или ИД другого элемента для получения значения"] }, + { + "name": "unpinAllMsg", + "descr": "Открепить все сообщения в чате.", + "params": [] + }, { "name": "editMsg", "descr": "Отредактировать последнее отправленное ботом сообщение.", @@ -67,7 +72,52 @@ "name": "editFile", "descr": "Отредактировать последний отправленный файл, с указанием типа файла: 0-фото, 1-аудио, 2-документ, 3-видео, 4-анимация, 5-голос", "params": ["Путь к файлу (/test.png)", "Тип файла/информации (число)"] - } + }, + { + "name": "btnMenu", + "descr": "Описание кнопки меню выводит запросит значение ID и выведит сообщение => Произвольное сообщение(message): значение. Пример: btnMenu(Темп.Дома, Текущая температура, IDbme280)", + "params": ["Name - название кнопки отображается ботом", "message - Произвольное сообщения присылается в ответ на кнопку", "Id - Вернет значение элемента"] + }, + { + "name": "btnMenu", + "descr": "Описание кнопки меню выводит запросит значение getID,установит значение value в setID и выведит сообщение => Произвольное сообщение(message): значение, IDrele=1. ВСЁ УКАЗЫВАТЬ В КАВЫЧКАХ, значение не обязательно! Пример: btnMenu(\"Обогрев\", \"Текущая температура\", \"IDbme280\", \"IDrele\", 1), btnMenu(Свет, Вклбчил свет, \"\", IDrele, 1)", + "params": ["Name - название кнопки отображается ботом", "message - Произвольное сообщения присылается в ответ на кнопку", "getId - Вернет значение элемента", "setId - Установит значение элементу", "value - Устанавливаемое значение"] + }, + { + "name": "showMenu", + "descr": "Отобразить меню, созданное в сценарии", + "params": [] + }, + { + "name": "closeMenu", + "descr": "Закрыть мменю", + "params": [] + }, + { + "name": "btnInline", + "descr": "Описание кнопки встроенного (inline) меню выводит запросит значение ID и выведит сообщение => Произвольное сообщение(message): значение. Пример: btnMenu(Темп.Дома, Текущая температура, IDbme280)", + "params": ["Name - название кнопки отображается ботом", "message - Произвольное сообщения присылается в ответ на кнопку", "Id - Вернет значение элемента"] + }, + { + "name": "btnInline", + "descr": "Описание кнопки встроенного (inline) меню выводит запросит значение getID,установит значение value в setID и выведит сообщение => Произвольное сообщение(message): значение, IDrele=1. ВСЁ УКАЗЫВАТЬ В КАВЫЧКАХ, значение не обязательно! Пример: btnMenu(\"Обогрев\", \"Текущая температура\", \"IDbme280\", \"IDrele\", 1), btnMenu(Свет, Вклбчил свет, \"\", IDrele, 1)", + "params": ["Name - название кнопки отображается ботом", "message - Произвольное сообщения присылается в ответ на кнопку", "getId - Вернет значение элемента", "setId - Установит значение элементу", "value - Устанавливаемое значение"] + }, + { + "name": "showInline", + "descr": "Отобразить встроенное (inline) меню, созданное в сценарии", + "params": [] + }, + { + "name": "clearInline", + "descr": "Очистить встроенное (inline) меню, вызвать перед для язменения, перед созданием новых кнопок", + "params": [] + }, + { + "name": "clearMenu", + "descr": "Очистить меню, вызвать перед для язменения, перед созданием новых кнопок", + "params": [] + } ] }, From ae8fb2c4c129b49950d5dd48e7c3616905592e1b Mon Sep 17 00:00:00 2001 From: Mit4el Date: Sun, 24 Dec 2023 21:13:34 +0300 Subject: [PATCH 04/15] bugfix ld2410 --- src/modules/sensors/ld2410/ld2410.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/sensors/ld2410/ld2410.cpp b/src/modules/sensors/ld2410/ld2410.cpp index c17c5751..bd0e7c30 100644 --- a/src/modules/sensors/ld2410/ld2410.cpp +++ b/src/modules/sensors/ld2410/ld2410.cpp @@ -237,7 +237,7 @@ public: } ~ld2410m() { - delete ld2410; + delete radar; radar = nullptr; }; }; @@ -297,7 +297,7 @@ public: ~ld2410t() { - delete ld2410; + delete radar; radar = nullptr; }; }; @@ -356,7 +356,7 @@ public: } ~ld2410d() { - delete ld2410; + delete radar; radar = nullptr; }; }; @@ -418,7 +418,7 @@ public: } ~ld2410e() { - delete ld2410; + delete radar; radar = nullptr; }; }; From 79fe2d29d24a0df0e4f9e9b6c1c9ad684d938c8f Mon Sep 17 00:00:00 2001 From: Ilya Belyakov Date: Wed, 27 Dec 2023 11:55:47 +0300 Subject: [PATCH 05/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA?= =?UTF-8?q?=D1=83=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BE=D0=BA=20=D0=B8=20=D0=BB?= =?UTF-8?q?=D0=B5=D0=B4=D0=BE=D0=B2=20=D0=B4=D0=BB=D1=8F=20tm1638?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/display/TM16XX/TM16XX.cpp | 169 ++++++++++++++++++++---- src/modules/display/TM16XX/modinfo.json | 109 +++------------ 2 files changed, 166 insertions(+), 112 deletions(-) diff --git a/src/modules/display/TM16XX/TM16XX.cpp b/src/modules/display/TM16XX/TM16XX.cpp index 7a8a1b3d..10199d38 100644 --- a/src/modules/display/TM16XX/TM16XX.cpp +++ b/src/modules/display/TM16XX/TM16XX.cpp @@ -4,19 +4,103 @@ #include #include #include +#include +TM16xxButtons* buttons = nullptr; // указатель на объект управления кнопками для TM1638 иначе nullptr +IoTItem* iotItemObj = nullptr; // указатель на объект конфигурации для доступа из функций calback + +void setIotItemValue(int buttonNum, int state) { + if (iotItemObj) { + String id = iotItemObj->getID() + "_" + String(buttonNum); + for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) { + if ((*it)->getID() == id) { + IoTValue value; + value.valD = state; + (*it)->setValue(value); + //value.valD = 0; // сбрасываем состояние в нулевое если статус конечный (т.к. библиотека отрабатывает события не по порядку) + //if (state == 1 || state == 5 || state == 2) (*it)->setValue(value, false); + break; + } + } + } +} + +// The Release function will be called when a button was released. +// It can be used for fast actions when no click or double click needs to be detected. +void fnRelease(byte nButton) { + // using isPressed or is LongPressed a shift-key can be implemented + if(buttons->isLongPressed(0)) + Serial.print(F("Button 0 still longpressed. ")); + else if(buttons->isPressed(0)) + Serial.print(F("Button 0 still pressed. ")); + + Serial.print(F("Button ")); + Serial.print(nButton); + Serial.println(F(" release.")); + + setIotItemValue(nButton, 0); +} // release + + +// This function will be called when a button was pressed 1 time (without a second press). +void fnClick(byte nButton) { + Serial.print(F("Button ")); + Serial.print(nButton); + Serial.println(F(" click.")); + + setIotItemValue(nButton, 1); +} // click + + +// This function will be called when a button was pressed 2 times in a short timeframe. +void fnDoubleclick(byte nButton) { + Serial.print(F("Button ")); + Serial.print(nButton); + Serial.println(F(" doubleclick.")); + + setIotItemValue(nButton, 2); +} // doubleclick + + +// This function will be called once, when a button is pressed for a long time. +void fnLongPressStart(byte nButton) { + Serial.print(F("Button ")); + Serial.print(nButton); + Serial.println(F(" longPress start")); + + setIotItemValue(nButton, 3); +} // longPressStart + + +// This function will be called often, while a button is pressed for a long time. +void fnLongPress(byte nButton) { + Serial.print(F("Button ")); + Serial.print(nButton); + Serial.println(F(" longPress...")); + + setIotItemValue(nButton, 4); +} // longPress + + +// This function will be called once, when a button is released after beeing pressed for a long time. +void fnLongPressStop(byte nButton) { + Serial.print(F("Button ")); + Serial.print(nButton); + Serial.println(F(" longPress stop")); + + setIotItemValue(nButton, 5); +} // longPressStop + class TM16XX : public IoTItem { private: TM16xxDisplay *_display = nullptr; TM16xx *_module = nullptr; - std::vector _ids2show; + String _id2show; public: TM16XX(String parameters) : IoTItem(parameters) { - //jsonRead(parameters, "id2show", _id2show); - int DIO, CLK, STB, chip, numDigits, intensity; bool onoff; String id2show; @@ -28,58 +112,97 @@ class TM16XX : public IoTItem { jsonRead(parameters, "intensity", intensity); jsonRead(parameters, "on", onoff); - jsonRead(parameters, "id2show", id2show); - if (id2show != "") _ids2show = splitStr(id2show, ","); + jsonRead(parameters, "id2show", _id2show); if (chip == 1637) { _module = new TM1637(DIO, CLK, numDigits); } else if (chip == 1638) { _module = new TM1638(DIO, CLK, STB, numDigits); + buttons = new TM16xxButtons(_module); + buttons->attachRelease(fnRelease); + buttons->attachClick(fnClick); + buttons->attachDoubleClick(fnDoubleclick); + buttons->attachLongPressStart(fnLongPressStart); + buttons->attachLongPressStop(fnLongPressStop); + buttons->attachDuringLongPress(fnLongPress); } _module->setupDisplay(onoff, intensity); _display = new TM16xxDisplay(_module, numDigits); + _display->println(getValue()); } - void doByInterval() { - + byte btLeds=0; + byte btPosition=0; + void loop() { + if(buttons) buttons->tick(); } void setValue(const IoTValue& Value, bool genEvent = true) { if (_display == nullptr) return; value = Value; - _display->println(getValue()); + //_display->println(getValue()); + _display->printf("%4s\n", getValue()); IoTItem::setValue(Value, genEvent); } void onRegEvent(IoTItem* eventItem) { if (_display == nullptr) return; - if (!eventItem || _ids2show.size() == 0) return; + if (!eventItem || _id2show == "") return; + + //_display->println(eventItem->getValue()); + if (_id2show == eventItem->getID()) { + setValue(eventItem->value, false); + } + // } else { + // _display->println(); + // for (int i = 0; i < _ids2show.size(); i++) { + // IoTItem* item = findIoTItem(_ids2show[i]); + // if (item) { + // _display->print(item->getValue()); + // } + // } + // } + } - if (strInVector(eventItem->getID(), _ids2show)) { - if (_ids2show.size() == 1) { - _display->println(eventItem->getValue()); - } else { - _display->println(); - for (int i = 0; i < _ids2show.size(); i++) { - IoTItem* item = findIoTItem(_ids2show[i]); - if (item) { - _display->print(item->getValue()); - } - } + IoTValue execute(String command, std::vector& param) { + if (command == "setLEDs") { + if (param.size() == 1) { + ((TM1638*)_module)->setLEDs(param[0].valD); + } + } else if (command == "onLED") { + if (param.size() == 1) { + ((TM1638*)_module)->setLED(TM1638_COLOR_RED, param[0].valD - 1); + } + } else if (command == "offLED") { + if (param.size() == 1) { + ((TM1638*)_module)->setLED(TM1638_COLOR_GREEN, param[0].valD - 1); + } + } else if (command == "setParamLED") { + if (param.size() == 2) { + _module->setupDisplay(param[0].valD, param[1].valD); + } + } else if (command == "id2show") { + if (param.size() == 1) { + _id2show = param[0].valS; } } + + return {}; } ~TM16XX() { - delete _display; - delete _module; + if (_display) delete _display; + if (_module) delete _module; + if (buttons) delete buttons; + iotItemObj = nullptr; + buttons = nullptr; }; }; void *getAPI_TM16XX(String subtype, String param) { if (subtype == F("TM16XX")) { - return new TM16XX(param); + return iotItemObj = new TM16XX(param); } else { return nullptr; } diff --git a/src/modules/display/TM16XX/modinfo.json b/src/modules/display/TM16XX/modinfo.json index a7c8c82f..bbbed517 100644 --- a/src/modules/display/TM16XX/modinfo.json +++ b/src/modules/display/TM16XX/modinfo.json @@ -15,7 +15,7 @@ "numDigits": 4, "DIO": "13", "CLK": "14", - "STB": "12", + "STB": "21", "intensity": "5", "on": "1", "id2show": "" @@ -33,6 +33,7 @@ "esp8266_4mb": 15 }, "moduleDesc": "Позволяет выводить на 7 сегментный экран серии TM16XX (TM1637, TM1638). Может быть расширен до поддержки TM1616, TM1620, TM1628, TM1630, TM1637, TM1638, TM1640, TM1650, TM1652 и TM1668", + "retInfo": "Если не установлен ИД для отслеживания значения, то внутренняя переменная будет использоваться как источник для информации", "propInfo": { "int": "Период времени в секундах обновления информации на экране по конкретному элементу.", "chip": "Номер чипа TM1637 или TM1638", @@ -42,54 +43,28 @@ "intensity": "Яркость 0-7", "on": "Вкл/выкл при старте 1/0", "STB": "Номер пина стекового сигнала - не используется на определенных моделях", - "id2show": "id элемента конфигурации для отображения. Если пустая строка, то дисплей использует свою переменную. Если указать несколько значений через запятую, то все данные будут последовательно выводиться в строку." + "id2show": "id элемента конфигурации для отображения. Если пустая строка, то дисплей использует свою переменную." }, "funcInfo": [ { - "name": "noBacklight", - "descr": "Выключить подсветку", - "params": [] + "name": "setLEDs", + "descr": "Зажигает верхние светодиоды через установку байта, где каждый разряд соответствует диоду. От 0 до 255", + "params": ["Значение байта"] }, { - "name": "backlight", - "descr": "Включить подсветку", - "params": [] + "name": "onLED", + "descr": "Включить один диод", + "params": ["Номер диода"] }, { - "name": "noDisplay", - "descr": "Спрятать все данные", - "params": [] + "name": "offLED", + "descr": "Выключить один диод", + "params": ["Номер диода"] }, { - "name": "display", - "descr": "Показать данные на экране", - "params": [] - }, - { - "name": "toggle", - "descr": "Переключает видимость значений на экране", - "params": [] - }, - { - "name": "x", - "descr": "Устанавливает первую координату", - "params": [ - "Номер строки первого символа" - ] - }, - { - "name": "y", - "descr": "Устанавливает вторую координату", - "params": [ - "Номер столбца первого символа" - ] - }, - { - "name": "descr", - "descr": "Задает приставку слева от значения", - "params": [ - "Строка" - ] + "name": "setParamLED", + "descr": "Включить/выключить (1/0) и установить яркость от 0 до 7 дисплея", + "params": ["Вкл/Выкл", "Яркость"] }, { "name": "id2show", @@ -100,57 +75,13 @@ } ] }, - "defActive": true, + "defActive": false, "usedLibs": { - "esp32_4mb": [ - "https://github.com/maxint-rd/TM16xx", - "adafruit/Adafruit GFX Library @ ^1.11.5", - "adafruit/Adafruit BusIO @ ^1.13.2" + "esp32*": [ + "https://github.com/maxint-rd/TM16xx" ], - "esp32_4mb3f": [ - "https://github.com/maxint-rd/TM16xx", - "adafruit/Adafruit GFX Library @ ^1.11.5", - "adafruit/Adafruit BusIO @ ^1.13.2" - ], - "esp32cam_4mb": [ - "https://github.com/maxint-rd/TM16xx", - "adafruit/Adafruit GFX Library @ ^1.11.5", - "adafruit/Adafruit BusIO @ ^1.13.2" - ], - "esp8266_4mb": [ - "https://github.com/maxint-rd/TM16xx", - "adafruit/Adafruit GFX Library @ ^1.11.5", - "adafruit/Adafruit BusIO @ ^1.13.2" - ], - "esp8266_1mb": [ - "https://github.com/maxint-rd/TM16xx", - "adafruit/Adafruit GFX Library @ ^1.11.5", - "adafruit/Adafruit BusIO @ ^1.13.2" - ], - "esp8266_1mb_ota": [ - "https://github.com/maxint-rd/TM16xx", - "adafruit/Adafruit GFX Library @ ^1.11.5", - "adafruit/Adafruit BusIO @ ^1.13.2" - ], - "esp8285_1mb": [ - "https://github.com/maxint-rd/TM16xx", - "adafruit/Adafruit GFX Library @ ^1.11.5", - "adafruit/Adafruit BusIO @ ^1.13.2" - ], - "esp8285_1mb_ota": [ - "https://github.com/maxint-rd/TM16xx", - "adafruit/Adafruit GFX Library @ ^1.11.5", - "adafruit/Adafruit BusIO @ ^1.13.2" - ], - "esp8266_2mb": [ - "https://github.com/maxint-rd/TM16xx", - "adafruit/Adafruit GFX Library @ ^1.11.5", - "adafruit/Adafruit BusIO @ ^1.13.2" - ], - "esp8266_2mb_ota": [ - "https://github.com/maxint-rd/TM16xx", - "adafruit/Adafruit GFX Library @ ^1.11.5", - "adafruit/Adafruit BusIO @ ^1.13.2" + "esp82*": [ + "https://github.com/maxint-rd/TM16xx" ] } } \ No newline at end of file From e7e900eb4c04912aa9e3034e343f86617d476234 Mon Sep 17 00:00:00 2001 From: Ilya Belyakov Date: Wed, 27 Dec 2023 11:58:50 +0300 Subject: [PATCH 06/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D0=BF=D1=80=D0=B8=D0=BC=D0=B5=D1=80=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20TM16XX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/display/TM16XX/example.json | 243 ++++++++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 src/modules/display/TM16XX/example.json diff --git a/src/modules/display/TM16XX/example.json b/src/modules/display/TM16XX/example.json new file mode 100644 index 00000000..68043ab5 --- /dev/null +++ b/src/modules/display/TM16XX/example.json @@ -0,0 +1,243 @@ +{ + "mark": "iotm", + "config": [ + { + "global": 0, + "type": "Writing", + "subtype": "TM16XX", + "id": "tm", + "widget": "inputDgt", + "page": "screens", + "descr": "Экран", + "round": 0, + "chip": "1638", + "numDigits": "8", + "DIO": "13", + "CLK": "14", + "STB": "27", + "intensity": "5", + "on": "1", + "id2show": "" + }, + { + "global": 0, + "type": "Writing", + "subtype": "ButtonOut", + "needSave": 0, + "id": "led", + "widget": "toggle", + "page": "screens", + "descr": "Освещение", + "int": 0, + "inv": 0, + "pin": 2 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "tm_16", + "needSave": 0, + "widget": "nil", + "page": "Вывод", + "descr": "Значение", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "tm_18", + "needSave": 0, + "widget": "nil", + "page": "Вывод", + "descr": "Значение", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "tm_20", + "needSave": 0, + "widget": "nil", + "page": "Вывод", + "descr": "Значение", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "tm_22", + "needSave": 0, + "widget": "nil", + "page": "Вывод", + "descr": "Значение", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "tm_17", + "needSave": 0, + "widget": "nil", + "page": "Вывод", + "descr": "Значение", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "tm_19", + "needSave": 0, + "widget": "nil", + "page": "Вывод", + "descr": "Значение", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "tm_21", + "needSave": 0, + "widget": "nil", + "page": "Вывод", + "descr": "Значение", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "tm_23", + "needSave": 0, + "widget": "nil", + "page": "Вывод", + "descr": "Значение", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Writing", + "subtype": "Timer", + "id": "timer1", + "widget": "anydataDef", + "page": "Таймеры", + "descr": "Таймер1", + "int": 1, + "countDown": "1000", + "ticker": "1", + "repeat": 1, + "needSave": 0 + }, + { + "global": 0, + "type": "Writing", + "subtype": "Timer", + "id": "timer2", + "widget": "anydataDef", + "page": "Таймеры", + "descr": "Таймер2", + "int": "15", + "countDown": "1000", + "ticker": 1, + "repeat": 1, + "needSave": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "page", + "needSave": 0, + "widget": "anydataDef", + "page": "Таймеры", + "descr": "Значение", + "int": "0", + "val": "1", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + } + ] +} + +scenario=>if tm_23 == 1 then tm.offLED(8) # выкл 8 леда при одном клике на кнопку 23 +if tm_23 == 2 then tm.onLED(8) # вкл 8 леда при двойном клике на кнопку 23 +if tm_23 == 5 then { # сброс всех индикаторов при долгом нажатии на кнопку 23 +tm = 0 +tm.setLEDs(0) +} + +if tm_16 == 4 then tm = tm - 100 # уменьшаем на 100 и увеличиваем при длительном нажатии +if tm_18 == 4 then tm = tm + 100 + +if tm_16 == 1 then tm = tm - 1 +if tm_18 == 1 then tm = tm + 1 + +if tm_16 == 2 then tm = tm - 1000 +if tm_18 == 2 then tm = tm + 1000 + +if timer1 >= 0 then tm.setLEDs(timer1) + +if tm_20 == 1 then tm = "HELLO!!" + +if tm_22 == 1 then tm.setParamLED(0, 7) +if tm_17 == 1 then tm.setParamLED(1, 7) +if tm_17 == 2 then tm.setParamLED(1, 0) + +if timer1 >= 0 & page == 1 then tm = "ttt1" + timer1 +if timer2 >= 0 & page == 2 then tm = "ttt2" + timer2 +if timer1 >= 0 | timer2 >= 0 then { +if page == 3 then tm = timer1 + " " + timer2 +} +if page == 0 then tm.setParamLED(0, 5) +if page > 0 then tm.setParamLED(1, 5) + +if tm_19 == 1 then page = page - 1 +if tm_21 == 1 then page = page + 1 \ No newline at end of file From d442588ac4df298a9f9adf6d6e1a802e833ecb12 Mon Sep 17 00:00:00 2001 From: Ilya Belyakov Date: Fri, 5 Jan 2024 22:00:28 +0500 Subject: [PATCH 07/15] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D1=8B=D0=B9=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B4=D1=83=D0=BB=D1=8C=20AnalogBtn=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D1=80=D0=B0=D1=81=D0=BF=D0=BE=D0=B7=D0=BD=D0=B0=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B0=D0=BD=D0=B0=D0=BB=D0=BE=D0=B3=D0=BE?= =?UTF-8?q?=D0=B2=D1=8B=D1=85=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BE=D0=BA=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=83=D1=80=D0=BE=D0=B2=D0=BD=D1=8E=20=D0=B0?= =?UTF-8?q?=D0=BD=D0=B0=D0=BB=D0=BE=D0=B3=D0=BE=D0=B2=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D1=81=D0=B8=D0=B3=D0=BD=D0=B0=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/exec/AnalogBtn/AnalogBtn.cpp | 54 ++++++++++++++++++++++++ src/modules/exec/AnalogBtn/modinfo.json | 43 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 src/modules/exec/AnalogBtn/AnalogBtn.cpp create mode 100644 src/modules/exec/AnalogBtn/modinfo.json diff --git a/src/modules/exec/AnalogBtn/AnalogBtn.cpp b/src/modules/exec/AnalogBtn/AnalogBtn.cpp new file mode 100644 index 00000000..3630f9f5 --- /dev/null +++ b/src/modules/exec/AnalogBtn/AnalogBtn.cpp @@ -0,0 +1,54 @@ +#include "Global.h" +#include "classes/IoTItem.h" + +extern IoTGpio IoTgpio; + + +class AnalogBtn : public IoTItem { + private: + int _pin, _aValue, _delta; + int _oldVal, _newVal; + + public: + AnalogBtn(String parameters) : IoTItem(parameters) { + _pin = 0; + _aValue = 0; + _delta = 50; + jsonRead(parameters, "pin", _pin); + jsonRead(parameters, "aValue", _aValue); + jsonRead(parameters, "delta", _delta); + _round = 0; + setInterval(-100); + } + + void doByInterval() { + _newVal = IoTgpio.analogRead(_pin); + if (_aValue == -1 && _oldVal != _newVal) { + _oldVal = _newVal; + SerialPrint("i", "AnalogBtn", (String)_newVal); + return; + } + + if ((_newVal > _aValue - _delta) && (_newVal < _aValue + _delta)) { + if (value.valD == 0) { + value.valD = 1; + regEvent(value.valD, "AnalogBtn"); + } + } else { + if (value.valD == 1) { + value.valD = 0; + regEvent(value.valD, "AnalogBtn"); + } + } + } + + ~AnalogBtn() {}; +}; + +void* getAPI_AnalogBtn(String subtype, String param) { + if (subtype == F("AnalogBtn")) { + return new AnalogBtn(param); + } else { + return nullptr; + } +} diff --git a/src/modules/exec/AnalogBtn/modinfo.json b/src/modules/exec/AnalogBtn/modinfo.json new file mode 100644 index 00000000..ca3d11d2 --- /dev/null +++ b/src/modules/exec/AnalogBtn/modinfo.json @@ -0,0 +1,43 @@ +{ + "menuSection": "executive_devices", + "configItem": [ + { + "global": 0, + "name": "Аналоговая кнопка", + "type": "Reading", + "subtype": "AnalogBtn", + "id": "abtn", + "widget": "toggle", + "page": "Кнопки", + "descr": "Освещение", + "pin": 34, + "aValue": -1, + "delta": 50 + } + ], + "about": { + "authorName": "Ilya Belyakov", + "authorContact": "https://t.me/Biveraxe", + "authorGit": "https://github.com/biveraxe", + "exampleURL": "https://iotmanager.org/wiki", + "specialThanks": "", + "moduleName": "AnalogBtn", + "moduleVersion": "1.0", + "usedRam": { + "esp32_4mb": 15, + "esp8266_4mb": 15 + }, + "title": "Аналоговая кнопка", + "moduleDesc": "Позволяет получить состояние кнопки на аналоговом пине.", + "propInfo": { + "pin": "Аналоговый GPIO номер, к которому подключена кнопка.", + "aValue": "Значение кнопки в диапазоне от 0 до 1023 (8266) или от 0 до 4095 (esp32). Если =-1 то включается режим отладки и в консоль отправляются значения нажимаемой кнопки.", + "delta": "Погрешность срабатывания кнопки в диапазоне +-delta." + } + }, + "defActive": true, + "usedLibs": { + "esp32*": [], + "esp82*": [] + } +} \ No newline at end of file From 9da0260a94e8c6d6dd77763e3f248d31ac599f15 Mon Sep 17 00:00:00 2001 From: Ilya Belyakov Date: Sat, 6 Jan 2024 11:24:49 +0500 Subject: [PATCH 08/15] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B6?= =?UTF-8?q?=D0=B0=D0=B5=D0=BC=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D0=B5=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D1=8D=D0=BB=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20=D1=81=D0=BE=D1=85?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BD=D0=B0=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B5=D0=BA=20=D0=A2=D0=B5=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D1=8C=20=D0=BF=D1=80=D0=B8=20=D1=81=D0=BE=D1=85=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8?= =?UTF-8?q?=D0=B3=D1=83=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D1=81=D0=B1=D1=80=D0=B0=D1=81=D1=8B=D0=B2=D0=B0=D1=8E=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D0=BF=D1=80=D0=B5=D0=B4=D1=83=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=BD=D1=8B=D0=B5=20=D0=B7?= =?UTF-8?q?=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=8D=D0=BB=D0=B5?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=9D=D0=BE=20=D0=BD?= =?UTF-8?q?=D0=B5=D0=BE=D0=B1=D1=85=D0=BE=D0=B4=D0=B8=D0=BC=D0=BE=20=D1=81?= =?UTF-8?q?=D0=BB=D0=B5=D0=B4=D0=B8=D1=82=D1=8C=20=D0=B7=D0=B0=20=D1=81?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=BE=D1=8F=D0=BD=D0=B8=D0=B5=D0=BC=20=D1=84?= =?UTF-8?q?=D0=B0=D0=B9=D0=BB=D0=B0=20values.json,=20=D0=BE=D0=BD=20=D0=BD?= =?UTF-8?q?=D0=B5=20=D0=BE=D1=87=D0=B8=D1=89=D0=B0=D0=B5=D1=82=D1=81=D1=8F?= =?UTF-8?q?=20=D0=A7=D1=82=D0=BE=D0=B1=20=D0=B7=D0=B0=D0=B1=D1=8B=D1=82?= =?UTF-8?q?=D1=8C=20=D0=B2=D1=81=D0=B5=20=D1=81=D0=BE=D1=85=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=BD=D1=8B=D0=B5=20=D0=B7=D0=BD=D0=B0=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=20=D1=82=D0=BE=D0=BC=20=D1=87?= =?UTF-8?q?=D0=B8=D1=81=D0=BB=D0=B5=20=D0=B8=20=D0=BC=D1=83=D1=81=D0=BE?= =?UTF-8?q?=D1=80,=20=D0=BD=D0=B5=D0=BE=D0=B1=D1=85=D0=BE=D0=B4=D0=B8?= =?UTF-8?q?=D0=BC=D0=BE=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20val?= =?UTF-8?q?ues.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WsServer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/WsServer.cpp b/src/WsServer.cpp index 0965338d..98123e75 100644 --- a/src/WsServer.cpp +++ b/src/WsServer.cpp @@ -117,6 +117,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length) if (headerStr == "/oiranecs|") { writeFileUint8tByFrames("scenario.txt", payload, length, headerLenth, 256); clearConfigure(); + globalVarsSync(); // в том числе подгружаем сохраненные значения элементов с флешки configure("/config.json"); iotScen.loadScenario("/scenario.txt"); // создаем событие завершения конфигурирования для возможности From e0ec19c5f79438d6424c363988918484e96570a6 Mon Sep 17 00:00:00 2001 From: Ilya Belyakov Date: Sat, 6 Jan 2024 17:30:23 +0500 Subject: [PATCH 09/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D0=B2=20=D0=BC=D0=B0=D1=82=D0=B5=D0=BC?= =?UTF-8?q?=D0=B0=D1=82=D0=B8=D0=BA=D1=83=20=D1=84=D1=83=D0=BD=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D1=8E=20=D0=B2=D1=85=D0=BE=D0=B6=D0=B4=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D1=82=D0=B5=D0=BA=D1=83=D1=89=D0=B5=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=B8=20=D0=B2=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B8=D0=BE=D0=B4=20=D0=92=20=D0=BF=D0=B0=D0=BF?= =?UTF-8?q?=D0=BA=D0=B5=20=D1=81=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B5?= =?UTF-8?q?=D0=BC=20=D0=B5=D1=81=D1=82=D1=8C=20=D0=BF=D1=80=D0=B8=D0=BC?= =?UTF-8?q?=D0=B5=D1=80=20=D1=82=D0=B0=D0=B9=D0=BC=D0=B5=D1=80=D0=B0=20?= =?UTF-8?q?=D1=81=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B5=D0=BC=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B9?= =?UTF-8?q?=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/virtual/Math/Math.cpp | 22 +- src/modules/virtual/Math/TimerRelay.json | 258 +++++++++++++++++++++++ src/modules/virtual/Math/modinfo.json | 10 +- 3 files changed, 286 insertions(+), 4 deletions(-) create mode 100644 src/modules/virtual/Math/TimerRelay.json diff --git a/src/modules/virtual/Math/Math.cpp b/src/modules/virtual/Math/Math.cpp index 7b14c396..d726d2dc 100644 --- a/src/modules/virtual/Math/Math.cpp +++ b/src/modules/virtual/Math/Math.cpp @@ -31,6 +31,18 @@ private: return mktime(&t); } + bool nowInTimePeriod(String startTime, String endTime) { + int h1 = selectToMarker(startTime, ":").toInt(); + int min1 = selectToMarkerLast(startTime, ":").toInt(); + int h2 = selectToMarker(endTime, ":").toInt(); + int min2 = selectToMarkerLast(endTime, ":").toInt(); + + int nowMinutes = _time_local.hour * 60 + _time_local.minute; + + return nowMinutes >= h1 * 60 + min1 && nowMinutes <= h2 * 60 + min2; + } + + public: IoTMath(String parameters) : IoTItem(parameters) {} @@ -42,7 +54,7 @@ public: //SerialPrint("i", F("IoTMath"), F("Mapping value done.")); return valTmp; } else if(command == "convertTime" && param.size() == 5) { - time_t unixTime = convertTime(param[0].valD, param[1].valD, param[2].valD, param[3].valD, param[4].valD); + uint32_t unixTime = convertTime(param[0].valD, param[1].valD, param[2].valD, param[3].valD, param[4].valD); if (unixTime == -1) { SerialPrint("E", F("IoTMath"), F("Failed to convert time.")); @@ -51,8 +63,12 @@ public: IoTValue valTmp; valTmp.isDecimal = true; - valTmp.valD = unixTime; - //SerialPrint("i", F("IoTMath"), F("Time conversion done.")); + valTmp.valD = static_cast< float > (unixTime); + return valTmp; + } else if(command == "nowInTimePeriod" && param.size() == 2) { + IoTValue valTmp; + valTmp.isDecimal = true; + valTmp.valD = nowInTimePeriod(param[0].valS, param[1].valS); return valTmp; } diff --git a/src/modules/virtual/Math/TimerRelay.json b/src/modules/virtual/Math/TimerRelay.json new file mode 100644 index 00000000..7a74884a --- /dev/null +++ b/src/modules/virtual/Math/TimerRelay.json @@ -0,0 +1,258 @@ +{ + "mark": "iotm", + "config": [ + { + "global": 0, + "type": "Writing", + "subtype": "ButtonOut", + "needSave": "1", + "id": "rel1", + "widget": "toggle", + "page": "Свет 1", + "descr": " Реле 1", + "int": 0, + "inv": "1", + "pin": "32" + }, + { + "global": 0, + "type": "Writing", + "subtype": "ButtonOut", + "needSave": "1", + "id": "rel2", + "widget": "toggle", + "page": "Свет 2", + "descr": " Реле 2", + "int": 0, + "inv": "1", + "pin": "33" + }, + { + "global": 0, + "type": "Reading", + "subtype": "RTC", + "id": "rtc", + "widget": "anydataDef", + "page": "Система", + "descr": "Время", + "chipCode": "3", + "timeFormat": "d-m-Y H:i:s", + "RST": -1, + "CLK": -1, + "DAT": -1, + "ticker": 0, + "int": 5, + "btn-setUTime": "0", + "btn-setSysTime": "nil" + }, + { + "global": 0, + "type": "Reading", + "subtype": "AnalogBtn", + "id": "btn1", + "widget": "nil", + "page": "Свет 1", + "descr": "Кнопка 1", + "pin": "34", + "aValue": 0, + "delta": 50 + }, + { + "global": 0, + "type": "Reading", + "subtype": "AnalogBtn", + "id": "btn2", + "widget": "nil", + "page": "Свет 2", + "descr": "Кнопка 2", + "pin": "34", + "aValue": "1910", + "delta": 50 + }, + { + "global": 0, + "type": "Reading", + "subtype": "IoTMath", + "id": "math", + "widget": "anydataValue", + "page": "Математика", + "descr": "" + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "start11", + "needSave": "1", + "widget": "inputTm", + "page": "Свет 1", + "descr": " Старт 1", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "stop11", + "needSave": "1", + "widget": "inputTm", + "page": "Свет 1", + "descr": " Стоп 1", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "start12", + "needSave": "1", + "widget": "inputTm", + "page": "Свет 1", + "descr": "Старт 2", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "stop12", + "needSave": "1", + "widget": "inputTm", + "page": "Свет 1", + "descr": "Стоп 2", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "start21", + "needSave": "1", + "widget": "inputTm", + "page": "Свет 2", + "descr": " Старт 1", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "stop21", + "needSave": "1", + "widget": "inputTm", + "page": "Свет 2", + "descr": " Стоп 1", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "start22", + "needSave": "1", + "widget": "inputTm", + "page": "Свет 2", + "descr": "Старт 2", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "Variable", + "id": "stop22", + "needSave": "1", + "widget": "inputTm", + "page": "Свет 2", + "descr": "Стоп 2", + "int": "0", + "val": "0.0", + "map": "1024,1024,1,100", + "plus": 0, + "multiply": 1, + "round": 0 + }, + { + "global": 0, + "type": "Writing", + "subtype": "Cron", + "id": "timer", + "widget": "anydataRed", + "page": "Система", + "descr": "Будильник", + "int": 1, + "val": "0 * * * * *", + "formatNextAlarm": "%H:%M:%S", + "needSave": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "rel1on", + "needSave": "1", + "widget": "toggle", + "page": "Свет 1", + "descr": " Работать", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "rel2on", + "needSave": "1", + "widget": "toggle", + "page": "Свет 2", + "descr": " Работать", + "int": "0", + "val": "0" + } + ] +} + +scenario=>if btn1>0 then rel1 = 1- rel1 +if btn2>0 then rel2 = 1- rel2 + +if timer == 0 | start11 | stop11 | start12 | stop12 | start21 | stop21 | start22 | stop22 then { +if rel1on then +if math.nowInTimePeriod(start11, stop11) | math.nowInTimePeriod(start12, stop12) then rel1=1 else rel1=0 + +if rel2on then +if math.nowInTimePeriod(start21, stop21) | math.nowInTimePeriod(start22, stop22) then rel2=1 else rel2=0 +} \ No newline at end of file diff --git a/src/modules/virtual/Math/modinfo.json b/src/modules/virtual/Math/modinfo.json index 6265e85b..27080b3c 100644 --- a/src/modules/virtual/Math/modinfo.json +++ b/src/modules/virtual/Math/modinfo.json @@ -38,10 +38,18 @@ }, { "name": "convertTime", - "descr": "Перевести время из формата d-m-Y H:i:s например, 13-08-2023 16:24:00 в юникс-время ", + "descr": "Перевести время из формата d-m-Y H:i:s например, 13-08-2023 16:24:00 в юникс-время", "params": [ "tm.convertTime(13, 08, 2023, 16, 24); - передаем пять целых чисел. секунды подставятся в ноль" ] + }, + { + "name": "nowInTimePeriod", + "descr": "Проверяет входит ли текущее время в указанный период. Возвращает 1 если входит, 0 если нет.", + "params": [ + "Начало периода в формате HH:MM", + "Конец периода в формате HH:MM" + ] } ] }, From 02cf1547a8a03af856cd4c2d5be8937f85a421f8 Mon Sep 17 00:00:00 2001 From: Ilya Belyakov Date: Sat, 6 Jan 2024 18:01:51 +0500 Subject: [PATCH 10/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D1=82=D1=80=D0=B5=D0=B1=D1=83=D0=B5=D0=BC?= =?UTF-8?q?=D1=8B=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20TM16XX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/display/TM16XX/modinfo.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/display/TM16XX/modinfo.json b/src/modules/display/TM16XX/modinfo.json index bbbed517..1aaf3857 100644 --- a/src/modules/display/TM16XX/modinfo.json +++ b/src/modules/display/TM16XX/modinfo.json @@ -78,10 +78,14 @@ "defActive": false, "usedLibs": { "esp32*": [ - "https://github.com/maxint-rd/TM16xx" + "https://github.com/maxint-rd/TM16xx", + "https://github.com/adafruit/Adafruit-GFX-Library", + "adafruit/Adafruit BusIO @ ^1.13.2" ], "esp82*": [ - "https://github.com/maxint-rd/TM16xx" + "https://github.com/maxint-rd/TM16xx", + "https://github.com/adafruit/Adafruit-GFX-Library", + "adafruit/Adafruit BusIO @ ^1.13.2" ] } } \ No newline at end of file From e43bfd90804bd71e65a9ce002bf6ea625baef6bb Mon Sep 17 00:00:00 2001 From: Ilya Belyakov Date: Sat, 6 Jan 2024 20:30:39 +0500 Subject: [PATCH 11/15] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D1=83=D0=BD=D0=B8=D0=B2=D0=B5=D1=80=D1=81?= =?UTF-8?q?=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BF=D1=80=D0=BE=D1=84?= =?UTF-8?q?=D0=B8=D0=BB=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=B1=D0=BE?= =?UTF-8?q?=D1=80=D0=BA=D0=B8=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=B8=D0=BE=D1=82?= =?UTF-8?q?=D0=B5=D0=BA=20=D0=B4=D0=BB=D1=8F=20=D0=BC=D0=BE=D0=B4=D1=83?= =?UTF-8?q?=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PrepareProject.py | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/PrepareProject.py b/PrepareProject.py index 55b4e383..1b99e8a3 100644 --- a/PrepareProject.py +++ b/PrepareProject.py @@ -131,7 +131,11 @@ if deviceName == 'esp8266_1mb_ota' or deviceName == 'esp8285_1mb_ota' or deviceN copy_tree("data_lite", "data_svelte") else: copy_tree("data_full", "data_svelte") - + +deviceType = 'esp32*' +if not 'esp32' in deviceName: + deviceType = 'esp82*' + # генерируем файлы проекта на основе подготовленного профиля # заполняем конфигурационный файл прошивки параметрами из профиля with open("data_svelte/settings.json", "r", encoding='utf-8') as read_file: @@ -158,15 +162,28 @@ for section, modules in profJson['modules'].items(): with open(module['path'] + "/modinfo.json", "r", encoding='utf-8') as read_file: moduleJson = json.load(read_file) if deviceName in moduleJson['usedLibs']: # проверяем поддерживает ли модуль текущее устройство - activeModulesName.append(moduleJson['about']['moduleName']) # запоминаем имена для использования на след шагах - includeDirs = includeDirs + "\n+<" + module['path'].replace("src/", "") + ">" # запоминаем пути к модулям для компиляции - for libPath in moduleJson['usedLibs'][deviceName]: # запоминаем библиотеки необходимые модулю для текущей платы - allLibs = allLibs + "\n" + libPath - for configItemsJson in moduleJson['configItem']: - configItemsJson['num'] = itemsCount - configItemsJson['name'] = str(itemsCount) + ". " + configItemsJson['name'] - itemsCount = itemsCount + 1 - itemsJson.append(configItemsJson) + if not 'exclude' in moduleJson['usedLibs'][deviceName]: # смотрим не нужно ли исключить данный модуль из указанной платы deviceName + activeModulesName.append(moduleJson['about']['moduleName']) # запоминаем имена для использования на след шагах + includeDirs = includeDirs + "\n+<" + module['path'].replace("src/", "") + ">" # запоминаем пути к модулям для компиляции + for libPath in moduleJson['usedLibs'][deviceName]: # запоминаем библиотеки необходимые модулю для текущей платы + allLibs = allLibs + "\n" + libPath + for configItemsJson in moduleJson['configItem']: + configItemsJson['num'] = itemsCount + configItemsJson['name'] = str(itemsCount) + ". " + configItemsJson['name'] + itemsCount = itemsCount + 1 + itemsJson.append(configItemsJson) + else: # В первую очередь ищем по имени deviceName, чтобы для данной платы можно было уточнить либы. Если не нашли плату по имени в usedLibs пробуем найти её по типу deviceType + if deviceType in moduleJson['usedLibs']: # проверяем поддерживает ли модуль текущее устройство + activeModulesName.append(moduleJson['about']['moduleName']) # запоминаем имена для использования на след шагах + includeDirs = includeDirs + "\n+<" + module['path'].replace("src/", "") + ">" # запоминаем пути к модулям для компиляции + for libPath in moduleJson['usedLibs'][deviceType]: # запоминаем библиотеки необходимые модулю для текущей платы + allLibs = allLibs + "\n" + libPath + for configItemsJson in moduleJson['configItem']: + configItemsJson['num'] = itemsCount + configItemsJson['name'] = str(itemsCount) + ". " + configItemsJson['name'] + itemsCount = itemsCount + 1 + itemsJson.append(configItemsJson) + with open("data_svelte/items.json", "w", encoding='utf-8') as write_file: json.dump(itemsJson, write_file, ensure_ascii=False, indent=4, sort_keys=False) From 047c0fc5cc7ad38f63dbb76041872021b97256f3 Mon Sep 17 00:00:00 2001 From: Ilya Belyakov Date: Sat, 6 Jan 2024 23:40:04 +0500 Subject: [PATCH 12/15] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=B0=D0=B3=D0=B0=20?= =?UTF-8?q?=D0=B2=20PrepareProject=20=D1=81=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC=20=D1=8D=D0=BB=D0=B5?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=20=D0=B2=20=D1=81=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=BA=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PrepareProject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PrepareProject.py b/PrepareProject.py index 1b99e8a3..857026b3 100644 --- a/PrepareProject.py +++ b/PrepareProject.py @@ -171,7 +171,7 @@ for section, modules in profJson['modules'].items(): configItemsJson['num'] = itemsCount configItemsJson['name'] = str(itemsCount) + ". " + configItemsJson['name'] itemsCount = itemsCount + 1 - itemsJson.append(configItemsJson) + itemsJson.append(configItemsJson) else: # В первую очередь ищем по имени deviceName, чтобы для данной платы можно было уточнить либы. Если не нашли плату по имени в usedLibs пробуем найти её по типу deviceType if deviceType in moduleJson['usedLibs']: # проверяем поддерживает ли модуль текущее устройство activeModulesName.append(moduleJson['about']['moduleName']) # запоминаем имена для использования на след шагах From e904ac1741a236a4bf55b9e206e52be320d0d9d5 Mon Sep 17 00:00:00 2001 From: Ilya Belyakov Date: Sun, 7 Jan 2024 19:57:28 +0500 Subject: [PATCH 13/15] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D1=8F=D0=B5=D0=BC=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83?= =?UTF-8?q?=20=D0=B2=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B5=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D1=8B=20=D0=B4=D0=BB=D1=8F=20ESP32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/exec/IoTServo/IoTServo.cpp | 13 ++++++++++--- src/modules/exec/IoTServo/modinfo.json | 6 ++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/modules/exec/IoTServo/IoTServo.cpp b/src/modules/exec/IoTServo/IoTServo.cpp index d9e95974..e66bc8df 100644 --- a/src/modules/exec/IoTServo/IoTServo.cpp +++ b/src/modules/exec/IoTServo/IoTServo.cpp @@ -15,12 +15,19 @@ class IoTServo : public IoTItem { public: IoTServo(String parameters): IoTItem(parameters) { - int pin, minPulseWidth, maxPulseWidth, neutralPulseWidth; + int pin, minPulseWidth, maxPulseWidth, minAngle, maxAngle; jsonRead(parameters, "pin", pin); jsonRead(parameters, "minPulseWidth", minPulseWidth); jsonRead(parameters, "maxPulseWidth", maxPulseWidth); - jsonRead(parameters, "neutralPulseWidth", neutralPulseWidth); - servObj.attach(pin, minPulseWidth, maxPulseWidth, neutralPulseWidth); + jsonRead(parameters, "minAngle", minAngle); + jsonRead(parameters, "maxAngle", maxAngle); + +#ifdef ESP32 + servObj.attach(pin, Servo::CHANNEL_NOT_ATTACHED, minAngle, maxAngle, minPulseWidth, maxPulseWidth); +#endif +#ifdef ESP8266 + servObj.attach(pin, minPulseWidth, maxPulseWidth, value.valD); +#endif // jsonRead(parameters, "apin", _apin); // if (_apin >= 0) IoTgpio.pinMode(_apin, INPUT); diff --git a/src/modules/exec/IoTServo/modinfo.json b/src/modules/exec/IoTServo/modinfo.json index 5557aeb4..56ecc51b 100644 --- a/src/modules/exec/IoTServo/modinfo.json +++ b/src/modules/exec/IoTServo/modinfo.json @@ -13,7 +13,8 @@ "pin": 12, "minPulseWidth": 544, "maxPulseWidth": 2400, - "neutralPulseWidth": 1500, + "minAngle": 0, + "maxAngle": 180, "trackingID": "" } ], @@ -34,7 +35,8 @@ "pin": "Пин, к которому подключен сервопривод", "minPulseWidth": "Минимальная длина импульса", "maxPulseWidth": "Максимальная длина импульса", - "neutralPulseWidth": "Нейтральная длина импульса", + "minAngle": "Минимальное значение угла (имеет значение для ESP32)", + "maxAngle": "Максимальное значение угла (имеет значение для ESP32)", "trackingID": "Идентификатор отслеживания значения другого элемента конфигурации, например, чтение аналога" }, "retInfo": "Содержит текущее значение поворота", From 398ce07d57659487ff16c77aea82b71094ff5d1e Mon Sep 17 00:00:00 2001 From: Ilya Belyakov Date: Wed, 10 Jan 2024 20:40:21 +0500 Subject: [PATCH 14/15] =?UTF-8?q?=D0=9E=D1=82=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B0=D0=B5=D0=BC=20=D0=BF=D0=B5=D1=80=D0=B2=D1=8B=D0=B9=20?= =?UTF-8?q?=D0=BF=D0=B7=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/Pzem004t/modinfo.json | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/modules/sensors/Pzem004t/modinfo.json b/src/modules/sensors/Pzem004t/modinfo.json index 68f6299b..5cf3832c 100644 --- a/src/modules/sensors/Pzem004t/modinfo.json +++ b/src/modules/sensors/Pzem004t/modinfo.json @@ -125,17 +125,9 @@ "reset": "Поставьте этот параметр равным 1 и pzem будет сброшен к нулю. Смотрите в логе результат: [i] Pzem reset done" } }, - "defActive": true, + "defActive": false, "usedLibs": { - "esp32_4mb": [], - "esp32_4mb3f": [], - "esp32cam_4mb": [], - "esp8266_4mb": [], - "esp8266_1mb": [], - "esp8266_1mb_ota": [], - "esp8285_1mb": [], - "esp8285_1mb_ota": [], - "esp8266_2mb": [], - "esp8266_2mb_ota": [] + "esp32*": [], + "esp82*": [] } } \ No newline at end of file From eff1c77864a96c2350e295e897b2945c302d7ace Mon Sep 17 00:00:00 2001 From: IoT Manager <67171972+IoTManagerProject@users.noreply.github.com> Date: Sat, 20 Jan 2024 22:32:31 +0100 Subject: [PATCH 15/15] 456 --- compilerProfile.json | 24 ++- data_svelte/flashProfile.json | 22 ++- data_svelte/items.json | 337 +++++++++++++++++++++------------- include/Const.h | 2 +- myProfile.json | 22 ++- platformio.ini | 11 +- src/modules/API.cpp | 14 +- 7 files changed, 284 insertions(+), 148 deletions(-) diff --git a/compilerProfile.json b/compilerProfile.json index 97fd71cd..b6246f40 100644 --- a/compilerProfile.json +++ b/compilerProfile.json @@ -59,7 +59,7 @@ "bootloader_qio_80m": "0x1000", "firmware": "0x10000", "partitions": "0x8000", - "littlefs": "0x290000" + "littlefs": "0x310000" }, { "name": "esp32_16mb", @@ -146,7 +146,7 @@ }, { "path": "src/modules/virtual/Math", - "active": false + "active": true }, { "path": "src/modules/virtual/owmWeather", @@ -290,12 +290,20 @@ "path": "src/modules/sensors/Mhz19", "active": false }, + { + "path": "src/modules/sensors/MQgas", + "active": true + }, { "path": "src/modules/sensors/Ntc", "active": false }, { "path": "src/modules/sensors/Pzem004t", + "active": false + }, + { + "path": "src/modules/sensors/Pzem004t_v2", "active": true }, { @@ -340,6 +348,10 @@ } ], "executive_devices": [ + { + "path": "src/modules/exec/AnalogBtn", + "active": true + }, { "path": "src/modules/exec/ButtonIn", "active": true @@ -436,12 +448,16 @@ "screens": [ { "path": "src/modules/display/DwinI", - "active": false + "active": true }, { "path": "src/modules/display/Lcd2004", "active": true }, + { + "path": "src/modules/display/Nextion", + "active": false + }, { "path": "src/modules/display/NextionUpload", "active": false @@ -460,7 +476,7 @@ }, { "path": "src/modules/display/TM16XX", - "active": true + "active": false }, { "path": "src/modules/display/Ws2812b", diff --git a/data_svelte/flashProfile.json b/data_svelte/flashProfile.json index dea9e970..b17a4af6 100644 --- a/data_svelte/flashProfile.json +++ b/data_svelte/flashProfile.json @@ -24,7 +24,7 @@ }, { "path": "src/modules/virtual/Math", - "active": false + "active": true }, { "path": "src/modules/virtual/owmWeather", @@ -168,12 +168,20 @@ "path": "src/modules/sensors/Mhz19", "active": false }, + { + "path": "src/modules/sensors/MQgas", + "active": true + }, { "path": "src/modules/sensors/Ntc", "active": false }, { "path": "src/modules/sensors/Pzem004t", + "active": false + }, + { + "path": "src/modules/sensors/Pzem004t_v2", "active": true }, { @@ -218,6 +226,10 @@ } ], "executive_devices": [ + { + "path": "src/modules/exec/AnalogBtn", + "active": true + }, { "path": "src/modules/exec/ButtonIn", "active": true @@ -314,12 +326,16 @@ "screens": [ { "path": "src/modules/display/DwinI", - "active": false + "active": true }, { "path": "src/modules/display/Lcd2004", "active": true }, + { + "path": "src/modules/display/Nextion", + "active": false + }, { "path": "src/modules/display/NextionUpload", "active": false @@ -338,7 +354,7 @@ }, { "path": "src/modules/display/TM16XX", - "active": true + "active": false }, { "path": "src/modules/display/Ws2812b", diff --git a/data_svelte/items.json b/data_svelte/items.json index 8ee594e1..e432f9b8 100644 --- a/data_svelte/items.json +++ b/data_svelte/items.json @@ -68,7 +68,18 @@ }, { "global": 0, - "name": "5. Погода OWM", + "name": "5. Math library", + "type": "Reading", + "subtype": "IoTMath", + "id": "math", + "widget": "anydataValue", + "page": "Математика", + "descr": "", + "num": 5 + }, + { + "global": 0, + "name": "6. Погода OWM", "type": "Reading", "subtype": "owmWeather", "id": "owm", @@ -86,11 +97,11 @@ "round": 1, "val": "...", "debug": 0, - "num": 5 + "num": 6 }, { "global": 0, - "name": "6. Таймер", + "name": "7. Таймер", "type": "Writing", "subtype": "Timer", "id": "timer", @@ -102,11 +113,11 @@ "ticker": 1, "repeat": 1, "needSave": 0, - "num": 6 + "num": 7 }, { "global": 0, - "name": "7. Окно ввода числа (переменная)", + "name": "8. Окно ввода числа (переменная)", "type": "Reading", "subtype": "Variable", "id": "value", @@ -120,11 +131,11 @@ "plus": 0, "multiply": 1, "round": 0, - "num": 7 + "num": 8 }, { "global": 0, - "name": "8. Окно ввода времени", + "name": "9. Окно ввода времени", "type": "Reading", "subtype": "Variable", "id": "time", @@ -134,11 +145,11 @@ "descr": "Введите время", "int": "0", "val": "02:00", - "num": 8 + "num": 9 }, { "global": 0, - "name": "9. Окно ввода даты", + "name": "10. Окно ввода даты", "type": "Reading", "subtype": "Variable", "id": "time", @@ -148,11 +159,11 @@ "descr": "Введите дату", "int": "0", "val": "24.05.2022", - "num": 9 + "num": 10 }, { "global": 0, - "name": "10. Окно ввода текста", + "name": "11. Окно ввода текста", "type": "Reading", "subtype": "Variable", "id": "txt", @@ -162,11 +173,11 @@ "descr": "Введите текст", "int": "0", "val": "текст", - "num": 10 + "num": 11 }, { "global": 0, - "name": "11. Вывод значения", + "name": "12. Вывод значения", "type": "Reading", "subtype": "Variable", "id": "vout", @@ -180,11 +191,11 @@ "plus": 0, "multiply": 1, "round": 0, - "num": 11 + "num": 12 }, { "global": 0, - "name": "12. Виртуальная кнопка", + "name": "13. Виртуальная кнопка", "type": "Reading", "subtype": "VButton", "id": "vbtn", @@ -194,13 +205,13 @@ "descr": "Кнопка", "int": "0", "val": "0", - "num": 12 + "num": 13 }, { "header": "sensors" }, { - "name": "13. A02 Дальность", + "name": "14. A02 Дальность", "type": "Reading", "subtype": "A02Distance", "id": "dist", @@ -209,10 +220,14 @@ "descr": "Дальность", "int": 5, "round": 1, - "num": 13 + "tx": 17, + "rx": 16, + "line": 2, + "speed": 9600, + "num": 14 }, { - "name": "14. Acs712 Ток", + "name": "15. Acs712 Ток", "type": "Reading", "subtype": "Acs712", "id": "amp", @@ -227,11 +242,11 @@ "sens": 100, "adczero": 512, "btn-setZero": "nil", - "num": 14 + "num": 15 }, { "global": 0, - "name": "15. AHTXX Температура", + "name": "16. AHTXX Температура", "type": "Reading", "subtype": "AhtXXt", "id": "Temp20", @@ -242,11 +257,11 @@ "addr": "0x38", "shtType": 1, "round": 1, - "num": 15 + "num": 16 }, { "global": 0, - "name": "16. AHTXX Влажность", + "name": "17. AHTXX Влажность", "type": "Reading", "subtype": "AhtXXh", "id": "Hum20", @@ -257,11 +272,11 @@ "addr": "0x38", "shtType": 1, "round": 1, - "num": 16 + "num": 17 }, { "global": 0, - "name": "17. Аналоговый сенсор", + "name": "18. Аналоговый сенсор", "type": "Reading", "subtype": "AnalogAdc", "id": "t", @@ -275,11 +290,11 @@ "pin": 0, "int": 15, "avgSteps": 1, - "num": 17 + "num": 18 }, { "global": 0, - "name": "18. BME280 Температура", + "name": "19. BME280 Температура", "type": "Reading", "subtype": "Bme280t", "id": "Tmp3", @@ -289,11 +304,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 18 + "num": 19 }, { "global": 0, - "name": "19. BME280 Давление", + "name": "20. BME280 Давление", "type": "Reading", "subtype": "Bme280p", "id": "Press3", @@ -303,11 +318,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 19 + "num": 20 }, { "global": 0, - "name": "20. BME280 Влажность", + "name": "21. BME280 Влажность", "type": "Reading", "subtype": "Bme280h", "id": "Hum3", @@ -317,11 +332,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 20 + "num": 21 }, { "global": 0, - "name": "21. BME280 Tочка росы", + "name": "22. BME280 Tочка росы", "type": "Reading", "subtype": "Bme280dp", "id": "Dew3", @@ -331,11 +346,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 21 + "num": 22 }, { "global": 0, - "name": "22. BMP280 Температура", + "name": "23. BMP280 Температура", "type": "Reading", "subtype": "Bmp280t", "id": "tmp3", @@ -345,11 +360,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 22 + "num": 23 }, { "global": 0, - "name": "23. BMP280 Давление", + "name": "24. BMP280 Давление", "type": "Reading", "subtype": "Bmp280p", "id": "Press3", @@ -359,11 +374,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 23 + "num": 24 }, { "global": 0, - "name": "24. DHT11 Температура", + "name": "25. DHT11 Температура", "type": "Reading", "subtype": "Dht1122t", "id": "tmp3", @@ -373,11 +388,11 @@ "int": 15, "pin": 0, "senstype": "dht11", - "num": 24 + "num": 25 }, { "global": 0, - "name": "25. DHT11 Влажность", + "name": "26. DHT11 Влажность", "type": "Reading", "subtype": "Dht1122h", "id": "Hum3", @@ -387,11 +402,11 @@ "int": 15, "pin": 0, "senstype": "dht11", - "num": 25 + "num": 26 }, { "global": 0, - "name": "26. DS18B20 Температура", + "name": "27. DS18B20 Температура", "type": "Reading", "subtype": "Ds18b20", "id": "dstmp", @@ -403,11 +418,11 @@ "index": 0, "addr": "", "round": 1, - "num": 26 + "num": 27 }, { "global": 0, - "name": "27. Аналоговый счетчик импульсов", + "name": "28. Аналоговый счетчик импульсов", "type": "Writing", "subtype": "Impulse", "id": "impulse", @@ -420,11 +435,52 @@ "pinMode": "INPUT", "debounceDelay": 3, "multiply": 1, - "num": 27 + "num": 28 }, { "global": 0, - "name": "28. PZEM 004t Напряжение", + "name": "29. MQ газовые анализаторы", + "type": "Reading", + "subtype": "MQgas", + "id": "MQ", + "widget": "anydataPpm", + "page": "Сенсоры", + "descr": "MQ-135", + "Series": 135, + "Gas": "CO2", + "Rl on board": 10, + "Ro in clean air": 0, + "Rl/Ro in clean air": 0, + "PPM in clean air": 397.13, + "aLimit": -0.42, + "bLimit": 1.92, + "Warm up time": 60, + "Sample interval": 20, + "Sample times": 10, + "Calibtation intensity": 5, + "autoCalibration": 1, + "autoCalib.Period": 24, + "TempHum correction": 1, + "temperature": 20, + "idTempSensor": "", + "humidity": 50, + "idHumSensor": "", + "k1": 0.00672096284322792, + "k2": -0.0159038179354688, + "b1": -0.741244323718154, + "b2": 1.77535862501753, + "Debug": 1, + "plus": 0, + "multiply": 1, + "round": 1, + "pin-Esp32": 34, + "operating voltage": 3.3, + "int": 15, + "num": 29 + }, + { + "global": 0, + "name": "30. PZEM 004t Напряжение", "type": "Reading", "subtype": "Pzem004v", "id": "v", @@ -434,11 +490,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 28 + "num": 30 }, { "global": 0, - "name": "29. PZEM 004t Сила тока", + "name": "31. PZEM 004t Сила тока", "type": "Reading", "subtype": "Pzem004a", "id": "a", @@ -448,11 +504,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 29 + "num": 31 }, { "global": 0, - "name": "30. PZEM 004t Мощность", + "name": "32. PZEM 004t Мощность", "type": "Reading", "subtype": "Pzem004w", "id": "w", @@ -462,11 +518,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 30 + "num": 32 }, { "global": 0, - "name": "31. PZEM 004t Энергия", + "name": "33. PZEM 004t Энергия", "type": "Reading", "subtype": "Pzem004wh", "id": "wh", @@ -476,11 +532,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 31 + "num": 33 }, { "global": 0, - "name": "32. PZEM 004t Частота", + "name": "34. PZEM 004t Частота", "type": "Reading", "subtype": "Pzem004hz", "id": "hz", @@ -490,11 +546,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 32 + "num": 34 }, { "global": 0, - "name": "33. PZEM 004t Косинус", + "name": "35. PZEM 004t Косинус", "type": "Reading", "subtype": "Pzem004pf", "id": "pf", @@ -504,11 +560,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 33 + "num": 35 }, { "global": 0, - "name": "34. PZEM настройка", + "name": "36. PZEM настройка", "type": "Reading", "subtype": "Pzem004cmd", "id": "set", @@ -517,14 +573,28 @@ "descr": "", "int": 15, "addr": "0xF8", - "changeaddr": 0, - "setaddr": "0x01", - "reset": 0, - "num": 34 + "btn-changeaddr": "0x01", + "btn-reset": "", + "num": 36 }, { "global": 0, - "name": "35. Часы реального времени", + "name": "37. PZEM uart", + "type": "Reading", + "subtype": "Pzem004uart", + "id": "upzem", + "widget": "nil", + "page": "", + "descr": "", + "tx": 17, + "rx": 16, + "line": 2, + "speed": 9600, + "num": 37 + }, + { + "global": 0, + "name": "38. Часы реального времени", "type": "Reading", "subtype": "RTC", "id": "rtc", @@ -540,11 +610,12 @@ "int": 5, "btn-setUTime": "0", "btn-setSysTime": "nil", - "num": 35 + "num": 38 }, { - "name": "36. (S8) Cенсор качества воздуха", - "num": 36, + "global": 0, + "name": "39. (S8) Cенсор качества воздуха", + "num": 39, "type": "Reading", "subtype": "S8co", "id": "s8co", @@ -558,7 +629,7 @@ }, { "global": 0, - "name": "37. Sht20 Температура", + "name": "40. Sht20 Температура", "type": "Reading", "subtype": "Sht20t", "id": "tmp2", @@ -567,11 +638,11 @@ "descr": "Температура", "int": 15, "round": 1, - "num": 37 + "num": 40 }, { "global": 0, - "name": "38. Sht20 Влажность", + "name": "41. Sht20 Влажность", "type": "Reading", "subtype": "Sht20h", "id": "Hum2", @@ -580,11 +651,11 @@ "descr": "Влажность", "int": 15, "round": 1, - "num": 38 + "num": 41 }, { "global": 0, - "name": "39. Sht30 Температура", + "name": "42. Sht30 Температура", "type": "Reading", "subtype": "Sht30t", "id": "tmp30", @@ -593,11 +664,11 @@ "descr": "SHT30 Температура", "int": 15, "round": 1, - "num": 39 + "num": 42 }, { "global": 0, - "name": "40. Sht30 Влажность", + "name": "43. Sht30 Влажность", "type": "Reading", "subtype": "Sht30h", "id": "Hum30", @@ -606,12 +677,12 @@ "descr": "SHT30 Влажность", "int": 15, "round": 1, - "num": 40 + "num": 43 }, { "global": 0, - "name": "41. HC-SR04 Ультразвуковой дальномер", - "num": 41, + "name": "44. HC-SR04 Ультразвуковой дальномер", + "num": 44, "type": "Reading", "subtype": "Sonar", "id": "sonar", @@ -623,7 +694,7 @@ "int": 5 }, { - "name": "42. UART", + "name": "45. UART", "type": "Reading", "subtype": "UART", "page": "", @@ -635,14 +706,28 @@ "line": 2, "speed": 9600, "eventFormat": 0, - "num": 42 + "num": 45 }, { "header": "executive_devices" }, { "global": 0, - "name": "43. Кнопка подключенная к пину", + "name": "46. Аналоговая кнопка", + "type": "Reading", + "subtype": "AnalogBtn", + "id": "abtn", + "widget": "toggle", + "page": "Кнопки", + "descr": "Освещение", + "pin": 34, + "aValue": -1, + "delta": 50, + "num": 46 + }, + { + "global": 0, + "name": "47. Кнопка подключенная к пину", "type": "Writing", "subtype": "ButtonIn", "id": "btn", @@ -657,11 +742,11 @@ "debounceDelay": 50, "fixState": 0, "inv": 0, - "num": 43 + "num": 47 }, { "global": 0, - "name": "44. Управление пином", + "name": "48. Управление пином", "type": "Writing", "subtype": "ButtonOut", "needSave": 0, @@ -672,11 +757,11 @@ "int": 0, "inv": 0, "pin": 2, - "num": 44 + "num": 48 }, { "global": 0, - "name": "45. Пассивный звуковой извещатель", + "name": "49. Пассивный звуковой извещатель", "type": "Writing", "subtype": "Buzzer", "id": "buzzer", @@ -695,11 +780,11 @@ "cycle": 0, "indication": 1, "val": 0, - "num": 45 + "num": 49 }, { "global": 0, - "name": "46. Энкодер", + "name": "50. Энкодер", "type": "Writing", "subtype": "Encoder", "id": "enc", @@ -712,11 +797,11 @@ "step": 1, "stepOnPress": 5, "pins": "4,5,2", - "num": 46 + "num": 50 }, { "global": 0, - "name": "47. Сервопривод", + "name": "51. Сервопривод", "type": "Writing", "subtype": "IoTServo", "id": "servo", @@ -726,13 +811,14 @@ "pin": 12, "minPulseWidth": 544, "maxPulseWidth": 2400, - "neutralPulseWidth": 1500, + "minAngle": 0, + "maxAngle": 180, "trackingID": "", - "num": 47 + "num": 51 }, { "global": 0, - "name": "48. Расширитель портов Mcp23017", + "name": "52. Расширитель портов Mcp23017", "type": "Reading", "subtype": "Mcp23017", "id": "Mcp", @@ -742,11 +828,11 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 48 + "num": 52 }, { "global": 0, - "name": "49. MP3 плеер", + "name": "53. MP3 плеер", "type": "Reading", "subtype": "Mp3", "id": "mp3", @@ -756,11 +842,11 @@ "int": 1, "pins": "14,12", "volume": 20, - "num": 49 + "num": 53 }, { "global": 0, - "name": "50. Сенсорная кнопка", + "name": "54. Сенсорная кнопка", "type": "Writing", "subtype": "Multitouch", "id": "impulse", @@ -774,11 +860,11 @@ "pinMode": "INPUT", "debounceDelay": 50, "PWMDelay": 500, - "num": 50 + "num": 54 }, { "global": 0, - "name": "51. Расширитель портов Pcf8574", + "name": "55. Расширитель портов Pcf8574", "type": "Reading", "subtype": "Pcf8574", "id": "Pcf", @@ -788,11 +874,11 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 51 + "num": 55 }, { "global": 0, - "name": "52. PWM ESP8266", + "name": "56. PWM ESP8266", "type": "Writing", "subtype": "Pwm8266", "id": "pwm", @@ -804,11 +890,11 @@ "freq": 5000, "val": 0, "apin": -1, - "num": 52 + "num": 56 }, { "global": 0, - "name": "53. Телеграм-Лайт", + "name": "57. Телеграм-Лайт", "type": "Writing", "subtype": "TelegramLT", "id": "tg", @@ -817,14 +903,29 @@ "descr": "", "token": "", "chatID": "", - "num": 53 + "num": 57 }, { "header": "screens" }, + { + "name": "58. LCD Dwin экран", + "type": "Reading", + "subtype": "DwinI", + "id": "dwin", + "widget": "", + "page": "", + "descr": "", + "tx": 17, + "rx": 16, + "line": 2, + "speed": 9600, + "btn-uploadUI": "", + "num": 58 + }, { "global": 0, - "name": "54. LCD экран 2004", + "name": "59. LCD экран 2004", "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -837,10 +938,10 @@ "id2show": "", "prefix": "", "postfix": "", - "num": 54 + "num": 59 }, { - "name": "55. LCD экран 1602", + "name": "60. LCD экран 1602", "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -853,11 +954,11 @@ "id2show": "", "prefix": "", "postfix": "", - "num": 55 + "num": 60 }, { "global": 0, - "name": "56. OLED экран 64 8266", + "name": "61. OLED экран 64 8266", "type": "Reading", "subtype": "Oled64", "id": "Oled", @@ -870,26 +971,6 @@ "id2show": "", "prefix": "", "postfix": "", - "num": 56 - }, - { - "global": 0, - "name": "57. 7 сегментный дисплей TM16XX", - "type": "Writing", - "subtype": "TM16XX", - "id": "tm", - "widget": "inputTxt", - "page": "screens", - "descr": "Экран", - "round": 0, - "chip": 1637, - "numDigits": 4, - "DIO": "13", - "CLK": "14", - "STB": "12", - "intensity": "5", - "on": "1", - "id2show": "", - "num": 57 + "num": 61 } ] \ No newline at end of file diff --git a/include/Const.h b/include/Const.h index e7abc35d..e170a3d2 100644 --- a/include/Const.h +++ b/include/Const.h @@ -2,7 +2,7 @@ #include "BuildTime.h" // Версия прошивки -#define FIRMWARE_VERSION 455 +#define FIRMWARE_VERSION 456 #ifdef esp8266_1mb_ota #define FIRMWARE_NAME "esp8266_1mb_ota" diff --git a/myProfile.json b/myProfile.json index 2ab4bf7a..b6246f40 100644 --- a/myProfile.json +++ b/myProfile.json @@ -146,7 +146,7 @@ }, { "path": "src/modules/virtual/Math", - "active": false + "active": true }, { "path": "src/modules/virtual/owmWeather", @@ -290,12 +290,20 @@ "path": "src/modules/sensors/Mhz19", "active": false }, + { + "path": "src/modules/sensors/MQgas", + "active": true + }, { "path": "src/modules/sensors/Ntc", "active": false }, { "path": "src/modules/sensors/Pzem004t", + "active": false + }, + { + "path": "src/modules/sensors/Pzem004t_v2", "active": true }, { @@ -340,6 +348,10 @@ } ], "executive_devices": [ + { + "path": "src/modules/exec/AnalogBtn", + "active": true + }, { "path": "src/modules/exec/ButtonIn", "active": true @@ -436,12 +448,16 @@ "screens": [ { "path": "src/modules/display/DwinI", - "active": false + "active": true }, { "path": "src/modules/display/Lcd2004", "active": true }, + { + "path": "src/modules/display/Nextion", + "active": false + }, { "path": "src/modules/display/NextionUpload", "active": false @@ -460,7 +476,7 @@ }, { "path": "src/modules/display/TM16XX", - "active": true + "active": false }, { "path": "src/modules/display/Ws2812b", diff --git a/platformio.ini b/platformio.ini index beb5f904..4d1dd51a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -544,17 +544,16 @@ lib_deps = adafruit/Adafruit BusIO @ ^1.13.2 dfrobot/DFRobotDFPlayerMini @ ^1.0.5 adafruit/Adafruit BusIO @ ^1.13.2 + plerup/EspSoftwareSerial https://github.com/robotclass/RobotClass_LiquidCrystal_I2C marcoschwartz/LiquidCrystal_I2C@^1.1.4 https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED https://github.com/adafruit/Adafruit-GFX-Library - https://github.com/maxint-rd/TM16xx - adafruit/Adafruit GFX Library @ ^1.11.5 - adafruit/Adafruit BusIO @ ^1.13.2 build_src_filter = + + + + + + + + @@ -568,13 +567,15 @@ build_src_filter = + + + - + + + + + + + + + + + + + + + + @@ -586,9 +587,9 @@ build_src_filter = + + + + + + + - + [env:esp32_4mb_fromitems] lib_deps = diff --git a/src/modules/API.cpp b/src/modules/API.cpp index af5a8dd8..a029331c 100644 --- a/src/modules/API.cpp +++ b/src/modules/API.cpp @@ -3,6 +3,7 @@ void* getAPI_Cron(String subtype, String params); void* getAPI_Loging(String subtype, String params); void* getAPI_LogingDaily(String subtype, String params); +void* getAPI_IoTMath(String subtype, String params); void* getAPI_owmWeather(String subtype, String params); void* getAPI_Timer(String subtype, String params); void* getAPI_Variable(String subtype, String params); @@ -16,13 +17,15 @@ void* getAPI_Bmp280(String subtype, String params); void* getAPI_Dht1122(String subtype, String params); void* getAPI_Ds18b20(String subtype, String params); void* getAPI_Impulse(String subtype, String params); -void* getAPI_Pzem004(String subtype, String params); +void* getAPI_MQgas(String subtype, String params); +void* getAPI_Pzem004_v2(String subtype, String params); void* getAPI_RTC(String subtype, String params); void* getAPI_S8(String subtype, String params); void* getAPI_Sht20(String subtype, String params); void* getAPI_Sht30(String subtype, String params); void* getAPI_Sonar(String subtype, String params); void* getAPI_UART(String subtype, String params); +void* getAPI_AnalogBtn(String subtype, String params); void* getAPI_ButtonIn(String subtype, String params); void* getAPI_ButtonOut(String subtype, String params); void* getAPI_Buzzer(String subtype, String params); @@ -34,15 +37,16 @@ void* getAPI_Multitouch(String subtype, String params); void* getAPI_Pcf8574(String subtype, String params); void* getAPI_Pwm8266(String subtype, String params); void* getAPI_TelegramLT(String subtype, String params); +void* getAPI_DwinI(String subtype, String params); void* getAPI_Lcd2004(String subtype, String params); void* getAPI_Oled64(String subtype, String params); -void* getAPI_TM16XX(String subtype, String params); void* getAPI(String subtype, String params) { void* tmpAPI; if ((tmpAPI = getAPI_Cron(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Loging(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_LogingDaily(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_IoTMath(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_owmWeather(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Timer(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Variable(subtype, params)) != nullptr) return tmpAPI; @@ -56,13 +60,15 @@ if ((tmpAPI = getAPI_Bmp280(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Dht1122(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Ds18b20(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Impulse(subtype, params)) != nullptr) return tmpAPI; -if ((tmpAPI = getAPI_Pzem004(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_MQgas(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_Pzem004_v2(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_RTC(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_S8(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Sht20(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Sht30(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Sonar(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_UART(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_AnalogBtn(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_ButtonIn(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Buzzer(subtype, params)) != nullptr) return tmpAPI; @@ -74,8 +80,8 @@ if ((tmpAPI = getAPI_Multitouch(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Pcf8574(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Pwm8266(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_TelegramLT(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_DwinI(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Lcd2004(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Oled64(subtype, params)) != nullptr) return tmpAPI; -if ((tmpAPI = getAPI_TM16XX(subtype, params)) != nullptr) return tmpAPI; return nullptr; } \ No newline at end of file