From 58bba94f019fce1bd94e4d82e8296b5360635805 Mon Sep 17 00:00:00 2001 From: biver Date: Sun, 30 Apr 2023 10:35:46 +0300 Subject: [PATCH 01/14] =?UTF-8?q?=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D1=81=D0=B1=D0=BE=D1=80=D0=BA=D1=83=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=83=D0=BC=D0=BE=D0=BB=D1=87=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_svelte/items.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/data_svelte/items.json b/data_svelte/items.json index 9e0e2f57..7e530a2f 100644 --- a/data_svelte/items.json +++ b/data_svelte/items.json @@ -202,6 +202,11 @@ "round": 3, "pin": 39, "int": 5, + "rms": 1, + "vref": 5000, + "sens": 100, + "adczero": 512, + "btn-setZero": "nil", "num": 13 }, { @@ -394,6 +399,7 @@ "pin": 16, "pinMode": "INPUT", "debounceDelay": 3, + "multiply": 1, "num": 26 }, { From 80b40373ddd004ec536843dfc7cbd5346a9034a2 Mon Sep 17 00:00:00 2001 From: biver Date: Sun, 30 Apr 2023 11:57:01 +0300 Subject: [PATCH 02/14] =?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=B1=D0=B0=D0=B3=20=D1=81=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=BE=D0=B9=20IoTGpio=20=D0=BD=D0=B0?= =?UTF-8?q?=20=D0=B8=D0=BD=D0=B4=D0=B5=D0=BA=D1=81=D0=B0=D1=85=203=20?= =?UTF-8?q?=D0=B8=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/classes/IoTGpio.h | 12 ++++++------ src/classes/IoTGpio.cpp | 12 ++++++------ src/modules/exec/Mcp23008/Mcp23008.cpp | 8 ++++---- src/modules/exec/Mcp23017/Mcp23017.cpp | 8 ++++---- src/modules/exec/Pcf8574/Pcf8574.cpp | 14 +++++++------- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/classes/IoTGpio.h b/include/classes/IoTGpio.h index 8f3175ab..ede36c2a 100644 --- a/include/classes/IoTGpio.h +++ b/include/classes/IoTGpio.h @@ -6,12 +6,12 @@ class IoTGpio { IoTGpio(int pins); ~IoTGpio(); - virtual void pinMode(uint8_t pin, uint8_t mode); - virtual void digitalWrite(uint8_t pin, uint8_t val); - virtual int digitalRead(uint8_t pin); - virtual int analogRead(uint8_t pin); - virtual void analogWrite(uint8_t pin, int val); - virtual void digitalInvert(uint8_t pin); + virtual void pinMode(int pin, uint8_t mode); + virtual void digitalWrite(int pin, uint8_t val); + virtual int digitalRead(int pin); + virtual int analogRead(int pin); + virtual void analogWrite(int pin, int val); + virtual void digitalInvert(int pin); int index; void regDriver(IoTGpio* newDriver); diff --git a/src/classes/IoTGpio.cpp b/src/classes/IoTGpio.cpp index 71e01b49..f5bef51f 100644 --- a/src/classes/IoTGpio.cpp +++ b/src/classes/IoTGpio.cpp @@ -10,32 +10,32 @@ IoTGpio::~IoTGpio(){ } -void IoTGpio::pinMode(uint8_t pin, uint8_t mode) { +void IoTGpio::pinMode(int pin, uint8_t mode) { int pinH = pin/100; if (_drivers[pinH]) _drivers[pinH]->pinMode(pin - pinH*100, mode); else ::pinMode(pin, mode); } -void IoTGpio::digitalWrite(uint8_t pin, uint8_t val) { +void IoTGpio::digitalWrite(int pin, uint8_t val) { int pinH = pin/100; if (_drivers[pinH]) _drivers[pinH]->digitalWrite(pin - pinH*100, val); else ::digitalWrite(pin, val); } -int IoTGpio::digitalRead(uint8_t pin) { +int IoTGpio::digitalRead(int pin) { int pinH = pin/100; if (_drivers[pinH]) return _drivers[pinH]->digitalRead(pin - pinH*100); else return ::digitalRead(pin); } -int IoTGpio::analogRead(uint8_t pin) { +int IoTGpio::analogRead(int pin) { int pinH = pin/100; if (_drivers[pinH]) return _drivers[pinH]->analogRead(pin - pinH*100); else return ::analogRead(pin); } -void IoTGpio::analogWrite(uint8_t pin, int val) { +void IoTGpio::analogWrite(int pin, int val) { int pinH = pin/100; if (_drivers[pinH]) _drivers[pinH]->analogWrite(pin - pinH*100, val); else { @@ -48,7 +48,7 @@ void IoTGpio::analogWrite(uint8_t pin, int val) { } } -void IoTGpio::digitalInvert(uint8_t pin) { +void IoTGpio::digitalInvert(int pin) { int pinH = pin/100; if (_drivers[pinH]) _drivers[pinH]->digitalInvert(pin - pinH*100); else ::digitalWrite(pin, 1 - ::digitalRead(pin)); diff --git a/src/modules/exec/Mcp23008/Mcp23008.cpp b/src/modules/exec/Mcp23008/Mcp23008.cpp index fef91121..956b2d8f 100644 --- a/src/modules/exec/Mcp23008/Mcp23008.cpp +++ b/src/modules/exec/Mcp23008/Mcp23008.cpp @@ -14,19 +14,19 @@ class Mcp23008Driver : public IoTGpio { } } - void pinMode(uint8_t pin, uint8_t mode) { + void pinMode(int pin, uint8_t mode) { _mcp.pinMode(pin, mode); } - void digitalWrite(uint8_t pin, uint8_t val) { + void digitalWrite(int pin, uint8_t val) { _mcp.digitalWrite(pin, val); } - int digitalRead(uint8_t pin) { + int digitalRead(int pin) { return _mcp.digitalRead(pin); } - void digitalInvert(uint8_t pin) { + void digitalInvert(int pin) { _mcp.digitalWrite(pin, 1 - _mcp.digitalRead(pin)); } diff --git a/src/modules/exec/Mcp23017/Mcp23017.cpp b/src/modules/exec/Mcp23017/Mcp23017.cpp index b5fc7f06..b22cf151 100644 --- a/src/modules/exec/Mcp23017/Mcp23017.cpp +++ b/src/modules/exec/Mcp23017/Mcp23017.cpp @@ -14,19 +14,19 @@ class Mcp23017Driver : public IoTGpio { } } - void pinMode(uint8_t pin, uint8_t mode) { + void pinMode(int pin, uint8_t mode) { _mcp.pinMode(pin, mode); } - void digitalWrite(uint8_t pin, uint8_t val) { + void digitalWrite(int pin, uint8_t val) { _mcp.digitalWrite(pin, val); } - int digitalRead(uint8_t pin) { + int digitalRead(int pin) { return _mcp.digitalRead(pin); } - void digitalInvert(uint8_t pin) { + void digitalInvert(int pin) { _mcp.digitalWrite(pin, 1 - _mcp.digitalRead(pin)); } diff --git a/src/modules/exec/Pcf8574/Pcf8574.cpp b/src/modules/exec/Pcf8574/Pcf8574.cpp index 962feea5..f7b5454a 100644 --- a/src/modules/exec/Pcf8574/Pcf8574.cpp +++ b/src/modules/exec/Pcf8574/Pcf8574.cpp @@ -30,7 +30,7 @@ class Adafruit_PCF8574_mod { return _readbuf; } - bool digitalWrite(uint8_t pinnum, bool val) { + bool digitalWrite(int pinnum, bool val) { if (val) { _writebuf |= 1 << pinnum; } else { @@ -39,7 +39,7 @@ class Adafruit_PCF8574_mod { return i2c_dev->write(&_writebuf, 1); } - bool pinMode(uint8_t pinnum, uint8_t val) { + bool pinMode(int pinnum, uint8_t val) { if ((val == INPUT) || (val == INPUT_PULLUP)) { _writebuf |= 1 << pinnum; } else { @@ -48,7 +48,7 @@ class Adafruit_PCF8574_mod { return i2c_dev->write(&_writebuf, 1); } - bool digitalRead(uint8_t pinnum) { + bool digitalRead(int pinnum) { i2c_dev->read(&_readbuf, 1); return (_readbuf >> pinnum) & 0x1; } @@ -70,19 +70,19 @@ class Pcf8574Driver : public IoTGpio { } } - void pinMode(uint8_t pin, uint8_t mode) { + void pinMode(int pin, uint8_t mode) { _pcf.pinMode(pin, mode); } - void digitalWrite(uint8_t pin, uint8_t val) { + void digitalWrite(int pin, uint8_t val) { _pcf.digitalWrite(pin, val); } - int digitalRead(uint8_t pin) { + int digitalRead(int pin) { return _pcf.digitalRead(pin); } - void digitalInvert(uint8_t pin) { + void digitalInvert(int pin) { _pcf.digitalWrite(pin, 1 - _pcf.digitalRead(pin)); } From 0dbcba4409d6d1358ae4eb7a0363e1c9a2c0dd74 Mon Sep 17 00:00:00 2001 From: biver Date: Sun, 30 Apr 2023 16:23:11 +0300 Subject: [PATCH 03/14] =?UTF-8?q?=D0=A3=D0=B1=D0=B8=D1=80=D0=B0=D0=B5?= =?UTF-8?q?=D0=BC=20=D0=B8=D0=B7=20EspCam=20=D0=B8=20SDcard=20=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D1=80=D1=8B=D0=B9=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82?= =?UTF-8?q?=20IoTValue=20=D0=B4=D0=BB=D1=8F=20=D1=8D=D0=BA=D1=81=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B8=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/exec/EspCam/EspCam.cpp | 52 ++++++++++++++++-------------- src/modules/exec/SDcard/SDcard.cpp | 24 +++++++------- 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/modules/exec/EspCam/EspCam.cpp b/src/modules/exec/EspCam/EspCam.cpp index 39866484..6f75ca52 100644 --- a/src/modules/exec/EspCam/EspCam.cpp +++ b/src/modules/exec/EspCam/EspCam.cpp @@ -2,8 +2,8 @@ #include "classes/IoTItem.h" #include "esp_camera.h" -#include "soc/soc.h" // Disable brownour problems -#include "soc/rtc_cntl_reg.h" // Disable brownour problems +// #include "soc/soc.h" // Disable brownour problems +// #include "soc/rtc_cntl_reg.h" // Disable brownour problems // Pin definition for CAMERA_MODEL_AI_THINKER @@ -32,12 +32,12 @@ IoTItem* globalItem = nullptr; bool webTicker = false; void handleGetCam() { - //Serial.printf("try send pic by size=%d", lastPhotoBSize); - if (globalItem && globalItem->value.extBinInfoSize) { - //Serial.printf("try send pic by size=%d", globalItem->value.extBinInfoSize); - HTTP.send_P(200, "image/jpeg", (char*)globalItem->value.extBinInfo, globalItem->value.extBinInfoSize); - if (webTicker) globalItem->regEvent("webAsk", "EspCam"); - } else HTTP.send(200, "text/json", "Item EspCam not prepared yet or camera hasn't taken a picture yet"); + ////Serial.printf("try send pic by size=%d", lastPhotoBSize); + // if (globalItem && globalItem->value.extBinInfoSize) { + // //Serial.printf("try send pic by size=%d", globalItem->value.extBinInfoSize); + // HTTP.send_P(200, "image/jpeg", (char*)globalItem->value.extBinInfo, globalItem->value.extBinInfoSize); + // if (webTicker) globalItem->regEvent("webAsk", "EspCam"); + // } else HTTP.send(200, "text/json", "Item EspCam not prepared yet or camera hasn't taken a picture yet"); } class EspCam : public IoTItem { @@ -47,7 +47,7 @@ class EspCam : public IoTItem { public: EspCam(String parameters): IoTItem(parameters) { - WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector + //WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector jsonRead(parameters, "useLed", _useLed); // используем = 1 или нет = 0 подсветку (вспышку) jsonRead(parameters, "ticker", _ticker); // тикать = 1 - сообщаем всем, что сделали снимок и он готов @@ -55,8 +55,8 @@ class EspCam : public IoTItem { webTicker = _webTicker; globalItem = this; // выносим адрес переменной экземпляра для доступа к данным из обработчика событий веб - pinMode(4, OUTPUT); - digitalWrite(4, LOW); + //pinMode(4, OUTPUT); + //digitalWrite(4, LOW); camera_config_t config; config.ledc_channel = LEDC_CHANNEL_0; @@ -80,16 +80,18 @@ class EspCam : public IoTItem { config.xclk_freq_hz = 20000000; config.pixel_format = PIXFORMAT_JPEG; - value.extBinInfo = (uint8_t*)malloc(sizeof(uint8_t) * PICBUF_SIZE); + config.grab_mode = CAMERA_GRAB_WHEN_EMPTY; + + //value.extBinInfo = (uint8_t*)malloc(sizeof(uint8_t) * PICBUF_SIZE); if(psramFound()){ - config.frame_size = FRAMESIZE_SVGA; // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA - config.jpeg_quality = 20; //0-63 lower number means higher quality + config.frame_size = FRAMESIZE_QVGA; // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA + config.jpeg_quality = 12; //0-63 lower number means higher quality config.fb_count = 1; Serial.printf("Camera psramFound\n"); } else { - config.frame_size = FRAMESIZE_SVGA; - config.jpeg_quality = 20; + config.frame_size = FRAMESIZE_QVGA; + config.jpeg_quality = 12; config.fb_count = 1; } @@ -116,12 +118,12 @@ class EspCam : public IoTItem { return; } - // if (value.extBinInfoSize < fb->len) { - // if (value.extBinInfo) free(value.extBinInfo); - // value.extBinInfo = (uint8_t*)malloc(sizeof(uint8_t) * fb->len); - // } - memcpy(value.extBinInfo, fb->buf, fb->len); - value.extBinInfoSize = fb->len; + // // if (value.extBinInfoSize < fb->len) { + // // if (value.extBinInfo) free(value.extBinInfo); + // // value.extBinInfo = (uint8_t*)malloc(sizeof(uint8_t) * fb->len); + // // } + // memcpy(value.extBinInfo, fb->buf, fb->len); + // value.extBinInfoSize = fb->len; Serial.printf("try send pic by size=%d", fb->len); @@ -131,7 +133,7 @@ class EspCam : public IoTItem { } void doByInterval() { - take_picture(); + //take_picture(); } IoTValue execute(String command, std::vector ¶m) { @@ -143,8 +145,8 @@ class EspCam : public IoTItem { } ~EspCam() { - free(value.extBinInfo); - //globalItem = nullptr; + //free(value.extBinInfo); + globalItem = nullptr; }; }; diff --git a/src/modules/exec/SDcard/SDcard.cpp b/src/modules/exec/SDcard/SDcard.cpp index 6fecb900..0b430f18 100644 --- a/src/modules/exec/SDcard/SDcard.cpp +++ b/src/modules/exec/SDcard/SDcard.cpp @@ -28,18 +28,18 @@ class SDcard : public IoTItem { } void savePicture(String path, IoTValue srcValue) { - if (srcValue.extBinInfoSize) { - fs::FS &fs = SD_MMC; - File file = fs.open(path.c_str(), FILE_WRITE); - if(!file){ - Serial.println("Failed to open file in writing mode"); - } - else { - file.write(srcValue.extBinInfo, srcValue.extBinInfoSize); // payload (image), payload length - Serial.printf("Picture file name: %s | bufsize: %d\n", path.c_str(), srcValue.extBinInfoSize); - } - file.close(); - } + // if (srcValue.extBinInfoSize) { + // fs::FS &fs = SD_MMC; + // File file = fs.open(path.c_str(), FILE_WRITE); + // if(!file){ + // Serial.println("Failed to open file in writing mode"); + // } + // else { + // file.write(srcValue.extBinInfo, srcValue.extBinInfoSize); // payload (image), payload length + // Serial.printf("Picture file name: %s | bufsize: %d\n", path.c_str(), srcValue.extBinInfoSize); + // } + // file.close(); + // } } void doByInterval() { From 1d04aae9e99cfebf895e1a54221223c16da6418e Mon Sep 17 00:00:00 2001 From: biver Date: Sun, 30 Apr 2023 21:30:37 +0300 Subject: [PATCH 04/14] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D1=8B=D0=B2=D0=B0=D0=B5=D0=BC=20esp32cam=20=D0=A2=D0=B5?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D1=8C=20=D0=B1=D0=BE=D0=BB=D1=8C=D1=88=D0=B5?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B5=D0=B4=D0=B2=D0=B0=D1=80=D0=B8=D1=82=D0=B5?= =?UTF-8?q?=D0=BB=D1=8C=D0=BD=D1=8B=D1=85=20=D0=BD=D0=B0=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=B5=D0=BA=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B7?= =?UTF-8?q?=D0=BD=D1=8B=D1=85=20=D0=BF=D0=BB=D0=B0=D1=82=20WROVER=5FKIT=20?= =?UTF-8?q?//=20Has=20PSRAM=20ESP=5FEYE=20//=20Has=20PSRAM=20ESP32S3=5FEYE?= =?UTF-8?q?=20//=20Has=20PSRAM=20M5STACK=5FPSRAM=20//=20Has=20PSRAM=20M5ST?= =?UTF-8?q?ACK=5FV2=5FPSRAM=20//=20M5Camera=20version=20B=20Has=20PSRAM=20?= =?UTF-8?q?M5STACK=5FWIDE=20//=20Has=20PSRAM=20M5STACK=5FESP32CAM=20//=20N?= =?UTF-8?q?o=20PSRAM=20M5STACK=5FUNITCAM=20//=20No=20PSRAM=20TTGO=5FT=5FJO?= =?UTF-8?q?URNAL=20//=20No=20PSRAM=20XIAO=5FESP32S3=20//=20Has=20PSRAM=20E?= =?UTF-8?q?SP32=5FCAM=5FBOARD=20ESP32S2=5FCAM=5FBOARD=20ESP32S3=5FCAM=5FLC?= =?UTF-8?q?D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/exec/EspCam/EspCam.cpp | 189 ++++++++++------ src/modules/exec/EspCam/camera_pins.h | 298 ++++++++++++++++++++++++++ src/modules/exec/EspCam/modinfo.json | 22 +- 3 files changed, 434 insertions(+), 75 deletions(-) create mode 100644 src/modules/exec/EspCam/camera_pins.h diff --git a/src/modules/exec/EspCam/EspCam.cpp b/src/modules/exec/EspCam/EspCam.cpp index 6f75ca52..4d609b69 100644 --- a/src/modules/exec/EspCam/EspCam.cpp +++ b/src/modules/exec/EspCam/EspCam.cpp @@ -2,62 +2,61 @@ #include "classes/IoTItem.h" #include "esp_camera.h" -// #include "soc/soc.h" // Disable brownour problems -// #include "soc/rtc_cntl_reg.h" // Disable brownour problems +#include "soc/soc.h" // Disable brownour problems +#include "soc/rtc_cntl_reg.h" // Disable brownour problems + +void handleGetPic(); + +// =================== +// Select camera model +// =================== +//#define CAMERA_MODEL_WROVER_KIT // Has PSRAM +//#define CAMERA_MODEL_ESP_EYE // Has PSRAM +//#define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM +//#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM +//#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM +//#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM +//#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM +//#define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM +#define CAMERA_MODEL_AI_THINKER // Has PSRAM +//#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM +//#define CAMERA_MODEL_XIAO_ESP32S3 // Has PSRAM +// ** Espressif Internal Boards ** +//#define CAMERA_MODEL_ESP32_CAM_BOARD +//#define CAMERA_MODEL_ESP32S2_CAM_BOARD +//#define CAMERA_MODEL_ESP32S3_CAM_LCD -// Pin definition for CAMERA_MODEL_AI_THINKER -#define PWDN_GPIO_NUM 32 -#define RESET_GPIO_NUM -1 -#define XCLK_GPIO_NUM 0 -#define SIOD_GPIO_NUM 26 -#define SIOC_GPIO_NUM 27 +#define LED_LEDC_CHANNEL 2 //Using different ledc channel/timer than camera +#define CONFIG_LED_MAX_INTENSITY 255 -#define Y9_GPIO_NUM 35 -#define Y8_GPIO_NUM 34 -#define Y7_GPIO_NUM 39 -#define Y6_GPIO_NUM 36 -#define Y5_GPIO_NUM 21 -#define Y4_GPIO_NUM 19 -#define Y3_GPIO_NUM 18 -#define Y2_GPIO_NUM 5 -#define VSYNC_GPIO_NUM 25 -#define HREF_GPIO_NUM 23 -#define PCLK_GPIO_NUM 22 - -#define PICBUF_SIZE 50000 +#include "camera_pins.h" IoTItem* globalItem = nullptr; -bool webTicker = false; -void handleGetCam() { - ////Serial.printf("try send pic by size=%d", lastPhotoBSize); - // if (globalItem && globalItem->value.extBinInfoSize) { - // //Serial.printf("try send pic by size=%d", globalItem->value.extBinInfoSize); - // HTTP.send_P(200, "image/jpeg", (char*)globalItem->value.extBinInfo, globalItem->value.extBinInfoSize); - // if (webTicker) globalItem->regEvent("webAsk", "EspCam"); - // } else HTTP.send(200, "text/json", "Item EspCam not prepared yet or camera hasn't taken a picture yet"); -} class EspCam : public IoTItem { private: - camera_fb_t * fb = NULL; bool _useLed, _ticker, _webTicker; public: + bool isUsedLed() { return _useLed; } + bool isWebTicker() { return _webTicker; } + EspCam(String parameters): IoTItem(parameters) { - //WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector + WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector jsonRead(parameters, "useLed", _useLed); // используем = 1 или нет = 0 подсветку (вспышку) + if (_useLed) { + ledcSetup(LED_LEDC_CHANNEL, 5000, 8); + ledcAttachPin(LED_GPIO_NUM, LED_LEDC_CHANNEL); + } + jsonRead(parameters, "ticker", _ticker); // тикать = 1 - сообщаем всем, что сделали снимок и он готов jsonRead(parameters, "webTicker", _webTicker); // сообщать всем, что через веб попросили отдать картинку с камеры - webTicker = _webTicker; globalItem = this; // выносим адрес переменной экземпляра для доступа к данным из обработчика событий веб - //pinMode(4, OUTPUT); - //digitalWrite(4, LOW); - camera_config_t config; config.ledc_channel = LEDC_CHANNEL_0; config.ledc_timer = LEDC_TIMER_0; @@ -78,45 +77,71 @@ class EspCam : public IoTItem { config.pin_pwdn = PWDN_GPIO_NUM; config.pin_reset = RESET_GPIO_NUM; config.xclk_freq_hz = 20000000; - config.pixel_format = PIXFORMAT_JPEG; - + config.frame_size = FRAMESIZE_UXGA; + config.pixel_format = PIXFORMAT_JPEG; // for streaming + //config.pixel_format = PIXFORMAT_RGB565; // for face detection/recognition config.grab_mode = CAMERA_GRAB_WHEN_EMPTY; - - //value.extBinInfo = (uint8_t*)malloc(sizeof(uint8_t) * PICBUF_SIZE); + config.fb_location = CAMERA_FB_IN_PSRAM; + config.jpeg_quality = 12; + config.fb_count = 1; + // if PSRAM IC present, init with UXGA resolution and higher JPEG quality + // for larger pre-allocated frame buffer. + if(psramFound()){ - config.frame_size = FRAMESIZE_QVGA; // FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA - config.jpeg_quality = 12; //0-63 lower number means higher quality - config.fb_count = 1; - Serial.printf("Camera psramFound\n"); + config.jpeg_quality = 10; + config.fb_count = 2; + config.grab_mode = CAMERA_GRAB_LATEST; } else { - config.frame_size = FRAMESIZE_QVGA; - config.jpeg_quality = 12; - config.fb_count = 1; + // Limit the frame size when PSRAM is not available + config.frame_size = FRAMESIZE_SVGA; + config.fb_location = CAMERA_FB_IN_DRAM; } - // Init Camera + #if defined(CAMERA_MODEL_ESP_EYE) + pinMode(13, INPUT_PULLUP); + pinMode(14, INPUT_PULLUP); + #endif + + // camera init esp_err_t err = esp_camera_init(&config); if (err != ESP_OK) { - Serial.printf("Camera init failed with error 0x%x\n", err); + Serial.printf("Camera init failed with error 0x%x", err); return; } - - HTTP.on("/getcam", HTTP_GET, handleGetCam); + + sensor_t * s = esp_camera_sensor_get(); + // initial sensors are flipped vertically and colors are a bit saturated + if (s->id.PID == OV3660_PID) { + s->set_vflip(s, 1); // flip it back + s->set_brightness(s, 1); // up the brightness just a bit + s->set_saturation(s, -2); // lower the saturation + } + + #if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM) + s->set_vflip(s, 1); + s->set_hmirror(s, 1); + #endif + + #if defined(CAMERA_MODEL_ESP32S3_EYE) + s->set_vflip(s, 1); + #endif + + HTTP.on("/getpic", HTTP_GET, handleGetPic); } - void take_picture() { - if (_useLed) digitalWrite(4, HIGH); //Turn on the flash + void save_picture() { + // if (_useLed) digitalWrite(4, HIGH); //Turn on the flash - // Take Picture with Camera - fb = esp_camera_fb_get(); - if(!fb || fb->len >= PICBUF_SIZE) { - if (fb) { - Serial.printf("Camera capture failed size=%d\n", fb->len); - esp_camera_fb_return(fb); - } else Serial.printf("Camera capture failed\n"); - return; - } + // // Take Picture with Camera + // fb = esp_camera_fb_get(); + // if(!fb || fb->len >= PICBUF_SIZE) { + // if (fb) { + // Serial.printf("Camera capture failed size=%d\n", fb->len); + // esp_camera_fb_return(fb); + // } else Serial.printf("Camera capture failed\n"); + // return; + // } // // if (value.extBinInfoSize < fb->len) { // // if (value.extBinInfo) free(value.extBinInfo); @@ -125,20 +150,26 @@ class EspCam : public IoTItem { // memcpy(value.extBinInfo, fb->buf, fb->len); // value.extBinInfoSize = fb->len; - Serial.printf("try send pic by size=%d", fb->len); + // Serial.printf("try send pic by size=%d", fb->len); - if (_useLed) digitalWrite(4, LOW); - if (_ticker) regEvent("shot", "EspCam"); - esp_camera_fb_return(fb); + // if (_useLed) digitalWrite(4, LOW); + // if (_ticker) regEvent("shot", "EspCam"); + // esp_camera_fb_return(fb); } void doByInterval() { - //take_picture(); + //save_picture(); } IoTValue execute(String command, std::vector ¶m) { - if (command == "shot") { - take_picture(); + if (command == "save") { + save_picture(); + } else if (command == "ledOn" && param.size() == 1) { + ledcSetup(LED_LEDC_CHANNEL, 5000, 8); + ledcAttachPin(LED_GPIO_NUM, LED_LEDC_CHANNEL); + ledcWrite(LED_LEDC_CHANNEL, param[0].valD); + } else if (command == "ledOff") { + ledcWrite(LED_LEDC_CHANNEL, 0); } return {}; @@ -150,6 +181,26 @@ class EspCam : public IoTItem { }; }; +void handleGetPic() { + if (!globalItem) return; + + if (((EspCam*)globalItem)->isUsedLed()) ledcWrite(LED_LEDC_CHANNEL, CONFIG_LED_MAX_INTENSITY); //Turn on the flash + + camera_fb_t* fb = NULL; + fb = esp_camera_fb_get(); + if (!fb) { + HTTP.send(200, "text/json", F("Item EspCam not prepared yet or camera hasn't taken a picture yet")); + return; + } + + HTTP.send_P(200, "image/jpeg", (char *)fb->buf, fb->len); + + if (((EspCam*)globalItem)->isUsedLed()) ledcWrite(LED_LEDC_CHANNEL, 0); + if (((EspCam*)globalItem)->isWebTicker()) globalItem->regEvent("webTakesPhoto", "EspCam"); + esp_camera_fb_return(fb); +} + + void* getAPI_EspCam(String subtype, String param) { if (subtype == F("EspCam")) { return new EspCam(param); diff --git a/src/modules/exec/EspCam/camera_pins.h b/src/modules/exec/EspCam/camera_pins.h new file mode 100644 index 00000000..48f49093 --- /dev/null +++ b/src/modules/exec/EspCam/camera_pins.h @@ -0,0 +1,298 @@ + +#if defined(CAMERA_MODEL_WROVER_KIT) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 21 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 + +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 19 +#define Y4_GPIO_NUM 18 +#define Y3_GPIO_NUM 5 +#define Y2_GPIO_NUM 4 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 + +#elif defined(CAMERA_MODEL_ESP_EYE) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 4 +#define SIOD_GPIO_NUM 18 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 36 +#define Y8_GPIO_NUM 37 +#define Y7_GPIO_NUM 38 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 35 +#define Y4_GPIO_NUM 14 +#define Y3_GPIO_NUM 13 +#define Y2_GPIO_NUM 34 +#define VSYNC_GPIO_NUM 5 +#define HREF_GPIO_NUM 27 +#define PCLK_GPIO_NUM 25 + +#define LED_GPIO_NUM 22 + +#elif defined(CAMERA_MODEL_M5STACK_PSRAM) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 25 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 32 +#define VSYNC_GPIO_NUM 22 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 + +#elif defined(CAMERA_MODEL_M5STACK_V2_PSRAM) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 22 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 32 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 + +#elif defined(CAMERA_MODEL_M5STACK_WIDE) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 22 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 32 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 + +#define LED_GPIO_NUM 2 + +#elif defined(CAMERA_MODEL_M5STACK_ESP32CAM) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 25 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 17 +#define VSYNC_GPIO_NUM 22 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 + +#elif defined(CAMERA_MODEL_M5STACK_UNITCAM) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 25 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 32 +#define VSYNC_GPIO_NUM 22 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 + +#elif defined(CAMERA_MODEL_AI_THINKER) +#define PWDN_GPIO_NUM 32 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 0 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 + +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 21 +#define Y4_GPIO_NUM 19 +#define Y3_GPIO_NUM 18 +#define Y2_GPIO_NUM 5 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 + +// 4 for flash led or 33 for normal led +#define LED_GPIO_NUM 4 + +#elif defined(CAMERA_MODEL_TTGO_T_JOURNAL) +#define PWDN_GPIO_NUM 0 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 25 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 17 +#define VSYNC_GPIO_NUM 22 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 + +#elif defined(CAMERA_MODEL_XIAO_ESP32S3) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 10 +#define SIOD_GPIO_NUM 40 +#define SIOC_GPIO_NUM 39 + +#define Y9_GPIO_NUM 48 +#define Y8_GPIO_NUM 11 +#define Y7_GPIO_NUM 12 +#define Y6_GPIO_NUM 14 +#define Y5_GPIO_NUM 16 +#define Y4_GPIO_NUM 18 +#define Y3_GPIO_NUM 17 +#define Y2_GPIO_NUM 15 +#define VSYNC_GPIO_NUM 38 +#define HREF_GPIO_NUM 47 +#define PCLK_GPIO_NUM 13 + +#elif defined(CAMERA_MODEL_ESP32_CAM_BOARD) +// The 18 pin header on the board has Y5 and Y3 swapped +#define USE_BOARD_HEADER 0 +#define PWDN_GPIO_NUM 32 +#define RESET_GPIO_NUM 33 +#define XCLK_GPIO_NUM 4 +#define SIOD_GPIO_NUM 18 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 36 +#define Y8_GPIO_NUM 19 +#define Y7_GPIO_NUM 21 +#define Y6_GPIO_NUM 39 +#if USE_BOARD_HEADER +#define Y5_GPIO_NUM 13 +#else +#define Y5_GPIO_NUM 35 +#endif +#define Y4_GPIO_NUM 14 +#if USE_BOARD_HEADER +#define Y3_GPIO_NUM 35 +#else +#define Y3_GPIO_NUM 13 +#endif +#define Y2_GPIO_NUM 34 +#define VSYNC_GPIO_NUM 5 +#define HREF_GPIO_NUM 27 +#define PCLK_GPIO_NUM 25 + +#elif defined(CAMERA_MODEL_ESP32S3_CAM_LCD) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 40 +#define SIOD_GPIO_NUM 17 +#define SIOC_GPIO_NUM 18 + +#define Y9_GPIO_NUM 39 +#define Y8_GPIO_NUM 41 +#define Y7_GPIO_NUM 42 +#define Y6_GPIO_NUM 12 +#define Y5_GPIO_NUM 3 +#define Y4_GPIO_NUM 14 +#define Y3_GPIO_NUM 47 +#define Y2_GPIO_NUM 13 +#define VSYNC_GPIO_NUM 21 +#define HREF_GPIO_NUM 38 +#define PCLK_GPIO_NUM 11 + +#elif defined(CAMERA_MODEL_ESP32S2_CAM_BOARD) +// The 18 pin header on the board has Y5 and Y3 swapped +#define USE_BOARD_HEADER 0 +#define PWDN_GPIO_NUM 1 +#define RESET_GPIO_NUM 2 +#define XCLK_GPIO_NUM 42 +#define SIOD_GPIO_NUM 41 +#define SIOC_GPIO_NUM 18 + +#define Y9_GPIO_NUM 16 +#define Y8_GPIO_NUM 39 +#define Y7_GPIO_NUM 40 +#define Y6_GPIO_NUM 15 +#if USE_BOARD_HEADER +#define Y5_GPIO_NUM 12 +#else +#define Y5_GPIO_NUM 13 +#endif +#define Y4_GPIO_NUM 5 +#if USE_BOARD_HEADER +#define Y3_GPIO_NUM 13 +#else +#define Y3_GPIO_NUM 12 +#endif +#define Y2_GPIO_NUM 14 +#define VSYNC_GPIO_NUM 38 +#define HREF_GPIO_NUM 4 +#define PCLK_GPIO_NUM 3 + +#elif defined(CAMERA_MODEL_ESP32S3_EYE) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 15 +#define SIOD_GPIO_NUM 4 +#define SIOC_GPIO_NUM 5 + +#define Y2_GPIO_NUM 11 +#define Y3_GPIO_NUM 9 +#define Y4_GPIO_NUM 8 +#define Y5_GPIO_NUM 10 +#define Y6_GPIO_NUM 12 +#define Y7_GPIO_NUM 18 +#define Y8_GPIO_NUM 17 +#define Y9_GPIO_NUM 16 + +#define VSYNC_GPIO_NUM 6 +#define HREF_GPIO_NUM 7 +#define PCLK_GPIO_NUM 13 + +#else +#error "Camera model not selected" +#endif \ No newline at end of file diff --git a/src/modules/exec/EspCam/modinfo.json b/src/modules/exec/EspCam/modinfo.json index ec35a2a2..429beddf 100644 --- a/src/modules/exec/EspCam/modinfo.json +++ b/src/modules/exec/EspCam/modinfo.json @@ -23,23 +23,33 @@ "authorGit": "https://github.com/biveraxe", "specialThanks": "", "moduleName": "EspCam", - "moduleVersion": "1.0", + "moduleVersion": "2.1", "usedRam": { "esp32_4mb": 15, "esp8266_4mb": 15 }, "title": "Camera OV2640 (ESPcam)", - "moduleDesc": "Предназначен для специальной платы esp32 со встроенной камерой. Добавляет в прошивку функцию создания фото и сохранения в оперативную память. Для сброса на флешкарту необходимо использовать парный модуль SDcard. Это экспериментальные модули и в будущем планируется пересобрать их.", + "moduleDesc": "Предназначен для специальной платы esp32 со встроенной камерой. Добавляет в прошивку функцию создания фото и сохранения на SD при наличии. По адресу /getpic можно получить текущее фото (работает в том числе без SD карты).", "propInfo": { - "int": "Пауза в секундах во время постоянной съемки.", + "int": "Пауза в секундах во время постоянной фотосъемки.", "useLed": "использовать диод подсветки при съемке.", "ticker": "Генерировать(1) или нет(0) событие с интервалом int", - "webTicker": "Генерировать(1) или нет(0) событие при обращении через веб-страницу с текущим фото в памяти." + "webTicker": "Генерировать(1) или нет(0) событие при обращении через веб-страницу по адресу /getpic." }, "funcInfo": [ { - "name": "shot", - "descr": "Сделать снимок", + "name": "save", + "descr": "Сохранить снимок на SD", + "params": [] + }, + { + "name": "ledOn", + "descr": "Включить подсветку", + "params": ["Яркость 0-255"] + }, + { + "name": "ledOff", + "descr": "Отключить подсветку", "params": [] } ] From ac25014552cb992e3d07cee78ece23de246e02b7 Mon Sep 17 00:00:00 2001 From: biver Date: Mon, 1 May 2023 19:49:20 +0300 Subject: [PATCH 05/14] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B1=D1=83=D0=B5?= =?UTF-8?q?=D0=BC=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20SD?= =?UTF-8?q?=20=D0=BA=D0=B0=D1=80=D1=82=D1=83=20=D0=B2=20ESP32cam?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/exec/EspCam/EspCam.cpp | 70 ++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/src/modules/exec/EspCam/EspCam.cpp b/src/modules/exec/EspCam/EspCam.cpp index 4d609b69..59cd07fd 100644 --- a/src/modules/exec/EspCam/EspCam.cpp +++ b/src/modules/exec/EspCam/EspCam.cpp @@ -1,10 +1,14 @@ #include "Global.h" #include "classes/IoTItem.h" +#include "NTP.h" #include "esp_camera.h" #include "soc/soc.h" // Disable brownour problems #include "soc/rtc_cntl_reg.h" // Disable brownour problems +#include "FS.h" // SD Card ESP32 +#include "SD_MMC.h" // SD Card ESP32 + void handleGetPic(); // =================== @@ -38,7 +42,7 @@ IoTItem* globalItem = nullptr; class EspCam : public IoTItem { private: - bool _useLed, _ticker, _webTicker; + bool _useLed, _ticker, _webTicker, _initSD; public: bool isUsedLed() { return _useLed; } @@ -128,9 +132,28 @@ class EspCam : public IoTItem { #endif HTTP.on("/getpic", HTTP_GET, handleGetPic); + + // Start Micro SD card + _initSD = true; + Serial.println("Starting SD Card"); + if(!SD_MMC.begin("/sdcard", true)){ + Serial.println("SD Card Mount Failed"); + _initSD = false; + return; + } + + uint8_t cardType = SD_MMC.cardType(); + if(cardType == CARD_NONE){ + Serial.println("No SD Card attached"); + _initSD = false; + return; + } + + fs::FS &fs = SD_MMC; + fs.mkdir("/photos/"); } - void save_picture() { + void save_picture(String path = "") { // if (_useLed) digitalWrite(4, HIGH); //Turn on the flash // // Take Picture with Camera @@ -155,6 +178,44 @@ class EspCam : public IoTItem { // if (_useLed) digitalWrite(4, LOW); // if (_ticker) regEvent("shot", "EspCam"); // esp_camera_fb_return(fb); + + + // Save picture to microSD card + fs::FS &fs = SD_MMC; + + if (path == "") { + path = "/photos/"; + path += getTodayDateDotFormated(); + path += "/"; + fs.mkdir(path.c_str()); + + char buf[32]; + sprintf(buf, "%02d-%02d-%02d", _time_local.hour, _time_local.minute, _time_local.second); + path += buf; + path += ".jpg"; + } + Serial.println(path); + + // Take Picture with Camera + camera_fb_t * fb = esp_camera_fb_get(); + + if(!fb) { + Serial.println("Camera capture failed"); + return; + } + + File file = fs.open(path.c_str(), FILE_WRITE); + if(!file){ + Serial.println("Failed to open file in writing mode"); + } + else { + file.write(fb->buf, fb->len); // payload (image), payload length + Serial.printf("Saved file to path: %s\n", path.c_str()); + } + file.close(); + + //return the frame buffer back to the driver for reuse + esp_camera_fb_return(fb); } void doByInterval() { @@ -163,7 +224,10 @@ class EspCam : public IoTItem { IoTValue execute(String command, std::vector ¶m) { if (command == "save") { - save_picture(); + if (param.size() == 1) + save_picture(param[0].valS); + else + save_picture(); } else if (command == "ledOn" && param.size() == 1) { ledcSetup(LED_LEDC_CHANNEL, 5000, 8); ledcAttachPin(LED_GPIO_NUM, LED_LEDC_CHANNEL); From 3e49a24d07f33e4d43f1f687afa6e3619e518562 Mon Sep 17 00:00:00 2001 From: biver Date: Sun, 7 May 2023 20:56:02 +0300 Subject: [PATCH 06/14] =?UTF-8?q?A02Distance=20=D0=BF=D0=BE=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=B8?= =?UTF-8?q?=D0=B2=D0=B0=D0=B5=D1=82=20esp32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/A02Distance/modinfo.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/sensors/A02Distance/modinfo.json b/src/modules/sensors/A02Distance/modinfo.json index 4e6d2368..2bee177d 100644 --- a/src/modules/sensors/A02Distance/modinfo.json +++ b/src/modules/sensors/A02Distance/modinfo.json @@ -28,7 +28,6 @@ }, "defActive": true, "usedLibs": { - "esp32_4mb": [], "esp8266_4mb": [], "esp8266_1mb": [], "esp8266_1mb_ota": [], From 1dff39eecf7430dca0a7eefa2020b962e8dc4503 Mon Sep 17 00:00:00 2001 From: biver Date: Tue, 9 May 2023 08:45:37 +0300 Subject: [PATCH 07/14] =?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=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20Uart=20=D0=B2=208285?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/UART/modinfo.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/sensors/UART/modinfo.json b/src/modules/sensors/UART/modinfo.json index 8ba5ea0a..1e63b4e1 100644 --- a/src/modules/sensors/UART/modinfo.json +++ b/src/modules/sensors/UART/modinfo.json @@ -82,7 +82,12 @@ ], "esp8266_2mb_ota": [ "plerup/EspSoftwareSerial" + ], + "esp8285_1mb": [ + "plerup/EspSoftwareSerial" + ], + "esp8285_1mb_ota": [ + "plerup/EspSoftwareSerial" ] - } } \ No newline at end of file From 8825a2996e9818481ce889e14b0420d8d36d9fcd Mon Sep 17 00:00:00 2001 From: biver Date: Tue, 9 May 2023 08:50:00 +0300 Subject: [PATCH 08/14] =?UTF-8?q?=D0=9D=D0=B0=20=D0=B1=D1=83=D0=B4=D1=83?= =?UTF-8?q?=D1=89=D0=B5=D0=B5=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D0=BC=20=D0=BF=D0=BE=D0=BB=D0=BD=D0=BE=D1=86=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D1=8B=D0=B9=20=D0=B8=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D1=8B=20=D1=81=20UTF=20=D0=93=D1=80=D1=83=D0=B1?= =?UTF-8?q?=D1=8B=D0=B9=20=D0=B8=20=D0=B1=D0=BE=D0=BB=D0=B5=D0=B5=20=D0=BB?= =?UTF-8?q?=D0=B5=D0=B3=D0=BA=D0=B8=D0=B9=20=D0=B0=D0=BB=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D0=B8=D1=82=D0=BC=20=D0=BA=D0=BE=D0=BD=D0=B2=D0=B5=D1=80=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=BA=20=D1=83=D0=B6=D0=B5=20=D0=B8=D1=81=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=B7=D1=83=D0=B5=D1=82=D1=81=D1=8F=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B5=20=D1=81=20?= =?UTF-8?q?Dwin,=20=D0=BD=D0=BE=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=BB=20=D1=8D=D1=82=D0=BE=D1=82=20=D0=BD=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=80=20=D0=BD=D0=B0=20=D1=81=D0=BB=D1=83=D1=87=D0=B0?= =?UTF-8?q?=D0=B9=20=D0=B2=D0=BE=D0=B7=D0=BD=D0=B8=D0=BA=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B1=D0=BB=D0=B5?= =?UTF-8?q?=D0=BC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/UART/utf.cpp.new | 543 +++++++++++++++++++++++++++ src/modules/sensors/UART/utf.h.new | 149 ++++++++ 2 files changed, 692 insertions(+) create mode 100644 src/modules/sensors/UART/utf.cpp.new create mode 100644 src/modules/sensors/UART/utf.h.new diff --git a/src/modules/sensors/UART/utf.cpp.new b/src/modules/sensors/UART/utf.cpp.new new file mode 100644 index 00000000..8a91af72 --- /dev/null +++ b/src/modules/sensors/UART/utf.cpp.new @@ -0,0 +1,543 @@ + +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + +/* --------------------------------------------------------------------- + + Conversions between UTF32, UTF-16, and UTF-8. Source code file. + Author: Mark E. Davis, 1994. + Rev History: Rick McGowan, fixes & updates May 2001. + Sept 2001: fixed const & error conditions per + mods suggested by S. Parent & A. Lillich. + June 2002: Tim Dodd added detection and handling of incomplete + source sequences, enhanced error detection, added casts + to eliminate compiler warnings. + July 2003: slight mods to back out aggressive FFFE detection. + Jan 2004: updated switches in from-UTF8 conversions. + Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. + + See the header file "ConvertUTF.h" for complete documentation. + +------------------------------------------------------------------------ */ + + +#include "utf.h" +#ifdef CVTUTF_DEBUG +#include +#endif + +static const int halfShift = 10; /* used for shifting by 10 bits */ + +static const UTF32 halfBase = 0x0010000UL; +static const UTF32 halfMask = 0x3FFUL; + +#define UNI_SUR_HIGH_START (UTF32)0xD800 +#define UNI_SUR_HIGH_END (UTF32)0xDBFF +#define UNI_SUR_LOW_START (UTF32)0xDC00 +#define UNI_SUR_LOW_END (UTF32)0xDFFF +#define false 0 +#define true 1 + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF32toUTF16 ( + const UTF32** sourceStart, const UTF32* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF32* source = *sourceStart; + UTF16* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + if (target >= targetEnd) { + result = targetExhausted; break; + } + ch = *source++; + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = (UTF16)ch; /* normal case */ + } + } else if (ch > UNI_MAX_LEGAL_UTF32) { + if (flags == strictConversion) { + result = sourceIllegal; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + --source; /* Back up source pointer! */ + result = targetExhausted; break; + } + ch -= halfBase; + *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF16toUTF32 ( + const UTF16** sourceStart, const UTF16* sourceEnd, + UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF16* source = *sourceStart; + UTF32* target = *targetStart; + UTF32 ch, ch2; + while (source < sourceEnd) { + const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */ + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { + /* If the 16 bits following the high surrogate are in the source buffer... */ + if (source < sourceEnd) { + ch2 = *source; + /* If it's a low surrogate, convert to UTF32. */ + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else { /* We don't have the 16 bits following the high surrogate. */ + --source; /* return to the high surrogate */ + result = sourceExhausted; + break; + } + } else if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + if (target >= targetEnd) { + source = oldSource; /* Back up source pointer! */ + result = targetExhausted; break; + } + *target++ = ch; + } + *sourceStart = source; + *targetStart = target; +#ifdef CVTUTF_DEBUG +if (result == sourceIllegal) { + fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2); + fflush(stderr); +} +#endif + return result; +} + +/* --------------------------------------------------------------------- */ + +/* + * Index into the table below with the first byte of a UTF-8 sequence to + * get the number of trailing bytes that are supposed to follow it. + * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is + * left as-is for anyone who may want to do such conversion, which was + * allowed in earlier algorithms. + */ +static const char trailingBytesForUTF8[256] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 +}; + +/* + * Magic values subtracted from a buffer value during UTF8 conversion. + * This table contains as many values as there might be trailing bytes + * in a UTF-8 sequence. + */ +static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, + 0x03C82080UL, 0xFA082080UL, 0x82082080UL }; + +/* + * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed + * into the first byte, depending on how many bytes follow. There are + * as many entries in this table as there are UTF-8 sequence types. + * (I.e., one byte sequence, two byte... etc.). Remember that sequencs + * for *legal* UTF-8 will be 4 or fewer bytes total. + */ +static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + +/* --------------------------------------------------------------------- */ + +/* The interface converts a whole buffer to avoid function-call overhead. + * Constants have been gathered. Loops & conditionals have been removed as + * much as possible for efficiency, in favor of drop-through switches. + * (See "Note A" at the bottom of the file for equivalent code.) + * If your compiler supports it, the "isLegalUTF8" call can be turned + * into an inline function. + */ + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF16toUTF8 ( + const UTF16** sourceStart, const UTF16* sourceEnd, + UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF16* source = *sourceStart; + UTF8* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */ + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { + /* If the 16 bits following the high surrogate are in the source buffer... */ + if (source < sourceEnd) { + UTF32 ch2 = *source; + /* If it's a low surrogate, convert to UTF32. */ + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else { /* We don't have the 16 bits following the high surrogate. */ + --source; /* return to the high surrogate */ + result = sourceExhausted; + break; + } + } else if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + /* Figure out how many bytes the result will require */ + if (ch < (UTF32)0x80) { bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { bytesToWrite = 3; + } else if (ch < (UTF32)0x110000) { bytesToWrite = 4; + } else { bytesToWrite = 3; + ch = UNI_REPLACEMENT_CHAR; + } + + target += bytesToWrite; + if (target > targetEnd) { + source = oldSource; /* Back up source pointer! */ + target -= bytesToWrite; result = targetExhausted; break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; + case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; + case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; + case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +/* + * Utility routine to tell whether a sequence of bytes is legal UTF-8. + * This must be called with the length pre-determined by the first byte. + * If not calling this from ConvertUTF8to*, then the length can be set by: + * length = trailingBytesForUTF8[*source]+1; + * and the sequence is illegal right away if there aren't that many bytes + * available. + * If presented with a length > 4, this returns false. The Unicode + * definition of UTF-8 goes up to 4-byte sequences. + */ + +static Boolean isLegalUTF8(const UTF8 *source, int length) { + UTF8 a; + const UTF8 *srcptr = source+length; + switch (length) { + default: return false; + /* Everything else falls through when "true"... */ + case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 2: if ((a = (*--srcptr)) > 0xBF) return false; + + switch (*source) { + /* no fall-through in this inner switch */ + case 0xE0: if (a < 0xA0) return false; break; + case 0xED: if (a > 0x9F) return false; break; + case 0xF0: if (a < 0x90) return false; break; + case 0xF4: if (a > 0x8F) return false; break; + default: if (a < 0x80) return false; + } + + case 1: if (*source >= 0x80 && *source < 0xC2) return false; + } + if (*source > 0xF4) return false; + return true; +} + +/* --------------------------------------------------------------------- */ + +/* + * Exported function to return whether a UTF-8 sequence is legal or not. + * This is not used here; it's just exported. + */ +Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) { + int length = trailingBytesForUTF8[*source]+1; + if (source+length > sourceEnd) { + return false; + } + return isLegalUTF8(source, length); +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF8toUTF16 ( + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF8* source = *sourceStart; + UTF16* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) { + result = sourceExhausted; break; + } + /* Do this check whether lenient or strict */ + if (! isLegalUTF8(source, extraBytesToRead+1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ + case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ + case 3: ch += *source++; ch <<= 6; + case 2: ch += *source++; ch <<= 6; + case 1: ch += *source++; ch <<= 6; + case 0: ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (target >= targetEnd) { + source -= (extraBytesToRead+1); /* Back up source pointer! */ + result = targetExhausted; break; + } + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + source -= (extraBytesToRead+1); /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = (UTF16)ch; /* normal case */ + } + } else if (ch > UNI_MAX_UTF16) { + if (flags == strictConversion) { + result = sourceIllegal; + source -= (extraBytesToRead+1); /* return to the start */ + break; /* Bail out; shouldn't continue */ + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + source -= (extraBytesToRead+1); /* Back up source pointer! */ + result = targetExhausted; break; + } + ch -= halfBase; + *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF32toUTF8 ( + const UTF32** sourceStart, const UTF32* sourceEnd, + UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF32* source = *sourceStart; + UTF8* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + ch = *source++; + if (flags == strictConversion ) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + /* + * Figure out how many bytes the result will require. Turn any + * illegally large UTF32 things (> Plane 17) into replacement chars. + */ + if (ch < (UTF32)0x80) { bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { bytesToWrite = 3; + } else if (ch <= UNI_MAX_LEGAL_UTF32) { bytesToWrite = 4; + } else { bytesToWrite = 3; + ch = UNI_REPLACEMENT_CHAR; + result = sourceIllegal; + } + + target += bytesToWrite; + if (target > targetEnd) { + --source; /* Back up source pointer! */ + target -= bytesToWrite; result = targetExhausted; break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; + case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; + case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; + case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + ConversionResult +ConvertUTF8toUTF32 ( + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) +{ + ConversionResult result = conversionOK; + const UTF8* source = *sourceStart; + UTF32 * target = *targetStart; + + while (source < sourceEnd) + { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8 [*source]; + + if (source + extraBytesToRead >= sourceEnd) + { + result = sourceExhausted; break; + } + + /* Do this check whether lenient or strict */ + if (! isLegalUTF8(source, extraBytesToRead+1)) + { + result = sourceIllegal; + break; + } + + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) + { + case 5: ch += *source++; ch <<= 6; + case 4: ch += *source++; ch <<= 6; + case 3: ch += *source++; ch <<= 6; + case 2: ch += *source++; ch <<= 6; + case 1: ch += *source++; ch <<= 6; + case 0: ch += *source++; + } + + ch -= offsetsFromUTF8 [extraBytesToRead]; + + if (target >= targetEnd) + { + source -= (extraBytesToRead + 1); /* Back up the source pointer! */ + result = targetExhausted; break; + } + + if (ch <= UNI_MAX_LEGAL_UTF32) + { + /* + * UTF-16 surrogate values are illegal in UTF-32, and anything + * over Plane 17 (> 0x10FFFF) is illegal. + */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) + { + if (flags == strictConversion) + { + source -= (extraBytesToRead+1); /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + else + { + *target++ = UNI_REPLACEMENT_CHAR; + } + } + else + { + *target++ = ch; + } + } + else + { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */ + result = sourceIllegal; + *target++ = UNI_REPLACEMENT_CHAR; + } + } + + *sourceStart = source; + *targetStart = target; + return result; +} diff --git a/src/modules/sensors/UART/utf.h.new b/src/modules/sensors/UART/utf.h.new new file mode 100644 index 00000000..e2649153 --- /dev/null +++ b/src/modules/sensors/UART/utf.h.new @@ -0,0 +1,149 @@ +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + +/* --------------------------------------------------------------------- + + Conversions between UTF32, UTF-16, and UTF-8. Header file. + + Several funtions are included here, forming a complete set of + conversions between the three formats. UTF-7 is not included + here, but is handled in a separate source file. + + Each of these routines takes pointers to input buffers and output + buffers. The input buffers are const. + + Each routine converts the text between *sourceStart and sourceEnd, + putting the result into the buffer between *targetStart and + targetEnd. Note: the end pointers are *after* the last item: e.g. + *(sourceEnd - 1) is the last item. + + The return result indicates whether the conversion was successful, + and if not, whether the problem was in the source or target buffers. + (Only the first encountered problem is indicated.) + + After the conversion, *sourceStart and *targetStart are both + updated to point to the end of last text successfully converted in + the respective buffers. + + Input parameters: + sourceStart - pointer to a pointer to the source buffer. + The contents of this are modified on return so that + it points at the next thing to be converted. + targetStart - similarly, pointer to pointer to the target buffer. + sourceEnd, targetEnd - respectively pointers to the ends of the + two buffers, for overflow checking only. + + These conversion functions take a ConversionFlags argument. When this + flag is set to strict, both irregular sequences and isolated surrogates + will cause an error. When the flag is set to lenient, both irregular + sequences and isolated surrogates are converted. + + Whether the flag is strict or lenient, all illegal sequences will cause + an error return. This includes sequences such as: , , + or in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code + must check for illegal sequences. + + When the flag is set to lenient, characters over 0x10FFFF are converted + to the replacement character; otherwise (when the flag is set to strict) + they constitute an error. + + Output parameters: + The value "sourceIllegal" is returned from some routines if the input + sequence is malformed. When "sourceIllegal" is returned, the source + value will point to the illegal value that caused the problem. E.g., + in UTF-8 when a sequence is malformed, it points to the start of the + malformed sequence. + + Author: Mark E. Davis, 1994. + Rev History: Rick McGowan, fixes & updates May 2001. + Fixes & updates, Sept 2001. + +------------------------------------------------------------------------ */ + +/* --------------------------------------------------------------------- + The following 4 definitions are compiler-specific. + The C standard does not guarantee that wchar_t has at least + 16 bits, so wchar_t is no less portable than unsigned short! + All should be unsigned values to avoid sign extension during + bit mask & shift operations. +------------------------------------------------------------------------ */ + +typedef unsigned long UTF32; /* at least 32 bits */ +typedef unsigned short UTF16; /* at least 16 bits */ +typedef unsigned char UTF8; /* typically 8 bits */ +typedef unsigned char Boolean; /* 0 or 1 */ + +/* Some fundamental constants */ +#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD +#define UNI_MAX_BMP (UTF32)0x0000FFFF +#define UNI_MAX_UTF16 (UTF32)0x0010FFFF +#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF +#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF + +typedef enum { + conversionOK, /* conversion successful */ + sourceExhausted, /* partial character in source, but hit end */ + targetExhausted, /* insuff. room in target for conversion */ + sourceIllegal /* source sequence is illegal/malformed */ +} ConversionResult; + +typedef enum { + strictConversion = 0, + lenientConversion +} ConversionFlags; + +/* This is for C++ and does no harm in C */ +#ifdef __cplusplus +extern "C" { +#endif + +ConversionResult ConvertUTF8toUTF16 ( + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF16toUTF8 ( + const UTF16** sourceStart, const UTF16* sourceEnd, + UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF8toUTF32 ( + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF32toUTF8 ( + const UTF32** sourceStart, const UTF32* sourceEnd, + UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF16toUTF32 ( + const UTF16** sourceStart, const UTF16* sourceEnd, + UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF32toUTF16 ( + const UTF32** sourceStart, const UTF32* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); + +Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); + +#ifdef __cplusplus +} +#endif + +/* --------------------------------------------------------------------- */ From bdff41a4b0db1012c39d2999bfa207814a69b0b6 Mon Sep 17 00:00:00 2001 From: biver Date: Thu, 11 May 2023 15:51:41 +0300 Subject: [PATCH 09/14] =?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=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8C=20S8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/S8/S8.cpp | 95 +++++++++++++++++++++++++++++ src/modules/sensors/S8/modinfo.json | 43 +++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 src/modules/sensors/S8/S8.cpp create mode 100644 src/modules/sensors/S8/modinfo.json diff --git a/src/modules/sensors/S8/S8.cpp b/src/modules/sensors/S8/S8.cpp new file mode 100644 index 00000000..f8efa10e --- /dev/null +++ b/src/modules/sensors/S8/S8.cpp @@ -0,0 +1,95 @@ +#include "Global.h" +#include "Classes/IoTItem.h" + +#include + +#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: + SoftwareSerial* s8Serial; + + unsigned int _s8_co2; + int _s8_co2_mean = 0; + int _s8_co2_mean2 = 0; + + float smoothing_factor = 0.5; + float smoothing_factor2 = 0.15; + + byte _response_s8[7] = {0, 0, 0, 0, 0, 0, 0}; + + void s8Request(byte cmd[]) { + while(!s8Serial->available()) { + s8Serial->write(cmd, C_LEN); + delay(50); + } + + int timeout=0; + while(s8Serial->available() < R_LEN) { + timeout++; + if(timeout > 10) { + while(s8Serial->available()) { + s8Serial->read(); + break; + } + } + delay(50); + } + + for (int i=0; i < R_LEN; i++) { + _response_s8[i] = s8Serial->read(); + } + + s8Serial->end(); + } + + void co2_measure() { + s8Request(cmd_s8); // запрашиваем значение загрязнения + _s8_co2 = _response_s8[3] * 256 + _response_s8[4]; // полученный недобайт-ответ преобразуем в значение загрязнения + + if (!_s8_co2_mean) _s8_co2_mean = _s8_co2; + _s8_co2_mean = _s8_co2_mean - smoothing_factor*(_s8_co2_mean - _s8_co2); + + if (!_s8_co2_mean2) _s8_co2_mean2 = _s8_co2; + _s8_co2_mean2 = _s8_co2_mean2 - smoothing_factor2*(_s8_co2_mean2 - _s8_co2); + + Serial.printf("CO2 value: %d, M1Value: %d, M2Value: %d\n", _s8_co2, _s8_co2_mean, _s8_co2_mean2); + } + + public: + S8co(String parameters): IoTItem(parameters) { + int S8_RX_PIN, S8_TX_PIN; + jsonRead(parameters, "rxPin", S8_RX_PIN); + jsonRead(parameters, "txPin", S8_TX_PIN); + + s8Serial = new SoftwareSerial(S8_RX_PIN, S8_TX_PIN); + if (!s8Serial) return; + s8Serial->begin(9600); + } + + void doByInterval() { + co2_measure(); + value.valD = _s8_co2; + if (value.valD < 15000) + regEvent(value.valD, "S8co"); + else + SerialPrint("E", "Sensor S8_uart", "Error"); + } + + ~S8co() { + if (s8Serial) delete s8Serial; + }; +}; + +void* getAPI_S8(String subtype, String param) { + if (subtype == F("S8co")) { + return new S8co(param); + } else { + return nullptr; + } +} diff --git a/src/modules/sensors/S8/modinfo.json b/src/modules/sensors/S8/modinfo.json new file mode 100644 index 00000000..6f702b87 --- /dev/null +++ b/src/modules/sensors/S8/modinfo.json @@ -0,0 +1,43 @@ +{ + "menuSection": "Сенсоры", + "configItem": [ + { + "name": "(S8) Cенсор качества воздуха", + "num": 3, + "type": "Reading", + "subtype": "S8co", + "id": "s8co", + "widget": "anydataPpm", + "page": "Сенсоры", + "descr": "S8_CO2", + "int": 15, + "round": 1, + "rxPin": 13, + "txPin": 15 + } + ], + "about": { + "authorName": "Serghei Crasnicov", + "authorContact": "https://t.me/Serghei63", + "authorGit": "https://github.com/Serghei63", + "specialThanks": "", + "moduleName": "S8", + "moduleVersion": "2.1", + "usedRam": 15, + "subTypes": [ + "S8co" + ], + "title": "Датчик углекислого газа S8", + "moduleDesc": "Измеряет параметвы воздуха.", + "propInfo": { + "int": "Количество секунд между опросами датчика." + } + }, + "defActive": true, + "usedLibs": { + "esp32_4mb": [ + ], + "esp8266_4mb": [ + ] + } +} \ No newline at end of file From b7a3bebd36912b2605f1870a654e8dada1b4ffe8 Mon Sep 17 00:00:00 2001 From: biver Date: Thu, 11 May 2023 15:52:16 +0300 Subject: [PATCH 10/14] =?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=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8C=20Enc?= =?UTF-8?q?onder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/exec/Enconder/Enconder.cpp | 63 ++++++++++++++++++++++++ src/modules/exec/Enconder/modinfo.json | 66 ++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 src/modules/exec/Enconder/Enconder.cpp create mode 100644 src/modules/exec/Enconder/modinfo.json diff --git a/src/modules/exec/Enconder/Enconder.cpp b/src/modules/exec/Enconder/Enconder.cpp new file mode 100644 index 00000000..2b5d916c --- /dev/null +++ b/src/modules/exec/Enconder/Enconder.cpp @@ -0,0 +1,63 @@ +#include "Global.h" +#include "classes/IoTItem.h" + +#define EB_FAST 30 // таймаут быстрого поворота энкодера, мс +#define EB_DEB 50 // дебаунс кнопки, мс +#define EB_CLICK 400 // таймаут накликивания кнопки, мс +#include "EncButton2.h" + + +class Encoder : public IoTItem { + private: + float step = 1; + float stepOnPress = 5; + EncButton2 enc1; + + public: + Encoder(String parameters) : IoTItem(parameters) { + String pins; + jsonRead(parameters, "pins", pins); + int CLK = selectFromMarkerToMarker(pins, ",", 0).toInt(); + int DT = selectFromMarkerToMarker(pins, ",", 1).toInt(); + int SW = selectFromMarkerToMarker(pins, ",", 2).toInt(); + + jsonRead(parameters, "step", step); + jsonRead(parameters, "stepOnPress", stepOnPress); + + enc1.setPins(INPUT, CLK, DT, SW); + enc1.setEncReverse(false); + } + + void loop() { + if (enc1.tick() != 0) { + if (enc1.left()) { + value.valD = value.valD - step; + regEvent(value.valD, "Encoder_left"); + } else if (enc1.right()) { + value.valD = value.valD + step; + regEvent(value.valD, "Encoder_right"); + } else if (stepOnPress) { + if (enc1.leftH()) { + value.valD = value.valD - stepOnPress; + regEvent(value.valD, "Encoder_leftH"); + } else if (enc1.rightH()) { + value.valD = value.valD + stepOnPress; + regEvent(value.valD, "Encoder_rightH"); + } + } + + // в конце лучше вызвать resetState(), чтобы сбросить необработанные флаги! + enc1.resetState(); + } + } + + ~Encoder() {}; +}; + +void* getAPI_Encoder(String subtype, String param) { + if (subtype == F("Encoder")) { + return new Encoder(param); + } else { + return nullptr; + } +} \ No newline at end of file diff --git a/src/modules/exec/Enconder/modinfo.json b/src/modules/exec/Enconder/modinfo.json new file mode 100644 index 00000000..ce92fb01 --- /dev/null +++ b/src/modules/exec/Enconder/modinfo.json @@ -0,0 +1,66 @@ +{ + "menuSection": "Исполнительные устройства", + "configItem": [ + { + "global": 0, + "name": "Энкодер", + "type": "Writing", + "subtype": "Encoder", + "id": "enc", + "widget": "inputDgt", + "page": "Энкодер", + "descr": "Громкость", + "needSave": 0, + "val": "0", + "round" : 0, + + "step": 1, + "stepOnPress": 5, + "pins": "4,5,2" + } + ], + "about": { + "authorName": "Sergei Yakovlev", + "authorContact": "", + "authorGit": "", + "specialThanks": "", + "moduleName": "Encoder", + "moduleVersion": "1.5", + "usedRam": { + "esp32_4mb": 15, + "esp8266_4mb": 15 + }, + "subTypes": [ + "Encoder" + ], + "title": "Энкодер", + "moduleDesc": "модуль для работы с Энкодером. Кнопочный вариант совместим с модулями Multitouch и ButtonIn", + "retInfo": "Значение счетчика", + "propInfo": { + "step" : "Размер шага Энкодера, может принимать значение 0.0001 или 1000", + "stepOnPress": "Размер шага Энкодера при нажатой кнопке, 0 - отключает учет", + "pins": "Подключеные пины (CLK, DT, SW)" + } + }, + "defActive": true, + "usedLibs": { + "esp32_4mb": [ + "gyverlibs/EncButton @ ^2.0" + ], + "esp8266_4mb": [ + "gyverlibs/EncButton @ ^2.0" + ], + "esp8266_1mb": [ + "gyverlibs/EncButton @ ^2.0" + ], + "esp8266_1mb_ota": [ + "gyverlibs/EncButton @ ^2.0" + ], + "esp8285_1mb": [ + "gyverlibs/EncButton @ ^2.0" + ], + "esp8285_1mb_ota": [ + "gyverlibs/EncButton @ ^2.0" + ] + } +} \ No newline at end of file From 45c0f6a39a81ae054f88a1dfcf10764555a50001 Mon Sep 17 00:00:00 2001 From: biver Date: Thu, 11 May 2023 15:54:05 +0300 Subject: [PATCH 11/14] =?UTF-8?q?=D0=92=D1=8B=D1=80=D0=B0=D0=B2=D0=BD?= =?UTF-8?q?=D0=B8=D0=B2=D0=B0=D0=B5=D0=BC=20=D1=81=D0=B1=D0=BE=D1=80=D0=BA?= =?UTF-8?q?=D1=83=20=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8=D0=BB?= =?UTF-8?q?=D1=8C=20esp8266=5F4mb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_svelte/items.json | 199 +++++++++++-------- data_svelte_lite/items.json | 371 ++++++++++++++++++++++++++++++------ platformio.ini | 152 ++++++++++++--- src/modules/API.cpp | 6 + 4 files changed, 568 insertions(+), 160 deletions(-) diff --git a/data_svelte/items.json b/data_svelte/items.json index 7e530a2f..f011b1ff 100644 --- a/data_svelte/items.json +++ b/data_svelte/items.json @@ -192,7 +192,19 @@ "header": "Сенсоры" }, { - "name": "13. Acs712 Ток", + "name": "13. A02 Дальность", + "type": "Reading", + "subtype": "A02Distance", + "id": "dist", + "widget": "anydataCm", + "page": "Сенсоры", + "descr": "Дальность", + "int": 5, + "round": 1, + "num": 13 + }, + { + "name": "14. Acs712 Ток", "type": "Reading", "subtype": "Acs712", "id": "amp", @@ -207,11 +219,11 @@ "sens": 100, "adczero": 512, "btn-setZero": "nil", - "num": 13 + "num": 14 }, { "global": 0, - "name": "14. AHTXX Температура", + "name": "15. AHTXX Температура", "type": "Reading", "subtype": "AhtXXt", "id": "Temp20", @@ -222,11 +234,11 @@ "addr": "0x38", "shtType": 1, "round": 1, - "num": 14 + "num": 15 }, { "global": 0, - "name": "15. AHTXX Влажность", + "name": "16. AHTXX Влажность", "type": "Reading", "subtype": "AhtXXh", "id": "Hum20", @@ -237,11 +249,11 @@ "addr": "0x38", "shtType": 1, "round": 1, - "num": 15 + "num": 16 }, { "global": 0, - "name": "16. Аналоговый сенсор", + "name": "17. Аналоговый сенсор", "type": "Reading", "subtype": "AnalogAdc", "id": "t", @@ -255,11 +267,11 @@ "pin": 0, "int": 15, "avgSteps": 1, - "num": 16 + "num": 17 }, { "global": 0, - "name": "17. BME280 Температура", + "name": "18. BME280 Температура", "type": "Reading", "subtype": "Bme280t", "id": "Tmp3", @@ -269,11 +281,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 17 + "num": 18 }, { "global": 0, - "name": "18. BME280 Давление", + "name": "19. BME280 Давление", "type": "Reading", "subtype": "Bme280p", "id": "Press3", @@ -283,11 +295,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 18 + "num": 19 }, { "global": 0, - "name": "19. BME280 Влажность", + "name": "20. BME280 Влажность", "type": "Reading", "subtype": "Bme280h", "id": "Hum3", @@ -297,11 +309,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 19 + "num": 20 }, { "global": 0, - "name": "20. BME280 Tочка росы", + "name": "21. BME280 Tочка росы", "type": "Reading", "subtype": "Bme280dp", "id": "Dew3", @@ -311,11 +323,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 20 + "num": 21 }, { "global": 0, - "name": "21. BMP280 Температура", + "name": "22. BMP280 Температура", "type": "Reading", "subtype": "Bmp280t", "id": "tmp3", @@ -325,11 +337,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 21 + "num": 22 }, { "global": 0, - "name": "22. BMP280 Давление", + "name": "23. BMP280 Давление", "type": "Reading", "subtype": "Bmp280p", "id": "Press3", @@ -339,11 +351,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 22 + "num": 23 }, { "global": 0, - "name": "23. DHT11 Температура", + "name": "24. DHT11 Температура", "type": "Reading", "subtype": "Dht1122t", "id": "tmp3", @@ -353,11 +365,11 @@ "int": 15, "pin": 0, "senstype": "dht11", - "num": 23 + "num": 24 }, { "global": 0, - "name": "24. DHT11 Влажность", + "name": "25. DHT11 Влажность", "type": "Reading", "subtype": "Dht1122h", "id": "Hum3", @@ -367,11 +379,11 @@ "int": 15, "pin": 0, "senstype": "dht11", - "num": 24 + "num": 25 }, { "global": 0, - "name": "25. DS18B20 Температура", + "name": "26. DS18B20 Температура", "type": "Reading", "subtype": "Ds18b20", "id": "dstmp", @@ -383,11 +395,11 @@ "index": 0, "addr": "", "round": 1, - "num": 25 + "num": 26 }, { "global": 0, - "name": "26. Аналоговый счетчик импульсов", + "name": "27. Аналоговый счетчик импульсов", "type": "Writing", "subtype": "Impulse", "id": "impulse", @@ -400,11 +412,11 @@ "pinMode": "INPUT", "debounceDelay": 3, "multiply": 1, - "num": 26 + "num": 27 }, { "global": 0, - "name": "27. PZEM 004t Напряжение", + "name": "28. PZEM 004t Напряжение", "type": "Reading", "subtype": "Pzem004v", "id": "v", @@ -414,11 +426,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 27 + "num": 28 }, { "global": 0, - "name": "28. PZEM 004t Сила тока", + "name": "29. PZEM 004t Сила тока", "type": "Reading", "subtype": "Pzem004a", "id": "a", @@ -428,11 +440,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 28 + "num": 29 }, { "global": 0, - "name": "29. PZEM 004t Мощность", + "name": "30. PZEM 004t Мощность", "type": "Reading", "subtype": "Pzem004w", "id": "w", @@ -442,11 +454,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 29 + "num": 30 }, { "global": 0, - "name": "30. PZEM 004t Энергия", + "name": "31. PZEM 004t Энергия", "type": "Reading", "subtype": "Pzem004wh", "id": "wh", @@ -456,11 +468,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 30 + "num": 31 }, { "global": 0, - "name": "31. PZEM 004t Частота", + "name": "32. PZEM 004t Частота", "type": "Reading", "subtype": "Pzem004hz", "id": "hz", @@ -470,11 +482,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 31 + "num": 32 }, { "global": 0, - "name": "32. PZEM 004t Косинус", + "name": "33. PZEM 004t Косинус", "type": "Reading", "subtype": "Pzem004pf", "id": "pf", @@ -484,11 +496,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 32 + "num": 33 }, { "global": 0, - "name": "33. PZEM настройка", + "name": "34. PZEM настройка", "type": "Reading", "subtype": "Pzem004cmd", "id": "set", @@ -500,11 +512,11 @@ "changeaddr": 0, "setaddr": "0x01", "reset": 0, - "num": 33 + "num": 34 }, { "global": 0, - "name": "34. Часы реального времени", + "name": "35. Часы реального времени", "type": "Reading", "subtype": "RTC", "id": "rtc", @@ -520,11 +532,25 @@ "int": 5, "btn-setUTime": "0", "btn-setSysTime": "nil", - "num": 34 + "num": 35 + }, + { + "name": "36. (S8) Cенсор качества воздуха", + "num": 36, + "type": "Reading", + "subtype": "S8co", + "id": "s8co", + "widget": "anydataPpm", + "page": "Сенсоры", + "descr": "S8_CO2", + "int": 15, + "round": 1, + "rxPin": 13, + "txPin": 15 }, { "global": 0, - "name": "35. Sht20 Температура", + "name": "37. Sht20 Температура", "type": "Reading", "subtype": "Sht20t", "id": "tmp2", @@ -533,11 +559,11 @@ "descr": "Температура", "int": 15, "round": 1, - "num": 35 + "num": 37 }, { "global": 0, - "name": "36. Sht20 Влажность", + "name": "38. Sht20 Влажность", "type": "Reading", "subtype": "Sht20h", "id": "Hum2", @@ -546,11 +572,11 @@ "descr": "Влажность", "int": 15, "round": 1, - "num": 36 + "num": 38 }, { "global": 0, - "name": "37. Sht30 Температура", + "name": "39. Sht30 Температура", "type": "Reading", "subtype": "Sht30t", "id": "tmp30", @@ -559,11 +585,11 @@ "descr": "SHT30 Температура", "int": 15, "round": 1, - "num": 37 + "num": 39 }, { "global": 0, - "name": "38. Sht30 Влажность", + "name": "40. Sht30 Влажность", "type": "Reading", "subtype": "Sht30h", "id": "Hum30", @@ -572,12 +598,12 @@ "descr": "SHT30 Влажность", "int": 15, "round": 1, - "num": 38 + "num": 40 }, { "global": 0, - "name": "39. HC-SR04 Ультразвуковой дальномер", - "num": 39, + "name": "41. HC-SR04 Ультразвуковой дальномер", + "num": 41, "type": "Reading", "subtype": "Sonar", "id": "sonar", @@ -589,7 +615,7 @@ "int": 5 }, { - "name": "40. UART", + "name": "42. UART", "type": "Reading", "subtype": "UART", "page": "", @@ -601,14 +627,14 @@ "line": 2, "speed": 9600, "eventFormat": 0, - "num": 40 + "num": 42 }, { "header": "Исполнительные устройства" }, { "global": 0, - "name": "41. Кнопка подключенная к пину", + "name": "43. Кнопка подключенная к пину", "type": "Writing", "subtype": "ButtonIn", "id": "btn", @@ -623,11 +649,11 @@ "debounceDelay": 50, "fixState": 0, "inv": 0, - "num": 41 + "num": 43 }, { "global": 0, - "name": "42. Управление пином", + "name": "44. Управление пином", "type": "Writing", "subtype": "ButtonOut", "needSave": 0, @@ -638,11 +664,28 @@ "int": 0, "inv": 0, "pin": 2, - "num": 42 + "num": 44 }, { "global": 0, - "name": "43. Сервопривод", + "name": "45. Энкодер", + "type": "Writing", + "subtype": "Encoder", + "id": "enc", + "widget": "inputDgt", + "page": "Энкодер", + "descr": "Громкость", + "needSave": 0, + "val": "0", + "round": 0, + "step": 1, + "stepOnPress": 5, + "pins": "4,5,2", + "num": 45 + }, + { + "global": 0, + "name": "46. Сервопривод", "type": "Writing", "subtype": "IoTServo", "id": "servo", @@ -653,11 +696,11 @@ "pin": 12, "apin": -1, "amap": "0, 4096, 0, 180", - "num": 43 + "num": 46 }, { "global": 0, - "name": "44. Расширитель портов Mcp23017", + "name": "47. Расширитель портов Mcp23017", "type": "Reading", "subtype": "Mcp23017", "id": "Mcp", @@ -667,11 +710,11 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 44 + "num": 47 }, { "global": 0, - "name": "45. MP3 плеер", + "name": "48. MP3 плеер", "type": "Reading", "subtype": "Mp3", "id": "mp3", @@ -681,11 +724,11 @@ "int": 1, "pins": "14,12", "volume": 20, - "num": 45 + "num": 48 }, { "global": 0, - "name": "46. Сенсорная кнопка", + "name": "49. Сенсорная кнопка", "type": "Writing", "subtype": "Multitouch", "id": "impulse", @@ -699,11 +742,11 @@ "pinMode": "INPUT", "debounceDelay": 50, "PWMDelay": 500, - "num": 46 + "num": 49 }, { "global": 0, - "name": "47. Расширитель портов Pcf8574", + "name": "50. Расширитель портов Pcf8574", "type": "Reading", "subtype": "Pcf8574", "id": "Pcf", @@ -713,11 +756,11 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 47 + "num": 50 }, { "global": 0, - "name": "48. PWM ESP8266", + "name": "51. PWM ESP8266", "type": "Writing", "subtype": "Pwm8266", "id": "pwm", @@ -729,11 +772,11 @@ "freq": 5000, "val": 0, "apin": -1, - "num": 48 + "num": 51 }, { "global": 0, - "name": "49. Телеграм-Лайт", + "name": "52. Телеграм-Лайт", "type": "Writing", "subtype": "TelegramLT", "id": "tg", @@ -742,14 +785,14 @@ "descr": "", "token": "", "chatID": "", - "num": 49 + "num": 52 }, { "header": "Экраны" }, { "global": 0, - "name": "50. LCD экран 2004", + "name": "53. LCD экран 2004", "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -761,10 +804,10 @@ "size": "20,4", "coord": "0,0", "id2show": "id датчика", - "num": 50 + "num": 53 }, { - "name": "51. LCD экран 1602", + "name": "54. LCD экран 1602", "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -776,6 +819,6 @@ "size": "16,2", "coord": "0,0", "id2show": "id датчика", - "num": 51 + "num": 54 } ] \ No newline at end of file diff --git a/data_svelte_lite/items.json b/data_svelte_lite/items.json index c1501407..2d7b8c7a 100644 --- a/data_svelte_lite/items.json +++ b/data_svelte_lite/items.json @@ -23,7 +23,52 @@ }, { "global": 0, - "name": "2. Таймер", + "name": "2. График", + "type": "Writing", + "subtype": "Loging", + "id": "log", + "widget": "chart2", + "page": "Графики", + "descr": "Температура", + "num": 2, + "int": 5, + "logid": "t", + "points": 300 + }, + { + "global": 0, + "name": "3. График по событию", + "type": "Writing", + "subtype": "Loging", + "id": "log", + "widget": "chart2", + "page": "Графики", + "descr": "Температура", + "int": 0, + "num": 3, + "points": 300 + }, + { + "global": 0, + "name": "4. График дневного расхода", + "type": "Writing", + "subtype": "LogingDaily", + "id": "log", + "widget": "chart3", + "page": "Графики", + "descr": "Температура", + "num": 4, + "int": 1, + "logid": "t", + "points": 365, + "telegram": 0, + "test": 0, + "btn-defvalue": 0, + "btn-reset": "nil" + }, + { + "global": 0, + "name": "5. Таймер", "type": "Writing", "subtype": "Timer", "id": "timer", @@ -35,11 +80,11 @@ "ticker": 1, "repeat": 1, "needSave": 0, - "num": 2 + "num": 5 }, { "global": 0, - "name": "3. Окно ввода числа (переменная)", + "name": "6. Окно ввода числа (переменная)", "type": "Reading", "subtype": "Variable", "id": "value", @@ -53,11 +98,11 @@ "plus": 0, "multiply": 1, "round": 0, - "num": 3 + "num": 6 }, { "global": 0, - "name": "4. Окно ввода времени", + "name": "7. Окно ввода времени", "type": "Reading", "subtype": "Variable", "id": "time", @@ -67,11 +112,11 @@ "descr": "Введите время", "int": "0", "val": "02:00", - "num": 4 + "num": 7 }, { "global": 0, - "name": "5. Окно ввода даты", + "name": "8. Окно ввода даты", "type": "Reading", "subtype": "Variable", "id": "time", @@ -81,11 +126,11 @@ "descr": "Введите дату", "int": "0", "val": "24.05.2022", - "num": 5 + "num": 8 }, { "global": 0, - "name": "6. Окно ввода текста", + "name": "9. Окно ввода текста", "type": "Reading", "subtype": "Variable", "id": "txt", @@ -95,11 +140,11 @@ "descr": "Введите текст", "int": "0", "val": "текст", - "num": 6 + "num": 9 }, { "global": 0, - "name": "7. Вывод значения", + "name": "10. Вывод значения", "type": "Reading", "subtype": "Variable", "id": "vout", @@ -113,11 +158,11 @@ "plus": 0, "multiply": 1, "round": 0, - "num": 7 + "num": 10 }, { "global": 0, - "name": "8. Цветной текст", + "name": "11. Цветной текст", "type": "Reading", "subtype": "VariableColor", "id": "color", @@ -127,11 +172,11 @@ "descr": "Цветной текст", "val": "...", "round": 0, - "num": 8 + "num": 11 }, { "global": 0, - "name": "9. Виртуальная кнопка", + "name": "12. Виртуальная кнопка", "type": "Reading", "subtype": "VButton", "id": "vbtn", @@ -141,14 +186,44 @@ "descr": "Кнопка", "int": "0", "val": "0", - "num": 9 + "num": 12 }, { "header": "Сенсоры" }, + { + "name": "13. A02 Дальность", + "type": "Reading", + "subtype": "A02Distance", + "id": "dist", + "widget": "anydataCm", + "page": "Сенсоры", + "descr": "Дальность", + "int": 5, + "round": 1, + "num": 13 + }, + { + "name": "14. Acs712 Ток", + "type": "Reading", + "subtype": "Acs712", + "id": "amp", + "widget": "anydataAmp", + "page": "Сенсоры", + "descr": "Ток", + "round": 3, + "pin": 39, + "int": 5, + "rms": 1, + "vref": 5000, + "sens": 100, + "adczero": 512, + "btn-setZero": "nil", + "num": 14 + }, { "global": 0, - "name": "10. Аналоговый сенсор", + "name": "15. Аналоговый сенсор", "type": "Reading", "subtype": "AnalogAdc", "id": "t", @@ -162,11 +237,67 @@ "pin": 0, "int": 15, "avgSteps": 1, - "num": 10 + "num": 15 }, { "global": 0, - "name": "11. BMP280 Температура", + "name": "16. BME280 Температура", + "type": "Reading", + "subtype": "Bme280t", + "id": "Tmp3", + "widget": "anydataTmp", + "page": "Сенсоры", + "descr": "Температура", + "int": 15, + "addr": "0x77", + "round": 1, + "num": 16 + }, + { + "global": 0, + "name": "17. BME280 Давление", + "type": "Reading", + "subtype": "Bme280p", + "id": "Press3", + "widget": "anydataMm", + "page": "Сенсоры", + "descr": "Давление", + "int": 15, + "addr": "0x77", + "round": 1, + "num": 17 + }, + { + "global": 0, + "name": "18. BME280 Влажность", + "type": "Reading", + "subtype": "Bme280h", + "id": "Hum3", + "widget": "anydataHum", + "page": "Сенсоры", + "descr": "Влажность", + "int": 15, + "addr": "0x77", + "round": 1, + "num": 18 + }, + { + "global": 0, + "name": "19. BME280 Tочка росы", + "type": "Reading", + "subtype": "Bme280dp", + "id": "Dew3", + "widget": "anydataTmp", + "page": "Сенсоры", + "descr": "Точка росы", + "int": 15, + "addr": "0x77", + "round": 1, + "num": 19 + }, + { + "global": 0, + "name": "20. BMP280 Температура", "type": "Reading", "subtype": "Bmp280t", "id": "tmp3", @@ -176,11 +307,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 11 + "num": 20 }, { "global": 0, - "name": "12. BMP280 Давление", + "name": "21. BMP280 Давление", "type": "Reading", "subtype": "Bmp280p", "id": "Press3", @@ -190,11 +321,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 12 + "num": 21 }, { "global": 0, - "name": "13. DS18B20 Температура", + "name": "22. DS18B20 Температура", "type": "Reading", "subtype": "Ds18b20", "id": "dstmp", @@ -206,11 +337,128 @@ "index": 0, "addr": "", "round": 1, - "num": 13 + "num": 22 }, { "global": 0, - "name": "14. Часы реального времени", + "name": "23. Аналоговый счетчик импульсов", + "type": "Writing", + "subtype": "Impulse", + "id": "impulse", + "widget": "anydataDef", + "page": "Счетчики", + "descr": "Импульсов", + "needSave": 0, + "int": 1, + "pin": 16, + "pinMode": "INPUT", + "debounceDelay": 3, + "multiply": 1, + "num": 23 + }, + { + "global": 0, + "name": "24. PZEM 004t Напряжение", + "type": "Reading", + "subtype": "Pzem004v", + "id": "v", + "widget": "anydataVlt", + "page": "PZEM", + "descr": "Напряжение", + "int": 15, + "addr": "0xF8", + "round": 1, + "num": 24 + }, + { + "global": 0, + "name": "25. PZEM 004t Сила тока", + "type": "Reading", + "subtype": "Pzem004a", + "id": "a", + "widget": "anydataAmp", + "page": "PZEM", + "descr": "Сила тока", + "int": 15, + "addr": "0xF8", + "round": 1, + "num": 25 + }, + { + "global": 0, + "name": "26. PZEM 004t Мощность", + "type": "Reading", + "subtype": "Pzem004w", + "id": "w", + "widget": "anydataWt", + "page": "PZEM", + "descr": "Мощность", + "int": 15, + "addr": "0xF8", + "round": 1, + "num": 26 + }, + { + "global": 0, + "name": "27. PZEM 004t Энергия", + "type": "Reading", + "subtype": "Pzem004wh", + "id": "wh", + "widget": "anydataWth", + "page": "PZEM", + "descr": "Энергия", + "int": 15, + "addr": "0xF8", + "round": 1, + "num": 27 + }, + { + "global": 0, + "name": "28. PZEM 004t Частота", + "type": "Reading", + "subtype": "Pzem004hz", + "id": "hz", + "widget": "anydataHtz", + "page": "PZEM", + "descr": "Частота", + "int": 15, + "addr": "0xF8", + "round": 1, + "num": 28 + }, + { + "global": 0, + "name": "29. PZEM 004t Косинус", + "type": "Reading", + "subtype": "Pzem004pf", + "id": "pf", + "widget": "anydata", + "page": "PZEM", + "descr": "Косинус F", + "int": 15, + "addr": "0xF8", + "round": 1, + "num": 29 + }, + { + "global": 0, + "name": "30. PZEM настройка", + "type": "Reading", + "subtype": "Pzem004cmd", + "id": "set", + "widget": "nil", + "page": "", + "descr": "", + "int": 15, + "addr": "0xF8", + "changeaddr": 0, + "setaddr": "0x01", + "reset": 0, + "num": 30 + }, + { + "global": 0, + "name": "31. Часы реального времени", "type": "Reading", "subtype": "RTC", "id": "rtc", @@ -226,11 +474,11 @@ "int": 5, "btn-setUTime": "0", "btn-setSysTime": "nil", - "num": 14 + "num": 31 }, { "global": 0, - "name": "15. Sht20 Температура", + "name": "32. Sht20 Температура", "type": "Reading", "subtype": "Sht20t", "id": "tmp2", @@ -239,11 +487,11 @@ "descr": "Температура", "int": 15, "round": 1, - "num": 15 + "num": 32 }, { "global": 0, - "name": "16. Sht20 Влажность", + "name": "33. Sht20 Влажность", "type": "Reading", "subtype": "Sht20h", "id": "Hum2", @@ -252,11 +500,11 @@ "descr": "Влажность", "int": 15, "round": 1, - "num": 16 + "num": 33 }, { "global": 0, - "name": "17. Sht30 Температура", + "name": "34. Sht30 Температура", "type": "Reading", "subtype": "Sht30t", "id": "tmp30", @@ -265,11 +513,11 @@ "descr": "SHT30 Температура", "int": 15, "round": 1, - "num": 17 + "num": 34 }, { "global": 0, - "name": "18. Sht30 Влажность", + "name": "35. Sht30 Влажность", "type": "Reading", "subtype": "Sht30h", "id": "Hum30", @@ -278,12 +526,12 @@ "descr": "SHT30 Влажность", "int": 15, "round": 1, - "num": 18 + "num": 35 }, { "global": 0, - "name": "19. HC-SR04 Ультразвуковой дальномер", - "num": 19, + "name": "36. HC-SR04 Ультразвуковой дальномер", + "num": 36, "type": "Reading", "subtype": "Sonar", "id": "sonar", @@ -294,12 +542,27 @@ "pinEcho": 4, "int": 5 }, + { + "name": "37. UART", + "type": "Reading", + "subtype": "UART", + "page": "", + "descr": "", + "widget": "nil", + "id": "u", + "tx": 4, + "rx": 5, + "line": 2, + "speed": 9600, + "eventFormat": 0, + "num": 37 + }, { "header": "Исполнительные устройства" }, { "global": 0, - "name": "20. Кнопка подключенная к пину", + "name": "38. Кнопка подключенная к пину", "type": "Writing", "subtype": "ButtonIn", "id": "btn", @@ -314,11 +577,11 @@ "debounceDelay": 50, "fixState": 0, "inv": 0, - "num": 20 + "num": 38 }, { "global": 0, - "name": "21. Управление пином", + "name": "39. Управление пином", "type": "Writing", "subtype": "ButtonOut", "needSave": 0, @@ -329,11 +592,11 @@ "int": 0, "inv": 0, "pin": 2, - "num": 21 + "num": 39 }, { "global": 0, - "name": "22. Расширитель портов Mcp23017", + "name": "40. Расширитель портов Mcp23017", "type": "Reading", "subtype": "Mcp23017", "id": "Mcp", @@ -343,11 +606,11 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 22 + "num": 40 }, { "global": 0, - "name": "23. Сенсорная кнопка", + "name": "41. Сенсорная кнопка", "type": "Writing", "subtype": "Multitouch", "id": "impulse", @@ -361,11 +624,11 @@ "pinMode": "INPUT", "debounceDelay": 50, "PWMDelay": 500, - "num": 23 + "num": 41 }, { "global": 0, - "name": "24. Расширитель портов Pcf8574", + "name": "42. Расширитель портов Pcf8574", "type": "Reading", "subtype": "Pcf8574", "id": "Pcf", @@ -375,11 +638,11 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 24 + "num": 42 }, { "global": 0, - "name": "25. PWM ESP8266", + "name": "43. PWM ESP8266", "type": "Writing", "subtype": "Pwm8266", "id": "pwm", @@ -391,11 +654,11 @@ "freq": 5000, "val": 0, "apin": -1, - "num": 25 + "num": 43 }, { "global": 0, - "name": "26. Телеграм-Лайт", + "name": "44. Телеграм-Лайт", "type": "Writing", "subtype": "TelegramLT", "id": "tg", @@ -404,14 +667,14 @@ "descr": "", "token": "", "chatID": "", - "num": 26 + "num": 44 }, { "header": "Экраны" }, { "global": 0, - "name": "27. LCD экран 2004", + "name": "45. LCD экран 2004", "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -423,10 +686,10 @@ "size": "20,4", "coord": "0,0", "id2show": "id датчика", - "num": 27 + "num": 45 }, { - "name": "28. LCD экран 1602", + "name": "46. LCD экран 1602", "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -438,6 +701,6 @@ "size": "16,2", "coord": "0,0", "id2show": "id датчика", - "num": 28 + "num": 46 } ] \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index f5e22a8e..f2239849 100644 --- a/platformio.ini +++ b/platformio.ini @@ -178,7 +178,16 @@ build_src_filter = lib_deps = adafruit/Adafruit BME280 Library adafruit/Adafruit BMP280 Library - plerup/espsoftwareserial + https://github.com/milesburton/Arduino-Temperature-Control-Library + https://github.com/tremaru/iarduino_RTC + robtillaart/SHT2x@^0.1.1 + WEMOS SHT3x@1.0.0 + plerup/EspSoftwareSerial + adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 + adafruit/Adafruit BusIO @ ^1.13.2 + adafruit/Adafruit BusIO @ ^1.13.2 + https://github.com/robotclass/RobotClass_LiquidCrystal_I2C + marcoschwartz/LiquidCrystal_I2C@^1.1.4 build_src_filter = + + @@ -187,18 +196,43 @@ build_src_filter = + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [env:esp8266_1mb_fromitems] lib_deps = adafruit/Adafruit BME280 Library adafruit/Adafruit BMP280 Library - plerup/espsoftwareserial + https://github.com/milesburton/Arduino-Temperature-Control-Library + IRremote @ ^4.1.2 + https://github.com/tremaru/iarduino_RTC + robtillaart/SHT2x@^0.1.1 + WEMOS SHT3x@1.0.0 + plerup/EspSoftwareSerial + adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 + adafruit/Adafruit BusIO @ ^1.13.2 + adafruit/Adafruit BusIO @ ^1.13.2 + https://github.com/robotclass/RobotClass_LiquidCrystal_I2C + marcoschwartz/LiquidCrystal_I2C@^1.1.4 build_src_filter = + + @@ -207,13 +241,28 @@ build_src_filter = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [env:esp8266_2mb_fromitems] lib_deps = @@ -274,27 +323,41 @@ build_src_filter = lib_deps = adafruit/Adafruit BME280 Library adafruit/Adafruit BMP280 Library - milesburton/DallasTemperature@^3.9.1 + https://github.com/milesburton/Arduino-Temperature-Control-Library + https://github.com/tremaru/iarduino_RTC robtillaart/SHT2x@^0.1.1 WEMOS SHT3x@1.0.0 + plerup/EspSoftwareSerial + gyverlibs/EncButton @ ^2.0 adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 adafruit/Adafruit BusIO @ ^1.13.2 adafruit/Adafruit BusIO @ ^1.13.2 + https://github.com/robotclass/RobotClass_LiquidCrystal_I2C marcoschwartz/LiquidCrystal_I2C@^1.1.4 build_src_filter = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -313,6 +376,61 @@ lib_deps = robtillaart/SHT2x@^0.1.1 WEMOS SHT3x@1.0.0 plerup/EspSoftwareSerial + gyverlibs/EncButton @ ^2.0 + adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 + adafruit/Adafruit BusIO @ ^1.13.2 + dfrobot/DFRobotDFPlayerMini @ ^1.0.5 + adafruit/Adafruit BusIO @ ^1.13.2 + https://github.com/robotclass/RobotClass_LiquidCrystal_I2C + marcoschwartz/LiquidCrystal_I2C@^1.1.4 +build_src_filter = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[env:esp32_4mb_fromitems] +lib_deps = + https://github.com/enjoyneering/AHTxx.git + adafruit/Adafruit BME280 Library + adafruit/Adafruit BMP280 Library + beegee-tokyo/DHT sensor library for ESPx + https://github.com/milesburton/Arduino-Temperature-Control-Library + https://github.com/tremaru/iarduino_RTC + robtillaart/SHT2x@^0.1.1 + WEMOS SHT3x@1.0.0 + plerup/EspSoftwareSerial + https://github.com/RoboticsBrno/ServoESP32 adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 adafruit/Adafruit BusIO @ ^1.13.2 dfrobot/DFRobotDFPlayerMini @ ^1.0.5 @@ -337,6 +455,7 @@ build_src_filter = + + + + + + + + @@ -348,30 +467,7 @@ build_src_filter = + + + - + + + + + -[env:esp32_4mb_fromitems] -lib_deps = - adafruit/Adafruit BME280 Library - adafruit/Adafruit BMP280 Library - https://github.com/tremaru/iarduino_RTC - plerup/EspSoftwareSerial -build_src_filter = - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - diff --git a/src/modules/API.cpp b/src/modules/API.cpp index 12480f10..7e9a1f3d 100644 --- a/src/modules/API.cpp +++ b/src/modules/API.cpp @@ -7,6 +7,7 @@ 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_A02Distance(String subtype, String params); void* getAPI_Acs712(String subtype, String params); void* getAPI_AhtXX(String subtype, String params); void* getAPI_AnalogAdc(String subtype, String params); @@ -17,12 +18,14 @@ void* getAPI_Ds18b20(String subtype, String params); void* getAPI_Impulse(String subtype, String params); void* getAPI_Pzem004(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_ButtonIn(String subtype, String params); void* getAPI_ButtonOut(String subtype, String params); +void* getAPI_Encoder(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); @@ -41,6 +44,7 @@ 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_A02Distance(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Acs712(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_AhtXX(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_AnalogAdc(subtype, params)) != nullptr) return tmpAPI; @@ -51,12 +55,14 @@ 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_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_ButtonIn(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_Encoder(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; From b146c75389b56dce8dfa18a798185b089d1fcd24 Mon Sep 17 00:00:00 2001 From: biver Date: Tue, 16 May 2023 12:22:48 +0300 Subject: [PATCH 12/14] =?UTF-8?q?=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D1=81=D0=B1=D0=BE=D1=80=D0=BA=D0=B5=20?= =?UTF-8?q?=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D1=8F=D0=B5=D0=BC=20=D1=82?= =?UTF-8?q?=D0=B5=D0=BA=D1=83=D1=89=D0=B8=D0=B9=20=D0=BF=D1=80=D0=BE=D1=84?= =?UTF-8?q?=D0=B8=D0=BB=D1=8C=20=D0=BD=D0=B0=20=D0=BA=D0=BE=D0=BD=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=BB=D0=BB=D0=B5=D1=80=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=B1=D1=83=D0=B4=D1=83=D1=89=D0=B5=D0=B3=D0=BE=20=D0=B8=D1=81?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B8=20=D0=BF=D0=BE=D0=BD=D0=B8=D0=BC=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BA=D0=B0=D0=BA=20=D0=B1=D1=8B=D0=BB=D0=B0=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B1=D1=80=D0=B0=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=88=D0=B8=D0=B2=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PrepareProject.py | 5 + data_svelte/items.json | 199 +++++++++------------- data_svelte/myProfile.json | 289 ++++++++++++++++++++++++++++++++ data_svelte_lite/items.json | 144 ++++++++-------- data_svelte_lite/myProfile.json | 289 ++++++++++++++++++++++++++++++++ platformio.ini | 5 - src/modules/API.cpp | 6 - 7 files changed, 727 insertions(+), 210 deletions(-) create mode 100644 data_svelte/myProfile.json create mode 100644 data_svelte_lite/myProfile.json diff --git a/PrepareProject.py b/PrepareProject.py index 50e37ebd..d29c8da4 100644 --- a/PrepareProject.py +++ b/PrepareProject.py @@ -26,6 +26,7 @@ import configparser import os, json, sys, getopt from pathlib import Path +import shutil config = configparser.ConfigParser() # создаём объекта парсера INI @@ -202,6 +203,10 @@ config["platformio"]["default_envs"] = deviceName config["platformio"]["data_dir"] = profJson['projectProp']['platformio']['data_dir'] with open("platformio.ini", 'w') as configFile: config.write(configFile) + +# сохраняем применяемый профиль в папку data_svelte для загрузки на контроллер и дальнейшего переиспользования +print(f"Сохраняем профиль {profile} в {dataDir}") +shutil.copy(profile, dataDir + "/" + profile) # import ctypes # An included library with Python install. diff --git a/data_svelte/items.json b/data_svelte/items.json index f011b1ff..7e530a2f 100644 --- a/data_svelte/items.json +++ b/data_svelte/items.json @@ -192,19 +192,7 @@ "header": "Сенсоры" }, { - "name": "13. A02 Дальность", - "type": "Reading", - "subtype": "A02Distance", - "id": "dist", - "widget": "anydataCm", - "page": "Сенсоры", - "descr": "Дальность", - "int": 5, - "round": 1, - "num": 13 - }, - { - "name": "14. Acs712 Ток", + "name": "13. Acs712 Ток", "type": "Reading", "subtype": "Acs712", "id": "amp", @@ -219,11 +207,11 @@ "sens": 100, "adczero": 512, "btn-setZero": "nil", - "num": 14 + "num": 13 }, { "global": 0, - "name": "15. AHTXX Температура", + "name": "14. AHTXX Температура", "type": "Reading", "subtype": "AhtXXt", "id": "Temp20", @@ -234,11 +222,11 @@ "addr": "0x38", "shtType": 1, "round": 1, - "num": 15 + "num": 14 }, { "global": 0, - "name": "16. AHTXX Влажность", + "name": "15. AHTXX Влажность", "type": "Reading", "subtype": "AhtXXh", "id": "Hum20", @@ -249,11 +237,11 @@ "addr": "0x38", "shtType": 1, "round": 1, - "num": 16 + "num": 15 }, { "global": 0, - "name": "17. Аналоговый сенсор", + "name": "16. Аналоговый сенсор", "type": "Reading", "subtype": "AnalogAdc", "id": "t", @@ -267,11 +255,11 @@ "pin": 0, "int": 15, "avgSteps": 1, - "num": 17 + "num": 16 }, { "global": 0, - "name": "18. BME280 Температура", + "name": "17. BME280 Температура", "type": "Reading", "subtype": "Bme280t", "id": "Tmp3", @@ -281,11 +269,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 18 + "num": 17 }, { "global": 0, - "name": "19. BME280 Давление", + "name": "18. BME280 Давление", "type": "Reading", "subtype": "Bme280p", "id": "Press3", @@ -295,11 +283,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 19 + "num": 18 }, { "global": 0, - "name": "20. BME280 Влажность", + "name": "19. BME280 Влажность", "type": "Reading", "subtype": "Bme280h", "id": "Hum3", @@ -309,11 +297,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 20 + "num": 19 }, { "global": 0, - "name": "21. BME280 Tочка росы", + "name": "20. BME280 Tочка росы", "type": "Reading", "subtype": "Bme280dp", "id": "Dew3", @@ -323,11 +311,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 21 + "num": 20 }, { "global": 0, - "name": "22. BMP280 Температура", + "name": "21. BMP280 Температура", "type": "Reading", "subtype": "Bmp280t", "id": "tmp3", @@ -337,11 +325,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 22 + "num": 21 }, { "global": 0, - "name": "23. BMP280 Давление", + "name": "22. BMP280 Давление", "type": "Reading", "subtype": "Bmp280p", "id": "Press3", @@ -351,11 +339,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 23 + "num": 22 }, { "global": 0, - "name": "24. DHT11 Температура", + "name": "23. DHT11 Температура", "type": "Reading", "subtype": "Dht1122t", "id": "tmp3", @@ -365,11 +353,11 @@ "int": 15, "pin": 0, "senstype": "dht11", - "num": 24 + "num": 23 }, { "global": 0, - "name": "25. DHT11 Влажность", + "name": "24. DHT11 Влажность", "type": "Reading", "subtype": "Dht1122h", "id": "Hum3", @@ -379,11 +367,11 @@ "int": 15, "pin": 0, "senstype": "dht11", - "num": 25 + "num": 24 }, { "global": 0, - "name": "26. DS18B20 Температура", + "name": "25. DS18B20 Температура", "type": "Reading", "subtype": "Ds18b20", "id": "dstmp", @@ -395,11 +383,11 @@ "index": 0, "addr": "", "round": 1, - "num": 26 + "num": 25 }, { "global": 0, - "name": "27. Аналоговый счетчик импульсов", + "name": "26. Аналоговый счетчик импульсов", "type": "Writing", "subtype": "Impulse", "id": "impulse", @@ -412,11 +400,11 @@ "pinMode": "INPUT", "debounceDelay": 3, "multiply": 1, - "num": 27 + "num": 26 }, { "global": 0, - "name": "28. PZEM 004t Напряжение", + "name": "27. PZEM 004t Напряжение", "type": "Reading", "subtype": "Pzem004v", "id": "v", @@ -426,11 +414,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 28 + "num": 27 }, { "global": 0, - "name": "29. PZEM 004t Сила тока", + "name": "28. PZEM 004t Сила тока", "type": "Reading", "subtype": "Pzem004a", "id": "a", @@ -440,11 +428,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 29 + "num": 28 }, { "global": 0, - "name": "30. PZEM 004t Мощность", + "name": "29. PZEM 004t Мощность", "type": "Reading", "subtype": "Pzem004w", "id": "w", @@ -454,11 +442,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 30 + "num": 29 }, { "global": 0, - "name": "31. PZEM 004t Энергия", + "name": "30. PZEM 004t Энергия", "type": "Reading", "subtype": "Pzem004wh", "id": "wh", @@ -468,11 +456,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 31 + "num": 30 }, { "global": 0, - "name": "32. PZEM 004t Частота", + "name": "31. PZEM 004t Частота", "type": "Reading", "subtype": "Pzem004hz", "id": "hz", @@ -482,11 +470,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 32 + "num": 31 }, { "global": 0, - "name": "33. PZEM 004t Косинус", + "name": "32. PZEM 004t Косинус", "type": "Reading", "subtype": "Pzem004pf", "id": "pf", @@ -496,11 +484,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 33 + "num": 32 }, { "global": 0, - "name": "34. PZEM настройка", + "name": "33. PZEM настройка", "type": "Reading", "subtype": "Pzem004cmd", "id": "set", @@ -512,11 +500,11 @@ "changeaddr": 0, "setaddr": "0x01", "reset": 0, - "num": 34 + "num": 33 }, { "global": 0, - "name": "35. Часы реального времени", + "name": "34. Часы реального времени", "type": "Reading", "subtype": "RTC", "id": "rtc", @@ -532,25 +520,11 @@ "int": 5, "btn-setUTime": "0", "btn-setSysTime": "nil", - "num": 35 - }, - { - "name": "36. (S8) Cенсор качества воздуха", - "num": 36, - "type": "Reading", - "subtype": "S8co", - "id": "s8co", - "widget": "anydataPpm", - "page": "Сенсоры", - "descr": "S8_CO2", - "int": 15, - "round": 1, - "rxPin": 13, - "txPin": 15 + "num": 34 }, { "global": 0, - "name": "37. Sht20 Температура", + "name": "35. Sht20 Температура", "type": "Reading", "subtype": "Sht20t", "id": "tmp2", @@ -559,11 +533,11 @@ "descr": "Температура", "int": 15, "round": 1, - "num": 37 + "num": 35 }, { "global": 0, - "name": "38. Sht20 Влажность", + "name": "36. Sht20 Влажность", "type": "Reading", "subtype": "Sht20h", "id": "Hum2", @@ -572,11 +546,11 @@ "descr": "Влажность", "int": 15, "round": 1, - "num": 38 + "num": 36 }, { "global": 0, - "name": "39. Sht30 Температура", + "name": "37. Sht30 Температура", "type": "Reading", "subtype": "Sht30t", "id": "tmp30", @@ -585,11 +559,11 @@ "descr": "SHT30 Температура", "int": 15, "round": 1, - "num": 39 + "num": 37 }, { "global": 0, - "name": "40. Sht30 Влажность", + "name": "38. Sht30 Влажность", "type": "Reading", "subtype": "Sht30h", "id": "Hum30", @@ -598,12 +572,12 @@ "descr": "SHT30 Влажность", "int": 15, "round": 1, - "num": 40 + "num": 38 }, { "global": 0, - "name": "41. HC-SR04 Ультразвуковой дальномер", - "num": 41, + "name": "39. HC-SR04 Ультразвуковой дальномер", + "num": 39, "type": "Reading", "subtype": "Sonar", "id": "sonar", @@ -615,7 +589,7 @@ "int": 5 }, { - "name": "42. UART", + "name": "40. UART", "type": "Reading", "subtype": "UART", "page": "", @@ -627,14 +601,14 @@ "line": 2, "speed": 9600, "eventFormat": 0, - "num": 42 + "num": 40 }, { "header": "Исполнительные устройства" }, { "global": 0, - "name": "43. Кнопка подключенная к пину", + "name": "41. Кнопка подключенная к пину", "type": "Writing", "subtype": "ButtonIn", "id": "btn", @@ -649,11 +623,11 @@ "debounceDelay": 50, "fixState": 0, "inv": 0, - "num": 43 + "num": 41 }, { "global": 0, - "name": "44. Управление пином", + "name": "42. Управление пином", "type": "Writing", "subtype": "ButtonOut", "needSave": 0, @@ -664,28 +638,11 @@ "int": 0, "inv": 0, "pin": 2, - "num": 44 + "num": 42 }, { "global": 0, - "name": "45. Энкодер", - "type": "Writing", - "subtype": "Encoder", - "id": "enc", - "widget": "inputDgt", - "page": "Энкодер", - "descr": "Громкость", - "needSave": 0, - "val": "0", - "round": 0, - "step": 1, - "stepOnPress": 5, - "pins": "4,5,2", - "num": 45 - }, - { - "global": 0, - "name": "46. Сервопривод", + "name": "43. Сервопривод", "type": "Writing", "subtype": "IoTServo", "id": "servo", @@ -696,11 +653,11 @@ "pin": 12, "apin": -1, "amap": "0, 4096, 0, 180", - "num": 46 + "num": 43 }, { "global": 0, - "name": "47. Расширитель портов Mcp23017", + "name": "44. Расширитель портов Mcp23017", "type": "Reading", "subtype": "Mcp23017", "id": "Mcp", @@ -710,11 +667,11 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 47 + "num": 44 }, { "global": 0, - "name": "48. MP3 плеер", + "name": "45. MP3 плеер", "type": "Reading", "subtype": "Mp3", "id": "mp3", @@ -724,11 +681,11 @@ "int": 1, "pins": "14,12", "volume": 20, - "num": 48 + "num": 45 }, { "global": 0, - "name": "49. Сенсорная кнопка", + "name": "46. Сенсорная кнопка", "type": "Writing", "subtype": "Multitouch", "id": "impulse", @@ -742,11 +699,11 @@ "pinMode": "INPUT", "debounceDelay": 50, "PWMDelay": 500, - "num": 49 + "num": 46 }, { "global": 0, - "name": "50. Расширитель портов Pcf8574", + "name": "47. Расширитель портов Pcf8574", "type": "Reading", "subtype": "Pcf8574", "id": "Pcf", @@ -756,11 +713,11 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 50 + "num": 47 }, { "global": 0, - "name": "51. PWM ESP8266", + "name": "48. PWM ESP8266", "type": "Writing", "subtype": "Pwm8266", "id": "pwm", @@ -772,11 +729,11 @@ "freq": 5000, "val": 0, "apin": -1, - "num": 51 + "num": 48 }, { "global": 0, - "name": "52. Телеграм-Лайт", + "name": "49. Телеграм-Лайт", "type": "Writing", "subtype": "TelegramLT", "id": "tg", @@ -785,14 +742,14 @@ "descr": "", "token": "", "chatID": "", - "num": 52 + "num": 49 }, { "header": "Экраны" }, { "global": 0, - "name": "53. LCD экран 2004", + "name": "50. LCD экран 2004", "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -804,10 +761,10 @@ "size": "20,4", "coord": "0,0", "id2show": "id датчика", - "num": 53 + "num": 50 }, { - "name": "54. LCD экран 1602", + "name": "51. LCD экран 1602", "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -819,6 +776,6 @@ "size": "16,2", "coord": "0,0", "id2show": "id датчика", - "num": 54 + "num": 51 } ] \ No newline at end of file diff --git a/data_svelte/myProfile.json b/data_svelte/myProfile.json new file mode 100644 index 00000000..17ee601d --- /dev/null +++ b/data_svelte/myProfile.json @@ -0,0 +1,289 @@ +{ + "iotmSettings": { + "name": "IoTmanagerVer4", + "apssid": "IoTmanager", + "appass": "", + "routerssid": "rise", + "routerpass": "hostel3333", + "timezone": 2, + "ntp": "pool.ntp.org", + "weblogin": "admin", + "webpass": "admin", + "mqttServer": "", + "mqttPort": 8021, + "mqttPrefix": "/risenew", + "mqttUser": "rise", + "mqttPass": "3hostel3", + "serverip": "http://iotmanager.org", + "log": 0, + "mqttin": 0, + "pinSCL": 0, + "pinSDA": 0, + "i2cFreq": 100000, + "wg": "group1" + }, + "projectProp": { + "platformio": { + "default_envs": "esp8266_4mb", + "comments_default_envs": "choose from: esp8266_4mb or esp32_4mb or esp8266_1mb or esp8266_1mb_ota or esp8285_1mb or esp8285_1mb_ota" + } + }, + "modules": { + "Виртуальные элементы": [ + { + "path": "src/modules/virtual/Cron", + "active": true + }, + { + "path": "src/modules/virtual/Loging", + "active": true + }, + { + "path": "src/modules/virtual/LogingDaily", + "active": true + }, + { + "path": "src/modules/virtual/Timer", + "active": true + }, + { + "path": "src/modules/virtual/Variable", + "active": true + }, + { + "path": "src/modules/virtual/VariableColor", + "active": true + }, + { + "path": "src/modules/virtual/VButton", + "active": true + }, + { + "path": "src/modules/virtual/Weather", + "active": false + } + ], + "Сенсоры": [ + { + "path": "src/modules/sensors/Acs712", + "active": true + }, + { + "path": "src/modules/sensors/Ads1115", + "active": false + }, + { + "path": "src/modules/sensors/AhtXX", + "active": true + }, + { + "path": "src/modules/sensors/AnalogAdc", + "active": true + }, + { + "path": "src/modules/sensors/BH_1750", + "active": false + }, + { + "path": "src/modules/sensors/Ble", + "active": false + }, + { + "path": "src/modules/sensors/Bme280", + "active": true + }, + { + "path": "src/modules/sensors/Bmp280", + "active": true + }, + { + "path": "src/modules/sensors/Dht1122", + "active": true + }, + { + "path": "src/modules/sensors/Ds18b20", + "active": true + }, + { + "path": "src/modules/sensors/DS2401", + "active": false + }, + { + "path": "src/modules/sensors/Emon", + "active": false + }, + { + "path": "src/modules/sensors/ExternalMQTT", + "active": false + }, + { + "path": "src/modules/sensors/FreqMeter", + "active": false + }, + { + "path": "src/modules/sensors/GY21", + "active": false + }, + { + "path": "src/modules/sensors/Hdc1080", + "active": false + }, + { + "path": "src/modules/sensors/Hx710", + "active": false + }, + { + "path": "src/modules/sensors/Hx711", + "active": false + }, + { + "path": "src/modules/sensors/Impulse", + "active": true + }, + { + "path": "src/modules/sensors/Ina219", + "active": false + }, + { + "path": "src/modules/sensors/IoTWiegand", + "active": false + }, + { + "path": "src/modules/sensors/Max6675", + "active": false + }, + { + "path": "src/modules/sensors/Mhz19", + "active": false + }, + { + "path": "src/modules/sensors/Pzem004t", + "active": true + }, + { + "path": "src/modules/sensors/RCswitch", + "active": false + }, + { + "path": "src/modules/sensors/RTC", + "active": true + }, + { + "path": "src/modules/sensors/Sds011", + "active": false + }, + { + "path": "src/modules/sensors/Sgp30", + "active": false + }, + { + "path": "src/modules/sensors/Sht20", + "active": true + }, + { + "path": "src/modules/sensors/Sht30", + "active": true + }, + { + "path": "src/modules/sensors/Sonar", + "active": true + }, + { + "path": "src/modules/sensors/UART", + "active": true + } + ], + "Исполнительные устройства": [ + { + "path": "src/modules/exec/ButtonIn", + "active": true + }, + { + "path": "src/modules/exec/ButtonOut", + "active": true + }, + { + "path": "src/modules/exec/EspCam", + "active": false + }, + { + "path": "src/modules/exec/HttpGet", + "active": false + }, + { + "path": "src/modules/exec/IoTServo", + "active": true + }, + { + "path": "src/modules/exec/Mcp23008", + "active": false + }, + { + "path": "src/modules/exec/Mcp23017", + "active": true + }, + { + "path": "src/modules/exec/Mp3", + "active": true + }, + { + "path": "src/modules/exec/Multitouch", + "active": true + }, + { + "path": "src/modules/exec/MySensors", + "active": false + }, + { + "path": "src/modules/exec/Pcf8574", + "active": true + }, + { + "path": "src/modules/exec/Pwm32", + "active": true + }, + { + "path": "src/modules/exec/Pwm8266", + "active": true + }, + { + "path": "src/modules/exec/SDcard", + "active": false + }, + { + "path": "src/modules/exec/SysExt", + "active": false + }, + { + "path": "src/modules/exec/Telegram", + "active": false + }, + { + "path": "src/modules/exec/TelegramLT", + "active": true + }, + { + "path": "src/modules/exec/Thermostat", + "active": false + } + ], + "Экраны": [ + { + "path": "src/modules/display/DwinI", + "active": false + }, + { + "path": "src/modules/display/Lcd2004", + "active": true + }, + { + "path": "src/modules/display/NextionUpload", + "active": false + }, + { + "path": "src/modules/display/Ws2812b", + "active": false + } + ] + } +} \ No newline at end of file diff --git a/data_svelte_lite/items.json b/data_svelte_lite/items.json index 2d7b8c7a..b8a7410e 100644 --- a/data_svelte_lite/items.json +++ b/data_svelte_lite/items.json @@ -192,19 +192,7 @@ "header": "Сенсоры" }, { - "name": "13. A02 Дальность", - "type": "Reading", - "subtype": "A02Distance", - "id": "dist", - "widget": "anydataCm", - "page": "Сенсоры", - "descr": "Дальность", - "int": 5, - "round": 1, - "num": 13 - }, - { - "name": "14. Acs712 Ток", + "name": "13. Acs712 Ток", "type": "Reading", "subtype": "Acs712", "id": "amp", @@ -219,11 +207,11 @@ "sens": 100, "adczero": 512, "btn-setZero": "nil", - "num": 14 + "num": 13 }, { "global": 0, - "name": "15. Аналоговый сенсор", + "name": "14. Аналоговый сенсор", "type": "Reading", "subtype": "AnalogAdc", "id": "t", @@ -237,11 +225,11 @@ "pin": 0, "int": 15, "avgSteps": 1, - "num": 15 + "num": 14 }, { "global": 0, - "name": "16. BME280 Температура", + "name": "15. BME280 Температура", "type": "Reading", "subtype": "Bme280t", "id": "Tmp3", @@ -251,11 +239,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 16 + "num": 15 }, { "global": 0, - "name": "17. BME280 Давление", + "name": "16. BME280 Давление", "type": "Reading", "subtype": "Bme280p", "id": "Press3", @@ -265,11 +253,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 17 + "num": 16 }, { "global": 0, - "name": "18. BME280 Влажность", + "name": "17. BME280 Влажность", "type": "Reading", "subtype": "Bme280h", "id": "Hum3", @@ -279,11 +267,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 18 + "num": 17 }, { "global": 0, - "name": "19. BME280 Tочка росы", + "name": "18. BME280 Tочка росы", "type": "Reading", "subtype": "Bme280dp", "id": "Dew3", @@ -293,11 +281,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 19 + "num": 18 }, { "global": 0, - "name": "20. BMP280 Температура", + "name": "19. BMP280 Температура", "type": "Reading", "subtype": "Bmp280t", "id": "tmp3", @@ -307,11 +295,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 20 + "num": 19 }, { "global": 0, - "name": "21. BMP280 Давление", + "name": "20. BMP280 Давление", "type": "Reading", "subtype": "Bmp280p", "id": "Press3", @@ -321,11 +309,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 21 + "num": 20 }, { "global": 0, - "name": "22. DS18B20 Температура", + "name": "21. DS18B20 Температура", "type": "Reading", "subtype": "Ds18b20", "id": "dstmp", @@ -337,11 +325,11 @@ "index": 0, "addr": "", "round": 1, - "num": 22 + "num": 21 }, { "global": 0, - "name": "23. Аналоговый счетчик импульсов", + "name": "22. Аналоговый счетчик импульсов", "type": "Writing", "subtype": "Impulse", "id": "impulse", @@ -354,11 +342,11 @@ "pinMode": "INPUT", "debounceDelay": 3, "multiply": 1, - "num": 23 + "num": 22 }, { "global": 0, - "name": "24. PZEM 004t Напряжение", + "name": "23. PZEM 004t Напряжение", "type": "Reading", "subtype": "Pzem004v", "id": "v", @@ -368,11 +356,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 24 + "num": 23 }, { "global": 0, - "name": "25. PZEM 004t Сила тока", + "name": "24. PZEM 004t Сила тока", "type": "Reading", "subtype": "Pzem004a", "id": "a", @@ -382,11 +370,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 25 + "num": 24 }, { "global": 0, - "name": "26. PZEM 004t Мощность", + "name": "25. PZEM 004t Мощность", "type": "Reading", "subtype": "Pzem004w", "id": "w", @@ -396,11 +384,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 26 + "num": 25 }, { "global": 0, - "name": "27. PZEM 004t Энергия", + "name": "26. PZEM 004t Энергия", "type": "Reading", "subtype": "Pzem004wh", "id": "wh", @@ -410,11 +398,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 27 + "num": 26 }, { "global": 0, - "name": "28. PZEM 004t Частота", + "name": "27. PZEM 004t Частота", "type": "Reading", "subtype": "Pzem004hz", "id": "hz", @@ -424,11 +412,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 28 + "num": 27 }, { "global": 0, - "name": "29. PZEM 004t Косинус", + "name": "28. PZEM 004t Косинус", "type": "Reading", "subtype": "Pzem004pf", "id": "pf", @@ -438,11 +426,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 29 + "num": 28 }, { "global": 0, - "name": "30. PZEM настройка", + "name": "29. PZEM настройка", "type": "Reading", "subtype": "Pzem004cmd", "id": "set", @@ -454,11 +442,11 @@ "changeaddr": 0, "setaddr": "0x01", "reset": 0, - "num": 30 + "num": 29 }, { "global": 0, - "name": "31. Часы реального времени", + "name": "30. Часы реального времени", "type": "Reading", "subtype": "RTC", "id": "rtc", @@ -474,11 +462,11 @@ "int": 5, "btn-setUTime": "0", "btn-setSysTime": "nil", - "num": 31 + "num": 30 }, { "global": 0, - "name": "32. Sht20 Температура", + "name": "31. Sht20 Температура", "type": "Reading", "subtype": "Sht20t", "id": "tmp2", @@ -487,11 +475,11 @@ "descr": "Температура", "int": 15, "round": 1, - "num": 32 + "num": 31 }, { "global": 0, - "name": "33. Sht20 Влажность", + "name": "32. Sht20 Влажность", "type": "Reading", "subtype": "Sht20h", "id": "Hum2", @@ -500,11 +488,11 @@ "descr": "Влажность", "int": 15, "round": 1, - "num": 33 + "num": 32 }, { "global": 0, - "name": "34. Sht30 Температура", + "name": "33. Sht30 Температура", "type": "Reading", "subtype": "Sht30t", "id": "tmp30", @@ -513,11 +501,11 @@ "descr": "SHT30 Температура", "int": 15, "round": 1, - "num": 34 + "num": 33 }, { "global": 0, - "name": "35. Sht30 Влажность", + "name": "34. Sht30 Влажность", "type": "Reading", "subtype": "Sht30h", "id": "Hum30", @@ -526,12 +514,12 @@ "descr": "SHT30 Влажность", "int": 15, "round": 1, - "num": 35 + "num": 34 }, { "global": 0, - "name": "36. HC-SR04 Ультразвуковой дальномер", - "num": 36, + "name": "35. HC-SR04 Ультразвуковой дальномер", + "num": 35, "type": "Reading", "subtype": "Sonar", "id": "sonar", @@ -543,7 +531,7 @@ "int": 5 }, { - "name": "37. UART", + "name": "36. UART", "type": "Reading", "subtype": "UART", "page": "", @@ -555,14 +543,14 @@ "line": 2, "speed": 9600, "eventFormat": 0, - "num": 37 + "num": 36 }, { "header": "Исполнительные устройства" }, { "global": 0, - "name": "38. Кнопка подключенная к пину", + "name": "37. Кнопка подключенная к пину", "type": "Writing", "subtype": "ButtonIn", "id": "btn", @@ -577,11 +565,11 @@ "debounceDelay": 50, "fixState": 0, "inv": 0, - "num": 38 + "num": 37 }, { "global": 0, - "name": "39. Управление пином", + "name": "38. Управление пином", "type": "Writing", "subtype": "ButtonOut", "needSave": 0, @@ -592,11 +580,11 @@ "int": 0, "inv": 0, "pin": 2, - "num": 39 + "num": 38 }, { "global": 0, - "name": "40. Расширитель портов Mcp23017", + "name": "39. Расширитель портов Mcp23017", "type": "Reading", "subtype": "Mcp23017", "id": "Mcp", @@ -606,11 +594,11 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 40 + "num": 39 }, { "global": 0, - "name": "41. Сенсорная кнопка", + "name": "40. Сенсорная кнопка", "type": "Writing", "subtype": "Multitouch", "id": "impulse", @@ -624,11 +612,11 @@ "pinMode": "INPUT", "debounceDelay": 50, "PWMDelay": 500, - "num": 41 + "num": 40 }, { "global": 0, - "name": "42. Расширитель портов Pcf8574", + "name": "41. Расширитель портов Pcf8574", "type": "Reading", "subtype": "Pcf8574", "id": "Pcf", @@ -638,11 +626,11 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 42 + "num": 41 }, { "global": 0, - "name": "43. PWM ESP8266", + "name": "42. PWM ESP8266", "type": "Writing", "subtype": "Pwm8266", "id": "pwm", @@ -654,11 +642,11 @@ "freq": 5000, "val": 0, "apin": -1, - "num": 43 + "num": 42 }, { "global": 0, - "name": "44. Телеграм-Лайт", + "name": "43. Телеграм-Лайт", "type": "Writing", "subtype": "TelegramLT", "id": "tg", @@ -667,14 +655,14 @@ "descr": "", "token": "", "chatID": "", - "num": 44 + "num": 43 }, { "header": "Экраны" }, { "global": 0, - "name": "45. LCD экран 2004", + "name": "44. LCD экран 2004", "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -686,10 +674,10 @@ "size": "20,4", "coord": "0,0", "id2show": "id датчика", - "num": 45 + "num": 44 }, { - "name": "46. LCD экран 1602", + "name": "45. LCD экран 1602", "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -701,6 +689,6 @@ "size": "16,2", "coord": "0,0", "id2show": "id датчика", - "num": 46 + "num": 45 } ] \ No newline at end of file diff --git a/data_svelte_lite/myProfile.json b/data_svelte_lite/myProfile.json new file mode 100644 index 00000000..24d8a8db --- /dev/null +++ b/data_svelte_lite/myProfile.json @@ -0,0 +1,289 @@ +{ + "iotmSettings": { + "name": "IoTmanagerVer4", + "apssid": "IoTmanager", + "appass": "", + "routerssid": "rise", + "routerpass": "hostel3333", + "timezone": 2, + "ntp": "pool.ntp.org", + "weblogin": "admin", + "webpass": "admin", + "mqttServer": "", + "mqttPort": 8021, + "mqttPrefix": "/risenew", + "mqttUser": "rise", + "mqttPass": "3hostel3", + "serverip": "http://iotmanager.org", + "log": 0, + "mqttin": 0, + "pinSCL": 0, + "pinSDA": 0, + "i2cFreq": 100000, + "wg": "group1" + }, + "projectProp": { + "platformio": { + "default_envs": "esp8266_1mb_ota", + "comments_default_envs": "choose from: esp8266_4mb or esp32_4mb or esp8266_1mb or esp8266_1mb_ota or esp8285_1mb or esp8285_1mb_ota" + } + }, + "modules": { + "Виртуальные элементы": [ + { + "path": "src/modules/virtual/Cron", + "active": true + }, + { + "path": "src/modules/virtual/Loging", + "active": true + }, + { + "path": "src/modules/virtual/LogingDaily", + "active": true + }, + { + "path": "src/modules/virtual/Timer", + "active": true + }, + { + "path": "src/modules/virtual/Variable", + "active": true + }, + { + "path": "src/modules/virtual/VariableColor", + "active": true + }, + { + "path": "src/modules/virtual/VButton", + "active": true + }, + { + "path": "src/modules/virtual/Weather", + "active": false + } + ], + "Сенсоры": [ + { + "path": "src/modules/sensors/Acs712", + "active": true + }, + { + "path": "src/modules/sensors/Ads1115", + "active": false + }, + { + "path": "src/modules/sensors/AhtXX", + "active": true + }, + { + "path": "src/modules/sensors/AnalogAdc", + "active": true + }, + { + "path": "src/modules/sensors/BH_1750", + "active": false + }, + { + "path": "src/modules/sensors/Ble", + "active": false + }, + { + "path": "src/modules/sensors/Bme280", + "active": true + }, + { + "path": "src/modules/sensors/Bmp280", + "active": true + }, + { + "path": "src/modules/sensors/Dht1122", + "active": true + }, + { + "path": "src/modules/sensors/Ds18b20", + "active": true + }, + { + "path": "src/modules/sensors/DS2401", + "active": false + }, + { + "path": "src/modules/sensors/Emon", + "active": false + }, + { + "path": "src/modules/sensors/ExternalMQTT", + "active": false + }, + { + "path": "src/modules/sensors/FreqMeter", + "active": false + }, + { + "path": "src/modules/sensors/GY21", + "active": false + }, + { + "path": "src/modules/sensors/Hdc1080", + "active": false + }, + { + "path": "src/modules/sensors/Hx710", + "active": false + }, + { + "path": "src/modules/sensors/Hx711", + "active": false + }, + { + "path": "src/modules/sensors/Impulse", + "active": true + }, + { + "path": "src/modules/sensors/Ina219", + "active": false + }, + { + "path": "src/modules/sensors/IoTWiegand", + "active": false + }, + { + "path": "src/modules/sensors/Max6675", + "active": false + }, + { + "path": "src/modules/sensors/Mhz19", + "active": false + }, + { + "path": "src/modules/sensors/Pzem004t", + "active": true + }, + { + "path": "src/modules/sensors/RCswitch", + "active": false + }, + { + "path": "src/modules/sensors/RTC", + "active": true + }, + { + "path": "src/modules/sensors/Sds011", + "active": false + }, + { + "path": "src/modules/sensors/Sgp30", + "active": false + }, + { + "path": "src/modules/sensors/Sht20", + "active": true + }, + { + "path": "src/modules/sensors/Sht30", + "active": true + }, + { + "path": "src/modules/sensors/Sonar", + "active": true + }, + { + "path": "src/modules/sensors/UART", + "active": true + } + ], + "Исполнительные устройства": [ + { + "path": "src/modules/exec/ButtonIn", + "active": true + }, + { + "path": "src/modules/exec/ButtonOut", + "active": true + }, + { + "path": "src/modules/exec/EspCam", + "active": false + }, + { + "path": "src/modules/exec/HttpGet", + "active": false + }, + { + "path": "src/modules/exec/IoTServo", + "active": true + }, + { + "path": "src/modules/exec/Mcp23008", + "active": false + }, + { + "path": "src/modules/exec/Mcp23017", + "active": true + }, + { + "path": "src/modules/exec/Mp3", + "active": true + }, + { + "path": "src/modules/exec/Multitouch", + "active": true + }, + { + "path": "src/modules/exec/MySensors", + "active": false + }, + { + "path": "src/modules/exec/Pcf8574", + "active": true + }, + { + "path": "src/modules/exec/Pwm32", + "active": true + }, + { + "path": "src/modules/exec/Pwm8266", + "active": true + }, + { + "path": "src/modules/exec/SDcard", + "active": false + }, + { + "path": "src/modules/exec/SysExt", + "active": false + }, + { + "path": "src/modules/exec/Telegram", + "active": false + }, + { + "path": "src/modules/exec/TelegramLT", + "active": true + }, + { + "path": "src/modules/exec/Thermostat", + "active": false + } + ], + "Экраны": [ + { + "path": "src/modules/display/DwinI", + "active": false + }, + { + "path": "src/modules/display/Lcd2004", + "active": true + }, + { + "path": "src/modules/display/NextionUpload", + "active": false + }, + { + "path": "src/modules/display/Ws2812b", + "active": false + } + ] + } +} \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index f2239849..0fce3495 100644 --- a/platformio.ini +++ b/platformio.ini @@ -196,7 +196,6 @@ build_src_filter = + + + - + + + + @@ -376,7 +375,6 @@ lib_deps = robtillaart/SHT2x@^0.1.1 WEMOS SHT3x@1.0.0 plerup/EspSoftwareSerial - gyverlibs/EncButton @ ^2.0 adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 adafruit/Adafruit BusIO @ ^1.13.2 dfrobot/DFRobotDFPlayerMini @ ^1.0.5 @@ -391,7 +389,6 @@ build_src_filter = + + + - + + + + @@ -402,14 +399,12 @@ build_src_filter = + + + - + + + + + + + - + + + + diff --git a/src/modules/API.cpp b/src/modules/API.cpp index 7e9a1f3d..12480f10 100644 --- a/src/modules/API.cpp +++ b/src/modules/API.cpp @@ -7,7 +7,6 @@ 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_A02Distance(String subtype, String params); void* getAPI_Acs712(String subtype, String params); void* getAPI_AhtXX(String subtype, String params); void* getAPI_AnalogAdc(String subtype, String params); @@ -18,14 +17,12 @@ void* getAPI_Ds18b20(String subtype, String params); void* getAPI_Impulse(String subtype, String params); void* getAPI_Pzem004(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_ButtonIn(String subtype, String params); void* getAPI_ButtonOut(String subtype, String params); -void* getAPI_Encoder(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); @@ -44,7 +41,6 @@ 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_A02Distance(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Acs712(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_AhtXX(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_AnalogAdc(subtype, params)) != nullptr) return tmpAPI; @@ -55,14 +51,12 @@ 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_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_ButtonIn(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI; -if ((tmpAPI = getAPI_Encoder(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; From 6fb06e2314af2477bfc14fe14b074c712cba05c0 Mon Sep 17 00:00:00 2001 From: biver Date: Tue, 16 May 2023 13:14:24 +0300 Subject: [PATCH 13/14] =?UTF-8?q?=D0=98=D1=81=D0=BF=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=B7=D1=83=D0=B5=D0=BC=20=D1=81=D1=82=D1=80=D0=BE=D1=87=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=B1=D1=83=D0=BA=D0=B2=D1=8B=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=B0=D0=BF=D0=BA=D0=B8=20classes=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D1=8F=D0=B5=D0=BC=20=D0=BE?= =?UTF-8?q?=D1=88=D0=B8=D0=B1=D0=BA=D1=83=20=D0=B2=20=D0=BC=D0=BE=D0=B4?= =?UTF-8?q?=D1=83=D0=BB=D0=B5=20S8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/S8/S8.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/sensors/S8/S8.cpp b/src/modules/sensors/S8/S8.cpp index f8efa10e..ce721103 100644 --- a/src/modules/sensors/S8/S8.cpp +++ b/src/modules/sensors/S8/S8.cpp @@ -1,5 +1,5 @@ #include "Global.h" -#include "Classes/IoTItem.h" +#include "classes/IoTItem.h" #include From c078c816369f2ca372e27d67d0b40f0ba1e8ea2f Mon Sep 17 00:00:00 2001 From: biver Date: Tue, 16 May 2023 15:24:30 +0300 Subject: [PATCH 14/14] =?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=BC=D0=BE=D1=83=D0=BB=D1=8C=20Buzzer=20?= =?UTF-8?q?=D0=B8=20=D1=81=D0=B8=D0=BD=D1=85=D1=80=D0=BE=D0=BD=D0=B8=D0=B7?= =?UTF-8?q?=D0=B8=D1=80=D1=83=D0=B5=D0=BC=20def=20=D0=BF=D1=80=D0=BE=D1=84?= =?UTF-8?q?=D0=B8=D0=BB=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 7 +- data_svelte/items.json | 222 ++++++++++------ data_svelte/myProfile.json | 16 ++ myProfile.json | 16 ++ platformio.ini | 5 + src/modules/API.cpp | 8 + src/modules/exec/Buzzer/Buzzer.cpp | 382 +++++++++++++++++++++++++++ src/modules/exec/Buzzer/export.json | 268 +++++++++++++++++++ src/modules/exec/Buzzer/modinfo.json | 96 +++++++ 9 files changed, 936 insertions(+), 84 deletions(-) create mode 100644 src/modules/exec/Buzzer/Buzzer.cpp create mode 100644 src/modules/exec/Buzzer/export.json create mode 100644 src/modules/exec/Buzzer/modinfo.json diff --git a/.gitignore b/.gitignore index 41f063ef..d74a9041 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,3 @@ .pio -.vscode/.browse.c_cpp.db* -.vscode/c_cpp_properties.json -.vscode/launch.json -.vscode/ipch +.vscode /myProfile_wm.json -/myProfile.json -data_svelte/settings.json diff --git a/data_svelte/items.json b/data_svelte/items.json index 7e530a2f..f8cc2674 100644 --- a/data_svelte/items.json +++ b/data_svelte/items.json @@ -192,7 +192,19 @@ "header": "Сенсоры" }, { - "name": "13. Acs712 Ток", + "name": "13. A02 Дальность", + "type": "Reading", + "subtype": "A02Distance", + "id": "dist", + "widget": "anydataCm", + "page": "Сенсоры", + "descr": "Дальность", + "int": 5, + "round": 1, + "num": 13 + }, + { + "name": "14. Acs712 Ток", "type": "Reading", "subtype": "Acs712", "id": "amp", @@ -207,11 +219,11 @@ "sens": 100, "adczero": 512, "btn-setZero": "nil", - "num": 13 + "num": 14 }, { "global": 0, - "name": "14. AHTXX Температура", + "name": "15. AHTXX Температура", "type": "Reading", "subtype": "AhtXXt", "id": "Temp20", @@ -222,11 +234,11 @@ "addr": "0x38", "shtType": 1, "round": 1, - "num": 14 + "num": 15 }, { "global": 0, - "name": "15. AHTXX Влажность", + "name": "16. AHTXX Влажность", "type": "Reading", "subtype": "AhtXXh", "id": "Hum20", @@ -237,11 +249,11 @@ "addr": "0x38", "shtType": 1, "round": 1, - "num": 15 + "num": 16 }, { "global": 0, - "name": "16. Аналоговый сенсор", + "name": "17. Аналоговый сенсор", "type": "Reading", "subtype": "AnalogAdc", "id": "t", @@ -255,11 +267,11 @@ "pin": 0, "int": 15, "avgSteps": 1, - "num": 16 + "num": 17 }, { "global": 0, - "name": "17. BME280 Температура", + "name": "18. BME280 Температура", "type": "Reading", "subtype": "Bme280t", "id": "Tmp3", @@ -269,11 +281,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 17 + "num": 18 }, { "global": 0, - "name": "18. BME280 Давление", + "name": "19. BME280 Давление", "type": "Reading", "subtype": "Bme280p", "id": "Press3", @@ -283,11 +295,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 18 + "num": 19 }, { "global": 0, - "name": "19. BME280 Влажность", + "name": "20. BME280 Влажность", "type": "Reading", "subtype": "Bme280h", "id": "Hum3", @@ -297,11 +309,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 19 + "num": 20 }, { "global": 0, - "name": "20. BME280 Tочка росы", + "name": "21. BME280 Tочка росы", "type": "Reading", "subtype": "Bme280dp", "id": "Dew3", @@ -311,11 +323,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 20 + "num": 21 }, { "global": 0, - "name": "21. BMP280 Температура", + "name": "22. BMP280 Температура", "type": "Reading", "subtype": "Bmp280t", "id": "tmp3", @@ -325,11 +337,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 21 + "num": 22 }, { "global": 0, - "name": "22. BMP280 Давление", + "name": "23. BMP280 Давление", "type": "Reading", "subtype": "Bmp280p", "id": "Press3", @@ -339,11 +351,11 @@ "int": 15, "addr": "0x77", "round": 1, - "num": 22 + "num": 23 }, { "global": 0, - "name": "23. DHT11 Температура", + "name": "24. DHT11 Температура", "type": "Reading", "subtype": "Dht1122t", "id": "tmp3", @@ -353,11 +365,11 @@ "int": 15, "pin": 0, "senstype": "dht11", - "num": 23 + "num": 24 }, { "global": 0, - "name": "24. DHT11 Влажность", + "name": "25. DHT11 Влажность", "type": "Reading", "subtype": "Dht1122h", "id": "Hum3", @@ -367,11 +379,11 @@ "int": 15, "pin": 0, "senstype": "dht11", - "num": 24 + "num": 25 }, { "global": 0, - "name": "25. DS18B20 Температура", + "name": "26. DS18B20 Температура", "type": "Reading", "subtype": "Ds18b20", "id": "dstmp", @@ -383,11 +395,11 @@ "index": 0, "addr": "", "round": 1, - "num": 25 + "num": 26 }, { "global": 0, - "name": "26. Аналоговый счетчик импульсов", + "name": "27. Аналоговый счетчик импульсов", "type": "Writing", "subtype": "Impulse", "id": "impulse", @@ -400,11 +412,11 @@ "pinMode": "INPUT", "debounceDelay": 3, "multiply": 1, - "num": 26 + "num": 27 }, { "global": 0, - "name": "27. PZEM 004t Напряжение", + "name": "28. PZEM 004t Напряжение", "type": "Reading", "subtype": "Pzem004v", "id": "v", @@ -414,11 +426,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 27 + "num": 28 }, { "global": 0, - "name": "28. PZEM 004t Сила тока", + "name": "29. PZEM 004t Сила тока", "type": "Reading", "subtype": "Pzem004a", "id": "a", @@ -428,11 +440,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 28 + "num": 29 }, { "global": 0, - "name": "29. PZEM 004t Мощность", + "name": "30. PZEM 004t Мощность", "type": "Reading", "subtype": "Pzem004w", "id": "w", @@ -442,11 +454,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 29 + "num": 30 }, { "global": 0, - "name": "30. PZEM 004t Энергия", + "name": "31. PZEM 004t Энергия", "type": "Reading", "subtype": "Pzem004wh", "id": "wh", @@ -456,11 +468,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 30 + "num": 31 }, { "global": 0, - "name": "31. PZEM 004t Частота", + "name": "32. PZEM 004t Частота", "type": "Reading", "subtype": "Pzem004hz", "id": "hz", @@ -470,11 +482,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 31 + "num": 32 }, { "global": 0, - "name": "32. PZEM 004t Косинус", + "name": "33. PZEM 004t Косинус", "type": "Reading", "subtype": "Pzem004pf", "id": "pf", @@ -484,11 +496,11 @@ "int": 15, "addr": "0xF8", "round": 1, - "num": 32 + "num": 33 }, { "global": 0, - "name": "33. PZEM настройка", + "name": "34. PZEM настройка", "type": "Reading", "subtype": "Pzem004cmd", "id": "set", @@ -500,11 +512,11 @@ "changeaddr": 0, "setaddr": "0x01", "reset": 0, - "num": 33 + "num": 34 }, { "global": 0, - "name": "34. Часы реального времени", + "name": "35. Часы реального времени", "type": "Reading", "subtype": "RTC", "id": "rtc", @@ -520,11 +532,25 @@ "int": 5, "btn-setUTime": "0", "btn-setSysTime": "nil", - "num": 34 + "num": 35 + }, + { + "name": "36. (S8) Cенсор качества воздуха", + "num": 36, + "type": "Reading", + "subtype": "S8co", + "id": "s8co", + "widget": "anydataPpm", + "page": "Сенсоры", + "descr": "S8_CO2", + "int": 15, + "round": 1, + "rxPin": 13, + "txPin": 15 }, { "global": 0, - "name": "35. Sht20 Температура", + "name": "37. Sht20 Температура", "type": "Reading", "subtype": "Sht20t", "id": "tmp2", @@ -533,11 +559,11 @@ "descr": "Температура", "int": 15, "round": 1, - "num": 35 + "num": 37 }, { "global": 0, - "name": "36. Sht20 Влажность", + "name": "38. Sht20 Влажность", "type": "Reading", "subtype": "Sht20h", "id": "Hum2", @@ -546,11 +572,11 @@ "descr": "Влажность", "int": 15, "round": 1, - "num": 36 + "num": 38 }, { "global": 0, - "name": "37. Sht30 Температура", + "name": "39. Sht30 Температура", "type": "Reading", "subtype": "Sht30t", "id": "tmp30", @@ -559,11 +585,11 @@ "descr": "SHT30 Температура", "int": 15, "round": 1, - "num": 37 + "num": 39 }, { "global": 0, - "name": "38. Sht30 Влажность", + "name": "40. Sht30 Влажность", "type": "Reading", "subtype": "Sht30h", "id": "Hum30", @@ -572,12 +598,12 @@ "descr": "SHT30 Влажность", "int": 15, "round": 1, - "num": 38 + "num": 40 }, { "global": 0, - "name": "39. HC-SR04 Ультразвуковой дальномер", - "num": 39, + "name": "41. HC-SR04 Ультразвуковой дальномер", + "num": 41, "type": "Reading", "subtype": "Sonar", "id": "sonar", @@ -589,7 +615,7 @@ "int": 5 }, { - "name": "40. UART", + "name": "42. UART", "type": "Reading", "subtype": "UART", "page": "", @@ -601,14 +627,14 @@ "line": 2, "speed": 9600, "eventFormat": 0, - "num": 40 + "num": 42 }, { "header": "Исполнительные устройства" }, { "global": 0, - "name": "41. Кнопка подключенная к пину", + "name": "43. Кнопка подключенная к пину", "type": "Writing", "subtype": "ButtonIn", "id": "btn", @@ -623,11 +649,11 @@ "debounceDelay": 50, "fixState": 0, "inv": 0, - "num": 41 + "num": 43 }, { "global": 0, - "name": "42. Управление пином", + "name": "44. Управление пином", "type": "Writing", "subtype": "ButtonOut", "needSave": 0, @@ -638,11 +664,51 @@ "int": 0, "inv": 0, "pin": 2, - "num": 42 + "num": 44 }, { "global": 0, - "name": "43. Сервопривод", + "name": "45. Пассивный звуковой извещатель", + "type": "Writing", + "subtype": "Buzzer", + "id": "buzzer", + "widget": "toggle", + "page": "Кнопки", + "descr": "Buzzer", + "int": 4000, + "pin": 14, + "freq": 2000, + "duration": 1000, + "beatLevel": 4, + "tempo": 120, + "tempoCorrection": 1, + "pauseBetween": 0, + "transpose": 0, + "cycle": 0, + "indication": 1, + "val": 0, + "num": 45 + }, + { + "global": 0, + "name": "46. Энкодер", + "type": "Writing", + "subtype": "Encoder", + "id": "enc", + "widget": "inputDgt", + "page": "Энкодер", + "descr": "Громкость", + "needSave": 0, + "val": "0", + "round": 0, + "step": 1, + "stepOnPress": 5, + "pins": "4,5,2", + "num": 46 + }, + { + "global": 0, + "name": "47. Сервопривод", "type": "Writing", "subtype": "IoTServo", "id": "servo", @@ -653,11 +719,11 @@ "pin": 12, "apin": -1, "amap": "0, 4096, 0, 180", - "num": 43 + "num": 47 }, { "global": 0, - "name": "44. Расширитель портов Mcp23017", + "name": "48. Расширитель портов Mcp23017", "type": "Reading", "subtype": "Mcp23017", "id": "Mcp", @@ -667,11 +733,11 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 44 + "num": 48 }, { "global": 0, - "name": "45. MP3 плеер", + "name": "49. MP3 плеер", "type": "Reading", "subtype": "Mp3", "id": "mp3", @@ -681,11 +747,11 @@ "int": 1, "pins": "14,12", "volume": 20, - "num": 45 + "num": 49 }, { "global": 0, - "name": "46. Сенсорная кнопка", + "name": "50. Сенсорная кнопка", "type": "Writing", "subtype": "Multitouch", "id": "impulse", @@ -699,11 +765,11 @@ "pinMode": "INPUT", "debounceDelay": 50, "PWMDelay": 500, - "num": 46 + "num": 50 }, { "global": 0, - "name": "47. Расширитель портов Pcf8574", + "name": "51. Расширитель портов Pcf8574", "type": "Reading", "subtype": "Pcf8574", "id": "Pcf", @@ -713,11 +779,11 @@ "int": "0", "addr": "0x20", "index": 1, - "num": 47 + "num": 51 }, { "global": 0, - "name": "48. PWM ESP8266", + "name": "52. PWM ESP8266", "type": "Writing", "subtype": "Pwm8266", "id": "pwm", @@ -729,11 +795,11 @@ "freq": 5000, "val": 0, "apin": -1, - "num": 48 + "num": 52 }, { "global": 0, - "name": "49. Телеграм-Лайт", + "name": "53. Телеграм-Лайт", "type": "Writing", "subtype": "TelegramLT", "id": "tg", @@ -742,14 +808,14 @@ "descr": "", "token": "", "chatID": "", - "num": 49 + "num": 53 }, { "header": "Экраны" }, { "global": 0, - "name": "50. LCD экран 2004", + "name": "54. LCD экран 2004", "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -761,10 +827,10 @@ "size": "20,4", "coord": "0,0", "id2show": "id датчика", - "num": 50 + "num": 54 }, { - "name": "51. LCD экран 1602", + "name": "55. LCD экран 1602", "type": "Reading", "subtype": "Lcd2004", "id": "Lcd", @@ -776,6 +842,6 @@ "size": "16,2", "coord": "0,0", "id2show": "id датчика", - "num": 51 + "num": 55 } ] \ No newline at end of file diff --git a/data_svelte/myProfile.json b/data_svelte/myProfile.json index 17ee601d..7432922b 100644 --- a/data_svelte/myProfile.json +++ b/data_svelte/myProfile.json @@ -64,6 +64,10 @@ } ], "Сенсоры": [ + { + "path": "src/modules/sensors/A02Distance", + "active": true + }, { "path": "src/modules/sensors/Acs712", "active": true @@ -168,6 +172,10 @@ "path": "src/modules/sensors/RTC", "active": true }, + { + "path": "src/modules/sensors/S8", + "active": true + }, { "path": "src/modules/sensors/Sds011", "active": false @@ -202,6 +210,14 @@ "path": "src/modules/exec/ButtonOut", "active": true }, + { + "path": "src/modules/exec/Buzzer", + "active": true + }, + { + "path": "src/modules/exec/Enconder", + "active": true + }, { "path": "src/modules/exec/EspCam", "active": false diff --git a/myProfile.json b/myProfile.json index 17ee601d..7432922b 100644 --- a/myProfile.json +++ b/myProfile.json @@ -64,6 +64,10 @@ } ], "Сенсоры": [ + { + "path": "src/modules/sensors/A02Distance", + "active": true + }, { "path": "src/modules/sensors/Acs712", "active": true @@ -168,6 +172,10 @@ "path": "src/modules/sensors/RTC", "active": true }, + { + "path": "src/modules/sensors/S8", + "active": true + }, { "path": "src/modules/sensors/Sds011", "active": false @@ -202,6 +210,14 @@ "path": "src/modules/exec/ButtonOut", "active": true }, + { + "path": "src/modules/exec/Buzzer", + "active": true + }, + { + "path": "src/modules/exec/Enconder", + "active": true + }, { "path": "src/modules/exec/EspCam", "active": false diff --git a/platformio.ini b/platformio.ini index 0fce3495..7f1d6593 100644 --- a/platformio.ini +++ b/platformio.ini @@ -375,6 +375,7 @@ lib_deps = robtillaart/SHT2x@^0.1.1 WEMOS SHT3x@1.0.0 plerup/EspSoftwareSerial + gyverlibs/EncButton @ ^2.0 adafruit/Adafruit MCP23017 Arduino Library@^2.1.0 adafruit/Adafruit BusIO @ ^1.13.2 dfrobot/DFRobotDFPlayerMini @ ^1.0.5 @@ -389,6 +390,7 @@ build_src_filter = + + + + + + + + @@ -399,12 +401,15 @@ build_src_filter = + + + + + + + + + + + + + + + + + + diff --git a/src/modules/API.cpp b/src/modules/API.cpp index 12480f10..e4f040c1 100644 --- a/src/modules/API.cpp +++ b/src/modules/API.cpp @@ -7,6 +7,7 @@ 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_A02Distance(String subtype, String params); void* getAPI_Acs712(String subtype, String params); void* getAPI_AhtXX(String subtype, String params); void* getAPI_AnalogAdc(String subtype, String params); @@ -17,12 +18,15 @@ void* getAPI_Ds18b20(String subtype, String params); void* getAPI_Impulse(String subtype, String params); void* getAPI_Pzem004(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_ButtonIn(String subtype, String params); void* getAPI_ButtonOut(String subtype, String params); +void* getAPI_Buzzer(String subtype, String params); +void* getAPI_Encoder(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); @@ -41,6 +45,7 @@ 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_A02Distance(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Acs712(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_AhtXX(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_AnalogAdc(subtype, params)) != nullptr) return tmpAPI; @@ -51,12 +56,15 @@ 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_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_ButtonIn(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_Buzzer(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_Encoder(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; diff --git a/src/modules/exec/Buzzer/Buzzer.cpp b/src/modules/exec/Buzzer/Buzzer.cpp new file mode 100644 index 00000000..5668b549 --- /dev/null +++ b/src/modules/exec/Buzzer/Buzzer.cpp @@ -0,0 +1,382 @@ +#include "Global.h" +#include "classes/IoTItem.h" + + +extern IoTGpio IoTgpio; + +class Buzzer : public IoTItem +{ +private: + int _pin; + int _freq; + int _duration; + int _beatLevel = 4; + int _originalTempo = 120; // bpm + float _tempoCorrection = 1; // less than 1 - is slower + float _pauseBetween = 0; + int _transpose = 0; + int _cycle = 0; + int _indication = 1; + + std::vector tonesList; // playMode 3 + std::vector melodyList; // playMode 4 + + int playMode = 0; + + bool firstTone = true; + int thisTone = 0; + int startPlayPrevTone = 0; + int pauseBetweenTones = 0; + int toneFrequency = 0; + int toneDuration = 0; + + bool firstNote = true; + int thisNote = 0; + bool pause = false; + int A4 = 440; // Ля 4-ой октавы + int freqToPlay = 440; + int prevFreqToPlay = 440; + float melodyFloat = 1; + int startPlayPrevNote = 0; + int pauseBetweenNotes = 0; + float intervalC0 = 69; // + float prevIntervalC0 = 69; // + + float natureInt[13] = {1, 1.0416666666667, 1.125, 1.2, 1.25, 1.3333333333, 1.3888888889, 1.5, 1.6, 1.6666666667, 1.8, 1.875, 2}; // New Nature + String notes[12] = {"C", "CS", "D", "DS", "E", "F", "FS", "G", "GS", "A", "AS", "B"}; + float minorSecond = 1.0416666666667; + float risingMinorSecond = 1.066667; + float majorSecond = 1.125; + float decreasingMajorSecond = 1.1111111; + +public: + Buzzer(String parameters) : IoTItem(parameters) + { + _interval = _interval / 1000; // корректируем величину интервала int, теперь он в миллисекундах + + jsonRead(parameters, "pin", _pin); + jsonRead(parameters, "freq", _freq); + jsonRead(parameters, "duration", _duration); + jsonRead(parameters, "beatLevel", _beatLevel); + jsonRead(parameters, "tempo", _originalTempo); + jsonRead(parameters, "tempoCorrection", _tempoCorrection); + jsonRead(parameters, "pauseBetween", _pauseBetween); + jsonRead(parameters, "transpose", _transpose); + jsonRead(parameters, "cycle", _cycle); + jsonRead(parameters, "indication", _indication); + + IoTgpio.pinMode(_pin, OUTPUT); + } + + void loop() + { + + switch (playMode) + { + case 0: // for stop + // noTone(_pin); + break; + + case 1: + // for doByIntervals + if (enableDoByInt) + { + currentMillis = millis(); + difference = currentMillis - prevMillis; + if (difference >= _interval) + { + prevMillis = millis(); + this->doByInterval(); + } + } + break; + + case 2: + // for tone + break; + case 3: + // for tones() ................................... + if (((millis() - startPlayPrevTone) > pauseBetweenTones)) + { + if (firstTone) + { + firstTone = false; + if (_indication) + { + value.valD = 1; + regEvent((String)(int)value.valD, "Buzzer", false, false); + } + } + else + { + thisTone = thisTone + 2; + } + + if (thisTone >= tonesList.size()) // если сиграли последнюю ноту + { + if (_cycle) + { + thisTone = 0; + } + else + { + playMode = 0; + if (_indication) + { + value.valD = 0; + regEvent((String)(int)value.valD, "Buzzer", false, false); + } + break; + } + } + + toneFrequency = tonesList[thisTone]; + toneDuration = tonesList[thisTone + 1]; + // noTone(_pin); // останавливаем, на всякий случай воспроизведение предыдущей ноты + tone(_pin, toneFrequency, toneDuration); + startPlayPrevTone = millis(); + pauseBetweenTones = toneDuration * (1 + _pauseBetween); + } + break; + + case 4: + // FOR melody ............................................ + if (((millis() - startPlayPrevNote) > pauseBetweenNotes)) + { + if (firstNote) + { + if (_indication) + { + value.valD = 1; + regEvent((String)(int)value.valD, "Buzzer", false, false); + } + } + else + { + thisNote++; + } + + if (thisNote >= melodyList.size()) // если сыграли последнюю ноту + { + if (_cycle) + { + thisNote = 0; + } + else + { + playMode = 0; + if (_indication) + { + value.valD = 0; + regEvent((String)(int)value.valD, "Buzzer", false, false); + } + break; + } + } + String melodyString = melodyList[thisNote]; + String fore, aft; + for (int i = 0; i < melodyString.length(); i++) + { + if (melodyString.charAt(i) == '.') + { + fore = melodyString.substring(0, i); // получили строку до точки + aft = melodyString.substring(i + 1); // получили строку после точки + break; + } + } + char last = fore.charAt(fore.length() - 1); // получили номер октавы + int octaveN = (int)(last - '0'); + String note = fore.substring(0, fore.length() - 1); // получили ноту + int noteindex; + pause = true; + for (int j = 0; j < 12; j++) + { + if (note == notes[j]) // если находим ноту, значит не пауза + { + noteindex = j; + pause = false; + break; + } + } + float noteDurationFloat = aft.toFloat(); // в миллидолях такта + int noteDuration = int(noteDurationFloat / (float(_originalTempo) / (_beatLevel * 60)) / _tempoCorrection); // в миллисекундах + if (!pause) // находим абсолютный интервал у ноты, паузу пропускаем + { + // номер октавы на нот в октаве номер ноты в октаве в целой части и длительность в дробной + intervalC0 = (octaveN + 1) * 12 + noteindex + _transpose; + pause = false; + int relIntervalC0 = int(intervalC0) - int(prevIntervalC0); // находим интервал от предыдущей ноты + float intervalA4 = 69 - int(intervalC0); + int monoFreqToPlay = A4 / pow(2.0, (intervalA4 / 12)); // расчет частоты по монохроматической гамме + if (firstNote) // для первой ноты не делаем перерасчет, играем как есть + { + freqToPlay = monoFreqToPlay; + } + else + { + if (relIntervalC0 == 0) // играем туже ноту + { + freqToPlay = prevFreqToPlay; + } + // далее расчет частоты новой ноты в природном интервале от предыдущей + if (relIntervalC0 > 0) + { + freqToPlay = prevFreqToPlay * (int(abs(relIntervalC0 / 12)) + natureInt[abs(relIntervalC0 - int(relIntervalC0 / 12) * 12)]); + } + if (relIntervalC0 < 0) + { + freqToPlay = prevFreqToPlay / (int(abs(relIntervalC0 / 12)) + natureInt[abs(relIntervalC0 - int(relIntervalC0 / 12) * 12)]); + } + // это приводит к рассогласованию нот и убеганию в конце произведения + if (freqToPlay < monoFreqToPlay) // делаем корректировку убегания с помощью выбора малых или больших секунд + { + natureInt[1] = risingMinorSecond; + natureInt[2] = majorSecond; + } + else + { + natureInt[2] = decreasingMajorSecond; + natureInt[1] = minorSecond; + } + } + } + else // если пауза + { + intervalC0 = prevIntervalC0; + freqToPlay = 0; + pause = false; + } + // noTone(_pin); // останавливаем, на всякий случай воспроизведение предыдущей ноты + if (freqToPlay < 31) + freqToPlay = 0; + // воспроизведём ноту + tone(_pin, freqToPlay, noteDuration); + startPlayPrevNote = millis(); + if (freqToPlay) // нулевые значения частоты (паузы) не сохраняем + { + prevFreqToPlay = freqToPlay; // if it was not 0 + } + prevIntervalC0 = intervalC0; + /* + Чтобы отделить ноты друг от друга, добавим небольшую паузу между ними + около 0.3 от длины ноты звучат неплохо + */ + pauseBetweenNotes = noteDuration * (1 + _pauseBetween); + if (firstNote) + firstNote = false; + } + break; + + default: + break; + } + } + + void doByInterval() + { + tone(_pin, _freq, _duration); + // regEvent(value.valD, "Buzzer"); + } + + IoTValue execute(String command, std::vector ¶m) + { + // param - вектор ("массив") значений параметров переданных вместе с командой: ID.Команда("пар1", 22, 33) -> param[0].ValS = "пар1", param[1].ValD = 22 + if (command == "tone") + { + playMode = 2; + tone(_pin, param[0].valD, param[1].valD); + SerialPrint("I", "Sensor Buzzer, tone(), playMode = ", String(playMode), _id); + } + else if (command == "tones") + { + int sizeOfParam = param.size(); + tonesList.clear(); + tonesList.reserve(sizeOfParam); + for (unsigned int i = 0; i < sizeOfParam; i++) + { + tonesList.push_back(param[i].valD); + } + playMode = 3; + SerialPrint("I", "Sensor Buzzer, tones(), playMode = ", String(playMode), _id); + startPlayPrevTone = 0; + pauseBetweenTones = 0; + firstTone = true; + thisTone = 0; + prevFreqToPlay = 440; + prevIntervalC0 = 69; + } + else if (command == "notone") + { + playMode = 0; + noTone(_pin); + if (_indication) + { + value.valD = 0; + regEvent((String)(int)value.valD, "Buzzer", false, false); + } + SerialPrint("I", "Sensor Buzzer, notone(), playMode = ", String(playMode), _id); + } + else if (command == "melodySetting") + { + if (param[0].isDecimal) + _beatLevel = param[0].valD; + if (param[1].isDecimal) + _originalTempo = param[1].valD; + if (param[2].isDecimal) + _tempoCorrection = param[2].valD; + if (param[3].isDecimal) + _pauseBetween = param[3].valD; + if (param[4].isDecimal) + _transpose = param[4].valD; + if (param[5].isDecimal) + _cycle = param[5].valD; + String input = "beatLevel = " + String(_beatLevel) + " originalTempo = " + String(_originalTempo) + " tempoCorrection = " + String(_tempoCorrection) + " pauseBetween = " + String(_pauseBetween) + " transpose = " + String(_transpose) + " cycle = " + String(_cycle); + SerialPrint("I", "Sensor Buzzer, melodySetting() exec", input, _id); + } + else if (command == "melody") + { + int sizeOfParam = param.size(); + melodyList.clear(); + melodyList.reserve(sizeOfParam); + for (unsigned int i = 0; i < sizeOfParam; i++) + { + melodyList.push_back(param[i].valS); + } + playMode = 4; + SerialPrint("I", "Sensor Buzzer, melody(), playMode = ", String(playMode), _id); + thisNote = 0; + firstNote = true; + startPlayPrevNote = 0; + pauseBetweenNotes = 0; + prevFreqToPlay = 440; + prevIntervalC0 = 69; + } + return {}; // команда поддерживает возвращаемое значения. Т.е. по итогу выполнения команды или общения с внешней системой, можно вернуть значение в сценарий для дальнейшей обработки + } + + void setValue(const IoTValue &Value, bool genEvent = true) + { + value = Value; + playMode = value.valD; + regEvent((String)(int)value.valD, "Buzzer", false, genEvent); + } + //======================================================================================================= + String getValue() + { + return (String)(int)value.valD; + } + + ~Buzzer(){}; +}; + +void *getAPI_Buzzer(String subtype, String param) +{ + if (subtype == F("Buzzer")) + { + return new Buzzer(param); + } + else + { + return nullptr; + } +} diff --git a/src/modules/exec/Buzzer/export.json b/src/modules/exec/Buzzer/export.json new file mode 100644 index 00000000..cfebf462 --- /dev/null +++ b/src/modules/exec/Buzzer/export.json @@ -0,0 +1,268 @@ +{ + "mark": "iotm", + "config": [ + { + "global": 0, + "type": "Writing", + "subtype": "Buzzer", + "id": "buzzer", + "widget": "toggle", + "page": "Кнопки", + "descr": "00.Buzzer", + "int": 4000, + "pin": 14, + "freq": 2000, + "duration": 1000, + "beatLevel": 4, + "tempo": "200", + "tempoCorrection": 1, + "pauseBetween": "0.1", + "transpose": 0, + "cycle": "1", + "indication": "1", + "val": 0 + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn1", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "01.Вкл. основаной сингал", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn2", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "02.Выкл. основаной сингал", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn3", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "03.Судовой свисток", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn4", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "04.European police", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn5", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "05.American police", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn6", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "06.Pirates of Caribbeans", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn7", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "07.Tigran Aivazian Opus71", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn8", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "08.Imperial March", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn9", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "09.Happy Birthday ", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn10", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "10.noTone Стоп", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn11", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "11.Settings Темп 200bpm", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn12", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "12.Settings Темп 100bpm", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn13", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "13.Setting Повтор (cycle)", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn14", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "14.Setting Пауза между нот", + "int": "0", + "val": "0" + }, + { + "global": 0, + "type": "Reading", + "subtype": "VButton", + "id": "vbtn15", + "needSave": 0, + "widget": "toggle", + "page": "Кнопки", + "descr": "15.Settings Default", + "int": "0", + "val": "0" + } + ] +} + +scenario=> +#включаем основаной одиночный сингал из настроек +if vbtn1 == 1 then {buzzer = 1 ;vbtn1 = 0;} + +#выключаем основаной одиночный сингал из настроек +if vbtn2 == 1 then {buzzer = 0 ;vbtn2 = 0;} + +#включаем одиночный сигнал ship's whistle +if vbtn3 == 1 then {buzzer.tone(200,3000); vbtn3 = 0;} + +# european police +if vbtn4 == 1 then {buzzer.tones(450,500, 600,500); vbtn4 = 0;} + +#american police +if vbtn5 == 1 then {buzzer.tones(600, 25, 606, 25, 613, 25, 620, 25, 626, 25, 633, 25, 640, 25, 647, 25, 654, 25, 662, 25, 669, 25, 676, 25, 684, 25, 691, 25, 699, 25, 706, 25, 714, 25, 722, 25, 730, 25, 738, 25, 746, 25, 754, 25, 763, 25, 771, 25, 780, 25, 788, 25, 797, 25, 806, 25, 815, 25, 824, 25, 833, 25, 842, 25, 851, 25, 860, 25, 870, 25, 879, 25, 889, 25, 899, 25, 909, 25, 919, 25, 929, 25, 939, 25, 949, 25, 960, 25, 970, 25, 981, 25, 992, 25, 1003, 25, 1014, 25, 1025, 25, 1036, 25, 1047, 25, 1058, 25, 1069, 25, 1080, 25, 1091, 25, 1103, 25, 1115, 25, 1127, 25, 1139, 25, 1151, 25, 1163, 25, 1175, 25, 1187, 25, 1200, 25, 1187, 25, 1174, 25, 1161, 25, 1148, 25, 1136, 25, 1123, 25, 1111, 25, 1099, 25, 1087, 25, 1075, 25, 1063, 25, 1052, 25, 1040, 25, 1029, 25, 1018, 25, 1007, 25, 996, 25, 985, 25, 974, 25, 964, 25, 953, 25, 943, 25, 933, 25, 922, 25, 912, 25, 902, 25, 893, 25, 883, 25, 873, 25, 864, 25, 854, 25, 845, 25, 836, 25, 827, 25, 818, 25, 809, 25, 800, 25, 791, 25, 783, 25, 774, 25, 766, 25, 757, 25, 749, 25, 741, 25, 733, 25, 725, 25, 717, 25, 709, 25, 702, 25, 694, 25, 686, 25, 679, 25, 672, 25, 664, 25, 657, 25, 650, 25, 643, 25, 636, 25, 629, 25, 622, 25, 615, 25, 609, 25, 602, 25);vbtn5=0} + + + + +#if vbtn7 == 0 then buzzer.notone() + +#включаем проигрывание мелодии Pirates of Caribbeans +if vbtn6 == 1 then {buzzer.melody("E4.125", "G4.125", "A4.250", "A4.125", "0.125", "A4.125", "B4.125", "C5.250", "C5.125", "0.125", "C5.125", "D5.125", "B4.250", "B4.125", "0.125", "A4.125", "G4.125", "A4.375", "0.125", "E4.125", "G4.125", "A4.250", "A4.125", "0.125", "A4.125", "B4.125", "C5.250", "C5.125", "0.125", "C5.125", "D5.125", "B4.250", "B4.125", "0.125", "A4.125", "G4.125", "A4.375", "0.125", "E4.125", "G4.125", "A4.250", "A4.125", "0.125", "A4.125", "C5.125", "D5.250", "D5.125", "0.125", "D5.125", "E5.125", "F5.250", "F5.125", "0.125", "E5.125", "D5.125", "E5.125", "A4.250", "0.125", "A4.125", "B4.125", "C5.250", "C5.125", "0.125", "D5.250", "E5.125", "A4.250", "0.125", "A4.125", "C5.125", "B4.250", "B4.125", "0.125", "C5.125", "A4.125", "B4.375", "0.375", "A4.250", "A4.125", "A4.125", "B4.125", "C5.250", "C5.125", "0.125", "C5.125", "D5.125", "B4.250", "B4.125", "0.125", "A4.125", "G4.125", "A4.375", "0.125", "E4.125", "G4.125", "A4.250", "A4.125", "0.125", "A4.125", "B4.125", "C5.250", "C5.125", "0.125", "C5.125", "D5.125", "B4.250", "B4.125", "0.125", "A4.125", "G4.125", "A4.375", "0.125", "E4.125", "G4.125", "A4.250", "A4.125", "0.125", "A4.125", "C5.125", "D5.250", "D5.125", "0.125", "D5.125", "E5.125", "F5.250", "F5.125", "0.125", "E5.125", "D5.125", "E5.125", "A4.250", "0.125", "A4.125", "B4.125", "C5.250", "C5.125", "0.125", "D5.250", "E5.125", "A4.250", "0.125", "A4.125", "C5.125", "B4.250", "B4.125", "0.125", "C5.125", "A4.125", "B4.375", "0.375", "E5.250", "0.125", "0.375", "F5.250", "0.125", "0.375", "E5.125", "E5.125", "0.125", "G5.125", "0.125", "E5.125", "D5.125", "0.125", "0.375", "D5.250", "0.125", "0.375", "C5.250", "0.125", "0.375", "B4.125", "C5.125", "0.125", "B4.125", "0.125", "A4.500", "E5.250", "0.125", "0.375", "F5.250", "0.125", "0.375", "E5.125", "E5.125", "0.125", "G5.125", "0.125", "E5.125", "D5.125", "0.125", "0.375", "D5.250", "0.125", "0.375", "C5.250", "0.125", "0.375", "B4.125", "C5.125", "0.125", "B4.125", "0.125", "A4.500"); vbtn6 = 0} + +# Tigran Aivazian Opus71-Melody +if vbtn7 == 1 then {buzzer.melody("P.999", "C4.250", "E4.250", "E4.250", "G4.250", "G4.250", "B4.250", "B4.250", "G4.250", "A4.250", "A4.125", "E4.125", "C4.250", "E4.250", "F4.250", "F4.125", "C4.125", "A3.250", "A3.250", "D4.250", "D4.125", "E4.125", "F4.250", "A4.250", "B4.250", "D5.125", "B4.125", "G4.250", "G4.250", "A4.125", "A4.125", "E4.125", "E4.125", "A4.500", "E4.125", "E4.125", "G4.125", "G4.125", "C4.500", "E4.250", "E4.125", "F4.125", "G4.250", "B4.250", "A4.250", "A4.125", "C5.125", "C5.250", "F4.250", "G4.250", "G4.125", "D4.125", "D4.250", "F4.250", "F4.250", "F4.125", "C4.125", "A3.250", "A3.250", "C4.250", "C4.125", "F4.125", "F4.250", "A4.250", "B4.250", "D5.125", "B4.125", "G4.250", "G4.250", "G4.125", "G4.125", "B4.125", "D4.125", "G4.500", "E4.250", "P.749", "P.250", "G4.125", "P.250", "E4.125", "P.500", "C4.500");vbtn7 = 0 } + +# Imperial Marsh +if vbtn8 == 1 then {buzzer.melody("E3.500", "E3.500", "E3.500", "CS3.250", "CS3.250", "E3.500", "E3.500", "E3.500", "CS3.250", "CS3.250", "E4.500", "E4.500", "E4.500", "C4.375", "G4.125", "E4.500", "C4.375", "G4.125", "E4.999", "B4.500", "B4.500", "B4.500", "CS5.375", "G4.125", "DS4.500", "C4.375", "G4.125", "F4.999", "E5.500", "E4.375", "E4.125", "E5.500", "DS5.375", "D5.125", "CS5.500", "F4.500", "AS4.500", "A4.375", "GS4.125", "G4.500", "C4.500", "DS4.500", "C4.375", "E4.125", "G4.500", "F4.375", "G4.125", "B4.999", "E5.500", "E4.375", "E4.125", "E5.500", "DS5.375", "D5.125", "CS5.500", "D4.500", "AS4.500", "A4.375", "GS4.125", "G4.500", "C4.500", "DS4.500", "C4.375", "G4.125", "F4.500", "C4.375", "G4.125", "E4.999", "E4.500", "E4.250");vbtn8 = 0 } + +# Happy Birthday +if vbtn9 == 1 then {buzzer.melody("C4.250", "C4.125", "D4.250", "C4.250", "F4.250", "E4.500", "C4.250", "C4.125", "D4.250", "C4.250", "G4.250", "F4.500", "C4.250", "C4.125", "C5.250", "A4.250", "F4.250", "E4.250", "D4.250", "AS4.250", "AS4.125", "A4.250", "F4.250", "G4.250", "F4.500", "P.500");vbtn9 = 0 } + +#stop +if vbtn10 == 1 then {buzzer.notone() ;vbtn10 = 0} + +# меняем настройки мелодии +if vbtn11 == 1 then {buzzer.melodySetting("beatLevel",200,"tempoCorr","pauseBetween","transpose","cycle"); +vbtn11=0} + +# меняем настройки мелодии +if vbtn12 == 1 then {buzzer.melodySetting("beatLevel",100,"tempoCorr","pauseBetween","transpose","cycle"); vbtn12 = 0} + +# меняем настройки мелодии +if vbtn13 == 1 then buzzer.melodySetting("beatLevel","tempo","tempoCorr","pauseBetween","transpose",1) + +# меняем настройки мелодии +if vbtn13 == 0 then buzzer.melodySetting("beatLevel","tempo","tempoCorr","pauseBetween","transpose",0) + +# меняем настройки мелодии +if vbtn14 == 1 then buzzer.melodySetting("beatLevel","tempo","tempoCorr",0.3,"transpose","cycle") + +# меняем настройки мелодии +if vbtn14 == 0 then buzzer.melodySetting("beatLevel","tempo","tempoCorr",0,"transpose","cycle") + + +# меняем настройки мелодии на базовые +if vbtn15 == 1 then {buzzer.melodySetting(4,120,1,0,1,0);vbtn15=0} + +# меняем настройки мелодии - шаблон +#if vbtn99 == 1 then buzzer.melodySetting("beatLevel","tempo","tempoCorr","pauseBetween","transpose","cycle") diff --git a/src/modules/exec/Buzzer/modinfo.json b/src/modules/exec/Buzzer/modinfo.json new file mode 100644 index 00000000..35f193a2 --- /dev/null +++ b/src/modules/exec/Buzzer/modinfo.json @@ -0,0 +1,96 @@ +{ + "menuSection": "Исполнительные устройства", + + "configItem": [{ + "global": 0, + "name": "Пассивный звуковой извещатель", + "type": "Writing", + "subtype": "Buzzer", + "id": "buzzer", + "widget": "toggle", + "page": "Кнопки", + "descr": "Buzzer", + "int": 4000, + "pin": 14, + "freq": 2000, + "duration": 1000, + "beatLevel": 4, + "tempo": 120, + "tempoCorrection": 1, + "pauseBetween": 0, + "transpose": 0, + "cycle": 0, + "indication": 1, + "val": 0 + }], + + "about": { + "authorName": "Alex K", + "authorContact": "https://t.me/cmche", + "authorGit": "https://github.com/CHE77/Buzzer_IotManager", + "exampleURL": "https://iotmanager.org/wiki", + "specialThanks": "@Biveraxe", + "moduleName": "Buzzer", + "moduleVersion": "1.0", + "usedRam": { + "esp32_4mb": 15, + "esp8266_4mb": 15 + }, + "title": "Пассивный звуковой извещатель", + "moduleDesc": "Генерирует одиночные ШИМ сигналы или их серию, нужной частоты и длительности или даже мелодию, до 256 нот. Мелодия проигрывается на основе природного звукоряда. Для Пьезо Извещателей High Level Trigger.", + "retInfo": "Статус элемента, извещателя: 0 - Выключен, 1 - Активирован на повторение сигнала в настроиках или проигрывается мелодия/серия сигналов", + "propInfo": { + "int": "Количество миллисекунд между повторами одиночного сигнала", + "pin": "Управляемый пин", + "freq": "Частота сигнала, Hz", + "duration": "Длительность сигнала, ms", + "beatLevel": "Долей в такте", + "tempo": "Оригинальный темп мелодии, bpm", + "tempoCorrection": "Коррекция темпа мелодии", + "pauseBetween": "Дополнительная пауза между нот, в долях от длительности ноты", + "transpose": "Транспонирование на количество полутонов. +/-12 - для повышения/понижения на октаву", + "cycle": "Повтор мелодии/серии сигналов", + "indication": "Индикация в виджет, что идет сигнал, играет мелодия", + "val": "Включение/Выключение повторяющегося сигнала указанного в настройках: int, freq, duration. Работает как через интерфейс, так и через сценарий" + }, + "funcInfo": [ + { + "name": "tone", + "descr": "Проигрывание одиночного сигнала (без индикации)", + "params": ["Частота", "Длительность (ms)"] + }, + { + "name": "tones", + "descr": "Проигрывание серии сигналов, до 128", + "params": ["Частота 1-го сигнала", "Длительность 1-го сигнала (ms)","Частота 2-го сигала", "Длительность 2-го сигнала", "....итд"] + }, + { + "name": "melody", + "descr": "Проигрывание мелодии, до 256 нот. Кодировка 'YYX.ZZZ'. Научная нотация: YY - обозначение ноты (C,CS,D,DS,E,F,FS,G,GS,A,AS,B), X - номер октавы (0-9), ZZZ - длительность в тысячных долях такта (0-999). Обязательно в двойных кавычках. 'AS4.50' - Ля# 4-й октавы, 1/2 такта. На Github лежит Excel файл для перекодировки.", + "params": ["Код 1-ой ноты","Код 2-й ноты"," и тд"] + }, + { + "name": "notone", + "descr": "Остановка звучания сигнала/ноты/мелодии", + "params": [] + }, + { + "name": "melodySetting", + "descr": "Перенастройка параметров мелодии: Долей в такте - (обычно 4), Оригинальный темп -(40-208 bpm), Коррекция темпа - в k раз быстрее/медленнее, Пауза между нот (стакато) - доля от длительности, Коррекция тональности (транспонирование) - в k раз выше/ниже, Повтор 1/0. Чтобы не изменялось значение вбить любой текст в ковычках ", + "params": ["Долей в такте", "Оригинальный темп", "Коррекция темпа", "Пауза между нот", "Коррекция тональности", "Повтор мелодии/серии сигналов"] + } + + ] + }, + + "defActive": true, + + "usedLibs": { + "esp32_4mb": [], + "esp8266_4mb": [], + "esp8266_1mb": [], + "esp8266_1mb_ota": [], + "esp8285_1mb": [], + "esp8285_1mb_ota": [] + } +}