diff --git a/data_svelte/items.json b/data_svelte/items.json index 40756f1a..7ee634ce 100644 --- a/data_svelte/items.json +++ b/data_svelte/items.json @@ -162,7 +162,21 @@ }, { "global": 0, - "name": "11. Виртуальная кнопка", + "name": "11. Цветной текст", + "type": "Reading", + "subtype": "VariableColor", + "id": "color", + "needSave": 0, + "widget": "anydataDef", + "page": "Вывод", + "descr": "Цветной текст", + "val": "...", + "round": 0, + "num": 11 + }, + { + "global": 0, + "name": "12. Виртуальная кнопка", "type": "Reading", "subtype": "VButton", "id": "vbtn", @@ -172,13 +186,13 @@ "descr": "Кнопка", "int": "0", "val": "0", - "num": 11 + "num": 12 }, { "header": "Сенсоры" }, { - "name": "12. Acs712 Ток", + "name": "13. Acs712 Ток", "type": "Reading", "subtype": "Acs712", "id": "amp", @@ -188,11 +202,11 @@ "round": 3, "pin": 39, "int": 5, - "num": 12 + "num": 13 }, { "global": 0, - "name": "13. AHTXX Температура", + "name": "14. AHTXX Температура", "type": "Reading", "subtype": "AhtXXt", "id": "Temp20", @@ -203,11 +217,11 @@ "addr": "0x38", "shtType": 1, "round": 1, - "num": 13 + "num": 14 }, { "global": 0, - "name": "14. AHTXX Влажность", + "name": "15. AHTXX Влажность", "type": "Reading", "subtype": "AhtXXh", "id": "Hum20", @@ -218,11 +232,11 @@ "addr": "0x38", "shtType": 1, "round": 1, - "num": 14 + "num": 15 }, { "global": 0, - "name": "15. Аналоговый сенсор", + "name": "16. Аналоговый сенсор", "type": "Reading", "subtype": "AnalogAdc", "id": "t", @@ -236,11 +250,11 @@ "pin": 0, "int": 15, "avgSteps": 1, - "num": 15 + "num": 16 }, { "global": 0, - "name": "16. BME280 Температура", + "name": "17. BME280 Температура", "type": "Reading", "subtype": "Bme280t", "id": "tmp3", @@ -250,11 +264,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 16 + "num": 17 }, { "global": 0, - "name": "17. BME280 Давление", + "name": "18. BME280 Давление", "type": "Reading", "subtype": "Bme280p", "id": "Press3", @@ -264,11 +278,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 17 + "num": 18 }, { "global": 0, - "name": "18. BME280 Влажность", + "name": "19. BME280 Влажность", "type": "Reading", "subtype": "Bme280h", "id": "Hum3", @@ -278,11 +292,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 18 + "num": 19 }, { "global": 0, - "name": "19. BMP280 Температура", + "name": "20. BMP280 Температура", "type": "Reading", "subtype": "Bmp280t", "id": "tmp3", @@ -292,11 +306,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 19 + "num": 20 }, { "global": 0, - "name": "20. BMP280 Давление", + "name": "21. BMP280 Давление", "type": "Reading", "subtype": "Bmp280p", "id": "Press3", @@ -306,11 +320,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 20 + "num": 21 }, { "global": 0, - "name": "21. DHT11 Температура", + "name": "22. DHT11 Температура", "type": "Reading", "subtype": "Dht1122t", "id": "tmp3", @@ -320,11 +334,11 @@ "int": 15, "pin": 0, "senstype": "dht11", - "num": 21 + "num": 22 }, { "global": 0, - "name": "22. DHT11 Влажность", + "name": "23. DHT11 Влажность", "type": "Reading", "subtype": "Dht1122h", "id": "Hum3", @@ -334,11 +348,11 @@ "int": 15, "pin": 0, "senstype": "dht11", - "num": 22 + "num": 23 }, { "global": 0, - "name": "23. DS18B20 Температура", + "name": "24. DS18B20 Температура", "type": "Reading", "subtype": "Ds18b20", "id": "dstmp", @@ -350,11 +364,11 @@ "index": 0, "addr": "", "round": 1, - "num": 23 + "num": 24 }, { "global": 0, - "name": "24. PZEM 004t Напряжение", + "name": "25. PZEM 004t Напряжение", "type": "Reading", "subtype": "Pzem004v", "id": "v", @@ -364,11 +378,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 24 + "num": 25 }, { "global": 0, - "name": "25. PZEM 004t Сила тока", + "name": "26. PZEM 004t Сила тока", "type": "Reading", "subtype": "Pzem004a", "id": "a", @@ -378,11 +392,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 25 + "num": 26 }, { "global": 0, - "name": "26. PZEM 004t Мощность", + "name": "27. PZEM 004t Мощность", "type": "Reading", "subtype": "Pzem004w", "id": "w", @@ -392,11 +406,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 26 + "num": 27 }, { "global": 0, - "name": "27. PZEM 004t Энергия", + "name": "28. PZEM 004t Энергия", "type": "Reading", "subtype": "Pzem004wh", "id": "wh", @@ -406,11 +420,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 27 + "num": 28 }, { "global": 0, - "name": "28. PZEM 004t Частота", + "name": "29. PZEM 004t Частота", "type": "Reading", "subtype": "Pzem004hz", "id": "hz", @@ -420,11 +434,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 28 + "num": 29 }, { "global": 0, - "name": "29. PZEM 004t Косинус", + "name": "30. PZEM 004t Косинус", "type": "Reading", "subtype": "Pzem004pf", "id": "pf", @@ -434,11 +448,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 29 + "num": 30 }, { "global": 0, - "name": "30. PZEM настройка", + "name": "31. PZEM настройка", "type": "Reading", "subtype": "Pzem004cmd", "id": "set", @@ -450,11 +464,11 @@ "changeaddr": 0, "setaddr": "0x01", "reset": 0, - "num": 30 + "num": 31 }, { "global": 0, - "name": "31. Sht20 Температура", + "name": "32. Sht20 Температура", "type": "Reading", "subtype": "Sht20t", "id": "tmp2", @@ -463,11 +477,11 @@ "descr": "Температура", "int": 15, "round": 1, - "num": 31 + "num": 32 }, { "global": 0, - "name": "32. Sht20 Влажность", + "name": "33. Sht20 Влажность", "type": "Reading", "subtype": "Sht20h", "id": "Hum2", @@ -476,11 +490,11 @@ "descr": "Влажность", "int": 15, "round": 1, - "num": 32 + "num": 33 }, { "global": 0, - "name": "33. Sht30 Температура", + "name": "34. Sht30 Температура", "type": "Reading", "subtype": "Sht30t", "id": "tmp30", @@ -489,11 +503,11 @@ "descr": "SHT30 Температура", "int": 15, "round": 1, - "num": 33 + "num": 34 }, { "global": 0, - "name": "34. Sht30 Влажность", + "name": "35. Sht30 Влажность", "type": "Reading", "subtype": "Sht30h", "id": "Hum30", @@ -502,12 +516,12 @@ "descr": "SHT30 Влажность", "int": 15, "round": 1, - "num": 34 + "num": 35 }, { "global": 0, - "name": "35. HC-SR04 Ультразвуковой дальномер", - "num": 35, + "name": "36. HC-SR04 Ультразвуковой дальномер", + "num": 36, "type": "Reading", "subtype": "Sonar", "id": "sonar", @@ -519,7 +533,7 @@ "int": 5 }, { - "name": "36. UART", + "name": "37. UART", "type": "Reading", "subtype": "UART", "page": "", @@ -531,14 +545,14 @@ "line": 2, "speed": 9600, "eventFormat": 0, - "num": 36 + "num": 37 }, { "header": "Исполнительные устройства" }, { "global": 0, - "name": "37. Кнопка подключенная к пину", + "name": "38. Кнопка подключенная к пину", "type": "Writing", "subtype": "ButtonIn", "id": "btn", @@ -552,11 +566,11 @@ "pinMode": "INPUT", "debounceDelay": 50, "fixState": 0, - "num": 37 + "num": 38 }, { "global": 0, - "name": "38. Управление пином", + "name": "39. Управление пином", "type": "Writing", "subtype": "ButtonOut", "needSave": 0, @@ -567,11 +581,11 @@ "int": 0, "inv": 0, "pin": 2, - "num": 38 + "num": 39 }, { "global": 0, - "name": "39. Сервопривод", + "name": "40. Сервопривод", "type": "Writing", "subtype": "IoTServo", "id": "servo", @@ -582,11 +596,11 @@ "pin": 12, "apin": -1, "amap": "0, 4096, 0, 180", - "num": 39 + "num": 40 }, { "global": 0, - "name": "40. Расширитель портов Mcp23017", + "name": "41. Расширитель портов Mcp23017", "type": "Reading", "subtype": "Mcp23017", "id": "Mcp", @@ -596,11 +610,11 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 40 + "num": 41 }, { "global": 0, - "name": "41. MP3 плеер", + "name": "42. MP3 плеер", "type": "Reading", "subtype": "Mp3", "id": "mp3", @@ -610,11 +624,11 @@ "int": 1, "pins": "14,12", "volume": 20, - "num": 41 + "num": 42 }, { "global": 0, - "name": "42. Сенсорная кнопка", + "name": "43. Сенсорная кнопка", "type": "Writing", "subtype": "Multitouch", "id": "impulse", @@ -628,11 +642,11 @@ "pinMode": "INPUT", "debounceDelay": 50, "PWMDelay": 500, - "num": 42 + "num": 43 }, { "global": 0, - "name": "43. Расширитель портов Pcf8574", + "name": "44. Расширитель портов Pcf8574", "type": "Reading", "subtype": "Pcf8574", "id": "Pcf", @@ -642,11 +656,11 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 43 + "num": 44 }, { "global": 0, - "name": "44. PWM ESP8266", + "name": "45. PWM ESP8266", "type": "Writing", "subtype": "Pwm8266", "id": "pwm", @@ -658,11 +672,11 @@ "freq": 5000, "val": 0, "apin": -1, - "num": 44 + "num": 45 }, { "global": 0, - "name": "45. Телеграм-Лайт", + "name": "46. Телеграм-Лайт", "type": "Writing", "subtype": "TelegramLT", "id": "tg", @@ -671,14 +685,14 @@ "descr": "", "token": "", "chatID": "", - "num": 45 + "num": 46 }, { "header": "Экраны" }, { "global": 0, - "name": "46. LCD экран 2004", + "name": "47. LCD экран 2004", "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -690,10 +704,10 @@ "size": "20,4", "coord": "0,0", "id2show": "id датчика", - "num": 46 + "num": 47 }, { - "name": "47. LCD экран 1602", + "name": "48. LCD экран 1602", "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -705,6 +719,6 @@ "size": "16,2", "coord": "0,0", "id2show": "id датчика", - "num": 47 + "num": 48 } ] \ No newline at end of file diff --git a/myProfile.json b/myProfile.json index 8d86cea2..c2d9cd48 100644 --- a/myProfile.json +++ b/myProfile.json @@ -50,6 +50,10 @@ "path": "src/modules/virtual/Variable", "active": true }, + { + "path": "src/modules/virtual/VariableColor", + "active": true + }, { "path": "src/modules/virtual/VButton", "active": true diff --git a/platformio.ini b/platformio.ini index 117bb9e5..d95e5db4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -264,6 +264,7 @@ build_src_filter = + + + + + + + + diff --git a/src/modules/API.cpp b/src/modules/API.cpp index 12df2c22..02ae7391 100644 --- a/src/modules/API.cpp +++ b/src/modules/API.cpp @@ -5,6 +5,7 @@ void* getAPI_Loging(String subtype, String params); void* getAPI_LogingDaily(String subtype, String params); void* getAPI_Timer(String subtype, String params); void* getAPI_Variable(String subtype, String params); +void* getAPI_VariableColor(String subtype, String params); void* getAPI_VButton(String subtype, String params); void* getAPI_Acs712(String subtype, String params); void* getAPI_AhtXX(String subtype, String params); @@ -36,6 +37,7 @@ if ((tmpAPI = getAPI_Loging(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_LogingDaily(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Timer(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Variable(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_VariableColor(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_VButton(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Acs712(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_AhtXX(subtype, params)) != nullptr) return tmpAPI; diff --git a/src/modules/virtual/VariableColor/VariableColor.cpp b/src/modules/virtual/VariableColor/VariableColor.cpp new file mode 100644 index 00000000..4bdc4bff --- /dev/null +++ b/src/modules/virtual/VariableColor/VariableColor.cpp @@ -0,0 +1,46 @@ +#include "Global.h" +#include "classes/IoTItem.h" + +// дочь - родитель +class VariableColor : public IoTItem +{ +private: +public: + VariableColor(String parameters) : IoTItem(parameters) + { + } + + void doByInterval() + { + } + + // событие когда пользователь подключается приложением или веб интерфейсом к усройству + void onMqttWsAppConnectEvent() + { + SerialPrint("i", "Connecting", "Dashbord open "); + regEvent(value.valD, "VariableColor", false, true); + } + + IoTValue execute(String command, std::vector ¶m) + { + if (command == "widget" && param.size() == 2) + { + String json = "{}"; + jsonWriteStr(json, param[0].valS, param[1].valS); + sendSubWidgetsValues(_id, json); + } + return {}; + } +}; + +void *getAPI_VariableColor(String subtype, String param) +{ + if (subtype == F("VariableColor")) + { + return new VariableColor(param); + } + else + { + return nullptr; + } +} diff --git a/src/modules/virtual/VariableColor/modinfo.json b/src/modules/virtual/VariableColor/modinfo.json new file mode 100644 index 00000000..7a2a6d72 --- /dev/null +++ b/src/modules/virtual/VariableColor/modinfo.json @@ -0,0 +1,46 @@ +{ + "menuSection": "Виртуальные элементы", + "configItem": [ + { + "global": 0, + "name": "Цветной текст", + "type": "Reading", + "subtype": "VariableColor", + "id": "color", + "needSave": 0, + "widget": "anydataDef", + "page": "Вывод", + "descr": "Цветной текст", + "val": "...", + "round": 0 + } + ], + "about": { + "authorName": "AVAKS", + "authorContact": "https://t.me/@avaks_dev", + "authorGit": "https://github.com/avaksru", + "specialThanks": "", + "moduleName": "VariableColor", + "moduleVersion": "1", + "usedRam": { + "esp32_4mb": 15, + "esp8266_4mb": 15 + }, + "title": "Цветной текст", + "moduleDesc": "Текст с возможностью динамического изменения цвета", + "propInfo": { + "val": "Значение при старте" + } + }, + + "defActive": true, + + "usedLibs": { + "esp32_4mb": [], + "esp8266_4mb": [], + "esp8266_1mb": [], + "esp8266_1mb_ota": [], + "esp8285_1mb": [], + "esp8285_1mb_ota": [] + } +} \ No newline at end of file