Merge branch 'ver4dev' of https://github.com/biveraxe/IoTManager into ver4dev

This commit is contained in:
2022-11-14 11:49:55 +05:00
6 changed files with 183 additions and 13 deletions

View File

@@ -545,7 +545,6 @@
"int": 5
},
{
"global": 0,
"name": "39. UART",
"type": "Reading",
"subtype": "UART",
@@ -556,6 +555,7 @@
"tx": 12,
"rx": 13,
"speed": 9600,
"eventFormat": 0,
"num": 39
},
{
@@ -639,7 +639,25 @@
},
{
"global": 0,
"name": "45. Расширитель портов Pcf8574",
"name": "45. Сенсорная кнопка",
"type": "Writing",
"subtype": "Multitouch",
"id": "impulse",
"widget": "anydataDef",
"page": "Кнопки",
"descr": "Количество нажаний",
"needSave": 0,
"int": 300,
"inv": 1,
"pin": 16,
"pinMode": "INPUT",
"debounceDelay": 50,
"PWMDelay": 500,
"num": 45
},
{
"global": 0,
"name": "46. Расширитель портов Pcf8574",
"type": "Reading",
"subtype": "Pcf8574",
"id": "Pcf",
@@ -649,11 +667,11 @@
"int": "0",
"addr": "0x20",
"index": 1,
"num": 45
"num": 46
},
{
"global": 0,
"name": "46. PWM ESP8266",
"name": "47. PWM ESP8266",
"type": "Writing",
"subtype": "Pwm8266",
"id": "pwm",
@@ -665,11 +683,11 @@
"freq": 5000,
"val": 0,
"apin": -1,
"num": 46
"num": 47
},
{
"global": 0,
"name": "47. Телеграм-Лайт",
"name": "48. Телеграм-Лайт",
"type": "Writing",
"subtype": "TelegramLT",
"id": "tg",
@@ -678,14 +696,14 @@
"descr": "",
"token": "",
"chatID": "",
"num": 47
"num": 48
},
{
"header": "Экраны"
},
{
"global": 0,
"name": "48. LCD экран 2004",
"name": "49. LCD экран 2004",
"type": "Reading",
"subtype": "Lcd2004",
"id": "Lcd",
@@ -697,10 +715,10 @@
"size": "20,4",
"coord": "0,0",
"id2show": "id датчика",
"num": 48
"num": 49
},
{
"name": "49. LCD экран 1602",
"name": "50. LCD экран 1602",
"type": "Reading",
"subtype": "Lcd2004",
"id": "Lcd",
@@ -712,11 +730,11 @@
"size": "16,2",
"coord": "0,0",
"id2show": "id датчика",
"num": 49
"num": 50
},
{
"global": 0,
"name": "50. Strip ws2812b",
"name": "51. Strip ws2812b",
"type": "Reading",
"subtype": "Ws2812b",
"id": "strip",
@@ -732,6 +750,6 @@
"min": "15",
"max": "30",
"idshow": "t",
"num": 50
"num": 51
}
]

View File

@@ -173,6 +173,10 @@
"path": "src/modules/exec/Mp3",
"active": true
},
{
"path": "src/modules/exec/Multitouch",
"active": true
},
{
"path": "src/modules/exec/Pcf8574",
"active": true

View File

@@ -185,6 +185,7 @@ build_src_filter =
+<modules/exec/IoTServo>
+<modules/exec/Mcp23017>
+<modules/exec/Mp3>
+<modules/exec/Multitouch>
+<modules/exec/Pcf8574>
+<modules/exec/Pwm8266>
+<modules/exec/TelegramLT>

View File

@@ -27,6 +27,7 @@ void* getAPI_ButtonOut(String subtype, String params);
void* getAPI_IoTServo(String subtype, String params);
void* getAPI_Mcp23017(String subtype, String params);
void* getAPI_Mp3(String subtype, String params);
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);
@@ -62,6 +63,7 @@ if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_IoTServo(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Mcp23017(subtype, params)) != nullptr) return tmpAPI;
if ((tmpAPI = getAPI_Mp3(subtype, params)) != nullptr) return tmpAPI;
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;

View File

@@ -0,0 +1,94 @@
#include "Global.h"
#include "classes/IoTItem.h"
extern IoTGpio IoTgpio;
class Multitouch : public IoTItem
{
private:
int _pin;
int _int;
int _inv;
String _pinMode;
int _lastButtonState = LOW;
unsigned long _lastDebounceTime = 0;
unsigned long timing;
long _debounceDelay = 50;
long _PWMDelay = 500;
int _buttonState;
int _reading;
int _count = 0;
int duration = 0;
public:
Multitouch(String parameters) : IoTItem(parameters)
{
jsonRead(parameters, "pin", _pin);
jsonRead(parameters, "pinMode", _pinMode);
jsonRead(parameters, "debounceDelay", _debounceDelay);
jsonRead(parameters, "PWMDelay", _PWMDelay);
jsonRead(parameters, "int", _int);
jsonRead(parameters, "inv", _inv);
_round = 0;
IoTgpio.pinMode(_pin, INPUT);
if (_pinMode == "INPUT_PULLUP")
IoTgpio.digitalWrite(_pin, HIGH);
else if (_pinMode == "INPUT_PULLDOWN")
IoTgpio.digitalWrite(_pin, LOW);
value.valD = _buttonState = IoTgpio.digitalRead(_pin);
// сообщаем всем о стартовом статусе без генерации события
regEvent(_buttonState, "", false, false);
}
void loop()
{
_reading = IoTgpio.digitalRead(_pin);
if (_reading != _lastButtonState)
{
_lastDebounceTime = millis();
}
if ((millis() - _lastDebounceTime) > _debounceDelay)
{
if (millis() - timing > _int && _reading == _inv && millis() - _lastDebounceTime > _PWMDelay)
{
timing = millis();
duration = millis() - _lastDebounceTime - _PWMDelay;
value.valD = duration / 50;
regEvent(value.valD, "Multitouch");
_count = -1;
}
if (_reading != _buttonState)
{
_buttonState = _reading;
_count++;
duration = 0;
}
if (1 < _count && millis() > _lastDebounceTime + _PWMDelay)
{
value.valD = _count / 2;
regEvent(value.valD, "Multitouch");
_count = 0;
}
}
_lastButtonState = _reading;
}
~Multitouch(){};
};
void *getAPI_Multitouch(String subtype, String param)
{
if (subtype == F("Multitouch"))
{
return new Multitouch(param);
}
else
{
return nullptr;
}
}

View File

@@ -0,0 +1,51 @@
{
"menuSection": "Исполнительные устройства",
"configItem": [
{
"global": 0,
"name": "Сенсорная кнопка",
"type": "Writing",
"subtype": "Multitouch",
"id": "impulse",
"widget": "anydataDef",
"page": "Кнопки",
"descr": "Количество нажаний",
"needSave": 0,
"int": 300,
"inv": 1,
"pin": 16,
"pinMode": "INPUT",
"debounceDelay": 50,
"PWMDelay": 500
}
],
"about": {
"authorName": "AVAKS",
"authorContact": "https://t.me/@avaks_dev",
"authorGit": "https://github.com/avaksru",
"specialThanks": "",
"moduleName": "Multitouch",
"moduleVersion": "1.0",
"usedRam": {
"esp32_4mb": 15,
"esp8266_4mb": 15
},
"title": "Модуль чтения состояния GPIO (pin)",
"moduleDesc": "Считает количество нажатий на выключатель без фиксации или сенсорную кнопку. При удержании кнопки нажатой - считает длительность нажатия. Позволяет реализовать логику работы: включения различных устройств в зависимости от количества нажатий, диммировать яркость удержанием выключателя нажатым, а так же счетчик импульсов, дверной звонок, сенсорный выключатель, концевой выключатель, датчик открытия окна, и т.п.",
"propInfo": {
"int": "Интервал отправки времени удержания кнопки (миллисекунд)",
"pin": "Укажите GPIO номер пина для чтения состояний подключенной кнопки",
"inv": "Инверсия GPIO",
"pinMode": "Может быть INPUT_PULLUP INPUT_PULLDOWN INPUT",
"debounceDelay": "Время обработки дребезга (миллисекунд)",
"PWMDelay": "Время ожидания повторного нажатия. И время после которого начитается отсчет длительности непрерывного ражатия (миллисекунд)"
}
},
"defActive": true,
"usedLibs": {
"esp32_4mb": [],
"esp8266_4mb": [],
"esp8266_1mb": [],
"esp8266_1mb_ota": []
}
}