From 48f4ee0436a2bd2a0424eca3f76b5511441952d1 Mon Sep 17 00:00:00 2001 From: Mickael Date: Mon, 4 May 2020 23:39:43 +0200 Subject: [PATCH 01/24] Add Use for Proximity and Color Signed-off-by: Mickael Gaillard --- tasmota/xsns_27_apds9960.ino | 129 ++++++++++++++++++++++------------- 1 file changed, 83 insertions(+), 46 deletions(-) diff --git a/tasmota/xsns_27_apds9960.ino b/tasmota/xsns_27_apds9960.ino index 4c557c28e..e3c9dd862 100644 --- a/tasmota/xsns_27_apds9960.ino +++ b/tasmota/xsns_27_apds9960.ino @@ -64,8 +64,8 @@ // TODO() : Move to my_user_config.h file #define USE_APDS9960_GESTURE // Enable Gesture feature (+2k code) -#define USE_APDS9960_PROXIMITY // Enable Proximity feature (Not use) -#define USE_APDS9960_COLOR // Enable Color feature (Not use) +#define USE_APDS9960_PROXIMITY // Enable Proximity feature (>50 code) +#define USE_APDS9960_COLOR // Enable Color feature (+0.8k code) /* Gesture parameters */ @@ -96,16 +96,19 @@ const char APDS9960_TAG[] PROGMEM = "APDS9960"; // Only one actualy #ifdef USE_WEBSERVER #ifdef USE_APDS9960_GESTURE - const char HTTP_SNS_GESTURE[] PROGMEM = "{s}%s " D_GESTURE "{m}%s{e}"; - #endif // USE_APDS9960_GESTURE +#ifdef USE_APDS9960_COLOR const char HTTP_SNS_COLOR_RED[] PROGMEM = "{s}%s " D_COLOR_RED "{m}%u{e}"; const char HTTP_SNS_COLOR_GREEN[] PROGMEM = "{s}%s " D_COLOR_GREEN "{m}%u{e}"; const char HTTP_SNS_COLOR_BLUE[] PROGMEM = "{s}%s " D_COLOR_BLUE "{m}%u{e}"; const char HTTP_SNS_CCT[] PROGMEM = "{s}%s " D_CCT "{m}%u " D_UNIT_KELVIN "{e}"; +#endif // USE_APDS9960_COLOR + +#ifdef USE_APDS9960_PROXIMITY const char HTTP_SNS_PROXIMITY[] PROGMEM = "{s}%s " D_PROXIMITY "{m}%u{e}"; +#endif // USE_APDS9960_PROXIMITY #endif // USE_WEBSERVER @@ -321,6 +324,7 @@ typedef struct gesture_type { #endif // USE_APDS9960_GESTURE +#if defined(USE_APDS9960_COLOR) || defined(USE_APDS9960_PROXIMITY) typedef struct color_data_type { uint16_t a; // measured ambient uint16_t r; // Red @@ -331,21 +335,21 @@ typedef struct color_data_type { uint16_t cct; // calculated color temperature uint16_t lux; // calculated illuminance - atm only from rgb } color_data_t; +#endif // USE_APDS9960_COLOR || USE_APDS9960_PROXIMITY /******************************************************************************\ * Globals \******************************************************************************/ #ifdef USE_APDS9960_GESTURE - gesture_data_t gesture_data; gesture_t gesture; - -#endif // USE_APDS9960_GESTURE char currentGesture[6]; +#endif // USE_APDS9960_GESTURE - +#if defined(USE_APDS9960_COLOR) || defined(USE_APDS9960_PROXIMITY) color_data_t color_data; +#endif // USE_APDS9960_COLOR || USE_APDS9960_PROXIMITY volatile uint8_t recovery_loop_counter = 0; // count number of stateloops to switch the sensor off, if needed bool APDS9960_overload = false; @@ -357,6 +361,7 @@ uint8_t gesture_mode = 1; * Helper functions \******************************************************************************/ +#ifdef USE_APDS9960_COLOR /** * Taken from the Adafruit-library * @brief Converts the raw R/G/B values to color temperature in degrees @@ -388,6 +393,7 @@ void calculateColorTemperature(void) { return; } +#endif // USE_APDS9960_COLOR /******************************************************************************\ * Getters and setters for register values @@ -1249,7 +1255,6 @@ bool APDS9960_init(void) { /* Set default values for gesture sense registers */ #ifdef USE_APDS9960_GESTURE - setGestureEnterThresh(DEFAULT_GPENTH); setGestureExitThresh(DEFAULT_GEXTH); @@ -1267,7 +1272,6 @@ bool APDS9960_init(void) { I2cWrite8(APDS9960_I2C_ADDR, APDS9960_GCONF3, DEFAULT_GCONF3); setGestureIntEnable(DEFAULT_GIEN); - #endif // USE_APDS9960_GESTURE disablePower(); // go to sleep @@ -1543,6 +1547,7 @@ inline void disablePower(void) { * Ambient light and color sensor controls \******************************************************************************/ +#if defined(USE_APDS9960_COLOR) || defined(USE_APDS9960_PROXIMITY) /** * @brief Reads the ARGB-Data and fills color_data */ @@ -1553,6 +1558,38 @@ inline void readAllColorAndProximityData(void) { } } +void APDS9960_adjustATime(void) { // not really used atm + // readAllColorAndProximityData(); + I2cValidRead16LE(&color_data.a, APDS9960_I2C_ADDR, APDS9960_CDATAL); + // disablePower(); + + if (color_data.a < (uint16_t)20) { + APDS9960_aTime = 0x40; + } else if (color_data.a < (uint16_t)40) { + APDS9960_aTime = 0x80; + } else if (color_data.a < (uint16_t)50) { + APDS9960_aTime = DEFAULT_ATIME; + } else if (color_data.a < (uint16_t)70) { + APDS9960_aTime = 0xc0; + } + + if (color_data.a < 200) { + APDS9960_aTime = 0xe9; + } + /* if (color_data.a < 10000){ + APDS9960_aTime = 0xF0; + }*/ + else { + APDS9960_aTime = 0xff; + } + + // disableLightSensor(); + I2cWrite8(APDS9960_I2C_ADDR, APDS9960_ATIME, APDS9960_aTime); + enablePower(); + enableLightSensor(); + delay(20); +} +#endif // USE_APDS9960_COLOR || USE_APDS9960_PROXIMITY /******************************************************************************\ * High-level gesture controls @@ -1754,42 +1791,6 @@ void handleGesture(void) { } } -#endif // USE_APDS9960_GESTURE - -void APDS9960_adjustATime(void) { // not really used atm - // readAllColorAndProximityData(); - I2cValidRead16LE(&color_data.a, APDS9960_I2C_ADDR, APDS9960_CDATAL); - // disablePower(); - - if (color_data.a < (uint16_t)20) { - APDS9960_aTime = 0x40; - } else if (color_data.a < (uint16_t)40) { - APDS9960_aTime = 0x80; - } else if (color_data.a < (uint16_t)50) { - APDS9960_aTime = DEFAULT_ATIME; - } else if (color_data.a < (uint16_t)70) { - APDS9960_aTime = 0xc0; - } - - if (color_data.a < 200) { - APDS9960_aTime = 0xe9; - } - /* if (color_data.a < 10000){ - APDS9960_aTime = 0xF0; - }*/ - else { - APDS9960_aTime = 0xff; - } - - // disableLightSensor(); - I2cWrite8(APDS9960_I2C_ADDR, APDS9960_ATIME, APDS9960_aTime); - enablePower(); - enableLightSensor(); - delay(20); -} - -#ifdef USE_APDS9960_GESTURE - void APDS9960_loop(void) { if (recovery_loop_counter > 0) { recovery_loop_counter -= 1; @@ -1845,7 +1846,9 @@ void APDS9960_detect(void) { APDS9960_type = 0; } +#ifdef USE_APDS9960_GESTURE currentGesture[0] = '\0'; +#endif // USE_APDS9960_GESTURE } /*********************************************************************************************\ @@ -1856,6 +1859,8 @@ void APDS9960_show(bool json) { if (!APDS9960_type) { return; } if (!gesture_mode && !APDS9960_overload) { + +#if defined(USE_APDS9960_COLOR) || defined(USE_APDS9960_PROXIMITY) uint16_t ambient; readAllColorAndProximityData(); @@ -1865,8 +1870,11 @@ void APDS9960_show(bool json) { I2cWrite8(APDS9960_I2C_ADDR, APDS9960_ATIME, DEFAULT_ATIME); // reset to default enableLightSensor();*/ +#ifdef USE_APDS9960_COLOR calculateColorTemperature(); // and calculate Lux +#endif // USE_APDS9960_COLOR if (json) { +#if defined(USE_APDS9960_COLOR) && defined(USE_APDS9960_PROXIMITY) ResponseAppend_P(PSTR(",\"%s\":{\"Red\":%u,\"Green\":%u,\"Blue\":%u,\"" D_JSON_ILLUMINANCE "\":%u,\"CCT\":%u,\"Proximity\":%u}"), APDS9960_TAG, color_data.r, @@ -1875,16 +1883,44 @@ void APDS9960_show(bool json) { ambient, color_data.cct, color_data.p); +#else + +#ifdef USE_APDS9960_COLOR + ResponseAppend_P(PSTR(",\"%s\":{\"Red\":%u,\"Green\":%u,\"Blue\":%u,\"" D_JSON_ILLUMINANCE "\":%u,\"CCT\":%u}"), + APDS9960_TAG, + color_data.r, + color_data.g, + color_data.b, + ambient, + color_data.cct); +#endif // USE_APDS9960_COLOR + +#ifdef USE_APDS9960_PROXIMITY + ResponseAppend_P(PSTR(",\"%s\":{\"Proximity\":%u}"), + APDS9960_TAG, + color_data.p); +#endif // USE_APDS9960_PROXIMITY + +#endif // USE_APDS9960_COLOR && USE_APDS9960_PROXIMITY #ifdef USE_WEBSERVER } else { + +#ifdef USE_APDS9960_COLOR WSContentSend_PD(HTTP_SNS_COLOR_RED, APDS9960_TAG, color_data.r); WSContentSend_PD(HTTP_SNS_COLOR_GREEN, APDS9960_TAG, color_data.g); WSContentSend_PD(HTTP_SNS_COLOR_BLUE, APDS9960_TAG, color_data.b); WSContentSend_PD(HTTP_SNS_ILLUMINANCE, APDS9960_TAG, ambient); WSContentSend_PD(HTTP_SNS_CCT, APDS9960_TAG, color_data.cct); +#endif // USE_APDS9960_COLOR + +#ifdef USE_APDS9960_PROXIMITY WSContentSend_PD(HTTP_SNS_PROXIMITY, APDS9960_TAG, color_data.p); +#endif // USE_APDS9960_PROXIMITY + #endif // USE_WEBSERVER } +#endif // USE_APDS9960_COLOR || USE_APDS9960_PROXIMITY + #ifdef USE_APDS9960_GESTURE } else { if (currentGesture[0] != '\0') { @@ -1898,6 +1934,7 @@ void APDS9960_show(bool json) { } } #endif // USE_APDS9960_GESTURE + } } From 8fb0a66785dd8dfb8353bab770c5befd1a8222b9 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 5 May 2020 08:03:47 +0200 Subject: [PATCH 02/24] PlatformIO ESP8266 v.2.5.0 --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 5074ee432..b63a1e41d 100755 --- a/platformio.ini +++ b/platformio.ini @@ -113,7 +113,7 @@ build_flags = ${tasmota_core.build_flags} [tasmota_core] ; *** Esp8266 Arduino core 2.7.0 -platform = espressif8266@2.4.0 +platform = espressif8266@2.5.0 platform_packages = framework-arduinoespressif8266 @ https://github.com/tasmota/Arduino/releases/download/2.7.0/esp8266-2.7.0.zip build_flags = ${esp82xx_defaults.build_flags} -DBEARSSL_SSL_BASIC From 424e4ee4a3ef824f31bddf6be16df54f81e5593d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 5 May 2020 08:06:37 +0200 Subject: [PATCH 03/24] PlatformIO ESP8266 2.5.0 use latest PlatformIO Arduino ESP8266 build chain as base --- platformio_override_sample.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio_override_sample.ini b/platformio_override_sample.ini index afd1e6a4b..22bd8cf70 100644 --- a/platformio_override_sample.ini +++ b/platformio_override_sample.ini @@ -83,7 +83,7 @@ extra_scripts = ${scripts_defaults.extra_scripts} [tasmota_stage] ; *** Esp8266 core for Arduino version Tasmota stage -platform = espressif8266@2.4.0 +platform = espressif8266@2.5.0 platform_packages = framework-arduinoespressif8266 @ https://github.com/esp8266/Arduino.git#36e047e908cfa6eafaaf824988070b49f2c2ff2a build_flags = ${esp82xx_defaults.build_flags} -DBEARSSL_SSL_BASIC @@ -127,7 +127,7 @@ build_flags = ${esp82xx_defaults.build_flags} [core_stage] ; *** Esp8266 core for Arduino version latest development version -platform = espressif8266@2.4.0 +platform = espressif8266@2.5.0 platform_packages = framework-arduinoespressif8266 @ https://github.com/esp8266/Arduino.git build_flags = ${esp82xx_defaults.build_flags} -DBEARSSL_SSL_BASIC From 048b88ab3ec9f3ab8db2e315dbeab14aa3805930 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 5 May 2020 08:51:03 +0200 Subject: [PATCH 04/24] Build all ESP32 variants --- .github/workflows/CI_github_ESP32.yml | 422 ++++++++++++++++++++++++++ 1 file changed, 422 insertions(+) diff --git a/.github/workflows/CI_github_ESP32.yml b/.github/workflows/CI_github_ESP32.yml index aeeb0e9ce..92b0c65fd 100644 --- a/.github/workflows/CI_github_ESP32.yml +++ b/.github/workflows/CI_github_ESP32.yml @@ -20,3 +20,425 @@ jobs: cp platformio_override_sample.ini platformio_override.ini platformio run -e tasmota32 + + tasmota32-minimal: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-minimal + + tasmota32-lite: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-lite + + tasmota32-knx: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-knx + + tasmota32-sensors: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-sensors + + + tasmota32-display: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-display + + tasmota32-ir: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-ir + + tasmota32-BG: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-BG + + tasmota32-BR: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-BR + + tasmota32-CN: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-CN + + tasmota32-CZ: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-CZ + + tasmota32-DE: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-DE + + tasmota32-ES: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-ES + + + tasmota32-FR: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-FR + + tasmota32-GR: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-GR + + tasmota32-HE: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-HE + + tasmota32-HU: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-HU + + tasmota32-IT: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-IT + + tasmota32-KO: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-KO + + tasmota32-NL: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-NL + + tasmota32-PL: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-PL + + tasmota32-PT: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-PT + + tasmota32-RO: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-RO + + tasmota32-RU: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-RU + + tasmota32-SE: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-SE + + tasmota32-SK: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-SK + + tasmota32-TR: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-TR + + tasmota32-TW: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-TW + + tasmota32-UK: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: platformio run -e tasmota32-UK From db155713368d364f5668694be5ed6637bdece396 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Tue, 5 May 2020 09:36:43 +0200 Subject: [PATCH 05/24] add face detect --- tasmota/xdrv_10_scripter.ino | 16 +++- tasmota/xdrv_39_webcam.ino | 177 +++++++++++++++++++++++++++++++++-- 2 files changed, 180 insertions(+), 13 deletions(-) diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index 040442084..3056e41a8 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -70,8 +70,10 @@ uint32_t DecodeLightId(uint32_t hue_id); #include "FS.h" #include "SPIFFS.h" + + void SaveFile(const char *name,const uint8_t *buf,uint32_t len) { - File file = SPIFFS.open(name, FILE_WRITE); + File file = SPIFFS.open(name,FILE_WRITE); if (!file) return; file.write(buf, len); file.close(); @@ -2048,7 +2050,14 @@ chknext: fvar=wc_set_motion_detect(fvar2); } break; - +#ifdef USE_FACE_DETECT + case 7: + { float fvar2; + lp=GetNumericResult(lp,OPER_EQU,&fvar2,0); + fvar=wc_set_face_detect(fvar2); + } + break; +#endif default: fvar=0; } @@ -5224,10 +5233,11 @@ bool Xdrv10(uint8_t function) case FUNC_WEB_ADD_BUTTON: WSContentSend_P(HTTP_BTN_MENU_RULES); break; +#ifdef USE_SCRIPT_WEB_DISPLAY case FUNC_WEB_ADD_MAIN_BUTTON: ScriptWebShow('&'); break; - +#endif case FUNC_WEB_ADD_HANDLER: Webserver->on("/" WEB_HANDLE_SCRIPT, HandleScriptConfiguration); Webserver->on("/ta",HTTP_POST, HandleScriptTextareaConfiguration); diff --git a/tasmota/xdrv_39_webcam.ino b/tasmota/xdrv_39_webcam.ino index a092bfecd..6e8a1c612 100644 --- a/tasmota/xdrv_39_webcam.ino +++ b/tasmota/xdrv_39_webcam.ino @@ -53,7 +53,9 @@ //#define USE_TEMPLATE #define WC_LOGLEVEL LOG_LEVEL_INFO - +#include "fb_gfx.h" +#include "fd_forward.h" +#include "fr_forward.h" #define PWDN_GPIO_NUM 32 #define RESET_GPIO_NUM -1 @@ -81,6 +83,10 @@ uint8_t wc_up; uint16_t wc_width; uint16_t wc_height; uint8_t wc_stream_active; +#ifdef USE_FACE_DETECT +uint8_t faces; +uint16_t face_detect_time; +#endif uint32_t wc_setup(int32_t fsiz) { if (fsiz > 10) { fsiz = 10; } @@ -89,11 +95,13 @@ uint32_t wc_setup(int32_t fsiz) { if (fsiz < 0) { esp_camera_deinit(); + wc_up = 0; return 0; } if (wc_up) { esp_camera_deinit(); + AddLog_P2(WC_LOGLEVEL, PSTR("CAM: deinit")); //return wc_up; } @@ -221,6 +229,11 @@ uint32_t wc_setup(int32_t fsiz) { wc_height = wc_fb->height; esp_camera_fb_return(wc_fb); + +#ifdef USE_FACE_DETECT + fd_init(); +#endif + AddLog_P2(WC_LOGLEVEL, PSTR("CAM: Initialized")); wc_up = 1; @@ -441,6 +454,140 @@ void handleMjpeg(void) { //} } +static mtmn_config_t mtmn_config = {0}; + +#ifdef USE_FACE_DETECT +void fd_init(void) { + mtmn_config.type = FAST; + mtmn_config.min_face = 80; + mtmn_config.pyramid = 0.707; + mtmn_config.pyramid_times = 4; + mtmn_config.p_threshold.score = 0.6; + mtmn_config.p_threshold.nms = 0.7; + mtmn_config.p_threshold.candidate_number = 20; + mtmn_config.r_threshold.score = 0.7; + mtmn_config.r_threshold.nms = 0.7; + mtmn_config.r_threshold.candidate_number = 10; + mtmn_config.o_threshold.score = 0.7; + mtmn_config.o_threshold.nms = 0.7; + mtmn_config.o_threshold.candidate_number = 1; +} + +#define FACE_COLOR_WHITE 0x00FFFFFF +#define FACE_COLOR_BLACK 0x00000000 +#define FACE_COLOR_RED 0x000000FF +#define FACE_COLOR_GREEN 0x0000FF00 +#define FACE_COLOR_BLUE 0x00FF0000 +#define FACE_COLOR_YELLOW (FACE_COLOR_RED | FACE_COLOR_GREEN) +#define FACE_COLOR_CYAN (FACE_COLOR_BLUE | FACE_COLOR_GREEN) +#define FACE_COLOR_PURPLE (FACE_COLOR_BLUE | FACE_COLOR_RED) +void draw_face_boxes(dl_matrix3du_t *image_matrix, box_array_t *boxes, int face_id); + +/* +void draw_face_boxes(dl_matrix3du_t *image_matrix, box_array_t *boxes, int face_id) { + int x, y, w, h, i; + uint32_t color = FACE_COLOR_YELLOW; + if(face_id < 0){ + color = FACE_COLOR_RED; + } else if(face_id > 0){ + color = FACE_COLOR_GREEN; + } + fb_data_t fb; + fb.width = image_matrix->w; + fb.height = image_matrix->h; + fb.data = image_matrix->item; + fb.bytes_per_pixel = 3; + fb.format = FB_BGR888; + for (i = 0; i < boxes->len; i++){ + // rectangle box + x = (int)boxes->box[i].box_p[0]; + y = (int)boxes->box[i].box_p[1]; + w = (int)boxes->box[i].box_p[2] - x + 1; + h = (int)boxes->box[i].box_p[3] - y + 1; + fb_gfx_drawFastHLine(&fb, x, y, w, color); + fb_gfx_drawFastHLine(&fb, x, y+h-1, w, color); + fb_gfx_drawFastVLine(&fb, x, y, h, color); + fb_gfx_drawFastVLine(&fb, x+w-1, y, h, color); +#if 0 + // landmark + int x0, y0, j; + for (j = 0; j < 10; j+=2) { + x0 = (int)boxes->landmark[i].landmark_p[j]; + y0 = (int)boxes->landmark[i].landmark_p[j+1]; + fb_gfx_fillRect(&fb, x0, y0, 3, 3, color); + } +#endif + } +} +*/ + +#define DL_SPIRAM_SUPPORT + +uint32_t wc_set_face_detect(int32_t value) { + if (value >= 0) { face_detect_time=value; } + return faces; +} + +uint32_t face_ltime; + +uint32_t detect_face(void); + +uint32_t detect_face(void) { +dl_matrix3du_t *image_matrix; +size_t out_len, out_width, out_height; +uint8_t * out_buf; +bool s; +bool detected = false; +int face_id = 0; +camera_fb_t *fb; + + if ((millis()-face_ltime) > face_detect_time) { + face_ltime = millis(); + fb = esp_camera_fb_get(); + if (!fb) { return ESP_FAIL; } + + image_matrix = dl_matrix3du_alloc(1, fb->width, fb->height, 3); + if (!image_matrix) { + AddLog_P2(WC_LOGLEVEL, PSTR("CAM: dl_matrix3du_alloc failed")); + esp_camera_fb_return(fb); + return ESP_FAIL; + } + + out_buf = image_matrix->item; + //out_len = fb->width * fb->height * 3; + //out_width = fb->width; + //out_height = fb->height; + + s = fmt2rgb888(fb->buf, fb->len, fb->format, out_buf); + esp_camera_fb_return(fb); + if (!s){ + dl_matrix3du_free(image_matrix); + AddLog_P2(WC_LOGLEVEL, PSTR("CAM: to rgb888 failed")); + return ESP_FAIL; + } + + box_array_t *net_boxes = face_detect(image_matrix, &mtmn_config); + if (net_boxes){ + detected = true; + faces=net_boxes->len; + //if(recognition_enabled){ + // face_id = run_face_recognition(image_matrix, net_boxes); + //} + //draw_face_boxes(image_matrix, net_boxes, face_id); + free(net_boxes->score); + free(net_boxes->box); + free(net_boxes->landmark); + free(net_boxes); + } else { + faces=0; + } + dl_matrix3du_free(image_matrix); + //Serial.printf("face detected: %d",faces); + + } +} +#endif + void handleMjpeg_task(void) { camera_fb_t *wc_fb; size_t _jpg_buf_len = 0; @@ -472,6 +619,7 @@ void handleMjpeg_task(void) { goto exit; } + if (wc_fb->format != PIXFORMAT_JPEG) { jpeg_converted = frame2jpg(wc_fb, 80, &_jpg_buf, &_jpg_buf_len); if (!jpeg_converted){ @@ -524,7 +672,6 @@ void CamHandleRoot(void) { //CamServer->redirect("http://" + String(ip) + ":81/cam.mjpeg"); CamServer->sendHeader("Location", WiFi.localIP().toString() + ":81/cam.mjpeg"); CamServer->send(302, "", ""); - //Serial.printf("WC root called"); AddLog_P2(WC_LOGLEVEL, PSTR("CAM: root called")); } @@ -538,7 +685,7 @@ uint32_t wc_set_motion_detect(int32_t value) { if (value >= 0) { motion_detect=value; } if (-1 == value) { return motion_trigger; - } else { + } else { return motion_brightness; } } @@ -589,12 +736,10 @@ void detect_motion(void) { } void wc_show_stream(void) { -#ifndef USE_SCRIPT if (CamServer) { WSContentSend_P(PSTR("

Webcam stream

"), - WiFi.localIP().toString().c_str()); + WiFi.localIP().toString().c_str()); } -#endif } uint32_t wc_set_streamserver(uint32_t flag) { @@ -625,6 +770,9 @@ uint32_t wc_set_streamserver(uint32_t flag) { void WcStreamControl(uint32_t resolution) { wc_set_streamserver(resolution); + /*if (0 == resolution) { + resolution=-1; + }*/ wc_setup(resolution); } @@ -632,6 +780,9 @@ void wc_loop(void) { if (CamServer) { CamServer->handleClient(); } if (wc_stream_active) { handleMjpeg_task(); } if (motion_detect) { detect_motion(); } +#ifdef USE_FACE_DETECT + if (face_detect_time) { detect_face(); } +#endif } void wc_pic_setup(void) { @@ -672,6 +823,7 @@ void WcInit(void) { } } + /*********************************************************************************************\ * Commands \*********************************************************************************************/ @@ -689,7 +841,7 @@ void (* const WCCommand[])(void) PROGMEM = { void CmndWebcam(void) { uint32_t flag = 0; if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 10)) { - Settings.esp32_webcam_resolution = XdrvMailbox.payload; + Settings.esp32_webcam_resolution=XdrvMailbox.payload; WcStreamControl(Settings.esp32_webcam_resolution); } if (CamServer) { flag = 1; } @@ -711,15 +863,20 @@ bool Xdrv39(uint8_t function) { wc_pic_setup(); break; case FUNC_WEB_ADD_MAIN_BUTTON: - WcStreamControl(Settings.esp32_webcam_resolution); - wc_show_stream(); - break; + //if (Settings.esp32_webcam_resolution) { +#ifndef USE_SCRIPT + WcStreamControl(Settings.esp32_webcam_resolution); + wc_show_stream(); +#endif + //} + break; case FUNC_COMMAND: result = DecodeCommand(kWCCommands, WCCommand); break; case FUNC_PRE_INIT: WcInit(); break; + } return result; } From 489865b82b43ef3fb9d92e8ed4c427174676fc9f Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Tue, 5 May 2020 09:39:35 +0200 Subject: [PATCH 06/24] Update xdrv_39_webcam.ino --- tasmota/xdrv_39_webcam.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasmota/xdrv_39_webcam.ino b/tasmota/xdrv_39_webcam.ino index 6e8a1c612..c852fc86c 100644 --- a/tasmota/xdrv_39_webcam.ino +++ b/tasmota/xdrv_39_webcam.ino @@ -454,9 +454,10 @@ void handleMjpeg(void) { //} } +#ifdef USE_FACE_DETECT + static mtmn_config_t mtmn_config = {0}; -#ifdef USE_FACE_DETECT void fd_init(void) { mtmn_config.type = FAST; mtmn_config.min_face = 80; From 3c77a6b4f2c08a9d16b9c663c55a087054b15586 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 5 May 2020 10:35:32 +0200 Subject: [PATCH 07/24] Add files via upload --- .github/workflows/CI_github_ESP32.yml | 113 +++++++++++++++++++------- 1 file changed, 84 insertions(+), 29 deletions(-) diff --git a/.github/workflows/CI_github_ESP32.yml b/.github/workflows/CI_github_ESP32.yml index 92b0c65fd..9e8312b51 100644 --- a/.github/workflows/CI_github_ESP32.yml +++ b/.github/workflows/CI_github_ESP32.yml @@ -34,7 +34,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-minimal + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-minimal tasmota32-lite: runs-on: ubuntu-latest @@ -49,7 +51,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-lite + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-lite tasmota32-knx: runs-on: ubuntu-latest @@ -64,7 +68,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-knx + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-knx tasmota32-sensors: runs-on: ubuntu-latest @@ -79,8 +85,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-sensors - + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-sensors tasmota32-display: runs-on: ubuntu-latest @@ -95,7 +102,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-display + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-display tasmota32-ir: runs-on: ubuntu-latest @@ -110,7 +119,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-ir + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-ir tasmota32-BG: runs-on: ubuntu-latest @@ -125,7 +136,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-BG + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-BG tasmota32-BR: runs-on: ubuntu-latest @@ -140,7 +153,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-BR + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-BR tasmota32-CN: runs-on: ubuntu-latest @@ -155,7 +170,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-CN + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-CN tasmota32-CZ: runs-on: ubuntu-latest @@ -170,7 +187,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-CZ + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-CZ tasmota32-DE: runs-on: ubuntu-latest @@ -185,7 +204,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-DE + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-DE tasmota32-ES: runs-on: ubuntu-latest @@ -200,7 +221,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-ES + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-ES tasmota32-FR: @@ -216,7 +239,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-FR + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-FR tasmota32-GR: runs-on: ubuntu-latest @@ -231,7 +256,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-GR + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-GR tasmota32-HE: runs-on: ubuntu-latest @@ -246,7 +273,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-HE + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-HE tasmota32-HU: runs-on: ubuntu-latest @@ -261,7 +290,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-HU + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-HU tasmota32-IT: runs-on: ubuntu-latest @@ -276,7 +307,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-IT + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-IT tasmota32-KO: runs-on: ubuntu-latest @@ -291,7 +324,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-KO + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-KO tasmota32-NL: runs-on: ubuntu-latest @@ -306,7 +341,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-NL + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-NL tasmota32-PL: runs-on: ubuntu-latest @@ -321,7 +358,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-PL + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-PL tasmota32-PT: runs-on: ubuntu-latest @@ -336,7 +375,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-PT + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-PT tasmota32-RO: runs-on: ubuntu-latest @@ -351,7 +392,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-RO + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-RO tasmota32-RU: runs-on: ubuntu-latest @@ -366,7 +409,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-RU + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-RU tasmota32-SE: runs-on: ubuntu-latest @@ -381,7 +426,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-SE + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-SE tasmota32-SK: runs-on: ubuntu-latest @@ -396,7 +443,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-SK + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-SK tasmota32-TR: runs-on: ubuntu-latest @@ -411,7 +460,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-TR + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-TR tasmota32-TW: runs-on: ubuntu-latest @@ -426,7 +477,9 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-TW + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-TW tasmota32-UK: runs-on: ubuntu-latest @@ -441,4 +494,6 @@ jobs: platformio upgrade --dev platformio update - name: Run PlatformIO - run: platformio run -e tasmota32-UK + run: | + cp platformio_override_sample.ini platformio_override.ini + platformio run -e tasmota32-UK From 9d3dbed4115ce1ad54abe204d25eb469f98a1be7 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Tue, 5 May 2020 11:40:50 +0200 Subject: [PATCH 08/24] some formatting --- tasmota/xdrv_10_scripter.ino | 4 ++-- tasmota/xdrv_39_webcam.ino | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index 3056e41a8..5040d38cb 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -73,7 +73,7 @@ uint32_t DecodeLightId(uint32_t hue_id); void SaveFile(const char *name,const uint8_t *buf,uint32_t len) { - File file = SPIFFS.open(name,FILE_WRITE); + File file = SPIFFS.open(name, FILE_WRITE); if (!file) return; file.write(buf, len); file.close(); @@ -5237,7 +5237,7 @@ bool Xdrv10(uint8_t function) case FUNC_WEB_ADD_MAIN_BUTTON: ScriptWebShow('&'); break; -#endif +#endif // USE_SCRIPT_WEB_DISPLAY case FUNC_WEB_ADD_HANDLER: Webserver->on("/" WEB_HANDLE_SCRIPT, HandleScriptConfiguration); Webserver->on("/ta",HTTP_POST, HandleScriptTextareaConfiguration); diff --git a/tasmota/xdrv_39_webcam.ino b/tasmota/xdrv_39_webcam.ino index c852fc86c..3035aa67b 100644 --- a/tasmota/xdrv_39_webcam.ino +++ b/tasmota/xdrv_39_webcam.ino @@ -525,7 +525,7 @@ void draw_face_boxes(dl_matrix3du_t *image_matrix, box_array_t *boxes, int face_ #define DL_SPIRAM_SUPPORT uint32_t wc_set_face_detect(int32_t value) { - if (value >= 0) { face_detect_time=value; } + if (value >= 0) { face_detect_time = value; } return faces; } @@ -542,7 +542,7 @@ bool detected = false; int face_id = 0; camera_fb_t *fb; - if ((millis()-face_ltime) > face_detect_time) { + if ((millis() - face_ltime) > face_detect_time) { face_ltime = millis(); fb = esp_camera_fb_get(); if (!fb) { return ESP_FAIL; } @@ -570,7 +570,7 @@ camera_fb_t *fb; box_array_t *net_boxes = face_detect(image_matrix, &mtmn_config); if (net_boxes){ detected = true; - faces=net_boxes->len; + faces = net_boxes->len; //if(recognition_enabled){ // face_id = run_face_recognition(image_matrix, net_boxes); //} @@ -580,7 +580,7 @@ camera_fb_t *fb; free(net_boxes->landmark); free(net_boxes); } else { - faces=0; + faces = 0; } dl_matrix3du_free(image_matrix); //Serial.printf("face detected: %d",faces); @@ -683,7 +683,7 @@ uint32_t motion_brightness; uint8_t *last_motion_buffer; uint32_t wc_set_motion_detect(int32_t value) { - if (value >= 0) { motion_detect=value; } + if (value >= 0) { motion_detect = value; } if (-1 == value) { return motion_trigger; } else { @@ -694,7 +694,7 @@ uint32_t wc_set_motion_detect(int32_t value) { // optional motion detector void detect_motion(void) { camera_fb_t *wc_fb; - uint8_t *out_buf=0; + uint8_t *out_buf = 0; if ((millis()-motion_ltime) > motion_detect) { motion_ltime = millis(); From 89e1475b367bb2db204545dcfb3b83abd71726a6 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 5 May 2020 14:30:07 +0200 Subject: [PATCH 09/24] Relax webcam setup time --- tasmota/xdrv_39_webcam.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/tasmota/xdrv_39_webcam.ino b/tasmota/xdrv_39_webcam.ino index 3035aa67b..cd2e5d2b1 100644 --- a/tasmota/xdrv_39_webcam.ino +++ b/tasmota/xdrv_39_webcam.ino @@ -867,6 +867,7 @@ bool Xdrv39(uint8_t function) { //if (Settings.esp32_webcam_resolution) { #ifndef USE_SCRIPT WcStreamControl(Settings.esp32_webcam_resolution); + delay(50); // Give the webcam webserver some time to prepare the stream wc_show_stream(); #endif //} From 139d32a86d23dfe4fcaef28ff40e143f443e6cbb Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 5 May 2020 15:53:16 +0200 Subject: [PATCH 10/24] Optimize ESP32 webserver --- tasmota/xdrv_01_webserver.ino | 60 ++++++++++------------------------- 1 file changed, 17 insertions(+), 43 deletions(-) diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 6246377be..fa9b35232 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -246,13 +246,15 @@ const char HTTP_SCRIPT_MODULE_TEMPLATE[] PROGMEM = "q.appendChild(o);" "}" "function ot(g,s){" // g = id and name, s = value - "var p,l,t=qs('#h'+g),u=s&0x001f;" + "var a=s&0xffe0,b=0,c,p,l,t=qs('#h'+g),u=s&0x001f;" "l=t.options.length;" // Remove current options "for(i=l;i;i--){p=t.options[i-1].parentNode;p.removeChild(t.options[i-1]);}" + "l=hs.length;" // Find max indexes for s + "for(i=0;i>=5;" // Add options - "for(i=1;i<=hs[s];i++){ce((i<10)?(' '+i):i,t);}" + "for(i=1;i<=b;i++){ce((i<10)?(' '+i):i,t);}" "eb('h'+g).value=u+1;" // Set selected value - "t.style.visibility=(hs[s]>0)?'':'hidden';" + "t.style.visibility=(b>0)?'':'hidden';" "}" "function sk(s,g){" // s = value, g = id and name "var o=os.replace(/}2/g,\"