From 70287d90ad0bb166b594be5e48614f8fd0bb3904 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:45:12 +0200 Subject: [PATCH 001/186] Bump v13.2.0.1 --- CHANGELOG.md | 21 ++++++++++++-- FIRMWARE.md | 2 +- README.md | 2 +- RELEASENOTES.md | 47 ++----------------------------- tasmota/include/tasmota_version.h | 2 +- 5 files changed, 24 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bb50c290fce..14f320353066 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,24 @@ All notable changes to this project will be documented in this file. ## [Unreleased] - Development -## [13.1.0.4] +## [13.2.0.1] +### Added + +### Breaking Changed + +### Changed + +### Fixed + +### Removed + + +## [Released] + +## [13.2.0] 20231019 +- Release Quincy + +## [13.1.0.4] 20231019 ### Added - Support for HC8 CO2 sensor (#19714) - ESP32 commands ``Ds18Rescan`` and ``Ds18RetryRead`` (#19700) @@ -86,8 +103,6 @@ All notable changes to this project will be documented in this file. - Teleinfo power (#19381) - Exception 3 in IRHVAC (#19389) -## [Released] - Development - ## [13.1.0] 20230815 - Release Quentin diff --git a/FIRMWARE.md b/FIRMWARE.md index ab962399c40c..f0e069a9a136 100644 --- a/FIRMWARE.md +++ b/FIRMWARE.md @@ -18,7 +18,7 @@ See [CHANGELOG.md](https://github.com/arendst/Tasmota/blob/development/tasmota/C ## Development -[![Dev Version](https://img.shields.io/badge/development%20version-v13.1.x.x-blue.svg)](https://github.com/arendst/Tasmota) +[![Dev Version](https://img.shields.io/badge/development%20version-v13.2.x.x-blue.svg)](https://github.com/arendst/Tasmota) [![Download Dev](https://img.shields.io/badge/download-development-yellow.svg)](http://ota.tasmota.com/tasmota/) [![Tasmota CI](https://github.com/arendst/Tasmota/workflows/Tasmota%20CI/badge.svg)](https://github.com/arendst/Tasmota/actions?query=workflow%3A%22Tasmota+CI%22) [![Tasmota ESP32 CI](https://github.com/arendst/Tasmota/workflows/Tasmota%20ESP32%20CI/badge.svg)](https://github.com/arendst/Tasmota/actions?query=workflow%3A%22Tasmota+ESP32+CI%22) diff --git a/README.md b/README.md index 14911249a137..f36d66b246a7 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Firmware binaries can be downloaded from http://ota.tasmota.com/tasmota/release/ ## Development -[![Dev Version](https://img.shields.io/badge/development%20version-v13.1.x.x-blue.svg)](https://github.com/arendst/Tasmota) +[![Dev Version](https://img.shields.io/badge/development%20version-v13.2.x.x-blue.svg)](https://github.com/arendst/Tasmota) [![Download Dev](https://img.shields.io/badge/download-development-yellow.svg)](http://ota.tasmota.com/tasmota/) [![Tasmota CI](https://github.com/arendst/Tasmota/actions/workflows/build_all_the_things.yml/badge.svg)](https://github.com/arendst/Tasmota/actions/workflows/build_all_the_things.yml) [![Build_development](https://github.com/arendst/Tasmota/actions/workflows/Tasmota_build_devel.yml/badge.svg)](https://github.com/arendst/Tasmota/actions/workflows/Tasmota_build_devel.yml) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 76473d08b704..0d752bd8a145 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -75,7 +75,7 @@ Latest released binaries can be downloaded from - http://ota.tasmota.com/tasmota/release Historical binaries can be downloaded from -- http://ota.tasmota.com/tasmota/release-13.1.0 +- http://ota.tasmota.com/tasmota/release-13.2.0 The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmota.com/tasmota/release/tasmota.bin.gz`` @@ -100,7 +100,7 @@ Latest released binaries can be downloaded from - https://ota.tasmota.com/tasmota32/release Historical binaries can be downloaded from -- https://ota.tasmota.com/tasmota32/release-13.1.0 +- https://ota.tasmota.com/tasmota32/release-13.2.0 The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasmota.com/tasmota32/release/tasmota32.bin`` @@ -110,55 +110,14 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm [Complete list](BUILDS.md) of available feature and sensors. -## Changelog v13.1.0.4 +## Changelog v13.2.0.1 ### Added - Experimental support for ESP32-C2 and ESP32-C6 using Arduino core v3 -- Commands to allow setting of timeprop parameters [#19310](https://github.com/arendst/Tasmota/issues/19310) -- Command ``Mi32Name`` [#19619](https://github.com/arendst/Tasmota/issues/19619) -- Variables ``%power<1..28>%`` and ``%switch<1..28>%`` to rules [#19331](https://github.com/arendst/Tasmota/issues/19331) -- Support different baudrates on BL0942 energy monitor -- Support for Shelly PlusPMMini, Plus1Mini and Plus1PMMini -- Support for HDMI CEC protocol [#19434](https://github.com/arendst/Tasmota/issues/19434) -- Support for ENS16x (air quality) and ENS210 (temp & RH) sensors [#19479](https://github.com/arendst/Tasmota/issues/19479) -- Support for HC8 CO2 sensor [#19714](https://github.com/arendst/Tasmota/issues/19714) -- Support for non-persistent ``WebButton17`` to ``WebButton32`` [#19580](https://github.com/arendst/Tasmota/issues/19580) -- ESP32 commands ``Ds18Rescan`` and ``Ds18RetryRead`` [#19700](https://github.com/arendst/Tasmota/issues/19700) -- ESP32 support for influxdb access using https [#19582](https://github.com/arendst/Tasmota/issues/19582) -- Berry read and write Counters [#19558](https://github.com/arendst/Tasmota/issues/19558) -- Matter support for Virtual Devices controllable via Rules or Berry [#19520](https://github.com/arendst/Tasmota/issues/19520) ### Breaking Changed -- `Sendmail` upgraded to ESP-Mail-Client v3.4.9 from v1.2.0, using BearSSL instead of MbedTLS [#19460](https://github.com/arendst/Tasmota/issues/19460) -- Removed support for Homekit in favour of Matter [#19738](https://github.com/arendst/Tasmota/issues/19738) ### Changed -- ESP32 Framework (Arduino Core) from v2.0.11 to v2.0.14 -- ESP32 LVGL library from v8.3.8 to v8.3.10 (no functional change) -- Display invert setting after tasmota start in uDisplay driver [#19337](https://github.com/arendst/Tasmota/issues/19337) -- Consolidate SGP40 and SGP41 into SGP4x driver [#19560](https://github.com/arendst/Tasmota/issues/19560) -- MAX31855/MAX6675 sensors driver support up to 6 [#19329](https://github.com/arendst/Tasmota/issues/19329) -- Teleinfo use Apparent Power as Active Power approximation [#19756](https://github.com/arendst/Tasmota/issues/19756) -- ESP32 LittleFS updated to version with grow option [#19635](https://github.com/arendst/Tasmota/issues/19635) -- ESP32 I2S audio preparation for Arduino Core v3 [#19637](https://github.com/arendst/Tasmota/issues/19637) -- ESP32 analog from `analogRead()` to calibrated `analogReadMilliVolts()` [#19732](https://github.com/arendst/Tasmota/issues/19732) ### Fixed -- Shutter invert [#19341](https://github.com/arendst/Tasmota/issues/19341) and [#19374](https://github.com/arendst/Tasmota/issues/19374) -- Teleinfo power [#19381](https://github.com/arendst/Tasmota/issues/19381) -- Exception 3 in IRHVAC [#19389](https://github.com/arendst/Tasmota/issues/19389) -- PCF8574 mode 1 with base relays exception 3/28 regression from v12.4.0.4 [#19408](https://github.com/arendst/Tasmota/issues/19408) -- ModbusBridge write memory leak [#19758](https://github.com/arendst/Tasmota/issues/19758) -- Zigbee timezone when device reads LocalTime attribute [#19772](https://github.com/arendst/Tasmota/issues/19772) -- ESP32 DS18x20 driver support extended over GPIO33 -- ESP32 Support for IPv6 link-local zones for esp-idf 5.1 (necessary for Matter) -- ESP32 Shutter migration [#19454](https://github.com/arendst/Tasmota/issues/19454) -- ESP32 Shutter multi press button events [#19465](https://github.com/arendst/Tasmota/issues/19465) -- ESP32 Shutter button quad press [#19589](https://github.com/arendst/Tasmota/issues/19589) -- ESP32 shutter frequency [#19717](https://github.com/arendst/Tasmota/issues/19717) -- ESP32 Arduino Core v2 wifi client flush [#19642](https://github.com/arendst/Tasmota/issues/19642) -- ESP32 Partition Wizard grow filesystem support [#19645](https://github.com/arendst/Tasmota/issues/19645) -- ESP32-C3 relay click on restart -- Matter support for Virtual Devices controllable via Rules or Berry [#19520](https://github.com/arendst/Tasmota/issues/19520) ### Removed -- Support for Homekit in favour of Matter [#19738](https://github.com/arendst/Tasmota/issues/19738) diff --git a/tasmota/include/tasmota_version.h b/tasmota/include/tasmota_version.h index 03e7b654fc57..bd3ed94ddec1 100644 --- a/tasmota/include/tasmota_version.h +++ b/tasmota/include/tasmota_version.h @@ -20,6 +20,6 @@ #ifndef _TASMOTA_VERSION_H_ #define _TASMOTA_VERSION_H_ -const uint32_t TASMOTA_VERSION = 0x0D010004; // 13.1.0.4 +const uint32_t TASMOTA_VERSION = 0x0D020001; // 13.2.0.1 #endif // _TASMOTA_VERSION_H_ From b6811b2f4e50deaf8e0fc499f858ae82f437b0a0 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 19 Oct 2023 16:59:53 +0200 Subject: [PATCH 002/186] Prep ESP32 I2C bus2 support --- CHANGELOG.md | 3 + RELEASENOTES.md | 2 + tasmota/tasmota_support/support_a_i2c.ino | 72 +++++++++---------- tasmota/tasmota_xsns_sensor/xsns_66_iAQ.ino | 47 ++++++++---- .../tasmota_xx2c_global/xx2c_interface.ino | 4 ++ 5 files changed, 74 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14f320353066..f194c4c7619f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,15 @@ All notable changes to this project will be documented in this file. ## [13.2.0.1] ### Added +- ESP32 I2C bus2 support to iAQ core driver (#19799) ### Breaking Changed ### Changed +- Prepare I2C drivers for bus2 support ### Fixed +- ESP32 I2C allow bus2 support when bus1 is not enabled ### Removed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 0d752bd8a145..e6361ba1bb87 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -113,11 +113,13 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ## Changelog v13.2.0.1 ### Added - Experimental support for ESP32-C2 and ESP32-C6 using Arduino core v3 +- ESP32 I2C bus2 support to iAQ core driver [#19799](https://github.com/arendst/Tasmota/issues/19799) ### Breaking Changed ### Changed ### Fixed +- ESP32 I2C allow bus2 support when bus1 is not enabled ### Removed diff --git a/tasmota/tasmota_support/support_a_i2c.ino b/tasmota/tasmota_support/support_a_i2c.ino index 32237d173f3d..68b557a54368 100644 --- a/tasmota/tasmota_support/support_a_i2c.ino +++ b/tasmota/tasmota_support/support_a_i2c.ino @@ -49,15 +49,25 @@ bool I2c2Begin(int sda, int scl, uint32_t frequency) { } #endif +TwoWire& I2cGetWire(uint8_t bus = 0) { + if (!bus && TasmotaGlobal.i2c_enabled) { + return Wire; +#ifdef ESP32 + } else if (bus && TasmotaGlobal.i2c_enabled_2) { + return Wire1; +#endif // ESP32 + } else { +// AddLog(LOG_LEVEL_ERROR, PSTR("I2C: bus%d not initialized"), bus +1); + return *(TwoWire*)nullptr; + } +} + bool I2cValidRead(uint8_t addr, uint8_t reg, uint8_t size, uint8_t bus = 0) { i2c_buffer = 0; -#ifdef ESP32 - if (bus && !TasmotaGlobal.i2c_enabled_2) { return false; } // Error - TwoWire & myWire = (bus == 0) ? Wire : Wire1; -#else - if (bus) { return false; } // Second I2c bus ESP32 only - TwoWire & myWire = Wire; -#endif + + TwoWire& myWire = I2cGetWire(bus); + if (&myWire == nullptr) { return false; } // No valid I2c bus + uint8_t retry = I2C_RETRY_COUNTER; bool status = false; while (!status && retry) { @@ -147,13 +157,9 @@ int32_t I2cRead24(uint8_t addr, uint8_t reg, uint8_t bus = 0) { } bool I2cWrite(uint8_t addr, uint8_t reg, uint32_t val, uint8_t size, uint8_t bus = 0) { -#ifdef ESP32 - if (bus && !TasmotaGlobal.i2c_enabled_2) { return false; } // Error - TwoWire & myWire = (bus == 0) ? Wire : Wire1; -#else - if (bus) { return false; } // Second I2c bus ESP32 only - TwoWire & myWire = Wire; -#endif + TwoWire& myWire = I2cGetWire(bus); + if (&myWire == nullptr) { return false; } // No valid I2c bus + uint8_t x = I2C_RETRY_COUNTER; do { myWire.beginTransmission((uint8_t)addr); // start transmission to device @@ -176,13 +182,9 @@ bool I2cWrite16(uint8_t addr, uint8_t reg, uint32_t val, uint8_t bus = 0) { } bool I2cReadBuffer(uint8_t addr, uint8_t reg, uint8_t *reg_data, uint16_t len, uint8_t bus = 0) { -#ifdef ESP32 - if (bus && !TasmotaGlobal.i2c_enabled_2) { return true; } // Error - TwoWire & myWire = (bus == 0) ? Wire : Wire1; -#else - if (bus) { return true; } // Second I2c bus ESP32 only - TwoWire & myWire = Wire; -#endif + TwoWire& myWire = I2cGetWire(bus); + if (&myWire == nullptr) { return true; } // No valid I2c bus + myWire.beginTransmission((uint8_t)addr); myWire.write((uint8_t)reg); myWire.endTransmission(); @@ -197,13 +199,9 @@ bool I2cReadBuffer(uint8_t addr, uint8_t reg, uint8_t *reg_data, uint16_t len, u } int8_t I2cWriteBuffer(uint8_t addr, uint8_t reg, uint8_t *reg_data, uint16_t len, uint8_t bus = 0) { -#ifdef ESP32 - if (bus && !TasmotaGlobal.i2c_enabled_2) { return 1; } // Error - TwoWire & myWire = (bus == 0) ? Wire : Wire1; -#else - if (bus) { return 1; } // Second I2c bus ESP32 only - TwoWire & myWire = Wire; -#endif + TwoWire& myWire = I2cGetWire(bus); + if (&myWire == nullptr) { return 1; } // No valid I2c bus + myWire.beginTransmission((uint8_t)addr); myWire.write((uint8_t)reg); while (len--) { @@ -229,16 +227,14 @@ void I2cScan(uint8_t bus = 0) { // 3: received NACK on transmit of data // 4: other error // 5: timeout - + TwoWire& myWire = I2cGetWire(bus); + if (&myWire == nullptr) { return; } // No valid I2c bus #ifdef ESP32 - if (bus && !TasmotaGlobal.i2c_enabled_2) { return; } - TwoWire & myWire = (bus == 0) ? Wire : Wire1; Response_P(PSTR("{\"" D_CMND_I2CSCAN "\":\"Device(s) found on bus%d at"), bus +1); #else - if (bus) { return; } // Second I2c bus ESP32 only - TwoWire & myWire = Wire; Response_P(PSTR("{\"" D_CMND_I2CSCAN "\":\"Device(s) found at")); #endif + uint8_t error = 0; uint8_t address = 0; uint8_t any = 0; @@ -311,13 +307,9 @@ bool I2cActive(uint32_t addr, uint8_t bus = 0) { } bool I2cSetDevice(uint32_t addr, uint8_t bus = 0) { -#ifdef ESP32 - if (bus && !TasmotaGlobal.i2c_enabled_2) { return false; } // If no second bus report as not present; - TwoWire & myWire = (bus == 0) ? Wire : Wire1; -#else - bus = 0; - TwoWire & myWire = Wire; -#endif + TwoWire& myWire = I2cGetWire(bus); + if (&myWire == nullptr) { return false; } // No valid I2c bus + addr &= 0x7F; // Max I2C address is 127 if (I2cActive(addr, bus)) { return false; // If already active report as not present; diff --git a/tasmota/tasmota_xsns_sensor/xsns_66_iAQ.ino b/tasmota/tasmota_xsns_sensor/xsns_66_iAQ.ino index 55b391a3ae45..36b9669123f9 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_66_iAQ.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_66_iAQ.ino @@ -41,15 +41,48 @@ struct { uint16_t pred; uint16_t Tvoc; uint8_t i2c_address; + uint8_t i2c_bus; uint8_t status; bool ready; } iAQ; +bool IAQ_Read(void) { + TwoWire& myWire = I2cGetWire(iAQ.i2c_bus); + if (&myWire == nullptr) { return false; } // No valid I2c bus + + uint8_t buf[9]; + buf[2] = IAQ_STATUS_I2C_ERR; // populate entry with error code + myWire.requestFrom(iAQ.i2c_address, sizeof(buf)); + for (uint32_t i = 0; i < 9; i++) { + buf[i] = myWire.read(); + } + // AddLog(LOG_LEVEL_DEBUG, "iAQ: buffer %x %x %x %x %x %x %x %x %x ", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8]); + if (IAQ_STATUS_I2C_ERR == buf[2]) { + return false; + } + iAQ.pred = (buf[0]<<8) + buf[1]; + iAQ.status = buf[2]; + iAQ.resistance = ((uint32_t)buf[3]<<24) + ((uint32_t)buf[4]<<16) + ((uint32_t)buf[5]<<8) + (uint32_t)buf[6]; + iAQ.Tvoc = (buf[7]<<8) + buf[8]; + return true; +} + void IAQ_Init(void) { + for (uint32_t bus = 0; bus < 2; bus++) { + if (!I2cSetDevice(I2_ADR_IAQ, bus)) { continue; } + iAQ.i2c_address = I2_ADR_IAQ; + iAQ.i2c_bus = bus; + if (!IAQ_Read()) { continue; } + I2cSetActiveFound(I2_ADR_IAQ, "IAQ", bus); + iAQ.ready = true; + } + +/* if (!I2cSetDevice(I2_ADR_IAQ)) { return; } I2cSetActiveFound(I2_ADR_IAQ, "IAQ"); iAQ.i2c_address = I2_ADR_IAQ; iAQ.ready = true; +*/ /* for (iAQ.i2c_address = I2_ADR_IAQ; iAQ.i2c_address < I2_ADR_IAQ +5; iAQ.i2c_address++) { if (I2cActive(iAQ.i2c_address)) { continue; } @@ -62,20 +95,6 @@ void IAQ_Init(void) { */ } -void IAQ_Read(void) { - uint8_t buf[9]; - buf[2] = IAQ_STATUS_I2C_ERR; // populate entry with error code - Wire.requestFrom(iAQ.i2c_address, sizeof(buf)); - for( uint32_t i=0; i<9; i++ ) { - buf[i]= Wire.read(); - } - // AddLog(LOG_LEVEL_DEBUG, "iAQ: buffer %x %x %x %x %x %x %x %x %x ", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8]); - iAQ.pred = (buf[0]<<8) + buf[1]; - iAQ.status = buf[2]; - iAQ.resistance = ((uint32_t)buf[3]<<24) + ((uint32_t)buf[4]<<16) + ((uint32_t)buf[5]<<8) + (uint32_t)buf[6]; - iAQ.Tvoc = (buf[7]<<8) + buf[8]; -} - /*********************************************************************************************\ * Presentation \*********************************************************************************************/ diff --git a/tasmota/tasmota_xx2c_global/xx2c_interface.ino b/tasmota/tasmota_xx2c_global/xx2c_interface.ino index 33e7041d3725..55e8a1a0a559 100644 --- a/tasmota/tasmota_xx2c_global/xx2c_interface.ino +++ b/tasmota/tasmota_xx2c_global/xx2c_interface.ino @@ -413,7 +413,11 @@ const uint8_t kI2cList[] = { /*********************************************************************************************/ bool I2cEnabled(uint32_t i2c_index) { +#ifdef ESP8266 return (TasmotaGlobal.i2c_enabled && bitRead(Settings->i2c_drivers[i2c_index / 32], i2c_index % 32)); +#else + return ((TasmotaGlobal.i2c_enabled || TasmotaGlobal.i2c_enabled_2) && bitRead(Settings->i2c_drivers[i2c_index / 32], i2c_index % 32)); +#endif } void I2cDriverState(void) { From 49709807c762f35d91cfd0b040d22fcdd5ff5d16 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 19 Oct 2023 17:37:19 +0200 Subject: [PATCH 003/186] Add I2C bus2 support to HTU temperature sensor --- CHANGELOG.md | 3 +- RELEASENOTES.md | 3 +- tasmota/tasmota_xsns_sensor/xsns_08_htu21.ino | 165 +++++++++--------- tasmota/tasmota_xsns_sensor/xsns_66_iAQ.ino | 7 +- 4 files changed, 87 insertions(+), 91 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f194c4c7619f..27a7f7be5d7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ All notable changes to this project will be documented in this file. ## [13.2.0.1] ### Added -- ESP32 I2C bus2 support to iAQ core driver (#19799) +- I2C bus2 support to iAQ core sensor (#19799) +- I2C bus2 support to HTU temperature sensor ### Breaking Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index e6361ba1bb87..0f841b2db01d 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -113,7 +113,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ## Changelog v13.2.0.1 ### Added - Experimental support for ESP32-C2 and ESP32-C6 using Arduino core v3 -- ESP32 I2C bus2 support to iAQ core driver [#19799](https://github.com/arendst/Tasmota/issues/19799) +- I2C bus2 support to iAQ core sensor [#19799](https://github.com/arendst/Tasmota/issues/19799) +- I2C bus2 support to HTU temperature sensor ### Breaking Changed diff --git a/tasmota/tasmota_xsns_sensor/xsns_08_htu21.ino b/tasmota/tasmota_xsns_sensor/xsns_08_htu21.ino index c9b535ffd0c9..a378de52de07 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_08_htu21.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_08_htu21.ino @@ -63,6 +63,7 @@ struct { float temperature = 0; float humidity = 0; uint8_t address; + uint8_t bus; uint8_t type = 0; uint8_t delay_temp; uint8_t delay_humidity = 50; @@ -72,8 +73,7 @@ struct { /*********************************************************************************************/ -uint8_t HtuCheckCrc8(uint16_t data) -{ +uint8_t HtuCheckCrc8(uint16_t data) { for (uint32_t bit = 0; bit < 16; bit++) { if (data & 0x8000) { data = (data << 1) ^ HTU21_CRC8_POLYNOM; @@ -84,22 +84,33 @@ uint8_t HtuCheckCrc8(uint16_t data) return data >>= 8; } -uint8_t HtuReadDeviceId(void) -{ - HtuReset(); // Fixes ESP32 sensor loss at restart +bool HtuReset(void) { + TwoWire& myWire = I2cGetWire(Htu.bus); + if (&myWire == nullptr) { return false; } // No valid I2c bus + + myWire.beginTransmission(HTU21_ADDR); + myWire.write(HTU21_RESET); + myWire.endTransmission(); + delay(15); // Reset takes 15ms + return true; +} + +uint8_t HtuReadDeviceId(void) { + if (!HtuReset()) { return 0; }; // Fixes ESP32 sensor loss at restart uint16_t deviceID = 0; uint8_t checksum = 0; - Wire.beginTransmission(HTU21_ADDR); - Wire.write(HTU21_SERIAL2_READ1); - Wire.write(HTU21_SERIAL2_READ2); - Wire.endTransmission(); + TwoWire& myWire = I2cGetWire(Htu.bus); + myWire.beginTransmission(HTU21_ADDR); + myWire.write(HTU21_SERIAL2_READ1); + myWire.write(HTU21_SERIAL2_READ2); + myWire.endTransmission(); - Wire.requestFrom(HTU21_ADDR, 3); - deviceID = Wire.read() << 8; - deviceID |= Wire.read(); - checksum = Wire.read(); + myWire.requestFrom(HTU21_ADDR, 3); + deviceID = myWire.read() << 8; + deviceID |= myWire.read(); + checksum = myWire.read(); if (HtuCheckCrc8(deviceID) == checksum) { deviceID = deviceID >> 8; } else { @@ -108,28 +119,17 @@ uint8_t HtuReadDeviceId(void) return (uint8_t)deviceID; } -void HtuSetResolution(uint8_t resolution) -{ - uint8_t current = I2cRead8(HTU21_ADDR, HTU21_READREG); +void HtuSetResolution(uint8_t resolution) { + uint8_t current = I2cRead8(HTU21_ADDR, HTU21_READREG, Htu.bus); current &= 0x7E; // Replace current resolution bits with 0 current |= resolution; // Add new resolution bits to register - I2cWrite8(HTU21_ADDR, HTU21_WRITEREG, current); -} - -void HtuReset(void) -{ - Wire.beginTransmission(HTU21_ADDR); - Wire.write(HTU21_RESET); - Wire.endTransmission(); - delay(15); // Reset takes 15ms + I2cWrite8(HTU21_ADDR, HTU21_WRITEREG, current, Htu.bus); } -void HtuHeater(uint8_t heater) -{ - uint8_t current = I2cRead8(HTU21_ADDR, HTU21_READREG); +void HtuHeater(uint8_t heater) { + uint8_t current = I2cRead8(HTU21_ADDR, HTU21_READREG, Htu.bus); - switch(heater) - { + switch(heater) { case HTU21_HEATER_ON : current |= heater; break; case HTU21_HEATER_OFF : current &= heater; @@ -137,48 +137,47 @@ void HtuHeater(uint8_t heater) default : current &= heater; break; } - I2cWrite8(HTU21_ADDR, HTU21_WRITEREG, current); + I2cWrite8(HTU21_ADDR, HTU21_WRITEREG, current, Htu.bus); } -void HtuInit(void) -{ +void HtuInit(void) { HtuReset(); HtuHeater(HTU21_HEATER_OFF); HtuSetResolution(HTU21_RES_RH12_T14); } -bool HtuRead(void) -{ +bool HtuRead(void) { uint8_t checksum = 0; uint16_t sensorval = 0; if (Htu.valid) { Htu.valid--; } - Wire.beginTransmission(HTU21_ADDR); - Wire.write(HTU21_READTEMP); - if (Wire.endTransmission() != 0) { return false; } // In case of error + TwoWire& myWire = I2cGetWire(Htu.bus); + myWire.beginTransmission(HTU21_ADDR); + myWire.write(HTU21_READTEMP); + if (myWire.endTransmission() != 0) { return false; } // In case of error delay(Htu.delay_temp); // Sensor time at max resolution - Wire.requestFrom(HTU21_ADDR, 3); - if (3 == Wire.available()) { - sensorval = Wire.read() << 8; // MSB - sensorval |= Wire.read(); // LSB - checksum = Wire.read(); + myWire.requestFrom(HTU21_ADDR, 3); + if (3 == myWire.available()) { + sensorval = myWire.read() << 8; // MSB + sensorval |= myWire.read(); // LSB + checksum = myWire.read(); } if (HtuCheckCrc8(sensorval) != checksum) { return false; } // Checksum mismatch Htu.temperature = ConvertTemp(0.002681f * (float)sensorval - 46.85f); - Wire.beginTransmission(HTU21_ADDR); - Wire.write(HTU21_READHUM); - if (Wire.endTransmission() != 0) { return false; } // In case of error + myWire.beginTransmission(HTU21_ADDR); + myWire.write(HTU21_READHUM); + if (myWire.endTransmission() != 0) { return false; } // In case of error delay(Htu.delay_humidity); // Sensor time at max resolution - Wire.requestFrom(HTU21_ADDR, 3); - if (3 <= Wire.available()) { - sensorval = Wire.read() << 8; // MSB - sensorval |= Wire.read(); // LSB - checksum = Wire.read(); + myWire.requestFrom(HTU21_ADDR, 3); + if (3 <= myWire.available()) { + sensorval = myWire.read() << 8; // MSB + sensorval |= myWire.read(); // LSB + checksum = myWire.read(); } if (HtuCheckCrc8(sensorval) != checksum) { return false; } // Checksum mismatch @@ -201,41 +200,42 @@ bool HtuRead(void) /********************************************************************************************/ -void HtuDetect(void) -{ +void HtuDetect(void) { Htu.address = HTU21_ADDR; - if (!I2cSetDevice(Htu.address)) { return; } - - Htu.type = HtuReadDeviceId(); - if (Htu.type) { - uint8_t index = 0; - HtuInit(); - switch (Htu.type) { - case HTU21_CHIPID: - Htu.delay_temp = 50; - Htu.delay_humidity = 16; - break; - case SI7021_CHIPID: - index++; // 3 - case SI7020_CHIPID: - index++; // 2 - case SI7013_CHIPID: - index++; // 1 - Htu.delay_temp = 12; - Htu.delay_humidity = 23; - break; - default: - index = 4; - Htu.delay_temp = 50; - Htu.delay_humidity = 23; + for (Htu.bus = 0; Htu.bus < 2; Htu.bus++) { + if (!I2cSetDevice(Htu.address, Htu.bus)) { continue; } + + Htu.type = HtuReadDeviceId(); + if (Htu.type) { + uint8_t index = 0; + HtuInit(); + switch (Htu.type) { + case HTU21_CHIPID: + Htu.delay_temp = 50; + Htu.delay_humidity = 16; + break; + case SI7021_CHIPID: + index++; // 3 + case SI7020_CHIPID: + index++; // 2 + case SI7013_CHIPID: + index++; // 1 + Htu.delay_temp = 12; + Htu.delay_humidity = 23; + break; + default: + index = 4; + Htu.delay_temp = 50; + Htu.delay_humidity = 23; + } + GetTextIndexed(Htu.types, sizeof(Htu.types), index, kHtuTypes); + I2cSetActiveFound(Htu.address, Htu.types); + break; } - GetTextIndexed(Htu.types, sizeof(Htu.types), index, kHtuTypes); - I2cSetActiveFound(Htu.address, Htu.types); } } -void HtuEverySecond(void) -{ +void HtuEverySecond(void) { if (TasmotaGlobal.uptime &1) { // Every 2 seconds // HTU21: 68mS, SI70xx: 37mS if (!HtuRead()) { @@ -244,8 +244,7 @@ void HtuEverySecond(void) } } -void HtuShow(bool json) -{ +void HtuShow(bool json) { if (Htu.valid) { TempHumDewShow(json, (0 == TasmotaGlobal.tele_period), Htu.types, Htu.temperature, Htu.humidity); } diff --git a/tasmota/tasmota_xsns_sensor/xsns_66_iAQ.ino b/tasmota/tasmota_xsns_sensor/xsns_66_iAQ.ino index 36b9669123f9..04dab95dd8fc 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_66_iAQ.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_66_iAQ.ino @@ -75,14 +75,9 @@ void IAQ_Init(void) { if (!IAQ_Read()) { continue; } I2cSetActiveFound(I2_ADR_IAQ, "IAQ", bus); iAQ.ready = true; + break; } -/* - if (!I2cSetDevice(I2_ADR_IAQ)) { return; } - I2cSetActiveFound(I2_ADR_IAQ, "IAQ"); - iAQ.i2c_address = I2_ADR_IAQ; - iAQ.ready = true; -*/ /* for (iAQ.i2c_address = I2_ADR_IAQ; iAQ.i2c_address < I2_ADR_IAQ +5; iAQ.i2c_address++) { if (I2cActive(iAQ.i2c_address)) { continue; } From b39adacc41eeed0cc2672ff2c2eb7460cac0a5e1 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 19 Oct 2023 17:44:59 +0200 Subject: [PATCH 004/186] Fix HTU21 bus number --- tasmota/tasmota_xsns_sensor/xsns_08_htu21.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/tasmota_xsns_sensor/xsns_08_htu21.ino b/tasmota/tasmota_xsns_sensor/xsns_08_htu21.ino index a378de52de07..311854dcbcb9 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_08_htu21.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_08_htu21.ino @@ -229,7 +229,7 @@ void HtuDetect(void) { Htu.delay_humidity = 23; } GetTextIndexed(Htu.types, sizeof(Htu.types), index, kHtuTypes); - I2cSetActiveFound(Htu.address, Htu.types); + I2cSetActiveFound(Htu.address, Htu.types, Htu.bus); break; } } From e3253fea8f75c5e97dcf1d0f555f89031dc5e8fd Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 19 Oct 2023 18:01:12 +0200 Subject: [PATCH 005/186] Add I2C bus2 support to BH1750 --- CHANGELOG.md | 3 +- RELEASENOTES.md | 3 +- .../tasmota_xsns_sensor/xsns_10_bh1750.ino | 45 +++++++++++-------- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27a7f7be5d7b..31bcb7cd85dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ All notable changes to this project will be documented in this file. ## [13.2.0.1] ### Added - I2C bus2 support to iAQ core sensor (#19799) -- I2C bus2 support to HTU temperature sensor +- I2C bus2 support to HTU temperature and humidity sensor +- I2C bus2 support to BH1750 ambient light sensor ### Breaking Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 0f841b2db01d..7d6f02ca0d67 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -114,7 +114,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ### Added - Experimental support for ESP32-C2 and ESP32-C6 using Arduino core v3 - I2C bus2 support to iAQ core sensor [#19799](https://github.com/arendst/Tasmota/issues/19799) -- I2C bus2 support to HTU temperature sensor +- I2C bus2 support to HTU temperature and humidity sensor +- I2C bus2 support to BH1750 ambient light sensor ### Breaking Changed diff --git a/tasmota/tasmota_xsns_sensor/xsns_10_bh1750.ino b/tasmota/tasmota_xsns_sensor/xsns_10_bh1750.ino index 521defe689e0..6f49bd450429 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_10_bh1750.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_10_bh1750.ino @@ -62,6 +62,7 @@ struct { struct { uint8_t address; + uint8_t bus; uint8_t valid = 0; uint8_t mtreg = 69; // Default Measurement Time uint16_t illuminance = 0; @@ -78,29 +79,33 @@ uint8_t Bh1750Resolution(uint32_t sensor_index) { } bool Bh1750SetResolution(uint32_t sensor_index) { - Wire.beginTransmission(Bh1750_sensors[sensor_index].address); - Wire.write(Bh1750.resolution[Bh1750Resolution(sensor_index)]); - return (!Wire.endTransmission()); + TwoWire& myWire = I2cGetWire(Bh1750_sensors[sensor_index].bus); + myWire.beginTransmission(Bh1750_sensors[sensor_index].address); + myWire.write(Bh1750.resolution[Bh1750Resolution(sensor_index)]); + return (!myWire.endTransmission()); } bool Bh1750SetMTreg(uint32_t sensor_index) { - Wire.beginTransmission(Bh1750_sensors[sensor_index].address); + TwoWire& myWire = I2cGetWire(Bh1750_sensors[sensor_index].bus); + if (&myWire == nullptr) { return false; } // No valid I2c bus + myWire.beginTransmission(Bh1750_sensors[sensor_index].address); uint8_t data = BH1750_MEASUREMENT_TIME_HIGH | ((Bh1750_sensors[sensor_index].mtreg >> 5) & 0x07); - Wire.write(data); - if (Wire.endTransmission()) { return false; } - Wire.beginTransmission(Bh1750_sensors[sensor_index].address); + myWire.write(data); + if (myWire.endTransmission()) { return false; } + myWire.beginTransmission(Bh1750_sensors[sensor_index].address); data = BH1750_MEASUREMENT_TIME_LOW | (Bh1750_sensors[sensor_index].mtreg & 0x1F); - Wire.write(data); - if (Wire.endTransmission()) { return false; } + myWire.write(data); + if (myWire.endTransmission()) { return false; } return Bh1750SetResolution(sensor_index); } bool Bh1750Read(uint32_t sensor_index) { if (Bh1750_sensors[sensor_index].valid) { Bh1750_sensors[sensor_index].valid--; } - if (2 != Wire.requestFrom(Bh1750_sensors[sensor_index].address, (uint8_t)2)) { return false; } + TwoWire& myWire = I2cGetWire(Bh1750_sensors[sensor_index].bus); + if (2 != myWire.requestFrom(Bh1750_sensors[sensor_index].address, (uint8_t)2)) { return false; } - float illuminance = (Wire.read() << 8) | Wire.read(); + float illuminance = (myWire.read() << 8) | myWire.read(); illuminance *= 57.5 / (float)Bh1750_sensors[sensor_index].mtreg; // Fix #16022 if (1 == Bh1750Resolution(sensor_index)) { illuminance /= 2; @@ -114,13 +119,17 @@ bool Bh1750Read(uint32_t sensor_index) { /********************************************************************************************/ void Bh1750Detect(void) { - for (uint32_t i = 0; i < sizeof(Bh1750.addresses); i++) { - if (!I2cSetDevice(Bh1750.addresses[i])) { continue; } - - Bh1750_sensors[Bh1750.count].address = Bh1750.addresses[i]; - if (Bh1750SetMTreg(Bh1750.count)) { - I2cSetActiveFound(Bh1750_sensors[Bh1750.count].address, Bh1750.types); - Bh1750.count++; + for (uint32_t bus = 0; bus < 2; bus++) { + for (uint32_t i = 0; i < sizeof(Bh1750.addresses); i++) { + if (!I2cSetDevice(Bh1750.addresses[i], bus)) { continue; } + + Bh1750_sensors[Bh1750.count].address = Bh1750.addresses[i]; + Bh1750_sensors[Bh1750.count].bus = bus; + if (Bh1750SetMTreg(Bh1750.count)) { + I2cSetActiveFound(Bh1750_sensors[Bh1750.count].address, Bh1750.types, Bh1750_sensors[Bh1750.count].bus); + Bh1750.count++; + if (2 == Bh1750.count) { return; } + } } } } From 1f8cd6a259dc49e2fd3d85e0fcb78a42065cc052 Mon Sep 17 00:00:00 2001 From: Norbert Richter Date: Thu, 19 Oct 2023 18:01:56 +0200 Subject: [PATCH 006/186] Fix NeoPool filtration mode display (#19801) --- CHANGELOG.md | 1 + tasmota/tasmota_xsns_sensor/xsns_83_neopool.ino | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31bcb7cd85dc..aadc049f8bea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file. - Prepare I2C drivers for bus2 support ### Fixed +- NeoPool filtration mode display - ESP32 I2C allow bus2 support when bus1 is not enabled ### Removed diff --git a/tasmota/tasmota_xsns_sensor/xsns_83_neopool.ino b/tasmota/tasmota_xsns_sensor/xsns_83_neopool.ino index 5bd28572912d..35d5c5b04332 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_83_neopool.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_83_neopool.ino @@ -1885,7 +1885,7 @@ void NeoPoolShow(bool json) } // Filtration mode - GetTextIndexed(stemp, sizeof(stemp), NeoPoolGetData(MBF_PAR_FILT_MODE) < MBV_PAR_FILT_INTELLIGENT ? NeoPoolGetData(MBF_PAR_FILT_MODE) : nitems(kNeoPoolFiltrationMode)-1, kNeoPoolFiltrationMode); + GetTextIndexed(stemp, sizeof(stemp), NeoPoolGetData(MBF_PAR_FILT_MODE) <= MBV_PAR_FILT_INTELLIGENT ? NeoPoolGetData(MBF_PAR_FILT_MODE) : nitems(kNeoPoolFiltrationMode)-1, kNeoPoolFiltrationMode); WSContentSend_PD(HTTP_SNS_NEOPOOL_FILT_MODE, neopool_type, stemp); // Relays From 88a3d6cb7e54139f86f35c48e40d75dabc0239da Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 19 Oct 2023 18:04:48 +0200 Subject: [PATCH 007/186] Update changelogs --- CHANGELOG.md | 2 +- RELEASENOTES.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aadc049f8bea..74b691ab8e35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ All notable changes to this project will be documented in this file. - Prepare I2C drivers for bus2 support ### Fixed -- NeoPool filtration mode display +- NeoPool filtration mode display (#19801) - ESP32 I2C allow bus2 support when bus1 is not enabled ### Removed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 7d6f02ca0d67..28b33560d56f 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -122,6 +122,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ### Changed ### Fixed +- NeoPool filtration mode display [#19801](https://github.com/arendst/Tasmota/issues/19801) - ESP32 I2C allow bus2 support when bus1 is not enabled ### Removed From 6844bb606d3f379bf5c252cf57c1869c08249b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20BOU=C3=89?= Date: Thu, 19 Oct 2023 22:55:29 +0200 Subject: [PATCH 008/186] Create Matter_Plugin_9_Virt_Sensor_Occupancy.h (#19786) * Create Matter_Plugin_9_Virt_Sensor_Occupancy.h * Create Matter_Plugin_9_Virt_Sensor_Occupancy.be Implements the behavior for a Virtual Occupancy Sensor * Update be_matter_module.c Enable Virt_Sensor_Occupancy * Create solidified_Matter_Plugin_9_Virt_Sensor_Occupancy.h * Update Matter_UI.be Add missing v_occupancy and v_onoff * Update solidified_Matter_UI.h * Update be_matter_module.c * Update be_matter_module.c * Update Matter_Plugin_9_Virt_Sensor_Occupancy.be * Delete lib/libesp32/berry_matter/src/solidify/Matter_Plugin_9_Virt_Sensor_Occupancy.h Remove undeeded file * Update solidified_Matter_Plugin_9_Virt_Sensor_Occupancy.h Fix case * Update solidified_Matter_UI.h Fix case * Update be_matter_module.c Update * Update Matter_UI.be remove v_onoff * Update solidified_Matter_UI.h update --------- Co-authored-by: s-hadinger <49731213+s-hadinger@users.noreply.github.com> --- .../berry_matter/src/be_matter_module.c | 2 ++ .../Matter_Plugin_9_Virt_Sensor_Occupancy.be | 34 +++++++++++++++++++ .../berry_matter/src/embedded/Matter_UI.be | 2 +- ...ed_Matter_Plugin_9_Virt_Sensor_Occupancy.h | 34 +++++++++++++++++++ .../src/solidify/solidified_Matter_UI.h | 2 +- 5 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 lib/libesp32/berry_matter/src/embedded/Matter_Plugin_9_Virt_Sensor_Occupancy.be create mode 100644 lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_9_Virt_Sensor_Occupancy.h diff --git a/lib/libesp32/berry_matter/src/be_matter_module.c b/lib/libesp32/berry_matter/src/be_matter_module.c index f5a97b7aebbb..96b64424ca21 100644 --- a/lib/libesp32/berry_matter/src/be_matter_module.c +++ b/lib/libesp32/berry_matter/src/be_matter_module.c @@ -237,6 +237,7 @@ extern const bclass be_class_Matter_TLV; // need to declare it upfront because #include "solidify/solidified_Matter_Plugin_3_Sensor_OnOff.h" #include "solidify/solidified_Matter_Plugin_3_Sensor_Contact.h" #include "solidify/solidified_Matter_Plugin_9_Virt_Sensor_Contact.h" +#include "solidify/solidified_Matter_Plugin_9_Virt_Sensor_Occupancy.h" #include "solidify/solidified_Matter_Plugin_2_Bridge_HTTP.h" #include "solidify/solidified_Matter_Plugin_4_Bridge_OnOff.h" #include "solidify/solidified_Matter_Plugin_3_Bridge_Light0.h" @@ -457,6 +458,7 @@ module matter (scope: global, strings: weak) { Plugin_Sensor_Occupancy, class(be_class_Matter_Plugin_Sensor_Occupancy) // Occupancy Sensor Plugin_Sensor_OnOff, class(be_class_Matter_Plugin_Sensor_OnOff) // Simple OnOff Sensor Plugin_Sensor_Contact, class(be_class_Matter_Plugin_Sensor_Contact) // Contact Sensor + Plugin_Virt_Sensor_Occupancy, class(be_class_Matter_Plugin_Virt_Sensor_Occupancy) // Virtual Occupancy Sensor Plugin_Virt_Sensor_Contact, class(be_class_Matter_Plugin_Virt_Sensor_Contact) // Virtual Contact Sensor Plugin_Bridge_HTTP, class(be_class_Matter_Plugin_Bridge_HTTP) // HTTP bridge superclass Plugin_Bridge_OnOff, class(be_class_Matter_Plugin_Bridge_OnOff) // HTTP Relay/Light behavior (OnOff) diff --git a/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_9_Virt_Sensor_Occupancy.be b/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_9_Virt_Sensor_Occupancy.be new file mode 100644 index 000000000000..9b4f8200499c --- /dev/null +++ b/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_9_Virt_Sensor_Occupancy.be @@ -0,0 +1,34 @@ +# +# Matter_Plugin_9_Virt_Sensor_Occupancy.be - implements the behavior for a Virtual Occupancy Sensor +# +# Copyright (C) 2023 Stephan Hadinger & Theo Arends +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import matter + +# Matter plug-in for core behavior + +#@ solidify:Matter_Plugin_Virt_Sensor_Occupancy,weak + +class Matter_Plugin_Virt_Sensor_Occupancy : Matter_Plugin_Sensor_Occupancy + static var TYPE = "v_occupancy" # name of the plug-in in json + static var DISPLAY_NAME = "v.Occupancy" # display name of the plug-in + static var ARG = "" # no arg for virtual device + static var ARG_HINT = "_Not used_" # Hint for entering the Argument (inside 'placeholder') + static var VIRTUAL = true # virtual device + +end +matter.Plugin_Virt_Sensor_Occupancy = Matter_Plugin_Virt_Sensor_Occupancy diff --git a/lib/libesp32/berry_matter/src/embedded/Matter_UI.be b/lib/libesp32/berry_matter/src/embedded/Matter_UI.be index 278d8c250f88..b600fd41f81a 100644 --- a/lib/libesp32/berry_matter/src/embedded/Matter_UI.be +++ b/lib/libesp32/berry_matter/src/embedded/Matter_UI.be @@ -35,7 +35,7 @@ class Matter_UI static var _CLASSES_TYPES = "|relay|light0|light1|light2|light3|shutter|shutter+tilt" "|temperature|pressure|illuminance|humidity|occupancy|onoff|contact" "|-virtual|v_relay|v_light0|v_light1|v_light2|v_light3" - "|v_temp|v_pressure|v_illuminance|v_humidity|v_contact" + "|v_temp|v_pressure|v_illuminance|v_humidity|v_occupancy|v_contact" # static var _CLASSES_HTTP = "-http" static var _CLASSES_TYPES2= "|http_relay|http_light0|http_light1|http_light2|http_light3" "|http_temperature|http_pressure|http_illuminance|http_humidity" diff --git a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_9_Virt_Sensor_Occupancy.h b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_9_Virt_Sensor_Occupancy.h new file mode 100644 index 000000000000..11e4261a4c79 --- /dev/null +++ b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_9_Virt_Sensor_Occupancy.h @@ -0,0 +1,34 @@ +/* Solidification of Matter_Plugin_9_Virt_Sensor_Occupancy.h */ +/********************************************************************\ +* Generated code, don't edit * +\********************************************************************/ +#include "be_constobj.h" + +extern const bclass be_class_Matter_Plugin_Virt_Sensor_Occupancy; + +/******************************************************************** +** Solidified class: Matter_Plugin_Virt_Sensor_Occupancy +********************************************************************/ +extern const bclass be_class_Matter_Plugin_Sensor_Occupancy; +be_local_class(Matter_Plugin_Virt_Sensor_Occupancy, + 0, + &be_class_Matter_Plugin_Sensor_Occupancy, + be_nested_map(5, + ( (struct bmapnode*) &(const bmapnode[]) { + { be_const_key_weak(VIRTUAL, 3), be_const_bool(1) }, + { be_const_key_weak(DISPLAY_NAME, -1), be_nested_str_weak(v_X2EOccupancy) }, + { be_const_key_weak(TYPE, -1), be_nested_str_weak(v_occupancy) }, + { be_const_key_weak(ARG_HINT, -1), be_nested_str_weak(_Not_X20used_) }, + { be_const_key_weak(ARG, 2), be_nested_str_weak() }, + })), + be_str_weak(Matter_Plugin_Virt_Sensor_Occupancy) +); +/*******************************************************************/ + +void be_load_Matter_Plugin_Virt_Sensor_Occupancy_class(bvm *vm) { + be_pushntvclass(vm, &be_class_Matter_Plugin_Virt_Sensor_Occupancy); + be_setglobal(vm, "Matter_Plugin_Virt_Sensor_Occupancy"); + be_pop(vm, 1); +} +/********************************************************************/ +/* End of solidification */ diff --git a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_UI.h b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_UI.h index ea7755189340..ab7c2e09ef8c 100644 --- a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_UI.h +++ b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_UI.h @@ -3372,7 +3372,7 @@ be_local_class(Matter_UI, { be_const_key_weak(show_commissioning_info, -1), be_const_closure(Matter_UI_show_commissioning_info_closure) }, { be_const_key_weak(page_part_ctl, 18), be_const_closure(Matter_UI_page_part_ctl_closure) }, { be_const_key_weak(show_fabric_info, -1), be_const_closure(Matter_UI_show_fabric_info_closure) }, - { be_const_key_weak(_CLASSES_TYPES, 4), be_nested_str_weak(_X7Crelay_X7Clight0_X7Clight1_X7Clight2_X7Clight3_X7Cshutter_X7Cshutter_X2Btilt_X7Ctemperature_X7Cpressure_X7Cilluminance_X7Chumidity_X7Coccupancy_X7Conoff_X7Ccontact_X7C_X2Dvirtual_X7Cv_relay_X7Cv_light0_X7Cv_light1_X7Cv_light2_X7Cv_light3_X7Cv_temp_X7Cv_pressure_X7Cv_illuminance_X7Cv_humidity_X7Cv_contact) }, + { be_const_key_weak(_CLASSES_TYPES, 4), be_nested_str_weak(_X7Crelay_X7Clight0_X7Clight1_X7Clight2_X7Clight3_X7Cshutter_X7Cshutter_X2Btilt_X7Ctemperature_X7Cpressure_X7Cilluminance_X7Chumidity_X7Coccupancy_X7Conoff_X7Ccontact_X7C_X2Dvirtual_X7Cv_relay_X7Cv_light0_X7Cv_light1_X7Cv_light2_X7Cv_light3_X7Cv_temp_X7Cv_pressure_X7Cv_illuminance_X7Cv_humidity_X7Cv_occupancy_X7Cv_contact) }, { be_const_key_weak(web_get_arg, -1), be_const_closure(Matter_UI_web_get_arg_closure) }, { be_const_key_weak(plugin_option, 5), be_const_closure(Matter_UI_plugin_option_closure) }, { be_const_key_weak(web_add_config_button, -1), be_const_closure(Matter_UI_web_add_config_button_closure) }, From 2cabbc68c39b7dccb15c337acff1fca6fffcde59 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 20 Oct 2023 11:51:44 +0200 Subject: [PATCH 009/186] Add bus2 info --- I2CDEVICES.md | 234 +++++++++++++++++++++++++------------------------- 1 file changed, 118 insertions(+), 116 deletions(-) diff --git a/I2CDEVICES.md b/I2CDEVICES.md index fcda3737752a..1002223f67e4 100644 --- a/I2CDEVICES.md +++ b/I2CDEVICES.md @@ -6,120 +6,122 @@ Using command ``I2cDriver`` individual drivers can be enabled or disabled at run ## Supported I2C devices The following table lists the supported I2C devices -Index | Define | Driver | Device | Address(es) | Description -------|---------------------|----------|----------|-------------|----------------------------------------------- - 1 | USE_PCA9685 | xdrv_15 | PCA9685 | 0x40 - 0x47 | 16-channel 12-bit pwm driver - 1 | USE_PCA9685_V2 | xdrv_15 | PCA9685 | 0x40 - 0x47 | 16-channel 12-bit pwm driver - 2 | USE_PCF8574 | xdrv_28 | PCF8574 | 0x20 - 0x26 | 8-bit I/O expander (address range overridable) - 2 | USE_PCF8574 | xdrv_28 | PCF8574A | 0x39 - 0x3F | 8-bit I/O expander (address range overridable) - 3 | USE_DISPLAY_LCD | xdsp_01 | | 0x27, 0x3F | LCD display - 4 | USE_DISPLAY_SSD1306 | xdsp_02 | SSD1306 | 0x3C - 0x3D | Oled display - 5 | USE_DISPLAY_MATRIX | xdsp_03 | HT16K33 | 0x70 - 0x77 | 8x8 led matrix - 6 | USE_DISPLAY_SH1106 | xdsp_07 | SH1106 | 0x3C - 0x3D | Oled display - 7 | USE_ADE7953 | xnrg_07 | ADE7953 | 0x38 | Energy monitor - 8 | USE_SHT | xsns_07 | SHT1X | Any | Temperature and Humidity sensor - 9 | USE_HTU | xsns_08 | HTU21 | 0x40 | Temperature and Humidity sensor - 9 | USE_HTU | xsns_08 | SI7013 | 0x40 | Temperature and Humidity sensor - 9 | USE_HTU | xsns_08 | SI7020 | 0x40 | Temperature and Humidity sensor - 9 | USE_HTU | xsns_08 | SI7021 | 0x40 | Temperature and Humidity sensor - 10 | USE_BMP | xsns_09 | BMP085 | 0x76 - 0x77 | Pressure and temperature sensor - 10 | USE_BMP | xsns_09 | BMP180 | 0x76 - 0x77 | Pressure and temperature sensor - 10 | USE_BMP | xsns_09 | BMP280 | 0x76 - 0x77 | Pressure and temperature sensor - 10 | USE_BMP | xsns_09 | BME280 | 0x76 - 0x77 | Pressure, temperature and humidity sensor - 10 | USE_BMP | xsns_09 | BME680 | 0x76 - 0x77 | Pressure, temperature, humidity and gas sensor - 11 | USE_BH1750 | xsns_10 | BH1750 | 0x23, 0x5C | Ambient light intensity sensor - 12 | USE_VEML6070 | xsns_11 | VEML6070 | 0x38 - 0x39 | Ultra violet light intensity sensor - 13 | USE_ADS1115 | xsns_12 | ADS1115 | 0x48 - 0x4B | 4-channel 16-bit A/D converter - 14 | USE_INA219 | xsns_13 | INA219 | 0x40 - 0x41, 0x44 - 0x45 | Low voltage current sensor - 15 | USE_SHT3X | xsns_14 | SHT3X | 0x44 - 0x45 | Temperature and Humidity sensor - 15 | USE_SHT3X | xsns_14 | SHT4X | 0x44 - 0x45 | Temperature and Humidity sensor - 15 | USE_SHT3X | xsns_14 | SHTCX | 0x70 | Temperature and Humidity sensor - 16 | USE_TSL2561 | xsns_16 | TSL2561 | 0x29, 0x39, 0x49 | Light intensity sensor - 17 | USE_MGS | xsns_19 | Grove | 0x04 | Multichannel gas sensor - 18 | USE_SGP30 | xsns_21 | SGP30 | 0x58 | Gas (TVOC) and air quality sensor - 19 | USE_SI1145 | xsns_24 | SI1145 | 0x60 | Ultra violet index and light sensor - 19 | USE_SI1145 | xsns_24 | SI1146 | 0x60 | Ultra violet index and light sensor - 19 | USE_SI1145 | xsns_24 | SI1147 | 0x60 | Ultra violet index and light sensor - 20 | USE_LM75AD | xsns_26 | LM75AD | 0x48 - 0x4F | Temperature sensor - 21 | USE_APDS9960 | xsns_27 | APDS9960 | 0x39 | Proximity ambient light RGB and gesture sensor - 22 | USE_MCP230xx | xsns_29 | MCP23008 | 0x20 - 0x26 | 8-bit I/O expander - 22 | USE_MCP230xx | xsns_29 | MCP23017 | 0x20 - 0x26 | 16-bit I/O expander - 23 | USE_MPR121 | xsns_30 | MPR121 | 0x5A - 0x5D | Proximity capacitive touch sensor - 24 | USE_CCS811 | xsns_31 | CCS811 | 0x5A | Gas (TVOC) and air quality sensor - 24' | USE_CCS811_V2 | xsns_31 | CCS811 | 0x5A - 0x5B | Gas (TVOC) and air quality sensor - 25 | USE_MPU6050 | xsns_32 | MPU6050 | 0x68 - 0x69 | 3-axis gyroscope and temperature sensor - 26 | USE_DS3231 | xsns_33 | DS3231 | 0x68 | Real time clock - 27 | USE_MGC3130 | xsns_36 | MGC3130 | 0x42 | Electric field sensor - 28 | USE_MAX44009 | xsns_41 | MAX44009 | 0x4A - 0x4B | Ambient light intensity sensor - 29 | USE_SCD30 | xsns_42 | SCD30 | 0x61 | CO2 sensor - 30 | USE_SPS30 | xsns_44 | SPS30 | 0x69 | Particle sensor - 31 | USE_VL53L0X | xsns_45 | VL53L0X | 0x29 | Time-of-flight (ToF) distance sensor - 32 | USE_MLX90614 | xsns_46 | MLX90614 | 0x5A | Infra red temperature sensor - 33 | USE_CHIRP | xsns_48 | CHIRP | 0x20 | Soil moisture sensor - 34 | USE_PAJ7620 | xsns_50 | PAJ7620 | 0x73 | Gesture sensor - 35 | USE_INA226 | xsns_54 | INA226 | 0x40 - 0x41, 0x44 - 0x45 | Low voltage current sensor - 36 | USE_HIH6 | xsns_55 | HIH6130 | 0x27 | Temperature and Humidity sensor - 37 | USE_24C256 | xdrv_10 | 24C256 | 0x50 | Scripter EEPROM storage - 38 | USE_DISPLAY_ILI9488 | xdsp_08 | FT6236 | 0x38 | Touch panel controller - 39 | USE_DISPLAY_RA8876 | xdsp_10 | FT5316 | 0x38 | Touch panel controller - 40 | USE_TSL2591 | xsns_57 | TSL2591 | 0x29 | Light intensity sensor - 41 | USE_DHT12 | xsns_58 | DHT12 | 0x5C | Temperature and humidity sensor - 42 | USE_DS1624 | xsns_59 | DS1621 | 0x48 - 0x4F | Temperature sensor - 42 | USE_DS1624 | xsns_59 | DS1624 | 0x48 - 0x4F | Temperature sensor - 43 | USE_AHT1x | xsns_63 | AHT10/15 | 0x38 - 0x39 | Temperature and humidity sensor - 43 | USE_AHT2x | xsns_63 | AHT20 | 0x38 | Temperature and humidity sensor - 43 | USE_AHT2x | xsns_63 | AM2301B | 0x38 | Temperature and humidity sensor - 44 | USE_WEMOS_MOTOR_V1 | xdrv_34 | | 0x2D - 0x30 | WEMOS motor shield v1.0.0 (6612FNG) - 45 | USE_HDC1080 | xsns_65 | HDC1080 | 0x40 | Temperature and Humidity sensor - 46 | USE_IAQ | xsns_66 | IAQ | 0x5a | Air quality sensor - 47 | USE_DISPLAY_SEVENSEG| xdsp_11 | HT16K33 | 0x70 - 0x77 | Seven segment LED - 48 | USE_AS3935 | xsns_67 | AS3935 | 0x03 | Franklin Lightning Sensor - 49 | USE_VEML6075 | xsns_70 | VEML6075 | 0x10 | UVA/UVB/UVINDEX Sensor - 50 | USE_VEML7700 | xsns_71 | VEML7700 | 0x10 | Ambient light intensity sensor - 51 | USE_MCP9808 | xsns_72 | MCP9808 | 0x18 - 0x1F | Temperature sensor - 52 | USE_HP303B | xsns_73 | HP303B | 0x76 - 0x77 | Pressure and temperature sensor - 53 | USE_MLX90640 | xdrv_43 | MLX90640 | 0x33 | IR array temperature sensor - 54 | USE_VL53L1X | xsns_77 | VL53L1X | 0x29 | Time-of-flight (ToF) distance sensor - 55 | USE_EZOPH | xsns_78 | EZOPH | 0x61 - 0x70 | pH sensor - 55 | USE_EZOORP | xsns_78 | EZOORP | 0x61 - 0x70 | ORP sensor - 55 | USE_EZORTD | xsns_78 | EZORTD | 0x61 - 0x70 | Temperature sensor - 55 | USE_EZOHUM | xsns_78 | EZOHUM | 0x61 - 0x70 | Humidity sensor - 55 | USE_EZOEC | xsns_78 | EZOEC | 0x61 - 0x70 | Electric conductivity sensor - 55 | USE_EZOCO2 | xsns_78 | EZOCO2 | 0x61 - 0x70 | CO2 sensor - 55 | USE_EZOO2 | xsns_78 | EZOO2 | 0x61 - 0x70 | O2 sensor - 55 | USE_EZOPRS | xsns_78 | EZOPRS | 0x61 - 0x70 | Pressure sensor - 55 | USE_EZOFLO | xsns_78 | EZOFLO | 0x61 - 0x70 | Flow meter sensor - 55 | USE_EZODO | xsns_78 | EZODO | 0x61 - 0x70 | Disolved Oxygen sensor - 55 | USE_EZORGB | xsns_78 | EZORGB | 0x61 - 0x70 | Color sensor - 55 | USE_EZOPMP | xsns_78 | EZOPMP | 0x61 - 0x70 | Peristaltic Pump - 56 | USE_SEESAW_SOIL | xsns_81 | SEESOIL | 0x36 - 0x39 | Adafruit seesaw soil moisture sensor - 57 | USE_TOF10120 | xsns_84 | TOF10120 | 0x52 | Time-of-flight (ToF) distance sensor - 58 | USE_MPU_ACCEL | xsns_85 | MPU_ACCEL| 0x68 | MPU6886/MPU9250 6-axis MotionTracking sensor from M5Stack - 59 | USE_BM8563 | xdrv_56 | BM8563 | 0x51 | BM8563 RTC from M5Stack - 60 | USE_AM2320 | xsns_88 | AM2320 | 0x5C | Temperature and Humidity sensor - 61 | USE_T67XX | xsns_89 | T67XX | 0x15 | CO2 sensor - 62 | USE_SCD40 | xsns_92 | SCD40 | 0x62 | CO2 sensor Sensirion SCD40/SCD41 - 63 | USE_HM330X | xsns_93 | HM330X | 0x40 | Particule sensor - 64 | USE_HDC2010 | xsns_94 | HDC2010 | 0x40 | Temperature and Humidity sensor - 65 | USE_ADE7880 | xnrg_23 | ADE7880 | 0x38 | Energy monitor - 66 | USE_PCF85363 | xsns_99 | PCF85363 | 0x51 | Real time clock - 67 | USE_DS3502 | xdrv_61 | DS3502 | 0x28 - 0x2B | Digital potentiometer - 68 | USE_HYT | xsns_97 | HYTxxx | 0x28 | Temperature and Humidity sensor - 69 | USE_SGP40 | xsns_98 | SGP40 | 0x59 | Gas (TVOC) and air quality - 70 | USE_LUXV30B | xsns_99 | LUXV30B | 0x4A | DFRobot SEN0390 V30B lux sensor - 71 | USE_QMC5883L | xsns_33 | QMC5883L | 0x0D | Magnetic Field Sensor - 72 | USE_INA3221 | xsns_100 | INA3221 | 0x40-0x43 | 3-channels Voltage and Current sensor - 73 | USE_HMC5883L | xsns_101 | HMC5883L | 0x1E | 3-channels Magnetic Field Sensor - 74 | USE_DISPLAY_TM1650 | xdsp_20 | TM1650 | 0x24 - 0x27, 0x34 - 0x37 | Four-digit seven-segment LED controller - 75 | USE_PCA9632 | xdrv_64 | PCA9632 | 0x60 | 4-channel 4-bit pwm driver - 76 | USE_SEN5X | xsns_103 | SEN5X | 0x69 | Gas (VOC/NOx index) and air quality (PPM <1,<2.5,<4,<10) - 77 | USE_MCP23XXX_DRV | xdrv_67 | MCP23x17 | 0x20 - 0x26 | 16-bit I/O expander as virtual button/switch/relay - 78 | USE_PMSA003I | xsns_104 | PMSA003I | 0x12 | PM2.5 Air Quality Sensor with I2C Interface - 79 | USE_GDK101 | xsns_106 | GDK101 | 0x18 - 0x1B | Gamma Radiation Sensor - 80 | USE_TC74 | xsns_108 | TC74 | 0x48 - 0x4F | Temperature sensor - 81 | USE_PCA9557 | xdrv_69 | PCA95xx | 0x18 - 0x1F | 8-bit I/O expander as virtual button/switch/relay - 82 | USE_SGP4X | xsns_109 | SGP4X | 0x59 | Gas (TVOC/NOx index) - 83 | USE_MAX17043 | xsns_110 | MAX17043 | 0x36 | Fuel-gauge for 3.7 Volt Lipo battery - 84 | USE_ENS16x | xsns_111 | ENS16x | 0x52 - 0x53 | Gas (TVOC, eCO2) and air quality sensor - 85 | USE_ENS210 | xsns_112 | ENS210 | 0x43 - 0x44 | Temperature and humidity sensor +Index | Define | Driver | Device | Address(es) | Bus2 | Description +------|---------------------|----------|----------|-------------|------|----------------------------------------------- + 1 | USE_PCA9685 | xdrv_15 | PCA9685 | 0x40 - 0x47 | | 16-channel 12-bit pwm driver + 1 | USE_PCA9685_V2 | xdrv_15 | PCA9685 | 0x40 - 0x47 | | 16-channel 12-bit pwm driver + 2 | USE_PCF8574 | xdrv_28 | PCF8574 | 0x20 - 0x26 | | 8-bit I/O expander (address range overridable) + 2 | USE_PCF8574 | xdrv_28 | PCF8574A | 0x39 - 0x3F | | 8-bit I/O expander (address range overridable) + 3 | USE_DISPLAY_LCD | xdsp_01 | | 0x27, 0x3F | | LCD display + 4 | USE_DISPLAY_SSD1306 | xdsp_02 | SSD1306 | 0x3C - 0x3D | | Oled display + 5 | USE_DISPLAY_MATRIX | xdsp_03 | HT16K33 | 0x70 - 0x77 | | 8x8 led matrix + 6 | USE_DISPLAY_SH1106 | xdsp_07 | SH1106 | 0x3C - 0x3D | | Oled display + 7 | USE_ADE7953 | xnrg_07 | ADE7953 | 0x38 | | Energy monitor + 8 | USE_SHT | xsns_07 | SHT1X | Any | | Temperature and Humidity sensor + 9 | USE_HTU | xsns_08 | HTU21 | 0x40 | Yes | Temperature and Humidity sensor + 9 | USE_HTU | xsns_08 | SI7013 | 0x40 | Yes | Temperature and Humidity sensor + 9 | USE_HTU | xsns_08 | SI7020 | 0x40 | Yes | Temperature and Humidity sensor + 9 | USE_HTU | xsns_08 | SI7021 | 0x40 | Yes | Temperature and Humidity sensor + 10 | USE_BMP | xsns_09 | BMP085 | 0x76 - 0x77 | Yes | Pressure and temperature sensor + 10 | USE_BMP | xsns_09 | BMP180 | 0x76 - 0x77 | Yes | Pressure and temperature sensor + 10 | USE_BMP | xsns_09 | BMP280 | 0x76 - 0x77 | Yes | Pressure and temperature sensor + 10 | USE_BMP | xsns_09 | BME280 | 0x76 - 0x77 | Yes | Pressure, temperature and humidity sensor + 10 | USE_BMP | xsns_09 | BME680 | 0x76 - 0x77 | Yes | Pressure, temperature, humidity and gas sensor + 11 | USE_BH1750 | xsns_10 | BH1750 | 0x23, 0x5C | Yes | Ambient light intensity sensor + 12 | USE_VEML6070 | xsns_11 | VEML6070 | 0x38 - 0x39 | | Ultra violet light intensity sensor + 13 | USE_ADS1115 | xsns_12 | ADS1115 | 0x48 - 0x4B | | 4-channel 16-bit A/D converter + 14 | USE_INA219 | xsns_13 | INA219 | 0x40 - 0x41, 0x44 - 0x45 | | Low voltage current sensor + 15 | USE_SHT3X | xsns_14 | SHT3X | 0x44 - 0x45 | | Temperature and Humidity sensor + 15 | USE_SHT3X | xsns_14 | SHT4X | 0x44 - 0x45 | | Temperature and Humidity sensor + 15 | USE_SHT3X | xsns_14 | SHTCX | 0x70 | | Temperature and Humidity sensor + 16 | USE_TSL2561 | xsns_16 | TSL2561 | 0x29, 0x39, 0x49 | | Light intensity sensor + 17 | USE_MGS | xsns_19 | Grove | 0x04 | | Multichannel gas sensor + 18 | USE_SGP30 | xsns_21 | SGP30 | 0x58 | | Gas (TVOC) and air quality sensor + 19 | USE_SI1145 | xsns_24 | SI1145 | 0x60 | | Ultra violet index and light sensor + 19 | USE_SI1145 | xsns_24 | SI1146 | 0x60 | | Ultra violet index and light sensor + 19 | USE_SI1145 | xsns_24 | SI1147 | 0x60 | | Ultra violet index and light sensor + 20 | USE_LM75AD | xsns_26 | LM75AD | 0x48 - 0x4F | | Temperature sensor + 21 | USE_APDS9960 | xsns_27 | APDS9960 | 0x39 | | Proximity ambient light RGB and gesture sensor + 22 | USE_MCP230xx | xsns_29 | MCP23008 | 0x20 - 0x26 | | 8-bit I/O expander + 22 | USE_MCP230xx | xsns_29 | MCP23017 | 0x20 - 0x26 | | 16-bit I/O expander + 23 | USE_MPR121 | xsns_30 | MPR121 | 0x5A - 0x5D | | Proximity capacitive touch sensor + 24 | USE_CCS811 | xsns_31 | CCS811 | 0x5A | | Gas (TVOC) and air quality sensor + 24' | USE_CCS811_V2 | xsns_31 | CCS811 | 0x5A - 0x5B | | Gas (TVOC) and air quality sensor + 25 | USE_MPU6050 | xsns_32 | MPU6050 | 0x68 - 0x69 | | 3-axis gyroscope and temperature sensor + 26 | USE_DS3231 | xsns_33 | DS1307 | 0x68 | | Real time clock + 26 | USE_DS3231 | xsns_33 | DS3231 | 0x68 | | Real time clock + 27 | USE_MGC3130 | xsns_36 | MGC3130 | 0x42 | | Electric field sensor + 28 | USE_MAX44009 | xsns_41 | MAX44009 | 0x4A - 0x4B | | Ambient light intensity sensor + 29 | USE_SCD30 | xsns_42 | SCD30 | 0x61 | | CO2 sensor + 30 | USE_SPS30 | xsns_44 | SPS30 | 0x69 | | Particle sensor + 31 | USE_VL53L0X | xsns_45 | VL53L0X | 0x29 | | Time-of-flight (ToF) distance sensor + 32 | USE_MLX90614 | xsns_46 | MLX90614 | 0x5A | | Infra red temperature sensor + 33 | USE_CHIRP | xsns_48 | CHIRP | 0x20 | | Soil moisture sensor + 34 | USE_PAJ7620 | xsns_50 | PAJ7620 | 0x73 | | Gesture sensor + 35 | USE_INA226 | xsns_54 | INA226 | 0x40 - 0x41, 0x44 - 0x45 | | Low voltage current sensor + 36 | USE_HIH6 | xsns_55 | HIH6130 | 0x27 | | Temperature and Humidity sensor + 37 | USE_24C256 | xdrv_10 | 24C256 | 0x50 | | Scripter EEPROM storage + 38 | USE_DISPLAY_ILI9488 | xdsp_08 | FT6236 | 0x38 | | Touch panel controller + 39 | USE_DISPLAY_RA8876 | xdsp_10 | FT5316 | 0x38 | | Touch panel controller + 40 | USE_TSL2591 | xsns_57 | TSL2591 | 0x29 | | Light intensity sensor + 41 | USE_DHT12 | xsns_58 | DHT12 | 0x5C | | Temperature and humidity sensor + 42 | USE_DS1624 | xsns_59 | DS1621 | 0x48 - 0x4F | | Temperature sensor + 42 | USE_DS1624 | xsns_59 | DS1624 | 0x48 - 0x4F | | Temperature sensor + 43 | USE_AHT1x | xsns_63 | AHT10/15 | 0x38 - 0x39 | | Temperature and humidity sensor + 43 | USE_AHT2x | xsns_63 | AHT20 | 0x38 | | Temperature and humidity sensor + 43 | USE_AHT2x | xsns_63 | AM2301B | 0x38 | | Temperature and humidity sensor + 44 | USE_WEMOS_MOTOR_V1 | xdrv_34 | | 0x2D - 0x30 | | WEMOS motor shield v1.0.0 (6612FNG) + 45 | USE_HDC1080 | xsns_65 | HDC1080 | 0x40 | | Temperature and Humidity sensor + 46 | USE_IAQ | xsns_66 | IAQ | 0x5a | Yes | Air quality sensor + 47 | USE_DISPLAY_SEVENSEG| xdsp_11 | HT16K33 | 0x70 - 0x77 | | Seven segment LED + 48 | USE_AS3935 | xsns_67 | AS3935 | 0x03 | | Franklin Lightning Sensor + 49 | USE_VEML6075 | xsns_70 | VEML6075 | 0x10 | | UVA/UVB/UVINDEX Sensor + 50 | USE_VEML7700 | xsns_71 | VEML7700 | 0x10 | | Ambient light intensity sensor + 51 | USE_MCP9808 | xsns_72 | MCP9808 | 0x18 - 0x1F | | Temperature sensor + 52 | USE_HP303B | xsns_73 | HP303B | 0x76 - 0x77 | | Pressure and temperature sensor + 53 | USE_MLX90640 | xdrv_43 | MLX90640 | 0x33 | | IR array temperature sensor + 54 | USE_VL53L1X | xsns_77 | VL53L1X | 0x29 | | Time-of-flight (ToF) distance sensor + 55 | USE_EZOPH | xsns_78 | EZOPH | 0x61 - 0x70 | | pH sensor + 55 | USE_EZOORP | xsns_78 | EZOORP | 0x61 - 0x70 | | ORP sensor + 55 | USE_EZORTD | xsns_78 | EZORTD | 0x61 - 0x70 | | Temperature sensor + 55 | USE_EZOHUM | xsns_78 | EZOHUM | 0x61 - 0x70 | | Humidity sensor + 55 | USE_EZOEC | xsns_78 | EZOEC | 0x61 - 0x70 | | Electric conductivity sensor + 55 | USE_EZOCO2 | xsns_78 | EZOCO2 | 0x61 - 0x70 | | CO2 sensor + 55 | USE_EZOO2 | xsns_78 | EZOO2 | 0x61 - 0x70 | | O2 sensor + 55 | USE_EZOPRS | xsns_78 | EZOPRS | 0x61 - 0x70 | | Pressure sensor + 55 | USE_EZOFLO | xsns_78 | EZOFLO | 0x61 - 0x70 | | Flow meter sensor + 55 | USE_EZODO | xsns_78 | EZODO | 0x61 - 0x70 | | Disolved Oxygen sensor + 55 | USE_EZORGB | xsns_78 | EZORGB | 0x61 - 0x70 | | Color sensor + 55 | USE_EZOPMP | xsns_78 | EZOPMP | 0x61 - 0x70 | | Peristaltic Pump + 56 | USE_SEESAW_SOIL | xsns_81 | SEESOIL | 0x36 - 0x39 | | Adafruit seesaw soil moisture sensor + 57 | USE_TOF10120 | xsns_84 | TOF10120 | 0x52 | | Time-of-flight (ToF) distance sensor + 58 | USE_MPU_ACCEL | xsns_85 | MPU_ACCEL| 0x68 | Yes | MPU6886/MPU9250 6-axis MotionTracking sensor from M5Stack + 59 | USE_BM8563 | xdrv_56 | BM8563 | 0x51 | Yes | BM8563 RTC from M5Stack + 60 | USE_AM2320 | xsns_88 | AM2320 | 0x5C | | Temperature and Humidity sensor + 61 | USE_T67XX | xsns_89 | T67XX | 0x15 | | CO2 sensor + 62 | USE_SCD40 | xsns_92 | SCD40 | 0x62 | | CO2 sensor Sensirion SCD40/SCD41 + 63 | USE_HM330X | xsns_93 | HM330X | 0x40 | | Particule sensor + 64 | USE_HDC2010 | xsns_94 | HDC2010 | 0x40 | | Temperature and Humidity sensor + 65 | USE_ADE7880 | xnrg_23 | ADE7880 | 0x38 | | Energy monitor + 66 | USE_PCF85363 | xsns_99 | PCF85363 | 0x51 | | Real time clock + 67 | USE_DS3502 | xdrv_61 | DS3502 | 0x28 - 0x2B | | Digital potentiometer + 68 | USE_HYT | xsns_97 | HYTxxx | 0x28 | | Temperature and Humidity sensor + 69 | USE_SGP40 | xsns_98 | SGP40 | 0x59 | | Gas (TVOC) and air quality + 70 | USE_LUXV30B | xsns_99 | LUXV30B | 0x4A | | DFRobot SEN0390 V30B lux sensor + 71 | USE_QMC5883L | xsns_33 | QMC5883L | 0x0D | | Magnetic Field Sensor + 72 | USE_INA3221 | xsns_100 | INA3221 | 0x40-0x43 | | 3-channels Voltage and Current sensor + 73 | USE_HMC5883L | xsns_101 | HMC5883L | 0x1E | | 3-channels Magnetic Field Sensor + 74 | USE_DISPLAY_TM1650 | xdsp_20 | TM1650 | 0x24 - 0x27, 0x34 - 0x37 | | Four-digit seven-segment LED controller + 75 | USE_PCA9632 | xdrv_64 | PCA9632 | 0x60 | | 4-channel 4-bit pwm driver + 76 | USE_SEN5X | xsns_103 | SEN5X | 0x69 | Yes | Gas (VOC/NOx index) and air quality (PPM <1,<2.5,<4,<10) + 77 | USE_MCP23XXX_DRV | xdrv_67 | MCP23x17 | 0x20 - 0x26 | | 16-bit I/O expander as virtual button/switch/relay + 78 | USE_PMSA003I | xsns_104 | PMSA003I | 0x12 | | PM2.5 Air Quality Sensor with I2C Interface + 79 | USE_GDK101 | xsns_106 | GDK101 | 0x18 - 0x1B | | Gamma Radiation Sensor + 80 | USE_TC74 | xsns_108 | TC74 | 0x48 - 0x4F | | Temperature sensor + 81 | USE_PCA9557 | xdrv_69 | PCA95xx | 0x18 - 0x1F | | 8-bit I/O expander as virtual button/switch/relay + 82 | USE_SGP4X | xsns_109 | SGP4X | 0x59 | | Gas (TVOC/NOx index) + 83 | USE_MAX17043 | xsns_110 | MAX17043 | 0x36 | | Fuel-gauge for 3.7 Volt Lipo battery + 84 | USE_ENS16x | xsns_111 | ENS16x | 0x52 - 0x53 | | Gas (TVOC, eCO2) and air quality sensor + 85 | USE_ENS210 | xsns_112 | ENS210 | 0x43 - 0x44 | | Temperature and humidity sensor + NOTE: Bus2 supported on ESP32 only. From f05470bf81dcb67a4b7cf33f322c2813ba40a922 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 20 Oct 2023 13:35:24 +0200 Subject: [PATCH 010/186] Add HYT I2c bus2 support --- I2CDEVICES.md | 2 +- tasmota/tasmota_xsns_sensor/xsns_97_hyt.ino | 29 +++++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/I2CDEVICES.md b/I2CDEVICES.md index 1002223f67e4..e63af6091242 100644 --- a/I2CDEVICES.md +++ b/I2CDEVICES.md @@ -105,7 +105,7 @@ Index | Define | Driver | Device | Address(es) | Bus2 | Descrip 65 | USE_ADE7880 | xnrg_23 | ADE7880 | 0x38 | | Energy monitor 66 | USE_PCF85363 | xsns_99 | PCF85363 | 0x51 | | Real time clock 67 | USE_DS3502 | xdrv_61 | DS3502 | 0x28 - 0x2B | | Digital potentiometer - 68 | USE_HYT | xsns_97 | HYTxxx | 0x28 | | Temperature and Humidity sensor + 68 | USE_HYT | xsns_97 | HYTxxx | 0x28 | Yes | Temperature and Humidity sensor 69 | USE_SGP40 | xsns_98 | SGP40 | 0x59 | | Gas (TVOC) and air quality 70 | USE_LUXV30B | xsns_99 | LUXV30B | 0x4A | | DFRobot SEN0390 V30B lux sensor 71 | USE_QMC5883L | xsns_33 | QMC5883L | 0x0D | | Magnetic Field Sensor diff --git a/tasmota/tasmota_xsns_sensor/xsns_97_hyt.ino b/tasmota/tasmota_xsns_sensor/xsns_97_hyt.ino index 8bdcbe782a68..2064d21a77f3 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_97_hyt.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_97_hyt.ino @@ -36,6 +36,7 @@ struct HYT { float humidity = NAN; float temperature = NAN; + uint8_t bus; uint8_t valid = 0; uint8_t count = 0; char name[6] = "HYT"; @@ -44,14 +45,16 @@ struct HYT { bool HYT_Read(void) { if (HYT.valid) { HYT.valid--; } - Wire.beginTransmission(HYT_ADDR); - Wire.requestFrom(HYT_ADDR, 4); - if (Wire.available() == 4) { - uint8_t data1 = Wire.read(); - uint8_t data2 = Wire.read(); - uint8_t data3 = Wire.read(); - uint8_t data4 = Wire.read(); - Wire.endTransmission(); + TwoWire& myWire = I2cGetWire(HYT.bus); + if (&myWire == nullptr) { return false; } // No valid I2c bus + myWire.beginTransmission(HYT_ADDR); + myWire.requestFrom(HYT_ADDR, 4); + if (myWire.available() == 4) { + uint8_t data1 = myWire.read(); + uint8_t data2 = myWire.read(); + uint8_t data3 = myWire.read(); + uint8_t data4 = myWire.read(); + myWire.endTransmission(); // Convert the data to 14-bits float humidity = ((((data1 & 0x3F) * 256) + data2) * 100.0) / 16383.0; @@ -72,9 +75,13 @@ bool HYT_Read(void) { /********************************************************************************************/ void HYT_Detect(void) { - if (I2cSetDevice(HYT_ADDR)) { - I2cSetActiveFound(HYT_ADDR, "HYT"); - HYT.count = 1; + for (HYT.bus = 0; HYT.bus < 2; HYT.bus++) { + if (!I2cSetDevice(HYT_ADDR, HYT.bus)) { continue; } + if (HYT_Read()) { + I2cSetActiveFound(HYT_ADDR, "HYT", HYT.bus); + HYT.count = 1; + break; + } } } From 7238d857e9fc4fe646e4554443a53081df2ff18e Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 20 Oct 2023 14:52:21 +0200 Subject: [PATCH 011/186] Add SHT3x I2C bus2 support --- I2CDEVICES.md | 6 +- tasmota/tasmota_xsns_sensor/xsns_14_sht3x.ino | 70 ++++++++++--------- 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/I2CDEVICES.md b/I2CDEVICES.md index e63af6091242..9a0baece2cda 100644 --- a/I2CDEVICES.md +++ b/I2CDEVICES.md @@ -31,9 +31,9 @@ Index | Define | Driver | Device | Address(es) | Bus2 | Descrip 12 | USE_VEML6070 | xsns_11 | VEML6070 | 0x38 - 0x39 | | Ultra violet light intensity sensor 13 | USE_ADS1115 | xsns_12 | ADS1115 | 0x48 - 0x4B | | 4-channel 16-bit A/D converter 14 | USE_INA219 | xsns_13 | INA219 | 0x40 - 0x41, 0x44 - 0x45 | | Low voltage current sensor - 15 | USE_SHT3X | xsns_14 | SHT3X | 0x44 - 0x45 | | Temperature and Humidity sensor - 15 | USE_SHT3X | xsns_14 | SHT4X | 0x44 - 0x45 | | Temperature and Humidity sensor - 15 | USE_SHT3X | xsns_14 | SHTCX | 0x70 | | Temperature and Humidity sensor + 15 | USE_SHT3X | xsns_14 | SHT3X | 0x44 - 0x45 | Yes | Temperature and Humidity sensor + 15 | USE_SHT3X | xsns_14 | SHT4X | 0x44 - 0x45 | Yes | Temperature and Humidity sensor + 15 | USE_SHT3X | xsns_14 | SHTCX | 0x70 | Yes | Temperature and Humidity sensor 16 | USE_TSL2561 | xsns_16 | TSL2561 | 0x29, 0x39, 0x49 | | Light intensity sensor 17 | USE_MGS | xsns_19 | Grove | 0x04 | | Multichannel gas sensor 18 | USE_SGP30 | xsns_21 | SGP30 | 0x58 | | Gas (TVOC) and air quality sensor diff --git a/tasmota/tasmota_xsns_sensor/xsns_14_sht3x.ino b/tasmota/tasmota_xsns_sensor/xsns_14_sht3x.ino index 24dd17394a4e..daf1b5a1fd5e 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_14_sht3x.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_14_sht3x.ino @@ -34,11 +34,7 @@ #define SHT3X_TYPES 3 // SHT3X, SHTCX and SHT4X #define SHT3X_ADDRESSES 3 // 0x44, 0x45 and 0x70 -enum SHT3X_Types { - SHT3X_TYPE_SHT3X, - SHT3X_TYPE_SHTCX, - SHT3X_TYPE_SHT4X -}; +enum SHT3X_Types { SHT3X_TYPE_SHT3X, SHT3X_TYPE_SHTCX, SHT3X_TYPE_SHT4X }; const char kSht3xTypes[] PROGMEM = "SHT3X|SHTC3|SHT4X"; uint8_t sht3x_addresses[] = { 0x44, 0x45, 0x70 }; @@ -47,6 +43,7 @@ uint8_t sht3x_count = 0; struct SHT3XSTRUCT { uint8_t type; // Sensor type uint8_t address; // I2C bus address + uint8_t bus; char types[6]; // Sensor type name and address, e.g. "SHT3X" } sht3x_sensors[SHT3X_ADDRESSES]; @@ -67,39 +64,42 @@ uint8_t Sht3xComputeCrc(uint8_t data[], uint8_t len) { return crc; } -bool Sht3xRead(uint32_t type, float &t, float &h, uint8_t i2c_address) { - uint8_t data[6]; - +bool Sht3xRead(uint32_t sensor, float &t, float &h) { t = NAN; h = NAN; - Wire.beginTransmission(i2c_address); + TwoWire& myWire = I2cGetWire(sht3x_sensors[sensor].bus); + if (&myWire == nullptr) { return false; } // No valid I2c bus + uint32_t type = sht3x_sensors[sensor].type; + uint8_t i2c_address = sht3x_sensors[sensor].address; + myWire.beginTransmission(i2c_address); switch (type) { case SHT3X_TYPE_SHT3X: // TODO: Clock stretching is used for SHT3x but not for SHTC3. Why? - Wire.write(0x2C); // Enable clock stretching - Wire.write(0x06); // High repeatability measurement + myWire.write(0x2C); // Enable clock stretching + myWire.write(0x06); // High repeatability measurement break; case SHT3X_TYPE_SHTCX: - Wire.write(0x35); // Wake from - Wire.write(0x17); // sleep - Wire.endTransmission(); - Wire.beginTransmission(i2c_address); + myWire.write(0x35); // Wake from + myWire.write(0x17); // sleep + myWire.endTransmission(); + myWire.beginTransmission(i2c_address); // TODO: Clock stretching is used for SHT3x but not for SHTC3. Why? - Wire.write(0x78); // Disable clock stretching - Wire.write(0x66); // Normal mode measurement + myWire.write(0x78); // Disable clock stretching + myWire.write(0x66); // Normal mode measurement break; case SHT3X_TYPE_SHT4X: - Wire.write(0xFD); // High repeatability measurement + myWire.write(0xFD); // High repeatability measurement break; } - if (Wire.endTransmission() != 0) { // Stop I2C transmission + if (myWire.endTransmission() != 0) { // Stop I2C transmission return false; } - delay(30); // Timing verified with logic analyzer (10 is to short) - Wire.requestFrom(i2c_address, (uint8_t)6); // Request 6 bytes of data + delay(30); // Timing verified with logic analyzer (10 is to short) + uint8_t data[6]; + myWire.requestFrom(i2c_address, (uint8_t)6); // Request 6 bytes of data for (uint32_t i = 0; i < 6; i++) { - data[i] = Wire.read(); // temperature (MSB, LSB, CRC), humidity (MSB, LSB, CRC) + data[i] = myWire.read(); // temperature (MSB, LSB, CRC), humidity (MSB, LSB, CRC) }; if ((Sht3xComputeCrc(&data[0], 2) != data[2]) || (Sht3xComputeCrc(&data[3], 2) != data[5])) { return false; @@ -119,15 +119,21 @@ void Sht3xDetect(void) { float t; float h; - for (uint32_t k = 0; k < SHT3X_TYPES; k++) { - sht3x_sensors[sht3x_count].type = k; - for (uint32_t i = 0; i < SHT3X_ADDRESSES; i++) { - if (!I2cSetDevice(sht3x_addresses[i])) { continue; } - sht3x_sensors[sht3x_count].address = sht3x_addresses[i]; - if (Sht3xRead(sht3x_sensors[sht3x_count].type, t, h, sht3x_sensors[sht3x_count].address)) { - GetTextIndexed(sht3x_sensors[sht3x_count].types, sizeof(sht3x_sensors[sht3x_count].types), sht3x_sensors[sht3x_count].type, kSht3xTypes); - I2cSetActiveFound(sht3x_sensors[sht3x_count].address, sht3x_sensors[sht3x_count].types); - sht3x_count++; + for (uint32_t bus = 0; bus < 2; bus++) { + for (uint32_t k = 0; k < SHT3X_TYPES; k++) { + sht3x_sensors[sht3x_count].type = k; + for (uint32_t i = 0; i < SHT3X_ADDRESSES; i++) { + if (!I2cSetDevice(sht3x_addresses[i], bus)) { continue; } + sht3x_sensors[sht3x_count].address = sht3x_addresses[i]; + sht3x_sensors[sht3x_count].bus = bus; + if (Sht3xRead(sht3x_count, t, h)) { + GetTextIndexed(sht3x_sensors[sht3x_count].types, sizeof(sht3x_sensors[sht3x_count].types), sht3x_sensors[sht3x_count].type, kSht3xTypes); + I2cSetActiveFound(sht3x_sensors[sht3x_count].address, sht3x_sensors[sht3x_count].types, sht3x_sensors[sht3x_count].bus); + sht3x_count++; + if (SHT3X_ADDRESSES == sht3x_count) { + return; + } + } } } } @@ -139,7 +145,7 @@ void Sht3xShow(bool json) { char types[11]; for (uint32_t i = 0; i < sht3x_count; i++) { - if (Sht3xRead(sht3x_sensors[i].type, t, h, sht3x_sensors[i].address)) { + if (Sht3xRead(i, t, h)) { t = ConvertTemp(t); h = ConvertHumidity(h); strlcpy(types, sht3x_sensors[i].types, sizeof(types)); From c91882daeb216e2b699ce4b35f26dd7f72374f48 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 20 Oct 2023 17:39:00 +0200 Subject: [PATCH 012/186] Add ADS1115 I2C bus2 support --- CHANGELOG.md | 3 + I2CDEVICES.md | 2 +- RELEASENOTES.md | 3 + .../tasmota_xsns_sensor/xsns_12_ads1115.ino | 240 ++++++++---------- 4 files changed, 117 insertions(+), 131 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74b691ab8e35..eab373678faa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file. - I2C bus2 support to iAQ core sensor (#19799) - I2C bus2 support to HTU temperature and humidity sensor - I2C bus2 support to BH1750 ambient light sensor +- I2C bus2 support to ADS1115 A/D Converter +- I2C bus2 support to SHTxX temperature and humidity sensor +- I2C bus2 support to HYTxxx temperature and humidity sensor ### Breaking Changed diff --git a/I2CDEVICES.md b/I2CDEVICES.md index 9a0baece2cda..a8ced405701e 100644 --- a/I2CDEVICES.md +++ b/I2CDEVICES.md @@ -29,7 +29,7 @@ Index | Define | Driver | Device | Address(es) | Bus2 | Descrip 10 | USE_BMP | xsns_09 | BME680 | 0x76 - 0x77 | Yes | Pressure, temperature, humidity and gas sensor 11 | USE_BH1750 | xsns_10 | BH1750 | 0x23, 0x5C | Yes | Ambient light intensity sensor 12 | USE_VEML6070 | xsns_11 | VEML6070 | 0x38 - 0x39 | | Ultra violet light intensity sensor - 13 | USE_ADS1115 | xsns_12 | ADS1115 | 0x48 - 0x4B | | 4-channel 16-bit A/D converter + 13 | USE_ADS1115 | xsns_12 | ADS1115 | 0x48 - 0x4B | Yes | 4-channel 16-bit A/D converter 14 | USE_INA219 | xsns_13 | INA219 | 0x40 - 0x41, 0x44 - 0x45 | | Low voltage current sensor 15 | USE_SHT3X | xsns_14 | SHT3X | 0x44 - 0x45 | Yes | Temperature and Humidity sensor 15 | USE_SHT3X | xsns_14 | SHT4X | 0x44 - 0x45 | Yes | Temperature and Humidity sensor diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 28b33560d56f..b0b1fe8b003b 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -116,6 +116,9 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - I2C bus2 support to iAQ core sensor [#19799](https://github.com/arendst/Tasmota/issues/19799) - I2C bus2 support to HTU temperature and humidity sensor - I2C bus2 support to BH1750 ambient light sensor +- I2C bus2 support to ADS1115 A/D Converter +- I2C bus2 support to SHTxX temperature and humidity sensor +- I2C bus2 support to HYTxxx temperature and humidity sensor ### Breaking Changed diff --git a/tasmota/tasmota_xsns_sensor/xsns_12_ads1115.ino b/tasmota/tasmota_xsns_sensor/xsns_12_ads1115.ino index 0610ca9d0f0a..a4a892ae5f6b 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_12_ads1115.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_12_ads1115.ino @@ -120,210 +120,190 @@ CONFIG REGISTER #define ADS1115_REG_CONFIG_CQUE_4CONV (0x0002) // Assert ALERT/RDY after four conversions #define ADS1115_REG_CONFIG_CQUE_NONE (0x0003) // Disable the comparator and put ALERT/RDY in high state (default) +uint16_t ads1115_ranges[] = { ADS1115_REG_CONFIG_PGA_6_144V, ADS1115_REG_CONFIG_PGA_4_096V, ADS1115_REG_CONFIG_PGA_2_048V, ADS1115_REG_CONFIG_PGA_1_024V, ADS1115_REG_CONFIG_PGA_0_512V, ADS1115_REG_CONFIG_PGA_0_256V }; +uint8_t ads1115_addresses[] = { ADS1115_ADDRESS_ADDR_GND, ADS1115_ADDRESS_ADDR_VDD, ADS1115_ADDRESS_ADDR_SDA, ADS1115_ADDRESS_ADDR_SCL }; +uint8_t ads1115_count = 0; +uint16_t ads1115_range; +uint8_t ads1115_channels; + struct ADS1115 { - uint8_t count = 0; - uint8_t address; - uint8_t addresses[4] = { ADS1115_ADDRESS_ADDR_GND, ADS1115_ADDRESS_ADDR_VDD, ADS1115_ADDRESS_ADDR_SDA, ADS1115_ADDRESS_ADDR_SCL }; - uint8_t channels; - uint16_t range; - uint8_t found[4] = {false,false,false,false}; - int16_t last_values[4][4] = {{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}; -} Ads1115; + int16_t last_values[4] = { 0,0,0,0 }; + uint8_t address; + uint8_t bus; +} Ads1115[4]; //Ads1115StartComparator(channel, ADS1115_REG_CONFIG_MODE_SINGLE); //Ads1115StartComparator(channel, ADS1115_REG_CONFIG_MODE_CONTIN); -void Ads1115StartComparator(uint8_t channel, uint16_t mode) -{ +void Ads1115StartComparator(uint32_t device, uint8_t channel, uint16_t mode) { // Start with default values uint16_t config = mode | ADS1115_REG_CONFIG_CQUE_NONE | // Comparator enabled and asserts on 1 match ADS1115_REG_CONFIG_CLAT_NONLAT | // Non Latching mode - Ads1115.range | // ADC Input voltage range (Gain) + ads1115_range | // ADC Input voltage range (Gain) ADS1115_REG_CONFIG_CPOL_ACTVLOW | // Alert/Rdy active low (default val) ADS1115_REG_CONFIG_CMODE_TRAD | // Traditional comparator (default val) ADS1115_REG_CONFIG_DR_6000SPS; // 6000 samples per second // Set single-ended or differential input channel - if (Ads1115.channels == ADS1115_SINGLE_CHANNELS) { + if (ads1115_channels == ADS1115_SINGLE_CHANNELS) { config |= (ADS1115_REG_CONFIG_MUX_SINGLE_0 + (0x1000 * channel)); } else { config |= (ADS1115_REG_CONFIG_MUX_DIFF_0_1 + (0x3000 * channel)); } // Write config register to the ADC - I2cWrite16(Ads1115.address, ADS1115_REG_POINTER_CONFIG, config); + I2cWrite16(Ads1115[device].address, ADS1115_REG_POINTER_CONFIG, config, Ads1115[device].bus); } -int16_t Ads1115GetConversion(uint8_t channel) -{ - Ads1115StartComparator(channel, ADS1115_REG_CONFIG_MODE_SINGLE); +int16_t Ads1115GetConversion(uint32_t device, uint8_t channel) { + Ads1115StartComparator(device, channel, ADS1115_REG_CONFIG_MODE_SINGLE); // Wait for the conversion to complete delay(ADS1115_CONVERSIONDELAY); // Read the conversion results - I2cRead16(Ads1115.address, ADS1115_REG_POINTER_CONVERT); + I2cRead16(Ads1115[device].address, ADS1115_REG_POINTER_CONVERT, Ads1115[device].bus); - Ads1115StartComparator(channel, ADS1115_REG_CONFIG_MODE_CONTIN); + Ads1115StartComparator(device, channel, ADS1115_REG_CONFIG_MODE_CONTIN); delay(ADS1115_CONVERSIONDELAY); // Read the conversion results - uint16_t res = I2cRead16(Ads1115.address, ADS1115_REG_POINTER_CONVERT); + uint16_t res = I2cRead16(Ads1115[device].address, ADS1115_REG_POINTER_CONVERT, Ads1115[device].bus); return (int16_t)res; } /********************************************************************************************/ -void Ads1115Detect(void) -{ +void Ads1115Detect(void) { // Set default mode and range - Ads1115.channels = ADS1115_SINGLE_CHANNELS; - Ads1115.range = ADS1115_REG_CONFIG_PGA_6_144V; - - for (uint32_t i = 0; i < sizeof(Ads1115.addresses); i++) { - if (!Ads1115.found[i]) { - Ads1115.address = Ads1115.addresses[i]; - if (!I2cSetDevice(Ads1115.address)) { continue; } + ads1115_channels = ADS1115_SINGLE_CHANNELS; + ads1115_range = ADS1115_REG_CONFIG_PGA_6_144V; + for (uint32_t bus = 0; bus < 2; bus++) { + for (uint32_t i = 0; i < sizeof(ads1115_addresses); i++) { + if (!I2cSetDevice(ads1115_addresses[i], bus)) { continue; } uint16_t buffer; - if (I2cValidRead16(&buffer, Ads1115.address, ADS1115_REG_POINTER_CONVERT) && - I2cValidRead16(&buffer, Ads1115.address, ADS1115_REG_POINTER_CONFIG)) { - Ads1115StartComparator(i, ADS1115_REG_CONFIG_MODE_CONTIN); - I2cSetActiveFound(Ads1115.address, "ADS1115"); - Ads1115.found[i] = 1; - Ads1115.count++; + if (I2cValidRead16(&buffer, ads1115_addresses[i], ADS1115_REG_POINTER_CONVERT, bus) && + I2cValidRead16(&buffer, ads1115_addresses[i], ADS1115_REG_POINTER_CONFIG, bus)) { + Ads1115[ads1115_count].address = ads1115_addresses[i]; + Ads1115[ads1115_count].bus = bus; + Ads1115StartComparator(ads1115_count, i, ADS1115_REG_CONFIG_MODE_CONTIN); + I2cSetActiveFound(Ads1115[ads1115_count].address, "ADS1115", Ads1115[ads1115_count].bus); + ads1115_count++; + if (4 == ads1115_count) { return; } } } } } -// Create the identifier of the the selected sensor -void Ads1115Label(char* label, uint32_t maxsize, uint8_t address) { - if (1 == Ads1115.count) { - // "ADS1115":{"A0":3240,"A1":3235,"A2":3269,"A3":3269} - snprintf_P(label, maxsize, PSTR("ADS1115")); - } else { +void Ads1115Label(char* label, uint32_t maxsize, uint32_t device) { + // Create the identifier of the the selected sensor + // "ADS1115":{"A0":3240,"A1":3235,"A2":3269,"A3":3269} + snprintf_P(label, maxsize, PSTR("ADS1115")); + if (ads1115_count > 1) { // "ADS1115-48":{"A0":3240,"A1":3235,"A2":3269,"A3":3269},"ADS1115-49":{"A0":3240,"A1":3235,"A2":3269,"A3":3269} - snprintf_P(label, maxsize, PSTR("ADS1115%c%02x"), IndexSeparator(), address); + snprintf_P(label, maxsize, PSTR("%s%c%02X"), label, IndexSeparator(), Ads1115[device].address); +#ifdef ESP32 + if (TasmotaGlobal.i2c_enabled_2) { // Second bus enabled + uint8_t bus = Ads1115[0].bus; + for (uint32_t i = 1; i < ads1115_count; i++) { + if (bus != Ads1115[i].bus) { // Different busses + // "ADS1115-48-1":{"A0":3240,"A1":3235,"A2":3269,"A3":3269},"ADS1115-48-2":{"A0":3240,"A1":3235,"A2":3269,"A3":3269} + snprintf_P(label, maxsize, PSTR("%s%c%d"), label, IndexSeparator(), Ads1115[device].bus +1); + break; + } + } + } +#endif } } #ifdef USE_RULES // Check every 250ms if there are relevant changes in any of the analog inputs // and if so then trigger a message -void AdsEvery250ms(void) -{ +void AdsEvery250ms(void) { int16_t value; - for (uint32_t t = 0; t < sizeof(Ads1115.addresses); t++) { - if (Ads1115.found[t]) { - - uint8_t old_address = Ads1115.address; - Ads1115.address = Ads1115.addresses[t]; - - // collect first wich addresses have changed. We can save on rule processing this way - uint32_t changed = 0; - for (uint32_t i = 0; i < Ads1115.channels; i++) { - value = Ads1115GetConversion(i); - - // Check if value has changed more than 1 percent from last stored value - // we assume that gain is set up correctly, and we could use the whole 16bit result space - if (value >= Ads1115.last_values[t][i] + 327 || value <= Ads1115.last_values[t][i] - 327) { - Ads1115.last_values[t][i] = value; - bitSet(changed, i); - } + for (uint32_t t = 0; t < ads1115_count; t++) { + // collect first wich addresses have changed. We can save on rule processing this way + uint32_t changed = 0; + for (uint32_t i = 0; i < ads1115_channels; i++) { + value = Ads1115GetConversion(t, i); + + // Check if value has changed more than 1 percent from last stored value + // we assume that gain is set up correctly, and we could use the whole 16bit result space + if (value >= Ads1115[t].last_values[i] + 327 || value <= Ads1115[t].last_values[i] - 327) { + Ads1115[t].last_values[i] = value; + bitSet(changed, i); } - Ads1115.address = old_address; - if (changed) { - char label[15]; - Ads1115Label(label, sizeof(label), Ads1115.addresses[t]); - - Response_P(PSTR("{\"%s\":{"), label); - - bool first = true; - for (uint32_t i = 0; i < Ads1115.channels; i++) { - if (bitRead(changed, i)) { - ResponseAppend_P(PSTR("%s\"A%ddiv10\":%d"), (first) ? "" : ",", i, Ads1115.last_values[t][i]); - first = false; - } - } - ResponseJsonEndEnd(); + } - XdrvRulesProcess(0); + if (changed) { + char label[16]; + Ads1115Label(label, sizeof(label), t); + Response_P(PSTR("{\"%s\":{"), label); + bool first = true; + for (uint32_t i = 0; i < ads1115_channels; i++) { + if (bitRead(changed, i)) { + ResponseAppend_P(PSTR("%s\"A%ddiv10\":%d"), (first) ? "" : ",", i, Ads1115[t].last_values[i]); + first = false; + } } + ResponseJsonEndEnd(); + XdrvRulesProcess(0); } } } #endif // USE_RULES -void Ads1115Show(bool json) -{ +void Ads1115Show(bool json) { int16_t values[4]; - for (uint32_t t = 0; t < sizeof(Ads1115.addresses); t++) { - //AddLog(LOG_LEVEL_INFO, "Logging ADS1115 %02x", Ads1115.addresses[t]); - if (Ads1115.found[t]) { - - uint8_t old_address = Ads1115.address; - Ads1115.address = Ads1115.addresses[t]; - for (uint32_t i = 0; i < Ads1115.channels; i++) { - values[i] = Ads1115GetConversion(i); - //AddLog(LOG_LEVEL_INFO, "Logging ADS1115 %02x (%i) = %i", Ads1115.address, i, values[i] ); - } - Ads1115.address = old_address; - - char label[15]; - Ads1115Label(label, sizeof(label), Ads1115.addresses[t]); + for (uint32_t t = 0; t < ads1115_count; t++) { +// AddLog(LOG_LEVEL_INFO, "Logging ADS1115 %02x", Ads1115[t].address); + for (uint32_t i = 0; i < ads1115_channels; i++) { + values[i] = Ads1115GetConversion(t, i); +// AddLog(LOG_LEVEL_INFO, "Logging ADS1115 %02x (%i) = %i", Ads1115[t].address, i, values[i] ); + } - if (json) { - ResponseAppend_P(PSTR(",\"%s\":{"), label); - for (uint32_t i = 0; i < Ads1115.channels; i++) { - ResponseAppend_P(PSTR("%s\"A%d\":%d"), (0 == i) ? "" : ",", i, values[i]); - } - ResponseJsonEnd(); + char label[16]; + Ads1115Label(label, sizeof(label), t); + if (json) { + ResponseAppend_P(PSTR(",\"%s\":{"), label); + for (uint32_t i = 0; i < ads1115_channels; i++) { + ResponseAppend_P(PSTR("%s\"A%d\":%d"), (0 == i) ? "" : ",", i, values[i]); } + ResponseJsonEnd(); + } #ifdef USE_WEBSERVER - else { - for (uint32_t i = 0; i < Ads1115.channels; i++) { - WSContentSend_PD(HTTP_SNS_ANALOG, label, i, values[i]); - } + else { + for (uint32_t i = 0; i < ads1115_channels; i++) { + WSContentSend_PD(HTTP_SNS_ANALOG, label, i, values[i]); } -#endif // USE_WEBSERVER } +#endif // USE_WEBSERVER } } -bool ADS1115_Command(void) -{ - const char ds[2][13] = {"Differential","Single ended"}; - const uint16_t r[6] = {6144,4096,2048,1024,512,256}; +bool ADS1115_Command(void) { + // Sensor12 D2 + // Sensor12 S0 if (XdrvMailbox.data_len > 1) { - UpperCase(XdrvMailbox.data,XdrvMailbox.data); + UpperCase(XdrvMailbox.data, XdrvMailbox.data); switch (XdrvMailbox.data[0]) { case 'D': - Ads1115.channels = ADS1115_DIFFERENTIAL_CHANNELS; + ads1115_channels = ADS1115_DIFFERENTIAL_CHANNELS; break; case 'S': - Ads1115.channels = ADS1115_SINGLE_CHANNELS; + ads1115_channels = ADS1115_SINGLE_CHANNELS; } - switch (XdrvMailbox.data[1]) { - case '0': - Ads1115.range = ADS1115_REG_CONFIG_PGA_6_144V; - break; - case '1': - Ads1115.range = ADS1115_REG_CONFIG_PGA_4_096V; - break; - case '2': - Ads1115.range = ADS1115_REG_CONFIG_PGA_2_048V; - break; - case '3': - Ads1115.range = ADS1115_REG_CONFIG_PGA_1_024V; - break; - case '4': - Ads1115.range = ADS1115_REG_CONFIG_PGA_0_512V; - break; - case '5': - Ads1115.range = ADS1115_REG_CONFIG_PGA_0_256V; +// uint32_t range_index = atoi((const char*)XdrvMailbox.data[1]); + uint32_t range_index = atoi((const char*)XdrvMailbox.data +1); + if ((range_index >= 0) && (range_index <= 5)) { + ads1115_range = ads1115_ranges[range_index]; } } - Response_P("{\"ADS1115\":{\"Settings\":\"%c%u\",\"Mode\":\"%s\",\"Range\":%u,\"Unit\":\"mV\"}}",ds[(Ads1115.channels>>1)-1][0],Ads1115.range>>9,ds[(Ads1115.channels>>1)-1],r[Ads1115.range>>9]); + const char ds[2][13] = { "Differential", "Single ended" }; + const uint16_t r[6] = { 6144, 4096, 2048, 1024, 512, 256 }; + Response_P("{\"ADS1115\":{\"Settings\":\"%c%u\",\"Mode\":\"%s\",\"Range\":%u,\"Unit\":\"mV\"}}", + ds[(ads1115_channels>>1)-1][0], ads1115_range>>9, ds[(ads1115_channels>>1)-1], r[ads1115_range>>9]); return true; } @@ -340,7 +320,7 @@ bool Xsns12(uint32_t function) if (FUNC_INIT == function) { Ads1115Detect(); } - else if (Ads1115.count) { + else if (ads1115_count) { switch (function) { #ifdef USE_RULES case FUNC_EVERY_250_MSECOND: From 59be99991c67f9124af56c4fe1a4dc23810a58e5 Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Fri, 20 Oct 2023 18:20:31 +0200 Subject: [PATCH 013/186] Matter Light0 now accept a Relay number (#19809) --- .../berry_matter/src/be_matter_module.c | 8 +- .../src/embedded/Matter_Plugin_2_Light0.be | 161 ---- ..._3_Light1.be => Matter_Plugin_2_Light1.be} | 61 +- .../src/embedded/Matter_Plugin_3_Light0.be | 40 + ..._4_Light2.be => Matter_Plugin_3_Light2.be} | 0 ..._4_Light3.be => Matter_Plugin_3_Light3.be} | 0 .../solidified_Matter_Plugin_2_Light0.h | 511 ----------- .../solidified_Matter_Plugin_2_Light1.h | 828 ++++++++++++++++++ .../solidified_Matter_Plugin_3_Light0.h | 36 + .../solidified_Matter_Plugin_3_Light1.h | 663 -------------- ....h => solidified_Matter_Plugin_3_Light2.h} | 2 +- ....h => solidified_Matter_Plugin_3_Light3.h} | 2 +- 12 files changed, 965 insertions(+), 1347 deletions(-) delete mode 100644 lib/libesp32/berry_matter/src/embedded/Matter_Plugin_2_Light0.be rename lib/libesp32/berry_matter/src/embedded/{Matter_Plugin_3_Light1.be => Matter_Plugin_2_Light1.be} (76%) create mode 100644 lib/libesp32/berry_matter/src/embedded/Matter_Plugin_3_Light0.be rename lib/libesp32/berry_matter/src/embedded/{Matter_Plugin_4_Light2.be => Matter_Plugin_3_Light2.be} (100%) rename lib/libesp32/berry_matter/src/embedded/{Matter_Plugin_4_Light3.be => Matter_Plugin_3_Light3.be} (100%) delete mode 100644 lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_2_Light0.h create mode 100644 lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_2_Light1.h create mode 100644 lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_3_Light0.h delete mode 100644 lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_3_Light1.h rename lib/libesp32/berry_matter/src/solidify/{solidified_Matter_Plugin_4_Light2.h => solidified_Matter_Plugin_3_Light2.h} (99%) rename lib/libesp32/berry_matter/src/solidify/{solidified_Matter_Plugin_4_Light3.h => solidified_Matter_Plugin_3_Light3.h} (99%) diff --git a/lib/libesp32/berry_matter/src/be_matter_module.c b/lib/libesp32/berry_matter/src/be_matter_module.c index 96b64424ca21..56e9d51d4d0f 100644 --- a/lib/libesp32/berry_matter/src/be_matter_module.c +++ b/lib/libesp32/berry_matter/src/be_matter_module.c @@ -214,13 +214,13 @@ extern const bclass be_class_Matter_TLV; // need to declare it upfront because #include "solidify/solidified_Matter_Plugin_1_Device.h" #include "solidify/solidified_Matter_Plugin_2_OnOff.h" #include "solidify/solidified_Matter_Plugin_9_Virt_OnOff.h" -#include "solidify/solidified_Matter_Plugin_2_Light0.h" +#include "solidify/solidified_Matter_Plugin_3_Light0.h" #include "solidify/solidified_Matter_Plugin_9_Virt_Light0.h" -#include "solidify/solidified_Matter_Plugin_3_Light1.h" +#include "solidify/solidified_Matter_Plugin_2_Light1.h" #include "solidify/solidified_Matter_Plugin_9_Virt_Light1.h" -#include "solidify/solidified_Matter_Plugin_4_Light2.h" +#include "solidify/solidified_Matter_Plugin_3_Light2.h" #include "solidify/solidified_Matter_Plugin_9_Virt_Light2.h" -#include "solidify/solidified_Matter_Plugin_4_Light3.h" +#include "solidify/solidified_Matter_Plugin_3_Light3.h" #include "solidify/solidified_Matter_Plugin_9_Virt_Light3.h" #include "solidify/solidified_Matter_Plugin_2_Shutter.h" #include "solidify/solidified_Matter_Plugin_3_ShutterTilt.h" diff --git a/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_2_Light0.be b/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_2_Light0.be deleted file mode 100644 index 1dbdd226619a..000000000000 --- a/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_2_Light0.be +++ /dev/null @@ -1,161 +0,0 @@ -# -# Matter_Plugin_Light0.be - implements the behavior for a generic Lighting (OnOff only) -# -# Copyright (C) 2023 Stephan Hadinger & Theo Arends -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -import matter - -# Matter plug-in for core behavior - -#@ solidify:Matter_Plugin_Light0,weak - -class Matter_Plugin_Light0 : Matter_Plugin_Device - static var TYPE = "light0" # name of the plug-in in json - static var DISPLAY_NAME = "Light 0 On" # display name of the plug-in - static var UPDATE_TIME = 250 # update every 250ms - static var CLUSTERS = matter.consolidate_clusters(_class, - { - # 0x001D: inherited # Descriptor Cluster 9.5 p.453 - # 0x0003: inherited # Identify 1.2 p.16 - # 0x0004: inherited # Groups 1.3 p.21 - # 0x0005: inherited # Scenes 1.4 p.30 - no writable - 0x0006: [0,0xFFFC,0xFFFD], # On/Off 1.5 p.48 - }) - static var UPDATE_COMMANDS = matter.UC_LIST(_class, "Power") - static var TYPES = { 0x0100: 2 } # OnOff Light, but not actually used because Relay is managed by OnOff - - # Inherited - # var device # reference to the `device` global object - # var endpoint # current endpoint - # var clusters # map from cluster to list of attributes, typically constructed from CLUSTERS hierachy - # var tick # tick value when it was last updated - # var node_label # name of the endpoint, used only in bridge mode, "" if none - var shadow_onoff # (bool) status of the light power on/off - - ############################################################# - # Constructor - def init(device, endpoint, config) - super(self).init(device, endpoint, config) - self.shadow_onoff = false - end - - ############################################################# - # Update shadow - # - def update_shadow() - if !self.VIRTUAL - import light - var light_status = light.get() - if light_status != nil - var pow = light_status.find('power', nil) - if pow != self.shadow_onoff - self.attribute_updated(0x0006, 0x0000) - self.shadow_onoff = pow - end - end - end - super(self).update_shadow() - end - - def set_onoff(pow) - if !self.VIRTUAL - import light - light.set({'power':pow}) - self.update_shadow() - else - if pow != self.shadow_onoff - self.attribute_updated(0x0006, 0x0000) - self.shadow_onoff = pow - end - end - end - - ############################################################# - # read an attribute - # - def read_attribute(session, ctx, tlv_solo) - var TLV = matter.TLV - var cluster = ctx.cluster - var attribute = ctx.attribute - - # ==================================================================================================== - if cluster == 0x0006 # ========== On/Off 1.5 p.48 ========== - self.update_shadow_lazy() - if attribute == 0x0000 # ---------- OnOff / bool ---------- - return tlv_solo.set(TLV.BOOL, self.shadow_onoff) - elif attribute == 0xFFFC # ---------- FeatureMap / map32 ---------- - return tlv_solo.set(TLV.U4, 0) # 0 = no Level Control for Lighting - elif attribute == 0xFFFD # ---------- ClusterRevision / u2 ---------- - return tlv_solo.set(TLV.U4, 4) # 0 = no Level Control for Lighting - end - - else - return super(self).read_attribute(session, ctx, tlv_solo) - end - end - - ############################################################# - # Invoke a command - # - # returns a TLV object if successful, contains the response - # or an `int` to indicate a status - def invoke_request(session, val, ctx) - import light - var TLV = matter.TLV - var cluster = ctx.cluster - var command = ctx.command - - # ==================================================================================================== - if cluster == 0x0006 # ========== On/Off 1.5 p.48 ========== - self.update_shadow_lazy() - if command == 0x0000 # ---------- Off ---------- - self.set_onoff(false) - self.publish_command('Power', 0) - return true - elif command == 0x0001 # ---------- On ---------- - self.set_onoff(true) - self.publish_command('Power', 1) - return true - elif command == 0x0002 # ---------- Toggle ---------- - self.set_onoff(!self.shadow_onoff) - self.publish_command('Power', self.shadow_onoff ? 1 : 0) - return true - end - end - end - - ############################################################# - # find_val_i - get value of map case insensitive - static def find_val_i(m, k) - var key_i = tasmota.find_key_i(m, k) - return m.find(key_i) - end - - ############################################################# - # update_virtual - # - # Update internal state for virtual devices - def update_virtual(payload_json) - var val_onoff = payload_json.find("Power") - if val_onoff != nil - self.set_onoff(bool(val_onoff)) - end - super(self).update_virtual(payload_json) - end - -end -matter.Plugin_Light0 = Matter_Plugin_Light0 diff --git a/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_3_Light1.be b/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_2_Light1.be similarity index 76% rename from lib/libesp32/berry_matter/src/embedded/Matter_Plugin_3_Light1.be rename to lib/libesp32/berry_matter/src/embedded/Matter_Plugin_2_Light1.be index 03a55b1c7d90..4ba09f081c6b 100644 --- a/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_3_Light1.be +++ b/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_2_Light1.be @@ -23,18 +23,19 @@ import matter #@ solidify:Matter_Plugin_Light1,weak -class Matter_Plugin_Light1 : Matter_Plugin_Light0 +class Matter_Plugin_Light1 : Matter_Plugin_Device static var TYPE = "light1" # name of the plug-in in json static var DISPLAY_NAME = "Light 1 Dimmer" # display name of the plug-in + static var UPDATE_TIME = 250 # update every 250ms static var CLUSTERS = matter.consolidate_clusters(_class, { # 0x001D: inherited # Descriptor Cluster 9.5 p.453 # 0x0003: inherited # Identify 1.2 p.16 # 0x0004: inherited # Groups 1.3 p.21 # 0x0005: inherited # Scenes 1.4 p.30 - no writable - # 0x0006: inherited # On/Off 1.5 p.48 + 0x0006: [0,0xFFFC,0xFFFD], # On/Off 1.5 p.48 0x0008: [0,2,3,0x0F,0x11,0xFFFC,0xFFFD], # Level Control 1.6 p.57 }) - static var UPDATE_COMMANDS = matter.UC_LIST(_class, "Bri") + static var UPDATE_COMMANDS = matter.UC_LIST(_class, "Power", "Bri") static var TYPES = { 0x0101: 2 } # Dimmable Light # Inherited @@ -43,13 +44,14 @@ class Matter_Plugin_Light1 : Matter_Plugin_Light0 # var clusters # map from cluster to list of attributes, typically constructed from CLUSTERS hierachy # var tick # tick value when it was last updated # var node_label # name of the endpoint, used only in bridge mode, "" if none - # var shadow_onoff # (bool) status of the light power on/off + var shadow_onoff # (bool) status of the light power on/off var shadow_bri # (int 0..254) brightness before Gamma correction - as per Matter 255 is not allowed ############################################################# # Constructor def init(device, endpoint, arguments) super(self).init(device, endpoint, arguments) + self.shadow_onoff = false self.shadow_bri = 0 end @@ -61,6 +63,11 @@ class Matter_Plugin_Light1 : Matter_Plugin_Light0 import light var light_status = light.get() if light_status != nil + var pow = light_status.find('power', nil) + if pow != self.shadow_onoff + self.attribute_updated(0x0006, 0x0000) + self.shadow_onoff = pow + end var bri = light_status.find('bri', nil) if bri != nil bri = tasmota.scale_uint(bri, 0, 255, 0, 254) @@ -74,6 +81,19 @@ class Matter_Plugin_Light1 : Matter_Plugin_Light0 super(self).update_shadow() # superclass manages 'power' end + def set_onoff(pow) + if !self.VIRTUAL + import light + light.set({'power':pow}) + self.update_shadow() + else + if pow != self.shadow_onoff + self.attribute_updated(0x0006, 0x0000) + self.shadow_onoff = pow + end + end + end + ############################################################# # Set Bri # @@ -113,7 +133,18 @@ class Matter_Plugin_Light1 : Matter_Plugin_Light0 var attribute = ctx.attribute # ==================================================================================================== - if cluster == 0x0008 # ========== Level Control 1.6 p.57 ========== + if cluster == 0x0006 # ========== On/Off 1.5 p.48 ========== + self.update_shadow_lazy() + if attribute == 0x0000 # ---------- OnOff / bool ---------- + return tlv_solo.set(TLV.BOOL, self.shadow_onoff) + elif attribute == 0xFFFC # ---------- FeatureMap / map32 ---------- + return tlv_solo.set(TLV.U4, 0) # 0 = no Level Control for Lighting + elif attribute == 0xFFFD # ---------- ClusterRevision / u2 ---------- + return tlv_solo.set(TLV.U4, 4) # 0 = no Level Control for Lighting + end + + # ==================================================================================================== + elif cluster == 0x0008 # ========== Level Control 1.6 p.57 ========== self.update_shadow_lazy() if attribute == 0x0000 # ---------- CurrentLevel / u1 ---------- return tlv_solo.set(TLV.U1, self.shadow_bri) @@ -148,7 +179,23 @@ class Matter_Plugin_Light1 : Matter_Plugin_Light0 var command = ctx.command # ==================================================================================================== - if cluster == 0x0008 # ========== Level Control 1.6 p.57 ========== + if cluster == 0x0006 # ========== On/Off 1.5 p.48 ========== + self.update_shadow_lazy() + if command == 0x0000 # ---------- Off ---------- + self.set_onoff(false) + self.publish_command('Power', 0) + return true + elif command == 0x0001 # ---------- On ---------- + self.set_onoff(true) + self.publish_command('Power', 1) + return true + elif command == 0x0002 # ---------- Toggle ---------- + self.set_onoff(!self.shadow_onoff) + self.publish_command('Power', self.shadow_onoff ? 1 : 0) + return true + end + # ==================================================================================================== + elif cluster == 0x0008 # ========== Level Control 1.6 p.57 ========== self.update_shadow_lazy() if command == 0x0000 # ---------- MoveToLevel ---------- var bri_254 = val.findsubval(0) # Hue 0..254 @@ -198,6 +245,8 @@ class Matter_Plugin_Light1 : Matter_Plugin_Light0 if val_bri != nil self.set_bri(int(val_bri), val_onoff) return # don't call super() because we already handeld 'Power' + elif val_onoff != nil + self.set_onoff(bool(val_onoff)) end super(self).update_virtual(payload_json) end diff --git a/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_3_Light0.be b/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_3_Light0.be new file mode 100644 index 000000000000..9c2108ebfb68 --- /dev/null +++ b/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_3_Light0.be @@ -0,0 +1,40 @@ +# +# Matter_Plugin_Light0.be - implements the behavior for a generic Lighting (OnOff only) +# +# Copyright (C) 2023 Stephan Hadinger & Theo Arends +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import matter + +# Matter plug-in for core behavior + +#@ solidify:Matter_Plugin_Light0,weak + +class Matter_Plugin_Light0 : Matter_Plugin_OnOff + static var TYPE = "light0" # name of the plug-in in json + static var DISPLAY_NAME = "Light 0 On" # display name of the plug-in + static var TYPES = { 0x0100: 2 } # OnOff Light, but not actually used because Relay is managed by OnOff + + # Inherited + # var device # reference to the `device` global object + # var endpoint # current endpoint + # var clusters # map from cluster to list of attributes, typically constructed from CLUSTERS hierachy + # var tick # tick value when it was last updated + # var node_label # name of the endpoint, used only in bridge mode, "" if none + # var shadow_onoff # (bool) status of the light power on/off + +end +matter.Plugin_Light0 = Matter_Plugin_Light0 diff --git a/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_4_Light2.be b/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_3_Light2.be similarity index 100% rename from lib/libesp32/berry_matter/src/embedded/Matter_Plugin_4_Light2.be rename to lib/libesp32/berry_matter/src/embedded/Matter_Plugin_3_Light2.be diff --git a/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_4_Light3.be b/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_3_Light3.be similarity index 100% rename from lib/libesp32/berry_matter/src/embedded/Matter_Plugin_4_Light3.be rename to lib/libesp32/berry_matter/src/embedded/Matter_Plugin_3_Light3.be diff --git a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_2_Light0.h b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_2_Light0.h deleted file mode 100644 index bd25d7a01735..000000000000 --- a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_2_Light0.h +++ /dev/null @@ -1,511 +0,0 @@ -/* Solidification of Matter_Plugin_2_Light0.h */ -/********************************************************************\ -* Generated code, don't edit * -\********************************************************************/ -#include "be_constobj.h" - -extern const bclass be_class_Matter_Plugin_Light0; - -/******************************************************************** -** Solidified function: read_attribute -********************************************************************/ -be_local_closure(Matter_Plugin_Light0_read_attribute, /* name */ - be_nested_proto( - 12, /* nstack */ - 4, /* argc */ - 2, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[11]) { /* constants */ - /* K0 */ be_nested_str_weak(matter), - /* K1 */ be_nested_str_weak(TLV), - /* K2 */ be_nested_str_weak(cluster), - /* K3 */ be_nested_str_weak(attribute), - /* K4 */ be_nested_str_weak(update_shadow_lazy), - /* K5 */ be_const_int(0), - /* K6 */ be_nested_str_weak(set), - /* K7 */ be_nested_str_weak(BOOL), - /* K8 */ be_nested_str_weak(shadow_onoff), - /* K9 */ be_nested_str_weak(U4), - /* K10 */ be_nested_str_weak(read_attribute), - }), - be_str_weak(read_attribute), - &be_const_str_solidified, - ( &(const binstruction[45]) { /* code */ - 0xB8120000, // 0000 GETNGBL R4 K0 - 0x88100901, // 0001 GETMBR R4 R4 K1 - 0x88140502, // 0002 GETMBR R5 R2 K2 - 0x88180503, // 0003 GETMBR R6 R2 K3 - 0x541E0005, // 0004 LDINT R7 6 - 0x1C1C0A07, // 0005 EQ R7 R5 R7 - 0x781E001B, // 0006 JMPF R7 #0023 - 0x8C1C0104, // 0007 GETMET R7 R0 K4 - 0x7C1C0200, // 0008 CALL R7 1 - 0x1C1C0D05, // 0009 EQ R7 R6 K5 - 0x781E0005, // 000A JMPF R7 #0011 - 0x8C1C0706, // 000B GETMET R7 R3 K6 - 0x88240907, // 000C GETMBR R9 R4 K7 - 0x88280108, // 000D GETMBR R10 R0 K8 - 0x7C1C0600, // 000E CALL R7 3 - 0x80040E00, // 000F RET 1 R7 - 0x70020010, // 0010 JMP #0022 - 0x541EFFFB, // 0011 LDINT R7 65532 - 0x1C1C0C07, // 0012 EQ R7 R6 R7 - 0x781E0005, // 0013 JMPF R7 #001A - 0x8C1C0706, // 0014 GETMET R7 R3 K6 - 0x88240909, // 0015 GETMBR R9 R4 K9 - 0x58280005, // 0016 LDCONST R10 K5 - 0x7C1C0600, // 0017 CALL R7 3 - 0x80040E00, // 0018 RET 1 R7 - 0x70020007, // 0019 JMP #0022 - 0x541EFFFC, // 001A LDINT R7 65533 - 0x1C1C0C07, // 001B EQ R7 R6 R7 - 0x781E0004, // 001C JMPF R7 #0022 - 0x8C1C0706, // 001D GETMET R7 R3 K6 - 0x88240909, // 001E GETMBR R9 R4 K9 - 0x542A0003, // 001F LDINT R10 4 - 0x7C1C0600, // 0020 CALL R7 3 - 0x80040E00, // 0021 RET 1 R7 - 0x70020008, // 0022 JMP #002C - 0x601C0003, // 0023 GETGBL R7 G3 - 0x5C200000, // 0024 MOVE R8 R0 - 0x7C1C0200, // 0025 CALL R7 1 - 0x8C1C0F0A, // 0026 GETMET R7 R7 K10 - 0x5C240200, // 0027 MOVE R9 R1 - 0x5C280400, // 0028 MOVE R10 R2 - 0x5C2C0600, // 0029 MOVE R11 R3 - 0x7C1C0800, // 002A CALL R7 4 - 0x80040E00, // 002B RET 1 R7 - 0x80000000, // 002C RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified function: set_onoff -********************************************************************/ -be_local_closure(Matter_Plugin_Light0_set_onoff, /* name */ - be_nested_proto( - 6, /* nstack */ - 2, /* argc */ - 2, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 8]) { /* constants */ - /* K0 */ be_nested_str_weak(VIRTUAL), - /* K1 */ be_nested_str_weak(light), - /* K2 */ be_nested_str_weak(set), - /* K3 */ be_nested_str_weak(power), - /* K4 */ be_nested_str_weak(update_shadow), - /* K5 */ be_nested_str_weak(shadow_onoff), - /* K6 */ be_nested_str_weak(attribute_updated), - /* K7 */ be_const_int(0), - }), - be_str_weak(set_onoff), - &be_const_str_solidified, - ( &(const binstruction[20]) { /* code */ - 0x88080100, // 0000 GETMBR R2 R0 K0 - 0x740A0008, // 0001 JMPT R2 #000B - 0xA40A0200, // 0002 IMPORT R2 K1 - 0x8C0C0502, // 0003 GETMET R3 R2 K2 - 0x60140013, // 0004 GETGBL R5 G19 - 0x7C140000, // 0005 CALL R5 0 - 0x98160601, // 0006 SETIDX R5 K3 R1 - 0x7C0C0400, // 0007 CALL R3 2 - 0x8C0C0104, // 0008 GETMET R3 R0 K4 - 0x7C0C0200, // 0009 CALL R3 1 - 0x70020007, // 000A JMP #0013 - 0x88080105, // 000B GETMBR R2 R0 K5 - 0x20080202, // 000C NE R2 R1 R2 - 0x780A0004, // 000D JMPF R2 #0013 - 0x8C080106, // 000E GETMET R2 R0 K6 - 0x54120005, // 000F LDINT R4 6 - 0x58140007, // 0010 LDCONST R5 K7 - 0x7C080600, // 0011 CALL R2 3 - 0x90020A01, // 0012 SETMBR R0 K5 R1 - 0x80000000, // 0013 RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified function: update_virtual -********************************************************************/ -be_local_closure(Matter_Plugin_Light0_update_virtual, /* name */ - be_nested_proto( - 7, /* nstack */ - 2, /* argc */ - 2, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 4]) { /* constants */ - /* K0 */ be_nested_str_weak(find), - /* K1 */ be_nested_str_weak(Power), - /* K2 */ be_nested_str_weak(set_onoff), - /* K3 */ be_nested_str_weak(update_virtual), - }), - be_str_weak(update_virtual), - &be_const_str_solidified, - ( &(const binstruction[18]) { /* code */ - 0x8C080300, // 0000 GETMET R2 R1 K0 - 0x58100001, // 0001 LDCONST R4 K1 - 0x7C080400, // 0002 CALL R2 2 - 0x4C0C0000, // 0003 LDNIL R3 - 0x200C0403, // 0004 NE R3 R2 R3 - 0x780E0004, // 0005 JMPF R3 #000B - 0x8C0C0102, // 0006 GETMET R3 R0 K2 - 0x60140017, // 0007 GETGBL R5 G23 - 0x5C180400, // 0008 MOVE R6 R2 - 0x7C140200, // 0009 CALL R5 1 - 0x7C0C0400, // 000A CALL R3 2 - 0x600C0003, // 000B GETGBL R3 G3 - 0x5C100000, // 000C MOVE R4 R0 - 0x7C0C0200, // 000D CALL R3 1 - 0x8C0C0703, // 000E GETMET R3 R3 K3 - 0x5C140200, // 000F MOVE R5 R1 - 0x7C0C0400, // 0010 CALL R3 2 - 0x80000000, // 0011 RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified function: init -********************************************************************/ -be_local_closure(Matter_Plugin_Light0_init, /* name */ - be_nested_proto( - 9, /* nstack */ - 4, /* argc */ - 2, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 2]) { /* constants */ - /* K0 */ be_nested_str_weak(init), - /* K1 */ be_nested_str_weak(shadow_onoff), - }), - be_str_weak(init), - &be_const_str_solidified, - ( &(const binstruction[11]) { /* code */ - 0x60100003, // 0000 GETGBL R4 G3 - 0x5C140000, // 0001 MOVE R5 R0 - 0x7C100200, // 0002 CALL R4 1 - 0x8C100900, // 0003 GETMET R4 R4 K0 - 0x5C180200, // 0004 MOVE R6 R1 - 0x5C1C0400, // 0005 MOVE R7 R2 - 0x5C200600, // 0006 MOVE R8 R3 - 0x7C100800, // 0007 CALL R4 4 - 0x50100000, // 0008 LDBOOL R4 0 0 - 0x90020204, // 0009 SETMBR R0 K1 R4 - 0x80000000, // 000A RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified function: update_shadow -********************************************************************/ -be_local_closure(Matter_Plugin_Light0_update_shadow, /* name */ - be_nested_proto( - 8, /* nstack */ - 1, /* argc */ - 2, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 9]) { /* constants */ - /* K0 */ be_nested_str_weak(VIRTUAL), - /* K1 */ be_nested_str_weak(light), - /* K2 */ be_nested_str_weak(get), - /* K3 */ be_nested_str_weak(find), - /* K4 */ be_nested_str_weak(power), - /* K5 */ be_nested_str_weak(shadow_onoff), - /* K6 */ be_nested_str_weak(attribute_updated), - /* K7 */ be_const_int(0), - /* K8 */ be_nested_str_weak(update_shadow), - }), - be_str_weak(update_shadow), - &be_const_str_solidified, - ( &(const binstruction[26]) { /* code */ - 0x88040100, // 0000 GETMBR R1 R0 K0 - 0x74060011, // 0001 JMPT R1 #0014 - 0xA4060200, // 0002 IMPORT R1 K1 - 0x8C080302, // 0003 GETMET R2 R1 K2 - 0x7C080200, // 0004 CALL R2 1 - 0x4C0C0000, // 0005 LDNIL R3 - 0x200C0403, // 0006 NE R3 R2 R3 - 0x780E000B, // 0007 JMPF R3 #0014 - 0x8C0C0503, // 0008 GETMET R3 R2 K3 - 0x58140004, // 0009 LDCONST R5 K4 - 0x4C180000, // 000A LDNIL R6 - 0x7C0C0600, // 000B CALL R3 3 - 0x88100105, // 000C GETMBR R4 R0 K5 - 0x20100604, // 000D NE R4 R3 R4 - 0x78120004, // 000E JMPF R4 #0014 - 0x8C100106, // 000F GETMET R4 R0 K6 - 0x541A0005, // 0010 LDINT R6 6 - 0x581C0007, // 0011 LDCONST R7 K7 - 0x7C100600, // 0012 CALL R4 3 - 0x90020A03, // 0013 SETMBR R0 K5 R3 - 0x60040003, // 0014 GETGBL R1 G3 - 0x5C080000, // 0015 MOVE R2 R0 - 0x7C040200, // 0016 CALL R1 1 - 0x8C040308, // 0017 GETMET R1 R1 K8 - 0x7C040200, // 0018 CALL R1 1 - 0x80000000, // 0019 RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified function: invoke_request -********************************************************************/ -be_local_closure(Matter_Plugin_Light0_invoke_request, /* name */ - be_nested_proto( - 12, /* nstack */ - 4, /* argc */ - 2, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[13]) { /* constants */ - /* K0 */ be_nested_str_weak(light), - /* K1 */ be_nested_str_weak(matter), - /* K2 */ be_nested_str_weak(TLV), - /* K3 */ be_nested_str_weak(cluster), - /* K4 */ be_nested_str_weak(command), - /* K5 */ be_nested_str_weak(update_shadow_lazy), - /* K6 */ be_const_int(0), - /* K7 */ be_nested_str_weak(set_onoff), - /* K8 */ be_nested_str_weak(publish_command), - /* K9 */ be_nested_str_weak(Power), - /* K10 */ be_const_int(1), - /* K11 */ be_const_int(2), - /* K12 */ be_nested_str_weak(shadow_onoff), - }), - be_str_weak(invoke_request), - &be_const_str_solidified, - ( &(const binstruction[53]) { /* code */ - 0xA4120000, // 0000 IMPORT R4 K0 - 0xB8160200, // 0001 GETNGBL R5 K1 - 0x88140B02, // 0002 GETMBR R5 R5 K2 - 0x88180703, // 0003 GETMBR R6 R3 K3 - 0x881C0704, // 0004 GETMBR R7 R3 K4 - 0x54220005, // 0005 LDINT R8 6 - 0x1C200C08, // 0006 EQ R8 R6 R8 - 0x7822002B, // 0007 JMPF R8 #0034 - 0x8C200105, // 0008 GETMET R8 R0 K5 - 0x7C200200, // 0009 CALL R8 1 - 0x1C200F06, // 000A EQ R8 R7 K6 - 0x78220009, // 000B JMPF R8 #0016 - 0x8C200107, // 000C GETMET R8 R0 K7 - 0x50280000, // 000D LDBOOL R10 0 0 - 0x7C200400, // 000E CALL R8 2 - 0x8C200108, // 000F GETMET R8 R0 K8 - 0x58280009, // 0010 LDCONST R10 K9 - 0x582C0006, // 0011 LDCONST R11 K6 - 0x7C200600, // 0012 CALL R8 3 - 0x50200200, // 0013 LDBOOL R8 1 0 - 0x80041000, // 0014 RET 1 R8 - 0x7002001D, // 0015 JMP #0034 - 0x1C200F0A, // 0016 EQ R8 R7 K10 - 0x78220009, // 0017 JMPF R8 #0022 - 0x8C200107, // 0018 GETMET R8 R0 K7 - 0x50280200, // 0019 LDBOOL R10 1 0 - 0x7C200400, // 001A CALL R8 2 - 0x8C200108, // 001B GETMET R8 R0 K8 - 0x58280009, // 001C LDCONST R10 K9 - 0x582C000A, // 001D LDCONST R11 K10 - 0x7C200600, // 001E CALL R8 3 - 0x50200200, // 001F LDBOOL R8 1 0 - 0x80041000, // 0020 RET 1 R8 - 0x70020011, // 0021 JMP #0034 - 0x1C200F0B, // 0022 EQ R8 R7 K11 - 0x7822000F, // 0023 JMPF R8 #0034 - 0x8C200107, // 0024 GETMET R8 R0 K7 - 0x8828010C, // 0025 GETMBR R10 R0 K12 - 0x782A0000, // 0026 JMPF R10 #0028 - 0x50280001, // 0027 LDBOOL R10 0 1 - 0x50280200, // 0028 LDBOOL R10 1 0 - 0x7C200400, // 0029 CALL R8 2 - 0x8C200108, // 002A GETMET R8 R0 K8 - 0x58280009, // 002B LDCONST R10 K9 - 0x882C010C, // 002C GETMBR R11 R0 K12 - 0x782E0001, // 002D JMPF R11 #0030 - 0x582C000A, // 002E LDCONST R11 K10 - 0x70020000, // 002F JMP #0031 - 0x582C0006, // 0030 LDCONST R11 K6 - 0x7C200600, // 0031 CALL R8 3 - 0x50200200, // 0032 LDBOOL R8 1 0 - 0x80041000, // 0033 RET 1 R8 - 0x80000000, // 0034 RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified function: find_val_i -********************************************************************/ -be_local_closure(Matter_Plugin_Light0_find_val_i, /* name */ - be_nested_proto( - 7, /* nstack */ - 2, /* argc */ - 4, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 4]) { /* constants */ - /* K0 */ be_const_class(be_class_Matter_Plugin_Light0), - /* K1 */ be_nested_str_weak(tasmota), - /* K2 */ be_nested_str_weak(find_key_i), - /* K3 */ be_nested_str_weak(find), - }), - be_str_weak(find_val_i), - &be_const_str_solidified, - ( &(const binstruction[10]) { /* code */ - 0x58080000, // 0000 LDCONST R2 K0 - 0xB80E0200, // 0001 GETNGBL R3 K1 - 0x8C0C0702, // 0002 GETMET R3 R3 K2 - 0x5C140000, // 0003 MOVE R5 R0 - 0x5C180200, // 0004 MOVE R6 R1 - 0x7C0C0600, // 0005 CALL R3 3 - 0x8C100103, // 0006 GETMET R4 R0 K3 - 0x5C180600, // 0007 MOVE R6 R3 - 0x7C100400, // 0008 CALL R4 2 - 0x80040800, // 0009 RET 1 R4 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified class: Matter_Plugin_Light0 -********************************************************************/ -extern const bclass be_class_Matter_Plugin_Device; -be_local_class(Matter_Plugin_Light0, - 1, - &be_class_Matter_Plugin_Device, - be_nested_map(14, - ( (struct bmapnode*) &(const bmapnode[]) { - { be_const_key_weak(read_attribute, 9), be_const_closure(Matter_Plugin_Light0_read_attribute_closure) }, - { be_const_key_weak(UPDATE_TIME, 4), be_const_int(250) }, - { be_const_key_weak(update_virtual, 1), be_const_closure(Matter_Plugin_Light0_update_virtual_closure) }, - { be_const_key_weak(UPDATE_COMMANDS, 13), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(1, - ( (struct bvalue*) &(const bvalue[]) { - be_nested_str_weak(Power), - })) ) } )) }, - { be_const_key_weak(find_val_i, -1), be_const_static_closure(Matter_Plugin_Light0_find_val_i_closure) }, - { be_const_key_weak(init, 11), be_const_closure(Matter_Plugin_Light0_init_closure) }, - { be_const_key_weak(set_onoff, 12), be_const_closure(Matter_Plugin_Light0_set_onoff_closure) }, - { be_const_key_weak(update_shadow, 8), be_const_closure(Matter_Plugin_Light0_update_shadow_closure) }, - { be_const_key_weak(invoke_request, -1), be_const_closure(Matter_Plugin_Light0_invoke_request_closure) }, - { be_const_key_weak(CLUSTERS, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_map, { - be_const_map( * be_nested_map(6, - ( (struct bmapnode*) &(const bmapnode[]) { - { be_const_key_int(6, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(3, - ( (struct bvalue*) &(const bvalue[]) { - be_const_int(0), - be_const_int(65532), - be_const_int(65533), - })) ) } )) }, - { be_const_key_int(5, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(8, - ( (struct bvalue*) &(const bvalue[]) { - be_const_int(0), - be_const_int(1), - be_const_int(2), - be_const_int(3), - be_const_int(4), - be_const_int(5), - be_const_int(65532), - be_const_int(65533), - })) ) } )) }, - { be_const_key_int(57, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(7, - ( (struct bvalue*) &(const bvalue[]) { - be_const_int(17), - be_const_int(3), - be_const_int(5), - be_const_int(10), - be_const_int(15), - be_const_int(17), - be_const_int(18), - })) ) } )) }, - { be_const_key_int(3, 2), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(4, - ( (struct bvalue*) &(const bvalue[]) { - be_const_int(0), - be_const_int(1), - be_const_int(65532), - be_const_int(65533), - })) ) } )) }, - { be_const_key_int(4, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(3, - ( (struct bvalue*) &(const bvalue[]) { - be_const_int(0), - be_const_int(65532), - be_const_int(65533), - })) ) } )) }, - { be_const_key_int(29, 1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(6, - ( (struct bvalue*) &(const bvalue[]) { - be_const_int(0), - be_const_int(1), - be_const_int(2), - be_const_int(3), - be_const_int(65532), - be_const_int(65533), - })) ) } )) }, - })) ) } )) }, - { be_const_key_weak(TYPES, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_map, { - be_const_map( * be_nested_map(1, - ( (struct bmapnode*) &(const bmapnode[]) { - { be_const_key_int(256, -1), be_const_int(2) }, - })) ) } )) }, - { be_const_key_weak(DISPLAY_NAME, -1), be_nested_str_weak(Light_X200_X20On) }, - { be_const_key_weak(shadow_onoff, -1), be_const_var(0) }, - { be_const_key_weak(TYPE, -1), be_nested_str_weak(light0) }, - })), - be_str_weak(Matter_Plugin_Light0) -); -/*******************************************************************/ - -void be_load_Matter_Plugin_Light0_class(bvm *vm) { - be_pushntvclass(vm, &be_class_Matter_Plugin_Light0); - be_setglobal(vm, "Matter_Plugin_Light0"); - be_pop(vm, 1); -} -/********************************************************************/ -/* End of solidification */ diff --git a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_2_Light1.h b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_2_Light1.h new file mode 100644 index 000000000000..d802a1c5f498 --- /dev/null +++ b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_2_Light1.h @@ -0,0 +1,828 @@ +/* Solidification of Matter_Plugin_2_Light1.h */ +/********************************************************************\ +* Generated code, don't edit * +\********************************************************************/ +#include "be_constobj.h" + +extern const bclass be_class_Matter_Plugin_Light1; + +/******************************************************************** +** Solidified function: init +********************************************************************/ +be_local_closure(Matter_Plugin_Light1_init, /* name */ + be_nested_proto( + 9, /* nstack */ + 4, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 4]) { /* constants */ + /* K0 */ be_nested_str_weak(init), + /* K1 */ be_nested_str_weak(shadow_onoff), + /* K2 */ be_nested_str_weak(shadow_bri), + /* K3 */ be_const_int(0), + }), + be_str_weak(init), + &be_const_str_solidified, + ( &(const binstruction[12]) { /* code */ + 0x60100003, // 0000 GETGBL R4 G3 + 0x5C140000, // 0001 MOVE R5 R0 + 0x7C100200, // 0002 CALL R4 1 + 0x8C100900, // 0003 GETMET R4 R4 K0 + 0x5C180200, // 0004 MOVE R6 R1 + 0x5C1C0400, // 0005 MOVE R7 R2 + 0x5C200600, // 0006 MOVE R8 R3 + 0x7C100800, // 0007 CALL R4 4 + 0x50100000, // 0008 LDBOOL R4 0 0 + 0x90020204, // 0009 SETMBR R0 K1 R4 + 0x90020503, // 000A SETMBR R0 K2 K3 + 0x80000000, // 000B RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: invoke_request +********************************************************************/ +be_local_closure(Matter_Plugin_Light1_invoke_request, /* name */ + be_nested_proto( + 22, /* nstack */ + 4, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[23]) { /* constants */ + /* K0 */ be_nested_str_weak(light), + /* K1 */ be_nested_str_weak(matter), + /* K2 */ be_nested_str_weak(TLV), + /* K3 */ be_nested_str_weak(cluster), + /* K4 */ be_nested_str_weak(command), + /* K5 */ be_nested_str_weak(update_shadow_lazy), + /* K6 */ be_const_int(0), + /* K7 */ be_nested_str_weak(set_onoff), + /* K8 */ be_nested_str_weak(publish_command), + /* K9 */ be_nested_str_weak(Power), + /* K10 */ be_const_int(1), + /* K11 */ be_const_int(2), + /* K12 */ be_nested_str_weak(shadow_onoff), + /* K13 */ be_nested_str_weak(findsubval), + /* K14 */ be_nested_str_weak(set_bri), + /* K15 */ be_nested_str_weak(log), + /* K16 */ be_nested_str_weak(bri_X3A), + /* K17 */ be_nested_str_weak(Bri), + /* K18 */ be_nested_str_weak(Dimmer), + /* K19 */ be_nested_str_weak(tasmota), + /* K20 */ be_nested_str_weak(scale_uint), + /* K21 */ be_const_int(3), + /* K22 */ be_nested_str_weak(invoke_request), + }), + be_str_weak(invoke_request), + &be_const_str_solidified, + ( &(const binstruction[167]) { /* code */ + 0xA4120000, // 0000 IMPORT R4 K0 + 0xB8160200, // 0001 GETNGBL R5 K1 + 0x88140B02, // 0002 GETMBR R5 R5 K2 + 0x88180703, // 0003 GETMBR R6 R3 K3 + 0x881C0704, // 0004 GETMBR R7 R3 K4 + 0x54220005, // 0005 LDINT R8 6 + 0x1C200C08, // 0006 EQ R8 R6 R8 + 0x7822002C, // 0007 JMPF R8 #0035 + 0x8C200105, // 0008 GETMET R8 R0 K5 + 0x7C200200, // 0009 CALL R8 1 + 0x1C200F06, // 000A EQ R8 R7 K6 + 0x78220009, // 000B JMPF R8 #0016 + 0x8C200107, // 000C GETMET R8 R0 K7 + 0x50280000, // 000D LDBOOL R10 0 0 + 0x7C200400, // 000E CALL R8 2 + 0x8C200108, // 000F GETMET R8 R0 K8 + 0x58280009, // 0010 LDCONST R10 K9 + 0x582C0006, // 0011 LDCONST R11 K6 + 0x7C200600, // 0012 CALL R8 3 + 0x50200200, // 0013 LDBOOL R8 1 0 + 0x80041000, // 0014 RET 1 R8 + 0x7002001D, // 0015 JMP #0034 + 0x1C200F0A, // 0016 EQ R8 R7 K10 + 0x78220009, // 0017 JMPF R8 #0022 + 0x8C200107, // 0018 GETMET R8 R0 K7 + 0x50280200, // 0019 LDBOOL R10 1 0 + 0x7C200400, // 001A CALL R8 2 + 0x8C200108, // 001B GETMET R8 R0 K8 + 0x58280009, // 001C LDCONST R10 K9 + 0x582C000A, // 001D LDCONST R11 K10 + 0x7C200600, // 001E CALL R8 3 + 0x50200200, // 001F LDBOOL R8 1 0 + 0x80041000, // 0020 RET 1 R8 + 0x70020011, // 0021 JMP #0034 + 0x1C200F0B, // 0022 EQ R8 R7 K11 + 0x7822000F, // 0023 JMPF R8 #0034 + 0x8C200107, // 0024 GETMET R8 R0 K7 + 0x8828010C, // 0025 GETMBR R10 R0 K12 + 0x782A0000, // 0026 JMPF R10 #0028 + 0x50280001, // 0027 LDBOOL R10 0 1 + 0x50280200, // 0028 LDBOOL R10 1 0 + 0x7C200400, // 0029 CALL R8 2 + 0x8C200108, // 002A GETMET R8 R0 K8 + 0x58280009, // 002B LDCONST R10 K9 + 0x882C010C, // 002C GETMBR R11 R0 K12 + 0x782E0001, // 002D JMPF R11 #0030 + 0x582C000A, // 002E LDCONST R11 K10 + 0x70020000, // 002F JMP #0031 + 0x582C0006, // 0030 LDCONST R11 K6 + 0x7C200600, // 0031 CALL R8 3 + 0x50200200, // 0032 LDBOOL R8 1 0 + 0x80041000, // 0033 RET 1 R8 + 0x70020070, // 0034 JMP #00A6 + 0x54220007, // 0035 LDINT R8 8 + 0x1C200C08, // 0036 EQ R8 R6 R8 + 0x78220064, // 0037 JMPF R8 #009D + 0x8C200105, // 0038 GETMET R8 R0 K5 + 0x7C200200, // 0039 CALL R8 1 + 0x1C200F06, // 003A EQ R8 R7 K6 + 0x7822001A, // 003B JMPF R8 #0057 + 0x8C20050D, // 003C GETMET R8 R2 K13 + 0x58280006, // 003D LDCONST R10 K6 + 0x7C200400, // 003E CALL R8 2 + 0x8C24010E, // 003F GETMET R9 R0 K14 + 0x5C2C1000, // 0040 MOVE R11 R8 + 0x7C240400, // 0041 CALL R9 2 + 0x60240008, // 0042 GETGBL R9 G8 + 0x5C281000, // 0043 MOVE R10 R8 + 0x7C240200, // 0044 CALL R9 1 + 0x00262009, // 0045 ADD R9 K16 R9 + 0x900E1E09, // 0046 SETMBR R3 K15 R9 + 0x8C240108, // 0047 GETMET R9 R0 K8 + 0x582C0011, // 0048 LDCONST R11 K17 + 0x5C301000, // 0049 MOVE R12 R8 + 0x58340012, // 004A LDCONST R13 K18 + 0xB83A2600, // 004B GETNGBL R14 K19 + 0x8C381D14, // 004C GETMET R14 R14 K20 + 0x5C401000, // 004D MOVE R16 R8 + 0x58440006, // 004E LDCONST R17 K6 + 0x544A00FD, // 004F LDINT R18 254 + 0x584C0006, // 0050 LDCONST R19 K6 + 0x54520063, // 0051 LDINT R20 100 + 0x7C380C00, // 0052 CALL R14 6 + 0x7C240A00, // 0053 CALL R9 5 + 0x50240200, // 0054 LDBOOL R9 1 0 + 0x80041200, // 0055 RET 1 R9 + 0x70020044, // 0056 JMP #009C + 0x1C200F0A, // 0057 EQ R8 R7 K10 + 0x78220002, // 0058 JMPF R8 #005C + 0x50200200, // 0059 LDBOOL R8 1 0 + 0x80041000, // 005A RET 1 R8 + 0x7002003F, // 005B JMP #009C + 0x1C200F0B, // 005C EQ R8 R7 K11 + 0x78220002, // 005D JMPF R8 #0061 + 0x50200200, // 005E LDBOOL R8 1 0 + 0x80041000, // 005F RET 1 R8 + 0x7002003A, // 0060 JMP #009C + 0x1C200F15, // 0061 EQ R8 R7 K21 + 0x78220002, // 0062 JMPF R8 #0066 + 0x50200200, // 0063 LDBOOL R8 1 0 + 0x80041000, // 0064 RET 1 R8 + 0x70020035, // 0065 JMP #009C + 0x54220003, // 0066 LDINT R8 4 + 0x1C200E08, // 0067 EQ R8 R7 R8 + 0x78220021, // 0068 JMPF R8 #008B + 0x8C20050D, // 0069 GETMET R8 R2 K13 + 0x58280006, // 006A LDCONST R10 K6 + 0x7C200400, // 006B CALL R8 2 + 0x24241106, // 006C GT R9 R8 K6 + 0x8C28010E, // 006D GETMET R10 R0 K14 + 0x5C301000, // 006E MOVE R12 R8 + 0x5C341200, // 006F MOVE R13 R9 + 0x7C280600, // 0070 CALL R10 3 + 0x60280008, // 0071 GETGBL R10 G8 + 0x5C2C1000, // 0072 MOVE R11 R8 + 0x7C280200, // 0073 CALL R10 1 + 0x002A200A, // 0074 ADD R10 K16 R10 + 0x900E1E0A, // 0075 SETMBR R3 K15 R10 + 0x8C280108, // 0076 GETMET R10 R0 K8 + 0x58300011, // 0077 LDCONST R12 K17 + 0x5C341000, // 0078 MOVE R13 R8 + 0x58380012, // 0079 LDCONST R14 K18 + 0xB83E2600, // 007A GETNGBL R15 K19 + 0x8C3C1F14, // 007B GETMET R15 R15 K20 + 0x5C441000, // 007C MOVE R17 R8 + 0x58480006, // 007D LDCONST R18 K6 + 0x544E00FD, // 007E LDINT R19 254 + 0x58500006, // 007F LDCONST R20 K6 + 0x54560063, // 0080 LDINT R21 100 + 0x7C3C0C00, // 0081 CALL R15 6 + 0x58400009, // 0082 LDCONST R16 K9 + 0x78260001, // 0083 JMPF R9 #0086 + 0x5844000A, // 0084 LDCONST R17 K10 + 0x70020000, // 0085 JMP #0087 + 0x58440006, // 0086 LDCONST R17 K6 + 0x7C280E00, // 0087 CALL R10 7 + 0x50280200, // 0088 LDBOOL R10 1 0 + 0x80041400, // 0089 RET 1 R10 + 0x70020010, // 008A JMP #009C + 0x54220004, // 008B LDINT R8 5 + 0x1C200E08, // 008C EQ R8 R7 R8 + 0x78220002, // 008D JMPF R8 #0091 + 0x50200200, // 008E LDBOOL R8 1 0 + 0x80041000, // 008F RET 1 R8 + 0x7002000A, // 0090 JMP #009C + 0x54220005, // 0091 LDINT R8 6 + 0x1C200E08, // 0092 EQ R8 R7 R8 + 0x78220002, // 0093 JMPF R8 #0097 + 0x50200200, // 0094 LDBOOL R8 1 0 + 0x80041000, // 0095 RET 1 R8 + 0x70020004, // 0096 JMP #009C + 0x54220006, // 0097 LDINT R8 7 + 0x1C200E08, // 0098 EQ R8 R7 R8 + 0x78220001, // 0099 JMPF R8 #009C + 0x50200200, // 009A LDBOOL R8 1 0 + 0x80041000, // 009B RET 1 R8 + 0x70020008, // 009C JMP #00A6 + 0x60200003, // 009D GETGBL R8 G3 + 0x5C240000, // 009E MOVE R9 R0 + 0x7C200200, // 009F CALL R8 1 + 0x8C201116, // 00A0 GETMET R8 R8 K22 + 0x5C280200, // 00A1 MOVE R10 R1 + 0x5C2C0400, // 00A2 MOVE R11 R2 + 0x5C300600, // 00A3 MOVE R12 R3 + 0x7C200800, // 00A4 CALL R8 4 + 0x80041000, // 00A5 RET 1 R8 + 0x80000000, // 00A6 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: set_onoff +********************************************************************/ +be_local_closure(Matter_Plugin_Light1_set_onoff, /* name */ + be_nested_proto( + 6, /* nstack */ + 2, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 8]) { /* constants */ + /* K0 */ be_nested_str_weak(VIRTUAL), + /* K1 */ be_nested_str_weak(light), + /* K2 */ be_nested_str_weak(set), + /* K3 */ be_nested_str_weak(power), + /* K4 */ be_nested_str_weak(update_shadow), + /* K5 */ be_nested_str_weak(shadow_onoff), + /* K6 */ be_nested_str_weak(attribute_updated), + /* K7 */ be_const_int(0), + }), + be_str_weak(set_onoff), + &be_const_str_solidified, + ( &(const binstruction[20]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x740A0008, // 0001 JMPT R2 #000B + 0xA40A0200, // 0002 IMPORT R2 K1 + 0x8C0C0502, // 0003 GETMET R3 R2 K2 + 0x60140013, // 0004 GETGBL R5 G19 + 0x7C140000, // 0005 CALL R5 0 + 0x98160601, // 0006 SETIDX R5 K3 R1 + 0x7C0C0400, // 0007 CALL R3 2 + 0x8C0C0104, // 0008 GETMET R3 R0 K4 + 0x7C0C0200, // 0009 CALL R3 1 + 0x70020007, // 000A JMP #0013 + 0x88080105, // 000B GETMBR R2 R0 K5 + 0x20080202, // 000C NE R2 R1 R2 + 0x780A0004, // 000D JMPF R2 #0013 + 0x8C080106, // 000E GETMET R2 R0 K6 + 0x54120005, // 000F LDINT R4 6 + 0x58140007, // 0010 LDCONST R5 K7 + 0x7C080600, // 0011 CALL R2 3 + 0x90020A01, // 0012 SETMBR R0 K5 R1 + 0x80000000, // 0013 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: update_shadow +********************************************************************/ +be_local_closure(Matter_Plugin_Light1_update_shadow, /* name */ + be_nested_proto( + 12, /* nstack */ + 1, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[13]) { /* constants */ + /* K0 */ be_nested_str_weak(VIRTUAL), + /* K1 */ be_nested_str_weak(light), + /* K2 */ be_nested_str_weak(get), + /* K3 */ be_nested_str_weak(find), + /* K4 */ be_nested_str_weak(power), + /* K5 */ be_nested_str_weak(shadow_onoff), + /* K6 */ be_nested_str_weak(attribute_updated), + /* K7 */ be_const_int(0), + /* K8 */ be_nested_str_weak(bri), + /* K9 */ be_nested_str_weak(tasmota), + /* K10 */ be_nested_str_weak(scale_uint), + /* K11 */ be_nested_str_weak(shadow_bri), + /* K12 */ be_nested_str_weak(update_shadow), + }), + be_str_weak(update_shadow), + &be_const_str_solidified, + ( &(const binstruction[50]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x74060029, // 0001 JMPT R1 #002C + 0xA4060200, // 0002 IMPORT R1 K1 + 0x8C080302, // 0003 GETMET R2 R1 K2 + 0x7C080200, // 0004 CALL R2 1 + 0x4C0C0000, // 0005 LDNIL R3 + 0x200C0403, // 0006 NE R3 R2 R3 + 0x780E0023, // 0007 JMPF R3 #002C + 0x8C0C0503, // 0008 GETMET R3 R2 K3 + 0x58140004, // 0009 LDCONST R5 K4 + 0x4C180000, // 000A LDNIL R6 + 0x7C0C0600, // 000B CALL R3 3 + 0x88100105, // 000C GETMBR R4 R0 K5 + 0x20100604, // 000D NE R4 R3 R4 + 0x78120004, // 000E JMPF R4 #0014 + 0x8C100106, // 000F GETMET R4 R0 K6 + 0x541A0005, // 0010 LDINT R6 6 + 0x581C0007, // 0011 LDCONST R7 K7 + 0x7C100600, // 0012 CALL R4 3 + 0x90020A03, // 0013 SETMBR R0 K5 R3 + 0x8C100503, // 0014 GETMET R4 R2 K3 + 0x58180008, // 0015 LDCONST R6 K8 + 0x4C1C0000, // 0016 LDNIL R7 + 0x7C100600, // 0017 CALL R4 3 + 0x4C140000, // 0018 LDNIL R5 + 0x20140805, // 0019 NE R5 R4 R5 + 0x78160010, // 001A JMPF R5 #002C + 0xB8161200, // 001B GETNGBL R5 K9 + 0x8C140B0A, // 001C GETMET R5 R5 K10 + 0x5C1C0800, // 001D MOVE R7 R4 + 0x58200007, // 001E LDCONST R8 K7 + 0x542600FE, // 001F LDINT R9 255 + 0x58280007, // 0020 LDCONST R10 K7 + 0x542E00FD, // 0021 LDINT R11 254 + 0x7C140C00, // 0022 CALL R5 6 + 0x5C100A00, // 0023 MOVE R4 R5 + 0x8814010B, // 0024 GETMBR R5 R0 K11 + 0x20140805, // 0025 NE R5 R4 R5 + 0x78160004, // 0026 JMPF R5 #002C + 0x8C140106, // 0027 GETMET R5 R0 K6 + 0x541E0007, // 0028 LDINT R7 8 + 0x58200007, // 0029 LDCONST R8 K7 + 0x7C140600, // 002A CALL R5 3 + 0x90021604, // 002B SETMBR R0 K11 R4 + 0x60040003, // 002C GETGBL R1 G3 + 0x5C080000, // 002D MOVE R2 R0 + 0x7C040200, // 002E CALL R1 1 + 0x8C04030C, // 002F GETMET R1 R1 K12 + 0x7C040200, // 0030 CALL R1 1 + 0x80000000, // 0031 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: update_virtual +********************************************************************/ +be_local_closure(Matter_Plugin_Light1_update_virtual, /* name */ + be_nested_proto( + 8, /* nstack */ + 2, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 6]) { /* constants */ + /* K0 */ be_nested_str_weak(find), + /* K1 */ be_nested_str_weak(Power), + /* K2 */ be_nested_str_weak(Bri), + /* K3 */ be_nested_str_weak(set_bri), + /* K4 */ be_nested_str_weak(set_onoff), + /* K5 */ be_nested_str_weak(update_virtual), + }), + be_str_weak(update_virtual), + &be_const_str_solidified, + ( &(const binstruction[32]) { /* code */ + 0x8C080300, // 0000 GETMET R2 R1 K0 + 0x58100001, // 0001 LDCONST R4 K1 + 0x7C080400, // 0002 CALL R2 2 + 0x8C0C0300, // 0003 GETMET R3 R1 K0 + 0x58140002, // 0004 LDCONST R5 K2 + 0x7C0C0400, // 0005 CALL R3 2 + 0x4C100000, // 0006 LDNIL R4 + 0x20100604, // 0007 NE R4 R3 R4 + 0x78120007, // 0008 JMPF R4 #0011 + 0x8C100103, // 0009 GETMET R4 R0 K3 + 0x60180009, // 000A GETGBL R6 G9 + 0x5C1C0600, // 000B MOVE R7 R3 + 0x7C180200, // 000C CALL R6 1 + 0x5C1C0400, // 000D MOVE R7 R2 + 0x7C100600, // 000E CALL R4 3 + 0x80000800, // 000F RET 0 + 0x70020007, // 0010 JMP #0019 + 0x4C100000, // 0011 LDNIL R4 + 0x20100404, // 0012 NE R4 R2 R4 + 0x78120004, // 0013 JMPF R4 #0019 + 0x8C100104, // 0014 GETMET R4 R0 K4 + 0x60180017, // 0015 GETGBL R6 G23 + 0x5C1C0400, // 0016 MOVE R7 R2 + 0x7C180200, // 0017 CALL R6 1 + 0x7C100400, // 0018 CALL R4 2 + 0x60100003, // 0019 GETGBL R4 G3 + 0x5C140000, // 001A MOVE R5 R0 + 0x7C100200, // 001B CALL R4 1 + 0x8C100905, // 001C GETMET R4 R4 K5 + 0x5C180200, // 001D MOVE R6 R1 + 0x7C100400, // 001E CALL R4 2 + 0x80000000, // 001F RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: read_attribute +********************************************************************/ +be_local_closure(Matter_Plugin_Light1_read_attribute, /* name */ + be_nested_proto( + 12, /* nstack */ + 4, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[16]) { /* constants */ + /* K0 */ be_nested_str_weak(matter), + /* K1 */ be_nested_str_weak(TLV), + /* K2 */ be_nested_str_weak(cluster), + /* K3 */ be_nested_str_weak(attribute), + /* K4 */ be_nested_str_weak(update_shadow_lazy), + /* K5 */ be_const_int(0), + /* K6 */ be_nested_str_weak(set), + /* K7 */ be_nested_str_weak(BOOL), + /* K8 */ be_nested_str_weak(shadow_onoff), + /* K9 */ be_nested_str_weak(U4), + /* K10 */ be_nested_str_weak(U1), + /* K11 */ be_nested_str_weak(shadow_bri), + /* K12 */ be_const_int(2), + /* K13 */ be_const_int(3), + /* K14 */ be_const_int(1), + /* K15 */ be_nested_str_weak(read_attribute), + }), + be_str_weak(read_attribute), + &be_const_str_solidified, + ( &(const binstruction[110]) { /* code */ + 0xB8120000, // 0000 GETNGBL R4 K0 + 0x88100901, // 0001 GETMBR R4 R4 K1 + 0x88140502, // 0002 GETMBR R5 R2 K2 + 0x88180503, // 0003 GETMBR R6 R2 K3 + 0x541E0005, // 0004 LDINT R7 6 + 0x1C1C0A07, // 0005 EQ R7 R5 R7 + 0x781E001B, // 0006 JMPF R7 #0023 + 0x8C1C0104, // 0007 GETMET R7 R0 K4 + 0x7C1C0200, // 0008 CALL R7 1 + 0x1C1C0D05, // 0009 EQ R7 R6 K5 + 0x781E0005, // 000A JMPF R7 #0011 + 0x8C1C0706, // 000B GETMET R7 R3 K6 + 0x88240907, // 000C GETMBR R9 R4 K7 + 0x88280108, // 000D GETMBR R10 R0 K8 + 0x7C1C0600, // 000E CALL R7 3 + 0x80040E00, // 000F RET 1 R7 + 0x70020010, // 0010 JMP #0022 + 0x541EFFFB, // 0011 LDINT R7 65532 + 0x1C1C0C07, // 0012 EQ R7 R6 R7 + 0x781E0005, // 0013 JMPF R7 #001A + 0x8C1C0706, // 0014 GETMET R7 R3 K6 + 0x88240909, // 0015 GETMBR R9 R4 K9 + 0x58280005, // 0016 LDCONST R10 K5 + 0x7C1C0600, // 0017 CALL R7 3 + 0x80040E00, // 0018 RET 1 R7 + 0x70020007, // 0019 JMP #0022 + 0x541EFFFC, // 001A LDINT R7 65533 + 0x1C1C0C07, // 001B EQ R7 R6 R7 + 0x781E0004, // 001C JMPF R7 #0022 + 0x8C1C0706, // 001D GETMET R7 R3 K6 + 0x88240909, // 001E GETMBR R9 R4 K9 + 0x542A0003, // 001F LDINT R10 4 + 0x7C1C0600, // 0020 CALL R7 3 + 0x80040E00, // 0021 RET 1 R7 + 0x70020049, // 0022 JMP #006D + 0x541E0007, // 0023 LDINT R7 8 + 0x1C1C0A07, // 0024 EQ R7 R5 R7 + 0x781E003D, // 0025 JMPF R7 #0064 + 0x8C1C0104, // 0026 GETMET R7 R0 K4 + 0x7C1C0200, // 0027 CALL R7 1 + 0x1C1C0D05, // 0028 EQ R7 R6 K5 + 0x781E0005, // 0029 JMPF R7 #0030 + 0x8C1C0706, // 002A GETMET R7 R3 K6 + 0x8824090A, // 002B GETMBR R9 R4 K10 + 0x8828010B, // 002C GETMBR R10 R0 K11 + 0x7C1C0600, // 002D CALL R7 3 + 0x80040E00, // 002E RET 1 R7 + 0x70020032, // 002F JMP #0063 + 0x1C1C0D0C, // 0030 EQ R7 R6 K12 + 0x781E0005, // 0031 JMPF R7 #0038 + 0x8C1C0706, // 0032 GETMET R7 R3 K6 + 0x8824090A, // 0033 GETMBR R9 R4 K10 + 0x58280005, // 0034 LDCONST R10 K5 + 0x7C1C0600, // 0035 CALL R7 3 + 0x80040E00, // 0036 RET 1 R7 + 0x7002002A, // 0037 JMP #0063 + 0x1C1C0D0D, // 0038 EQ R7 R6 K13 + 0x781E0005, // 0039 JMPF R7 #0040 + 0x8C1C0706, // 003A GETMET R7 R3 K6 + 0x8824090A, // 003B GETMBR R9 R4 K10 + 0x542A00FD, // 003C LDINT R10 254 + 0x7C1C0600, // 003D CALL R7 3 + 0x80040E00, // 003E RET 1 R7 + 0x70020022, // 003F JMP #0063 + 0x541E000E, // 0040 LDINT R7 15 + 0x1C1C0C07, // 0041 EQ R7 R6 R7 + 0x781E0005, // 0042 JMPF R7 #0049 + 0x8C1C0706, // 0043 GETMET R7 R3 K6 + 0x8824090A, // 0044 GETMBR R9 R4 K10 + 0x58280005, // 0045 LDCONST R10 K5 + 0x7C1C0600, // 0046 CALL R7 3 + 0x80040E00, // 0047 RET 1 R7 + 0x70020019, // 0048 JMP #0063 + 0x541E0010, // 0049 LDINT R7 17 + 0x1C1C0C07, // 004A EQ R7 R6 R7 + 0x781E0005, // 004B JMPF R7 #0052 + 0x8C1C0706, // 004C GETMET R7 R3 K6 + 0x8824090A, // 004D GETMBR R9 R4 K10 + 0x8828010B, // 004E GETMBR R10 R0 K11 + 0x7C1C0600, // 004F CALL R7 3 + 0x80040E00, // 0050 RET 1 R7 + 0x70020010, // 0051 JMP #0063 + 0x541EFFFB, // 0052 LDINT R7 65532 + 0x1C1C0C07, // 0053 EQ R7 R6 R7 + 0x781E0005, // 0054 JMPF R7 #005B + 0x8C1C0706, // 0055 GETMET R7 R3 K6 + 0x88240909, // 0056 GETMBR R9 R4 K9 + 0x5828000E, // 0057 LDCONST R10 K14 + 0x7C1C0600, // 0058 CALL R7 3 + 0x80040E00, // 0059 RET 1 R7 + 0x70020007, // 005A JMP #0063 + 0x541EFFFC, // 005B LDINT R7 65533 + 0x1C1C0C07, // 005C EQ R7 R6 R7 + 0x781E0004, // 005D JMPF R7 #0063 + 0x8C1C0706, // 005E GETMET R7 R3 K6 + 0x88240909, // 005F GETMBR R9 R4 K9 + 0x542A0004, // 0060 LDINT R10 5 + 0x7C1C0600, // 0061 CALL R7 3 + 0x80040E00, // 0062 RET 1 R7 + 0x70020008, // 0063 JMP #006D + 0x601C0003, // 0064 GETGBL R7 G3 + 0x5C200000, // 0065 MOVE R8 R0 + 0x7C1C0200, // 0066 CALL R7 1 + 0x8C1C0F0F, // 0067 GETMET R7 R7 K15 + 0x5C240200, // 0068 MOVE R9 R1 + 0x5C280400, // 0069 MOVE R10 R2 + 0x5C2C0600, // 006A MOVE R11 R3 + 0x7C1C0800, // 006B CALL R7 4 + 0x80040E00, // 006C RET 1 R7 + 0x80000000, // 006D RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: set_bri +********************************************************************/ +be_local_closure(Matter_Plugin_Light1_set_bri, /* name */ + be_nested_proto( + 11, /* nstack */ + 3, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[12]) { /* constants */ + /* K0 */ be_const_int(0), + /* K1 */ be_nested_str_weak(VIRTUAL), + /* K2 */ be_nested_str_weak(light), + /* K3 */ be_nested_str_weak(tasmota), + /* K4 */ be_nested_str_weak(scale_uint), + /* K5 */ be_nested_str_weak(set), + /* K6 */ be_nested_str_weak(bri), + /* K7 */ be_nested_str_weak(power), + /* K8 */ be_nested_str_weak(update_shadow), + /* K9 */ be_nested_str_weak(shadow_onoff), + /* K10 */ be_nested_str_weak(attribute_updated), + /* K11 */ be_nested_str_weak(shadow_bri), + }), + be_str_weak(set_bri), + &be_const_str_solidified, + ( &(const binstruction[65]) { /* code */ + 0x140C0300, // 0000 LT R3 R1 K0 + 0x780E0000, // 0001 JMPF R3 #0003 + 0x58040000, // 0002 LDCONST R1 K0 + 0x540E00FD, // 0003 LDINT R3 254 + 0x240C0203, // 0004 GT R3 R1 R3 + 0x780E0000, // 0005 JMPF R3 #0007 + 0x540600FD, // 0006 LDINT R1 254 + 0x4C0C0000, // 0007 LDNIL R3 + 0x200C0403, // 0008 NE R3 R2 R3 + 0x780E0003, // 0009 JMPF R3 #000E + 0x600C0017, // 000A GETGBL R3 G23 + 0x5C100400, // 000B MOVE R4 R2 + 0x7C0C0200, // 000C CALL R3 1 + 0x70020000, // 000D JMP #000F + 0x4C0C0000, // 000E LDNIL R3 + 0x5C080600, // 000F MOVE R2 R3 + 0x880C0101, // 0010 GETMBR R3 R0 K1 + 0x740E001A, // 0011 JMPT R3 #002D + 0xA40E0400, // 0012 IMPORT R3 K2 + 0xB8120600, // 0013 GETNGBL R4 K3 + 0x8C100904, // 0014 GETMET R4 R4 K4 + 0x5C180200, // 0015 MOVE R6 R1 + 0x581C0000, // 0016 LDCONST R7 K0 + 0x542200FD, // 0017 LDINT R8 254 + 0x58240000, // 0018 LDCONST R9 K0 + 0x542A00FE, // 0019 LDINT R10 255 + 0x7C100C00, // 001A CALL R4 6 + 0x4C140000, // 001B LDNIL R5 + 0x1C140405, // 001C EQ R5 R2 R5 + 0x78160005, // 001D JMPF R5 #0024 + 0x8C140705, // 001E GETMET R5 R3 K5 + 0x601C0013, // 001F GETGBL R7 G19 + 0x7C1C0000, // 0020 CALL R7 0 + 0x981E0C04, // 0021 SETIDX R7 K6 R4 + 0x7C140400, // 0022 CALL R5 2 + 0x70020005, // 0023 JMP #002A + 0x8C140705, // 0024 GETMET R5 R3 K5 + 0x601C0013, // 0025 GETGBL R7 G19 + 0x7C1C0000, // 0026 CALL R7 0 + 0x981E0C04, // 0027 SETIDX R7 K6 R4 + 0x981E0E02, // 0028 SETIDX R7 K7 R2 + 0x7C140400, // 0029 CALL R5 2 + 0x8C140108, // 002A GETMET R5 R0 K8 + 0x7C140200, // 002B CALL R5 1 + 0x70020012, // 002C JMP #0040 + 0x4C0C0000, // 002D LDNIL R3 + 0x200C0403, // 002E NE R3 R2 R3 + 0x780E0007, // 002F JMPF R3 #0038 + 0x880C0109, // 0030 GETMBR R3 R0 K9 + 0x200C0403, // 0031 NE R3 R2 R3 + 0x780E0004, // 0032 JMPF R3 #0038 + 0x8C0C010A, // 0033 GETMET R3 R0 K10 + 0x54160005, // 0034 LDINT R5 6 + 0x58180000, // 0035 LDCONST R6 K0 + 0x7C0C0600, // 0036 CALL R3 3 + 0x90021202, // 0037 SETMBR R0 K9 R2 + 0x880C010B, // 0038 GETMBR R3 R0 K11 + 0x200C0203, // 0039 NE R3 R1 R3 + 0x780E0004, // 003A JMPF R3 #0040 + 0x8C0C010A, // 003B GETMET R3 R0 K10 + 0x54160007, // 003C LDINT R5 8 + 0x58180000, // 003D LDCONST R6 K0 + 0x7C0C0600, // 003E CALL R3 3 + 0x90021601, // 003F SETMBR R0 K11 R1 + 0x80000000, // 0040 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified class: Matter_Plugin_Light1 +********************************************************************/ +extern const bclass be_class_Matter_Plugin_Device; +be_local_class(Matter_Plugin_Light1, + 2, + &be_class_Matter_Plugin_Device, + be_nested_map(15, + ( (struct bmapnode*) &(const bmapnode[]) { + { be_const_key_weak(init, -1), be_const_closure(Matter_Plugin_Light1_init_closure) }, + { be_const_key_weak(update_shadow, -1), be_const_closure(Matter_Plugin_Light1_update_shadow_closure) }, + { be_const_key_weak(invoke_request, -1), be_const_closure(Matter_Plugin_Light1_invoke_request_closure) }, + { be_const_key_weak(set_onoff, -1), be_const_closure(Matter_Plugin_Light1_set_onoff_closure) }, + { be_const_key_weak(TYPE, 10), be_nested_str_weak(light1) }, + { be_const_key_weak(update_virtual, 11), be_const_closure(Matter_Plugin_Light1_update_virtual_closure) }, + { be_const_key_weak(UPDATE_TIME, 8), be_const_int(250) }, + { be_const_key_weak(shadow_bri, 1), be_const_var(1) }, + { be_const_key_weak(DISPLAY_NAME, -1), be_nested_str_weak(Light_X201_X20Dimmer) }, + { be_const_key_weak(UPDATE_COMMANDS, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { + be_const_list( * be_nested_list(2, + ( (struct bvalue*) &(const bvalue[]) { + be_nested_str_weak(Power), + be_nested_str_weak(Bri), + })) ) } )) }, + { be_const_key_weak(CLUSTERS, 7), be_const_simple_instance(be_nested_simple_instance(&be_class_map, { + be_const_map( * be_nested_map(7, + ( (struct bmapnode*) &(const bmapnode[]) { + { be_const_key_int(29, 2), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { + be_const_list( * be_nested_list(6, + ( (struct bvalue*) &(const bvalue[]) { + be_const_int(0), + be_const_int(1), + be_const_int(2), + be_const_int(3), + be_const_int(65532), + be_const_int(65533), + })) ) } )) }, + { be_const_key_int(8, 0), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { + be_const_list( * be_nested_list(7, + ( (struct bvalue*) &(const bvalue[]) { + be_const_int(0), + be_const_int(2), + be_const_int(3), + be_const_int(15), + be_const_int(17), + be_const_int(65532), + be_const_int(65533), + })) ) } )) }, + { be_const_key_int(57, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { + be_const_list( * be_nested_list(7, + ( (struct bvalue*) &(const bvalue[]) { + be_const_int(17), + be_const_int(3), + be_const_int(5), + be_const_int(10), + be_const_int(15), + be_const_int(17), + be_const_int(18), + })) ) } )) }, + { be_const_key_int(3, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { + be_const_list( * be_nested_list(4, + ( (struct bvalue*) &(const bvalue[]) { + be_const_int(0), + be_const_int(1), + be_const_int(65532), + be_const_int(65533), + })) ) } )) }, + { be_const_key_int(4, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { + be_const_list( * be_nested_list(3, + ( (struct bvalue*) &(const bvalue[]) { + be_const_int(0), + be_const_int(65532), + be_const_int(65533), + })) ) } )) }, + { be_const_key_int(5, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { + be_const_list( * be_nested_list(8, + ( (struct bvalue*) &(const bvalue[]) { + be_const_int(0), + be_const_int(1), + be_const_int(2), + be_const_int(3), + be_const_int(4), + be_const_int(5), + be_const_int(65532), + be_const_int(65533), + })) ) } )) }, + { be_const_key_int(6, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { + be_const_list( * be_nested_list(3, + ( (struct bvalue*) &(const bvalue[]) { + be_const_int(0), + be_const_int(65532), + be_const_int(65533), + })) ) } )) }, + })) ) } )) }, + { be_const_key_weak(TYPES, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_map, { + be_const_map( * be_nested_map(1, + ( (struct bmapnode*) &(const bmapnode[]) { + { be_const_key_int(257, -1), be_const_int(2) }, + })) ) } )) }, + { be_const_key_weak(read_attribute, -1), be_const_closure(Matter_Plugin_Light1_read_attribute_closure) }, + { be_const_key_weak(shadow_onoff, -1), be_const_var(0) }, + { be_const_key_weak(set_bri, -1), be_const_closure(Matter_Plugin_Light1_set_bri_closure) }, + })), + be_str_weak(Matter_Plugin_Light1) +); +/*******************************************************************/ + +void be_load_Matter_Plugin_Light1_class(bvm *vm) { + be_pushntvclass(vm, &be_class_Matter_Plugin_Light1); + be_setglobal(vm, "Matter_Plugin_Light1"); + be_pop(vm, 1); +} +/********************************************************************/ +/* End of solidification */ diff --git a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_3_Light0.h b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_3_Light0.h new file mode 100644 index 000000000000..617c428aa6e4 --- /dev/null +++ b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_3_Light0.h @@ -0,0 +1,36 @@ +/* Solidification of Matter_Plugin_3_Light0.h */ +/********************************************************************\ +* Generated code, don't edit * +\********************************************************************/ +#include "be_constobj.h" + +extern const bclass be_class_Matter_Plugin_Light0; + +/******************************************************************** +** Solidified class: Matter_Plugin_Light0 +********************************************************************/ +extern const bclass be_class_Matter_Plugin_OnOff; +be_local_class(Matter_Plugin_Light0, + 0, + &be_class_Matter_Plugin_OnOff, + be_nested_map(3, + ( (struct bmapnode*) &(const bmapnode[]) { + { be_const_key_weak(DISPLAY_NAME, -1), be_nested_str_weak(Light_X200_X20On) }, + { be_const_key_weak(TYPE, -1), be_nested_str_weak(light0) }, + { be_const_key_weak(TYPES, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_map, { + be_const_map( * be_nested_map(1, + ( (struct bmapnode*) &(const bmapnode[]) { + { be_const_key_int(256, -1), be_const_int(2) }, + })) ) } )) }, + })), + be_str_weak(Matter_Plugin_Light0) +); +/*******************************************************************/ + +void be_load_Matter_Plugin_Light0_class(bvm *vm) { + be_pushntvclass(vm, &be_class_Matter_Plugin_Light0); + be_setglobal(vm, "Matter_Plugin_Light0"); + be_pop(vm, 1); +} +/********************************************************************/ +/* End of solidification */ diff --git a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_3_Light1.h b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_3_Light1.h deleted file mode 100644 index 2d227550a83c..000000000000 --- a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_3_Light1.h +++ /dev/null @@ -1,663 +0,0 @@ -/* Solidification of Matter_Plugin_3_Light1.h */ -/********************************************************************\ -* Generated code, don't edit * -\********************************************************************/ -#include "be_constobj.h" - -extern const bclass be_class_Matter_Plugin_Light1; - -/******************************************************************** -** Solidified function: set_bri -********************************************************************/ -be_local_closure(Matter_Plugin_Light1_set_bri, /* name */ - be_nested_proto( - 11, /* nstack */ - 3, /* argc */ - 2, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[12]) { /* constants */ - /* K0 */ be_const_int(0), - /* K1 */ be_nested_str_weak(VIRTUAL), - /* K2 */ be_nested_str_weak(light), - /* K3 */ be_nested_str_weak(tasmota), - /* K4 */ be_nested_str_weak(scale_uint), - /* K5 */ be_nested_str_weak(set), - /* K6 */ be_nested_str_weak(bri), - /* K7 */ be_nested_str_weak(power), - /* K8 */ be_nested_str_weak(update_shadow), - /* K9 */ be_nested_str_weak(shadow_onoff), - /* K10 */ be_nested_str_weak(attribute_updated), - /* K11 */ be_nested_str_weak(shadow_bri), - }), - be_str_weak(set_bri), - &be_const_str_solidified, - ( &(const binstruction[65]) { /* code */ - 0x140C0300, // 0000 LT R3 R1 K0 - 0x780E0000, // 0001 JMPF R3 #0003 - 0x58040000, // 0002 LDCONST R1 K0 - 0x540E00FD, // 0003 LDINT R3 254 - 0x240C0203, // 0004 GT R3 R1 R3 - 0x780E0000, // 0005 JMPF R3 #0007 - 0x540600FD, // 0006 LDINT R1 254 - 0x4C0C0000, // 0007 LDNIL R3 - 0x200C0403, // 0008 NE R3 R2 R3 - 0x780E0003, // 0009 JMPF R3 #000E - 0x600C0017, // 000A GETGBL R3 G23 - 0x5C100400, // 000B MOVE R4 R2 - 0x7C0C0200, // 000C CALL R3 1 - 0x70020000, // 000D JMP #000F - 0x4C0C0000, // 000E LDNIL R3 - 0x5C080600, // 000F MOVE R2 R3 - 0x880C0101, // 0010 GETMBR R3 R0 K1 - 0x740E001A, // 0011 JMPT R3 #002D - 0xA40E0400, // 0012 IMPORT R3 K2 - 0xB8120600, // 0013 GETNGBL R4 K3 - 0x8C100904, // 0014 GETMET R4 R4 K4 - 0x5C180200, // 0015 MOVE R6 R1 - 0x581C0000, // 0016 LDCONST R7 K0 - 0x542200FD, // 0017 LDINT R8 254 - 0x58240000, // 0018 LDCONST R9 K0 - 0x542A00FE, // 0019 LDINT R10 255 - 0x7C100C00, // 001A CALL R4 6 - 0x4C140000, // 001B LDNIL R5 - 0x1C140405, // 001C EQ R5 R2 R5 - 0x78160005, // 001D JMPF R5 #0024 - 0x8C140705, // 001E GETMET R5 R3 K5 - 0x601C0013, // 001F GETGBL R7 G19 - 0x7C1C0000, // 0020 CALL R7 0 - 0x981E0C04, // 0021 SETIDX R7 K6 R4 - 0x7C140400, // 0022 CALL R5 2 - 0x70020005, // 0023 JMP #002A - 0x8C140705, // 0024 GETMET R5 R3 K5 - 0x601C0013, // 0025 GETGBL R7 G19 - 0x7C1C0000, // 0026 CALL R7 0 - 0x981E0C04, // 0027 SETIDX R7 K6 R4 - 0x981E0E02, // 0028 SETIDX R7 K7 R2 - 0x7C140400, // 0029 CALL R5 2 - 0x8C140108, // 002A GETMET R5 R0 K8 - 0x7C140200, // 002B CALL R5 1 - 0x70020012, // 002C JMP #0040 - 0x4C0C0000, // 002D LDNIL R3 - 0x200C0403, // 002E NE R3 R2 R3 - 0x780E0007, // 002F JMPF R3 #0038 - 0x880C0109, // 0030 GETMBR R3 R0 K9 - 0x200C0403, // 0031 NE R3 R2 R3 - 0x780E0004, // 0032 JMPF R3 #0038 - 0x8C0C010A, // 0033 GETMET R3 R0 K10 - 0x54160005, // 0034 LDINT R5 6 - 0x58180000, // 0035 LDCONST R6 K0 - 0x7C0C0600, // 0036 CALL R3 3 - 0x90021202, // 0037 SETMBR R0 K9 R2 - 0x880C010B, // 0038 GETMBR R3 R0 K11 - 0x200C0203, // 0039 NE R3 R1 R3 - 0x780E0004, // 003A JMPF R3 #0040 - 0x8C0C010A, // 003B GETMET R3 R0 K10 - 0x54160007, // 003C LDINT R5 8 - 0x58180000, // 003D LDCONST R6 K0 - 0x7C0C0600, // 003E CALL R3 3 - 0x90021601, // 003F SETMBR R0 K11 R1 - 0x80000000, // 0040 RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified function: init -********************************************************************/ -be_local_closure(Matter_Plugin_Light1_init, /* name */ - be_nested_proto( - 9, /* nstack */ - 4, /* argc */ - 2, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 3]) { /* constants */ - /* K0 */ be_nested_str_weak(init), - /* K1 */ be_nested_str_weak(shadow_bri), - /* K2 */ be_const_int(0), - }), - be_str_weak(init), - &be_const_str_solidified, - ( &(const binstruction[10]) { /* code */ - 0x60100003, // 0000 GETGBL R4 G3 - 0x5C140000, // 0001 MOVE R5 R0 - 0x7C100200, // 0002 CALL R4 1 - 0x8C100900, // 0003 GETMET R4 R4 K0 - 0x5C180200, // 0004 MOVE R6 R1 - 0x5C1C0400, // 0005 MOVE R7 R2 - 0x5C200600, // 0006 MOVE R8 R3 - 0x7C100800, // 0007 CALL R4 4 - 0x90020302, // 0008 SETMBR R0 K1 K2 - 0x80000000, // 0009 RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified function: update_shadow -********************************************************************/ -be_local_closure(Matter_Plugin_Light1_update_shadow, /* name */ - be_nested_proto( - 11, /* nstack */ - 1, /* argc */ - 2, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[11]) { /* constants */ - /* K0 */ be_nested_str_weak(VIRTUAL), - /* K1 */ be_nested_str_weak(light), - /* K2 */ be_nested_str_weak(get), - /* K3 */ be_nested_str_weak(find), - /* K4 */ be_nested_str_weak(bri), - /* K5 */ be_nested_str_weak(tasmota), - /* K6 */ be_nested_str_weak(scale_uint), - /* K7 */ be_const_int(0), - /* K8 */ be_nested_str_weak(shadow_bri), - /* K9 */ be_nested_str_weak(attribute_updated), - /* K10 */ be_nested_str_weak(update_shadow), - }), - be_str_weak(update_shadow), - &be_const_str_solidified, - ( &(const binstruction[38]) { /* code */ - 0x88040100, // 0000 GETMBR R1 R0 K0 - 0x7406001D, // 0001 JMPT R1 #0020 - 0xA4060200, // 0002 IMPORT R1 K1 - 0x8C080302, // 0003 GETMET R2 R1 K2 - 0x7C080200, // 0004 CALL R2 1 - 0x4C0C0000, // 0005 LDNIL R3 - 0x200C0403, // 0006 NE R3 R2 R3 - 0x780E0017, // 0007 JMPF R3 #0020 - 0x8C0C0503, // 0008 GETMET R3 R2 K3 - 0x58140004, // 0009 LDCONST R5 K4 - 0x4C180000, // 000A LDNIL R6 - 0x7C0C0600, // 000B CALL R3 3 - 0x4C100000, // 000C LDNIL R4 - 0x20100604, // 000D NE R4 R3 R4 - 0x78120010, // 000E JMPF R4 #0020 - 0xB8120A00, // 000F GETNGBL R4 K5 - 0x8C100906, // 0010 GETMET R4 R4 K6 - 0x5C180600, // 0011 MOVE R6 R3 - 0x581C0007, // 0012 LDCONST R7 K7 - 0x542200FE, // 0013 LDINT R8 255 - 0x58240007, // 0014 LDCONST R9 K7 - 0x542A00FD, // 0015 LDINT R10 254 - 0x7C100C00, // 0016 CALL R4 6 - 0x5C0C0800, // 0017 MOVE R3 R4 - 0x88100108, // 0018 GETMBR R4 R0 K8 - 0x20100604, // 0019 NE R4 R3 R4 - 0x78120004, // 001A JMPF R4 #0020 - 0x8C100109, // 001B GETMET R4 R0 K9 - 0x541A0007, // 001C LDINT R6 8 - 0x581C0007, // 001D LDCONST R7 K7 - 0x7C100600, // 001E CALL R4 3 - 0x90021003, // 001F SETMBR R0 K8 R3 - 0x60040003, // 0020 GETGBL R1 G3 - 0x5C080000, // 0021 MOVE R2 R0 - 0x7C040200, // 0022 CALL R1 1 - 0x8C04030A, // 0023 GETMET R1 R1 K10 - 0x7C040200, // 0024 CALL R1 1 - 0x80000000, // 0025 RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified function: read_attribute -********************************************************************/ -be_local_closure(Matter_Plugin_Light1_read_attribute, /* name */ - be_nested_proto( - 12, /* nstack */ - 4, /* argc */ - 2, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[14]) { /* constants */ - /* K0 */ be_nested_str_weak(matter), - /* K1 */ be_nested_str_weak(TLV), - /* K2 */ be_nested_str_weak(cluster), - /* K3 */ be_nested_str_weak(attribute), - /* K4 */ be_nested_str_weak(update_shadow_lazy), - /* K5 */ be_const_int(0), - /* K6 */ be_nested_str_weak(set), - /* K7 */ be_nested_str_weak(U1), - /* K8 */ be_nested_str_weak(shadow_bri), - /* K9 */ be_const_int(2), - /* K10 */ be_const_int(3), - /* K11 */ be_nested_str_weak(U4), - /* K12 */ be_const_int(1), - /* K13 */ be_nested_str_weak(read_attribute), - }), - be_str_weak(read_attribute), - &be_const_str_solidified, - ( &(const binstruction[79]) { /* code */ - 0xB8120000, // 0000 GETNGBL R4 K0 - 0x88100901, // 0001 GETMBR R4 R4 K1 - 0x88140502, // 0002 GETMBR R5 R2 K2 - 0x88180503, // 0003 GETMBR R6 R2 K3 - 0x541E0007, // 0004 LDINT R7 8 - 0x1C1C0A07, // 0005 EQ R7 R5 R7 - 0x781E003D, // 0006 JMPF R7 #0045 - 0x8C1C0104, // 0007 GETMET R7 R0 K4 - 0x7C1C0200, // 0008 CALL R7 1 - 0x1C1C0D05, // 0009 EQ R7 R6 K5 - 0x781E0005, // 000A JMPF R7 #0011 - 0x8C1C0706, // 000B GETMET R7 R3 K6 - 0x88240907, // 000C GETMBR R9 R4 K7 - 0x88280108, // 000D GETMBR R10 R0 K8 - 0x7C1C0600, // 000E CALL R7 3 - 0x80040E00, // 000F RET 1 R7 - 0x70020032, // 0010 JMP #0044 - 0x1C1C0D09, // 0011 EQ R7 R6 K9 - 0x781E0005, // 0012 JMPF R7 #0019 - 0x8C1C0706, // 0013 GETMET R7 R3 K6 - 0x88240907, // 0014 GETMBR R9 R4 K7 - 0x58280005, // 0015 LDCONST R10 K5 - 0x7C1C0600, // 0016 CALL R7 3 - 0x80040E00, // 0017 RET 1 R7 - 0x7002002A, // 0018 JMP #0044 - 0x1C1C0D0A, // 0019 EQ R7 R6 K10 - 0x781E0005, // 001A JMPF R7 #0021 - 0x8C1C0706, // 001B GETMET R7 R3 K6 - 0x88240907, // 001C GETMBR R9 R4 K7 - 0x542A00FD, // 001D LDINT R10 254 - 0x7C1C0600, // 001E CALL R7 3 - 0x80040E00, // 001F RET 1 R7 - 0x70020022, // 0020 JMP #0044 - 0x541E000E, // 0021 LDINT R7 15 - 0x1C1C0C07, // 0022 EQ R7 R6 R7 - 0x781E0005, // 0023 JMPF R7 #002A - 0x8C1C0706, // 0024 GETMET R7 R3 K6 - 0x88240907, // 0025 GETMBR R9 R4 K7 - 0x58280005, // 0026 LDCONST R10 K5 - 0x7C1C0600, // 0027 CALL R7 3 - 0x80040E00, // 0028 RET 1 R7 - 0x70020019, // 0029 JMP #0044 - 0x541E0010, // 002A LDINT R7 17 - 0x1C1C0C07, // 002B EQ R7 R6 R7 - 0x781E0005, // 002C JMPF R7 #0033 - 0x8C1C0706, // 002D GETMET R7 R3 K6 - 0x88240907, // 002E GETMBR R9 R4 K7 - 0x88280108, // 002F GETMBR R10 R0 K8 - 0x7C1C0600, // 0030 CALL R7 3 - 0x80040E00, // 0031 RET 1 R7 - 0x70020010, // 0032 JMP #0044 - 0x541EFFFB, // 0033 LDINT R7 65532 - 0x1C1C0C07, // 0034 EQ R7 R6 R7 - 0x781E0005, // 0035 JMPF R7 #003C - 0x8C1C0706, // 0036 GETMET R7 R3 K6 - 0x8824090B, // 0037 GETMBR R9 R4 K11 - 0x5828000C, // 0038 LDCONST R10 K12 - 0x7C1C0600, // 0039 CALL R7 3 - 0x80040E00, // 003A RET 1 R7 - 0x70020007, // 003B JMP #0044 - 0x541EFFFC, // 003C LDINT R7 65533 - 0x1C1C0C07, // 003D EQ R7 R6 R7 - 0x781E0004, // 003E JMPF R7 #0044 - 0x8C1C0706, // 003F GETMET R7 R3 K6 - 0x8824090B, // 0040 GETMBR R9 R4 K11 - 0x542A0004, // 0041 LDINT R10 5 - 0x7C1C0600, // 0042 CALL R7 3 - 0x80040E00, // 0043 RET 1 R7 - 0x70020008, // 0044 JMP #004E - 0x601C0003, // 0045 GETGBL R7 G3 - 0x5C200000, // 0046 MOVE R8 R0 - 0x7C1C0200, // 0047 CALL R7 1 - 0x8C1C0F0D, // 0048 GETMET R7 R7 K13 - 0x5C240200, // 0049 MOVE R9 R1 - 0x5C280400, // 004A MOVE R10 R2 - 0x5C2C0600, // 004B MOVE R11 R3 - 0x7C1C0800, // 004C CALL R7 4 - 0x80040E00, // 004D RET 1 R7 - 0x80000000, // 004E RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified function: update_virtual -********************************************************************/ -be_local_closure(Matter_Plugin_Light1_update_virtual, /* name */ - be_nested_proto( - 8, /* nstack */ - 2, /* argc */ - 2, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 5]) { /* constants */ - /* K0 */ be_nested_str_weak(find), - /* K1 */ be_nested_str_weak(Power), - /* K2 */ be_nested_str_weak(Bri), - /* K3 */ be_nested_str_weak(set_bri), - /* K4 */ be_nested_str_weak(update_virtual), - }), - be_str_weak(update_virtual), - &be_const_str_solidified, - ( &(const binstruction[23]) { /* code */ - 0x8C080300, // 0000 GETMET R2 R1 K0 - 0x58100001, // 0001 LDCONST R4 K1 - 0x7C080400, // 0002 CALL R2 2 - 0x8C0C0300, // 0003 GETMET R3 R1 K0 - 0x58140002, // 0004 LDCONST R5 K2 - 0x7C0C0400, // 0005 CALL R3 2 - 0x4C100000, // 0006 LDNIL R4 - 0x20100604, // 0007 NE R4 R3 R4 - 0x78120006, // 0008 JMPF R4 #0010 - 0x8C100103, // 0009 GETMET R4 R0 K3 - 0x60180009, // 000A GETGBL R6 G9 - 0x5C1C0600, // 000B MOVE R7 R3 - 0x7C180200, // 000C CALL R6 1 - 0x5C1C0400, // 000D MOVE R7 R2 - 0x7C100600, // 000E CALL R4 3 - 0x80000800, // 000F RET 0 - 0x60100003, // 0010 GETGBL R4 G3 - 0x5C140000, // 0011 MOVE R5 R0 - 0x7C100200, // 0012 CALL R4 1 - 0x8C100904, // 0013 GETMET R4 R4 K4 - 0x5C180200, // 0014 MOVE R6 R1 - 0x7C100400, // 0015 CALL R4 2 - 0x80000000, // 0016 RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified function: invoke_request -********************************************************************/ -be_local_closure(Matter_Plugin_Light1_invoke_request, /* name */ - be_nested_proto( - 22, /* nstack */ - 4, /* argc */ - 2, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[21]) { /* constants */ - /* K0 */ be_nested_str_weak(light), - /* K1 */ be_nested_str_weak(matter), - /* K2 */ be_nested_str_weak(TLV), - /* K3 */ be_nested_str_weak(cluster), - /* K4 */ be_nested_str_weak(command), - /* K5 */ be_nested_str_weak(update_shadow_lazy), - /* K6 */ be_const_int(0), - /* K7 */ be_nested_str_weak(findsubval), - /* K8 */ be_nested_str_weak(set_bri), - /* K9 */ be_nested_str_weak(log), - /* K10 */ be_nested_str_weak(bri_X3A), - /* K11 */ be_nested_str_weak(publish_command), - /* K12 */ be_nested_str_weak(Bri), - /* K13 */ be_nested_str_weak(Dimmer), - /* K14 */ be_nested_str_weak(tasmota), - /* K15 */ be_nested_str_weak(scale_uint), - /* K16 */ be_const_int(1), - /* K17 */ be_const_int(2), - /* K18 */ be_const_int(3), - /* K19 */ be_nested_str_weak(Power), - /* K20 */ be_nested_str_weak(invoke_request), - }), - be_str_weak(invoke_request), - &be_const_str_solidified, - ( &(const binstruction[119]) { /* code */ - 0xA4120000, // 0000 IMPORT R4 K0 - 0xB8160200, // 0001 GETNGBL R5 K1 - 0x88140B02, // 0002 GETMBR R5 R5 K2 - 0x88180703, // 0003 GETMBR R6 R3 K3 - 0x881C0704, // 0004 GETMBR R7 R3 K4 - 0x54220007, // 0005 LDINT R8 8 - 0x1C200C08, // 0006 EQ R8 R6 R8 - 0x78220064, // 0007 JMPF R8 #006D - 0x8C200105, // 0008 GETMET R8 R0 K5 - 0x7C200200, // 0009 CALL R8 1 - 0x1C200F06, // 000A EQ R8 R7 K6 - 0x7822001A, // 000B JMPF R8 #0027 - 0x8C200507, // 000C GETMET R8 R2 K7 - 0x58280006, // 000D LDCONST R10 K6 - 0x7C200400, // 000E CALL R8 2 - 0x8C240108, // 000F GETMET R9 R0 K8 - 0x5C2C1000, // 0010 MOVE R11 R8 - 0x7C240400, // 0011 CALL R9 2 - 0x60240008, // 0012 GETGBL R9 G8 - 0x5C281000, // 0013 MOVE R10 R8 - 0x7C240200, // 0014 CALL R9 1 - 0x00261409, // 0015 ADD R9 K10 R9 - 0x900E1209, // 0016 SETMBR R3 K9 R9 - 0x8C24010B, // 0017 GETMET R9 R0 K11 - 0x582C000C, // 0018 LDCONST R11 K12 - 0x5C301000, // 0019 MOVE R12 R8 - 0x5834000D, // 001A LDCONST R13 K13 - 0xB83A1C00, // 001B GETNGBL R14 K14 - 0x8C381D0F, // 001C GETMET R14 R14 K15 - 0x5C401000, // 001D MOVE R16 R8 - 0x58440006, // 001E LDCONST R17 K6 - 0x544A00FD, // 001F LDINT R18 254 - 0x584C0006, // 0020 LDCONST R19 K6 - 0x54520063, // 0021 LDINT R20 100 - 0x7C380C00, // 0022 CALL R14 6 - 0x7C240A00, // 0023 CALL R9 5 - 0x50240200, // 0024 LDBOOL R9 1 0 - 0x80041200, // 0025 RET 1 R9 - 0x70020044, // 0026 JMP #006C - 0x1C200F10, // 0027 EQ R8 R7 K16 - 0x78220002, // 0028 JMPF R8 #002C - 0x50200200, // 0029 LDBOOL R8 1 0 - 0x80041000, // 002A RET 1 R8 - 0x7002003F, // 002B JMP #006C - 0x1C200F11, // 002C EQ R8 R7 K17 - 0x78220002, // 002D JMPF R8 #0031 - 0x50200200, // 002E LDBOOL R8 1 0 - 0x80041000, // 002F RET 1 R8 - 0x7002003A, // 0030 JMP #006C - 0x1C200F12, // 0031 EQ R8 R7 K18 - 0x78220002, // 0032 JMPF R8 #0036 - 0x50200200, // 0033 LDBOOL R8 1 0 - 0x80041000, // 0034 RET 1 R8 - 0x70020035, // 0035 JMP #006C - 0x54220003, // 0036 LDINT R8 4 - 0x1C200E08, // 0037 EQ R8 R7 R8 - 0x78220021, // 0038 JMPF R8 #005B - 0x8C200507, // 0039 GETMET R8 R2 K7 - 0x58280006, // 003A LDCONST R10 K6 - 0x7C200400, // 003B CALL R8 2 - 0x24241106, // 003C GT R9 R8 K6 - 0x8C280108, // 003D GETMET R10 R0 K8 - 0x5C301000, // 003E MOVE R12 R8 - 0x5C341200, // 003F MOVE R13 R9 - 0x7C280600, // 0040 CALL R10 3 - 0x60280008, // 0041 GETGBL R10 G8 - 0x5C2C1000, // 0042 MOVE R11 R8 - 0x7C280200, // 0043 CALL R10 1 - 0x002A140A, // 0044 ADD R10 K10 R10 - 0x900E120A, // 0045 SETMBR R3 K9 R10 - 0x8C28010B, // 0046 GETMET R10 R0 K11 - 0x5830000C, // 0047 LDCONST R12 K12 - 0x5C341000, // 0048 MOVE R13 R8 - 0x5838000D, // 0049 LDCONST R14 K13 - 0xB83E1C00, // 004A GETNGBL R15 K14 - 0x8C3C1F0F, // 004B GETMET R15 R15 K15 - 0x5C441000, // 004C MOVE R17 R8 - 0x58480006, // 004D LDCONST R18 K6 - 0x544E00FD, // 004E LDINT R19 254 - 0x58500006, // 004F LDCONST R20 K6 - 0x54560063, // 0050 LDINT R21 100 - 0x7C3C0C00, // 0051 CALL R15 6 - 0x58400013, // 0052 LDCONST R16 K19 - 0x78260001, // 0053 JMPF R9 #0056 - 0x58440010, // 0054 LDCONST R17 K16 - 0x70020000, // 0055 JMP #0057 - 0x58440006, // 0056 LDCONST R17 K6 - 0x7C280E00, // 0057 CALL R10 7 - 0x50280200, // 0058 LDBOOL R10 1 0 - 0x80041400, // 0059 RET 1 R10 - 0x70020010, // 005A JMP #006C - 0x54220004, // 005B LDINT R8 5 - 0x1C200E08, // 005C EQ R8 R7 R8 - 0x78220002, // 005D JMPF R8 #0061 - 0x50200200, // 005E LDBOOL R8 1 0 - 0x80041000, // 005F RET 1 R8 - 0x7002000A, // 0060 JMP #006C - 0x54220005, // 0061 LDINT R8 6 - 0x1C200E08, // 0062 EQ R8 R7 R8 - 0x78220002, // 0063 JMPF R8 #0067 - 0x50200200, // 0064 LDBOOL R8 1 0 - 0x80041000, // 0065 RET 1 R8 - 0x70020004, // 0066 JMP #006C - 0x54220006, // 0067 LDINT R8 7 - 0x1C200E08, // 0068 EQ R8 R7 R8 - 0x78220001, // 0069 JMPF R8 #006C - 0x50200200, // 006A LDBOOL R8 1 0 - 0x80041000, // 006B RET 1 R8 - 0x70020008, // 006C JMP #0076 - 0x60200003, // 006D GETGBL R8 G3 - 0x5C240000, // 006E MOVE R9 R0 - 0x7C200200, // 006F CALL R8 1 - 0x8C201114, // 0070 GETMET R8 R8 K20 - 0x5C280200, // 0071 MOVE R10 R1 - 0x5C2C0400, // 0072 MOVE R11 R2 - 0x5C300600, // 0073 MOVE R12 R3 - 0x7C200800, // 0074 CALL R8 4 - 0x80041000, // 0075 RET 1 R8 - 0x80000000, // 0076 RET 0 - }) - ) -); -/*******************************************************************/ - - -/******************************************************************** -** Solidified class: Matter_Plugin_Light1 -********************************************************************/ -extern const bclass be_class_Matter_Plugin_Light0; -be_local_class(Matter_Plugin_Light1, - 1, - &be_class_Matter_Plugin_Light0, - be_nested_map(12, - ( (struct bmapnode*) &(const bmapnode[]) { - { be_const_key_weak(invoke_request, -1), be_const_closure(Matter_Plugin_Light1_invoke_request_closure) }, - { be_const_key_weak(shadow_bri, 7), be_const_var(0) }, - { be_const_key_weak(TYPES, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_map, { - be_const_map( * be_nested_map(1, - ( (struct bmapnode*) &(const bmapnode[]) { - { be_const_key_int(257, -1), be_const_int(2) }, - })) ) } )) }, - { be_const_key_weak(UPDATE_COMMANDS, 4), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(2, - ( (struct bvalue*) &(const bvalue[]) { - be_nested_str_weak(Power), - be_nested_str_weak(Bri), - })) ) } )) }, - { be_const_key_weak(init, -1), be_const_closure(Matter_Plugin_Light1_init_closure) }, - { be_const_key_weak(update_shadow, -1), be_const_closure(Matter_Plugin_Light1_update_shadow_closure) }, - { be_const_key_weak(read_attribute, -1), be_const_closure(Matter_Plugin_Light1_read_attribute_closure) }, - { be_const_key_weak(TYPE, 5), be_nested_str_weak(light1) }, - { be_const_key_weak(update_virtual, -1), be_const_closure(Matter_Plugin_Light1_update_virtual_closure) }, - { be_const_key_weak(DISPLAY_NAME, -1), be_nested_str_weak(Light_X201_X20Dimmer) }, - { be_const_key_weak(CLUSTERS, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_map, { - be_const_map( * be_nested_map(7, - ( (struct bmapnode*) &(const bmapnode[]) { - { be_const_key_int(29, 2), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(6, - ( (struct bvalue*) &(const bvalue[]) { - be_const_int(0), - be_const_int(1), - be_const_int(2), - be_const_int(3), - be_const_int(65532), - be_const_int(65533), - })) ) } )) }, - { be_const_key_int(8, 0), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(7, - ( (struct bvalue*) &(const bvalue[]) { - be_const_int(0), - be_const_int(2), - be_const_int(3), - be_const_int(15), - be_const_int(17), - be_const_int(65532), - be_const_int(65533), - })) ) } )) }, - { be_const_key_int(57, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(7, - ( (struct bvalue*) &(const bvalue[]) { - be_const_int(17), - be_const_int(3), - be_const_int(5), - be_const_int(10), - be_const_int(15), - be_const_int(17), - be_const_int(18), - })) ) } )) }, - { be_const_key_int(3, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(4, - ( (struct bvalue*) &(const bvalue[]) { - be_const_int(0), - be_const_int(1), - be_const_int(65532), - be_const_int(65533), - })) ) } )) }, - { be_const_key_int(4, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(3, - ( (struct bvalue*) &(const bvalue[]) { - be_const_int(0), - be_const_int(65532), - be_const_int(65533), - })) ) } )) }, - { be_const_key_int(5, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(8, - ( (struct bvalue*) &(const bvalue[]) { - be_const_int(0), - be_const_int(1), - be_const_int(2), - be_const_int(3), - be_const_int(4), - be_const_int(5), - be_const_int(65532), - be_const_int(65533), - })) ) } )) }, - { be_const_key_int(6, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { - be_const_list( * be_nested_list(3, - ( (struct bvalue*) &(const bvalue[]) { - be_const_int(0), - be_const_int(65532), - be_const_int(65533), - })) ) } )) }, - })) ) } )) }, - { be_const_key_weak(set_bri, 0), be_const_closure(Matter_Plugin_Light1_set_bri_closure) }, - })), - be_str_weak(Matter_Plugin_Light1) -); -/*******************************************************************/ - -void be_load_Matter_Plugin_Light1_class(bvm *vm) { - be_pushntvclass(vm, &be_class_Matter_Plugin_Light1); - be_setglobal(vm, "Matter_Plugin_Light1"); - be_pop(vm, 1); -} -/********************************************************************/ -/* End of solidification */ diff --git a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_4_Light2.h b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_3_Light2.h similarity index 99% rename from lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_4_Light2.h rename to lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_3_Light2.h index a52eb72295d2..623e34ed5bcf 100644 --- a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_4_Light2.h +++ b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_3_Light2.h @@ -1,4 +1,4 @@ -/* Solidification of Matter_Plugin_4_Light2.h */ +/* Solidification of Matter_Plugin_3_Light2.h */ /********************************************************************\ * Generated code, don't edit * \********************************************************************/ diff --git a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_4_Light3.h b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_3_Light3.h similarity index 99% rename from lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_4_Light3.h rename to lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_3_Light3.h index 538d02b80427..8d3ee8ad0fdc 100644 --- a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_4_Light3.h +++ b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_3_Light3.h @@ -1,4 +1,4 @@ -/* Solidification of Matter_Plugin_4_Light3.h */ +/* Solidification of Matter_Plugin_3_Light3.h */ /********************************************************************\ * Generated code, don't edit * \********************************************************************/ From 3412c17e2d772ed8f0ea6797c959a1e9c279d2e9 Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Fri, 20 Oct 2023 18:24:39 +0200 Subject: [PATCH 014/186] Add latest Matter changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eab373678faa..8d34eddb6613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. ### Changed - Prepare I2C drivers for bus2 support +- Matter Light0 now accept a Relay number ### Fixed - NeoPool filtration mode display (#19801) From bd90363565a0a3e8eac81093d31e44356d1b708e Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:48:12 +0200 Subject: [PATCH 015/186] Update changelogs --- CHANGELOG.md | 2 +- RELEASENOTES.md | 1 + tasmota/tasmota_xsns_sensor/xsns_12_ads1115.ino | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d34eddb6613..c8367101868c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ All notable changes to this project will be documented in this file. ### Changed - Prepare I2C drivers for bus2 support -- Matter Light0 now accept a Relay number +- Matter Light0 now accept a Relay number (#19809) ### Fixed - NeoPool filtration mode display (#19801) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index b0b1fe8b003b..598c913742a2 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -123,6 +123,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ### Breaking Changed ### Changed +- Matter Light0 now accept a Relay number [#19809](https://github.com/arendst/Tasmota/issues/19809) ### Fixed - NeoPool filtration mode display [#19801](https://github.com/arendst/Tasmota/issues/19801) diff --git a/tasmota/tasmota_xsns_sensor/xsns_12_ads1115.ino b/tasmota/tasmota_xsns_sensor/xsns_12_ads1115.ino index a4a892ae5f6b..11dbda0f919a 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_12_ads1115.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_12_ads1115.ino @@ -183,7 +183,7 @@ void Ads1115Detect(void) { I2cValidRead16(&buffer, ads1115_addresses[i], ADS1115_REG_POINTER_CONFIG, bus)) { Ads1115[ads1115_count].address = ads1115_addresses[i]; Ads1115[ads1115_count].bus = bus; - Ads1115StartComparator(ads1115_count, i, ADS1115_REG_CONFIG_MODE_CONTIN); + Ads1115StartComparator(ads1115_count, 0, ADS1115_REG_CONFIG_MODE_CONTIN); I2cSetActiveFound(Ads1115[ads1115_count].address, "ADS1115", Ads1115[ads1115_count].bus); ads1115_count++; if (4 == ads1115_count) { return; } From bec0c277501b2d601f07c4417d7ee86d6e360859 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 21 Oct 2023 15:31:54 +0200 Subject: [PATCH 016/186] Add I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor --- CHANGELOG.md | 1 + I2CDEVICES.md | 6 ++-- RELEASENOTES.md | 1 + .../tasmota_xsns_sensor/xsns_24_si1145.ino | 33 +++++++++---------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8367101868c..ed9ade0a19b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file. - I2C bus2 support to ADS1115 A/D Converter - I2C bus2 support to SHTxX temperature and humidity sensor - I2C bus2 support to HYTxxx temperature and humidity sensor +- I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor ### Breaking Changed diff --git a/I2CDEVICES.md b/I2CDEVICES.md index a8ced405701e..981ae465b8ba 100644 --- a/I2CDEVICES.md +++ b/I2CDEVICES.md @@ -37,9 +37,9 @@ Index | Define | Driver | Device | Address(es) | Bus2 | Descrip 16 | USE_TSL2561 | xsns_16 | TSL2561 | 0x29, 0x39, 0x49 | | Light intensity sensor 17 | USE_MGS | xsns_19 | Grove | 0x04 | | Multichannel gas sensor 18 | USE_SGP30 | xsns_21 | SGP30 | 0x58 | | Gas (TVOC) and air quality sensor - 19 | USE_SI1145 | xsns_24 | SI1145 | 0x60 | | Ultra violet index and light sensor - 19 | USE_SI1145 | xsns_24 | SI1146 | 0x60 | | Ultra violet index and light sensor - 19 | USE_SI1145 | xsns_24 | SI1147 | 0x60 | | Ultra violet index and light sensor + 19 | USE_SI1145 | xsns_24 | SI1145 | 0x60 | Yes | Ultra violet index and light sensor + 19 | USE_SI1145 | xsns_24 | SI1146 | 0x60 | Yes | Ultra violet index and light sensor + 19 | USE_SI1145 | xsns_24 | SI1147 | 0x60 | Yes | Ultra violet index and light sensor 20 | USE_LM75AD | xsns_26 | LM75AD | 0x48 - 0x4F | | Temperature sensor 21 | USE_APDS9960 | xsns_27 | APDS9960 | 0x39 | | Proximity ambient light RGB and gesture sensor 22 | USE_MCP230xx | xsns_29 | MCP23008 | 0x20 - 0x26 | | 8-bit I/O expander diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 598c913742a2..979261865292 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -119,6 +119,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - I2C bus2 support to ADS1115 A/D Converter - I2C bus2 support to SHTxX temperature and humidity sensor - I2C bus2 support to HYTxxx temperature and humidity sensor +- I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor ### Breaking Changed diff --git a/tasmota/tasmota_xsns_sensor/xsns_24_si1145.ino b/tasmota/tasmota_xsns_sensor/xsns_24_si1145.ino index 0f4df82e5f86..0cdc73a36d9f 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_24_si1145.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_24_si1145.ino @@ -188,27 +188,24 @@ uint16_t si1145_infrared; uint16_t si1145_uvindex; bool si1145_type = false; +uint8_t si1145_bus = 0; uint8_t si1145_valid = 0; /********************************************************************************************/ -uint8_t Si1145ReadByte(uint8_t reg) -{ - return I2cRead8(SI114X_ADDR, reg); +uint8_t Si1145ReadByte(uint8_t reg) { + return I2cRead8(SI114X_ADDR, reg, si1145_bus); } -uint16_t Si1145ReadHalfWord(uint8_t reg) -{ - return I2cRead16LE(SI114X_ADDR, reg); +uint16_t Si1145ReadHalfWord(uint8_t reg) { + return I2cRead16LE(SI114X_ADDR, reg, si1145_bus); } -void Si1145WriteByte(uint8_t reg, uint16_t val) -{ - I2cWrite8(SI114X_ADDR, reg, val); +void Si1145WriteByte(uint8_t reg, uint16_t val) { + I2cWrite8(SI114X_ADDR, reg, val, si1145_bus); } -uint8_t Si1145WriteParamData(uint8_t p, uint8_t v) -{ +uint8_t Si1145WriteParamData(uint8_t p, uint8_t v) { Si1145WriteByte(SI114X_WR, v); Si1145WriteByte(SI114X_COMMAND, p | SI114X_SET); return Si1145ReadByte(SI114X_RD); @@ -324,13 +321,15 @@ bool Si1145Read(void) return true; } -void Si1145Detect(void) -{ - if (!I2cSetDevice(SI114X_ADDR)) { return; } +void Si1145Detect(void) { + for (si1145_bus = 0; si1145_bus < 2; si1145_bus++) { + if (!I2cSetDevice(SI114X_ADDR, si1145_bus)) { continue; } - if (Si1145Begin()) { - si1145_type = true; - I2cSetActiveFound(SI114X_ADDR, "SI1145"); + if (Si1145Begin()) { + si1145_type = true; + I2cSetActiveFound(SI114X_ADDR, "SI1145", si1145_bus); + return; + } } } From 6efe2ab5142784d46e42d82583acf13b6e9b7982 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 21 Oct 2023 15:42:32 +0200 Subject: [PATCH 017/186] Add I2C bus2 support to LM75AD temperature sensor --- CHANGELOG.md | 1 + I2CDEVICES.md | 2 +- RELEASENOTES.md | 1 + .../tasmota_xsns_sensor/xsns_26_lm75ad.ino | 36 +++++++++---------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed9ade0a19b1..4ce6f0948269 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. - I2C bus2 support to SHTxX temperature and humidity sensor - I2C bus2 support to HYTxxx temperature and humidity sensor - I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor +- I2C bus2 support to LM75AD temperature sensor ### Breaking Changed diff --git a/I2CDEVICES.md b/I2CDEVICES.md index 981ae465b8ba..1a8500954b3f 100644 --- a/I2CDEVICES.md +++ b/I2CDEVICES.md @@ -40,7 +40,7 @@ Index | Define | Driver | Device | Address(es) | Bus2 | Descrip 19 | USE_SI1145 | xsns_24 | SI1145 | 0x60 | Yes | Ultra violet index and light sensor 19 | USE_SI1145 | xsns_24 | SI1146 | 0x60 | Yes | Ultra violet index and light sensor 19 | USE_SI1145 | xsns_24 | SI1147 | 0x60 | Yes | Ultra violet index and light sensor - 20 | USE_LM75AD | xsns_26 | LM75AD | 0x48 - 0x4F | | Temperature sensor + 20 | USE_LM75AD | xsns_26 | LM75AD | 0x48 - 0x4F | Yes | Temperature sensor 21 | USE_APDS9960 | xsns_27 | APDS9960 | 0x39 | | Proximity ambient light RGB and gesture sensor 22 | USE_MCP230xx | xsns_29 | MCP23008 | 0x20 - 0x26 | | 8-bit I/O expander 22 | USE_MCP230xx | xsns_29 | MCP23017 | 0x20 - 0x26 | | 16-bit I/O expander diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 979261865292..2e58c19c8651 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -120,6 +120,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - I2C bus2 support to SHTxX temperature and humidity sensor - I2C bus2 support to HYTxxx temperature and humidity sensor - I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor +- I2C bus2 support to LM75AD temperature sensor ### Breaking Changed diff --git a/tasmota/tasmota_xsns_sensor/xsns_26_lm75ad.ino b/tasmota/tasmota_xsns_sensor/xsns_26_lm75ad.ino index b8c2711805f1..502deb515421 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_26_lm75ad.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_26_lm75ad.ino @@ -47,31 +47,30 @@ bool lm75ad_type = false; uint8_t lm75ad_address; +uint8_t lm75ad_bus; uint8_t lm75ad_addresses[] = { LM75AD_ADDRESS1, LM75AD_ADDRESS2, LM75AD_ADDRESS3, LM75AD_ADDRESS4, LM75AD_ADDRESS5, LM75AD_ADDRESS6, LM75AD_ADDRESS7, LM75AD_ADDRESS8 }; -void LM75ADDetect(void) -{ - for (uint32_t i = 0; i < sizeof(lm75ad_addresses); i++) { - lm75ad_address = lm75ad_addresses[i]; - if (!I2cSetDevice(lm75ad_address)) { - continue; // do not make the next step without a confirmed device on the bus - } - uint16_t buffer; - if (I2cValidRead16(&buffer, lm75ad_address, LM75_THYST_REGISTER)) { - if (buffer == 0x4B00) { - lm75ad_type = true; - I2cSetActiveFound(lm75ad_address, "LM75AD"); - break; +void LM75ADDetect(void) { + for (lm75ad_bus = 0; lm75ad_bus < 2; lm75ad_bus++) { + for (uint32_t i = 0; i < sizeof(lm75ad_addresses); i++) { + lm75ad_address = lm75ad_addresses[i]; + if (!I2cSetDevice(lm75ad_address, lm75ad_bus)) { continue; } // do not make the next step without a confirmed device on the bus + uint16_t buffer; + if (I2cValidRead16(&buffer, lm75ad_address, LM75_THYST_REGISTER, lm75ad_bus)) { + if (buffer == 0x4B00) { + lm75ad_type = true; + I2cSetActiveFound(lm75ad_address, "LM75AD", lm75ad_bus); + return; + } } } } } -float LM75ADGetTemp(void) -{ +float LM75ADGetTemp(void) { int16_t sign = 1; - uint16_t t = I2cRead16(lm75ad_address, LM75_TEMP_REGISTER); + uint16_t t = I2cRead16(lm75ad_address, LM75_TEMP_REGISTER, lm75ad_bus); if (t & 0x8000) { // we are getting a negative temperature value t = (~t) +0x20; sign = -1; @@ -80,14 +79,13 @@ float LM75ADGetTemp(void) return ConvertTemp(sign * t * 0.125f); } -void LM75ADShow(bool json) -{ +void LM75ADShow(bool json) { float t = LM75ADGetTemp(); if (json) { ResponseAppend_P(JSON_SNS_F_TEMP, "LM75AD", Settings->flag2.temperature_resolution, &t); #ifdef USE_DOMOTICZ - if (0 == TasmotaGlobal.tele_period) DomoticzFloatSensor(DZ_TEMP, t); + if (0 == TasmotaGlobal.tele_period) { DomoticzFloatSensor(DZ_TEMP, t); } #endif // USE_DOMOTICZ #ifdef USE_WEBSERVER } else { From 356de1a16aaa9b8aa0d02261286156560ccc870a Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Sat, 21 Oct 2023 15:56:40 +0200 Subject: [PATCH 018/186] Add command ``GpioRead`` (#19814) * Add command ``GpioRead`` * change output --- CHANGELOG.md | 1 + tasmota/include/i18n.h | 1 + tasmota/tasmota_support/support_command.ino | 25 +++++++++++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ce6f0948269..def2c5b3f616 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. - I2C bus2 support to HYTxxx temperature and humidity sensor - I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor - I2C bus2 support to LM75AD temperature sensor +- Add command ``GpioRead`` ### Breaking Changed diff --git a/tasmota/include/i18n.h b/tasmota/include/i18n.h index 6bf37dd978fa..66feb6fd5792 100644 --- a/tasmota/include/i18n.h +++ b/tasmota/include/i18n.h @@ -302,6 +302,7 @@ #define D_CMND_GPIO "GPIO" #define D_JSON_NOT_SUPPORTED "Not supported" #define D_CMND_GPIOS "GPIOs" +#define D_CMND_GPIOREAD "GPIORead" #define D_CMND_PWM "PWM" #define D_CMND_PWMFREQUENCY "PWMFrequency" #define D_CMND_PWMRANGE "PWMRange" diff --git a/tasmota/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino index e5c6274146c4..34182ebd20e9 100644 --- a/tasmota/tasmota_support/support_command.ino +++ b/tasmota/tasmota_support/support_command.ino @@ -27,7 +27,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix D_CMND_POWERONSTATE "|" D_CMND_PULSETIME "|" D_CMND_BLINKTIME "|" D_CMND_BLINKCOUNT "|" D_CMND_SAVEDATA "|" D_CMND_SO "|" D_CMND_SETOPTION "|" D_CMND_TEMPERATURE_RESOLUTION "|" D_CMND_HUMIDITY_RESOLUTION "|" D_CMND_PRESSURE_RESOLUTION "|" D_CMND_POWER_RESOLUTION "|" D_CMND_VOLTAGE_RESOLUTION "|" D_CMND_FREQUENCY_RESOLUTION "|" D_CMND_CURRENT_RESOLUTION "|" D_CMND_ENERGY_RESOLUTION "|" D_CMND_WEIGHT_RESOLUTION "|" - D_CMND_MODULE "|" D_CMND_MODULES "|" D_CMND_GPIO "|" D_CMND_GPIOS "|" D_CMND_TEMPLATE "|" D_CMND_PWM "|" D_CMND_PWMFREQUENCY "|" D_CMND_PWMRANGE "|" + D_CMND_MODULE "|" D_CMND_MODULES "|" D_CMND_GPIO "|" D_CMND_GPIOREAD "|" D_CMND_GPIOS "|" D_CMND_TEMPLATE "|" D_CMND_PWM "|" D_CMND_PWMFREQUENCY "|" D_CMND_PWMRANGE "|" D_CMND_BUTTONDEBOUNCE "|" D_CMND_SWITCHDEBOUNCE "|" D_CMND_SYSLOG "|" D_CMND_LOGHOST "|" D_CMND_LOGPORT "|" D_CMND_SERIALBUFFER "|" D_CMND_SERIALSEND "|" D_CMND_BAUDRATE "|" D_CMND_SERIALCONFIG "|" D_CMND_SERIALDELIMITER "|" D_CMND_IPADDRESS "|" D_CMND_NTPSERVER "|" D_CMND_AP "|" D_CMND_SSID "|" D_CMND_PASSWORD "|" D_CMND_HOSTNAME "|" D_CMND_WIFICONFIG "|" D_CMND_WIFI "|" D_CMND_DNSTIMEOUT "|" @@ -67,7 +67,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = { &CmndPowerOnState, &CmndPulsetime, &CmndBlinktime, &CmndBlinkcount, &CmndSavedata, &CmndSetoption, &CmndSetoption, &CmndTemperatureResolution, &CmndHumidityResolution, &CmndPressureResolution, &CmndPowerResolution, &CmndVoltageResolution, &CmndFrequencyResolution, &CmndCurrentResolution, &CmndEnergyResolution, &CmndWeightResolution, - &CmndModule, &CmndModules, &CmndGpio, &CmndGpios, &CmndTemplate, &CmndPwm, &CmndPwmfrequency, &CmndPwmrange, + &CmndModule, &CmndModules, &CmndGpio, &CmndGpioRead, &CmndGpios, &CmndTemplate, &CmndPwm, &CmndPwmfrequency, &CmndPwmrange, &CmndButtonDebounce, &CmndSwitchDebounce, &CmndSyslog, &CmndLoghost, &CmndLogport, &CmndSerialBuffer, &CmndSerialSend, &CmndBaudrate, &CmndSerialConfig, &CmndSerialDelimiter, &CmndIpAddress, &CmndNtpServer, &CmndAp, &CmndSsid, &CmndPassword, &CmndHostname, &CmndWifiConfig, &CmndWifi, &CmndDnsTimeout, @@ -1768,6 +1768,27 @@ void CmndGpio(void) } } +// Perform a digitalRead on each configured PGIO +void CmndGpioRead(void) +{ + myio template_gp; + TemplateGpios(&template_gp); + bool jsflg = false; + Response_P(PSTR("{\"" D_CMND_GPIOREAD "\":{")); + for (uint32_t i = 0; i < nitems(Settings->my_gp.io); i++) { + uint32_t sensor_type = template_gp.io[i]; + if ((sensor_type != GPIO_NONE) && (AGPIO(GPIO_USER) != sensor_type)) { + if (jsflg) { + ResponseAppend_P(PSTR(",")); + } + jsflg = true; + bool state = digitalRead(i); + ResponseAppend_P(PSTR("\"" D_CMND_GPIO "%d\":%d"), i, state); + } + } + ResponseAppend_P(PSTR("}}")); +} + void ShowGpios(const uint16_t *NiceList, uint32_t size, uint32_t offset, uint32_t &lines) { uint32_t ridx; uint32_t midx; From 57860b692d85a38fcb8d4d7e0d886b54eddda392 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:20:55 +0200 Subject: [PATCH 019/186] Fix GpioRead (#19810) --- CHANGELOG.md | 2 +- RELEASENOTES.md | 3 ++- tasmota/tasmota_support/support_command.ino | 15 ++++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index def2c5b3f616..162127dd80ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ All notable changes to this project will be documented in this file. - I2C bus2 support to HYTxxx temperature and humidity sensor - I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor - I2C bus2 support to LM75AD temperature sensor -- Add command ``GpioRead`` +- Command ``GpioRead`` to show input state (#19810) ### Breaking Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 2e58c19c8651..cd1fed94f6f4 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -112,7 +112,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ## Changelog v13.2.0.1 ### Added -- Experimental support for ESP32-C2 and ESP32-C6 using Arduino core v3 +- Command ``GpioRead`` to show input state [#19810](https://github.com/arendst/Tasmota/issues/19810) - I2C bus2 support to iAQ core sensor [#19799](https://github.com/arendst/Tasmota/issues/19799) - I2C bus2 support to HTU temperature and humidity sensor - I2C bus2 support to BH1750 ambient light sensor @@ -121,6 +121,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - I2C bus2 support to HYTxxx temperature and humidity sensor - I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor - I2C bus2 support to LM75AD temperature sensor +- Experimental support for ESP32-C2 and ESP32-C6 using Arduino core v3 ### Breaking Changed diff --git a/tasmota/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino index 34182ebd20e9..1ebcf936cbee 100644 --- a/tasmota/tasmota_support/support_command.ino +++ b/tasmota/tasmota_support/support_command.ino @@ -1768,16 +1768,21 @@ void CmndGpio(void) } } -// Perform a digitalRead on each configured PGIO -void CmndGpioRead(void) -{ +void CmndGpioRead(void) { + // Perform a digitalRead on each configured GPIO myio template_gp; TemplateGpios(&template_gp); bool jsflg = false; Response_P(PSTR("{\"" D_CMND_GPIOREAD "\":{")); for (uint32_t i = 0; i < nitems(Settings->my_gp.io); i++) { - uint32_t sensor_type = template_gp.io[i]; - if ((sensor_type != GPIO_NONE) && (AGPIO(GPIO_USER) != sensor_type)) { + bool sensor_active = false; + uint32_t sensor_type = template_gp.io[i]; // Template GPIO + if ((sensor_type != GPIO_NONE) && (AGPIO(GPIO_USER) != sensor_type)) { + sensor_active = true; + } else if (Settings->my_gp.io[i] != GPIO_NONE) { // Module GPIO + sensor_active = true; + } + if (sensor_active) { if (jsflg) { ResponseAppend_P(PSTR(",")); } From 0ae793a8d4fbebd09c3ce0ec4a60474776e4e1e2 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:37:31 +0200 Subject: [PATCH 020/186] Save some bytes --- tasmota/tasmota_support/support_command.ino | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tasmota/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino index 1ebcf936cbee..2c582878617d 100644 --- a/tasmota/tasmota_support/support_command.ino +++ b/tasmota/tasmota_support/support_command.ino @@ -1775,14 +1775,9 @@ void CmndGpioRead(void) { bool jsflg = false; Response_P(PSTR("{\"" D_CMND_GPIOREAD "\":{")); for (uint32_t i = 0; i < nitems(Settings->my_gp.io); i++) { - bool sensor_active = false; - uint32_t sensor_type = template_gp.io[i]; // Template GPIO - if ((sensor_type != GPIO_NONE) && (AGPIO(GPIO_USER) != sensor_type)) { - sensor_active = true; - } else if (Settings->my_gp.io[i] != GPIO_NONE) { // Module GPIO - sensor_active = true; - } - if (sensor_active) { + uint32_t sensor_type = template_gp.io[i]; // Template GPIO + if (((sensor_type != GPIO_NONE) && (AGPIO(GPIO_USER) != sensor_type)) || + (Settings->my_gp.io[i] != GPIO_NONE)) { // Module GPIO if (jsflg) { ResponseAppend_P(PSTR(",")); } From 30521027ab8aab6c7760f519fc8f66b27991fc68 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 22 Oct 2023 17:10:59 +0200 Subject: [PATCH 021/186] Keep FS intact when over flashing with VSC (#403) (#19816) --- pio-tools/get_flash_size.py | 45 ---------------------------- pio-tools/name-firmware.py | 13 ++++---- pio-tools/post_esp32.py | 59 +++++++++++++++++++++++-------------- platformio_tasmota32.ini | 3 +- 4 files changed, 46 insertions(+), 74 deletions(-) delete mode 100644 pio-tools/get_flash_size.py diff --git a/pio-tools/get_flash_size.py b/pio-tools/get_flash_size.py deleted file mode 100644 index c0480d854fd4..000000000000 --- a/pio-tools/get_flash_size.py +++ /dev/null @@ -1,45 +0,0 @@ -from os.path import join -import subprocess -from SCons.Script import COMMAND_LINE_TARGETS - -Import("env") -env = DefaultEnvironment() -platform = env.PioPlatform() - -if "upload" in COMMAND_LINE_TARGETS: - - def esp32_detect_flashsize(): - esptoolpy = join(platform.get_package_dir("tool-esptoolpy") or "", "esptool.py") - esptoolpy_flags = ["flash_id"] - esptoolpy_cmd = [env["PYTHONEXE"], esptoolpy] + esptoolpy_flags - try: - output = subprocess.run(esptoolpy_cmd, capture_output=True).stdout.splitlines() - for l in output: - if l.decode().startswith("Detected flash size: "): - size = (l.decode().split(": ")[1]) - print("Did get flash size:",size) - return size, True - return "4MB",False - except subprocess.CalledProcessError as exc: - print("Did get chip info failed with " + str(exc)) - return "4MB",False - - size, overridden = esp32_detect_flashsize() - old_flash_size = env.BoardConfig().get("upload.flash_size") - old_maximum_size = env.BoardConfig().get("upload.maximum_size") - new_maximum_size = int(size.split("MB")[0]) * 0x100000 - - if new_maximum_size > old_maximum_size: - - extra_flags = env.BoardConfig().get("build.extra_flags").split(" ") - new_flags = "" - for flag in extra_flags: - if flag.startswith("-DESP32"): - flag = f"-DESP32_{size}" - new_flags += flag + " " - env.BoardConfig().update("build.extra_flags",new_flags) - env.BoardConfig().update("upload.flash_size",size) - - env.BoardConfig().update("upload.maximum_size", new_maximum_size) - - env.Replace(TASMOTA_flash_size=size) \ No newline at end of file diff --git a/pio-tools/name-firmware.py b/pio-tools/name-firmware.py index e2d38f6fd96a..43e595117a17 100644 --- a/pio-tools/name-firmware.py +++ b/pio-tools/name-firmware.py @@ -14,12 +14,14 @@ def bin_map_copy(source, target, env): map_file = tasmotapiolib.get_final_map_path(env) bin_file = tasmotapiolib.get_final_bin_path(env) one_bin_file = bin_file + firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin") if env["PIOPLATFORM"] == "espressif32": - factory_tmp = pathlib.Path(firsttarget).with_suffix("") - factory = factory_tmp.with_suffix(factory_tmp.suffix + ".factory.bin") - one_bin_tmp = pathlib.Path(bin_file).with_suffix("") - one_bin_file = one_bin_tmp.with_suffix(one_bin_tmp.suffix + ".factory.bin") + if("safeboot" not in firmware_name): + factory_tmp = pathlib.Path(firsttarget).with_suffix("") + factory = factory_tmp.with_suffix(factory_tmp.suffix + ".factory.bin") + one_bin_tmp = pathlib.Path(bin_file).with_suffix("") + one_bin_file = one_bin_tmp.with_suffix(one_bin_tmp.suffix + ".factory.bin") # check if new target files exist and remove if necessary for f in [map_file, bin_file, one_bin_file]: @@ -31,7 +33,8 @@ def bin_map_copy(source, target, env): if env["PIOPLATFORM"] == "espressif32": # the map file is needed later for fimrmware-metrics.py shutil.copy(tasmotapiolib.get_source_map_path(env), map_file) - shutil.copy(factory, one_bin_file) + if("safeboot" not in firmware_name): + shutil.copy(factory, one_bin_file) else: map_firm = join(env.subst("$BUILD_DIR")) + os.sep + "firmware.map" shutil.copy(tasmotapiolib.get_source_map_path(env), map_firm) diff --git a/pio-tools/post_esp32.py b/pio-tools/post_esp32.py index facff33e7e87..0d1dff34efd0 100644 --- a/pio-tools/post_esp32.py +++ b/pio-tools/post_esp32.py @@ -56,6 +56,35 @@ variants_dir = join(FRAMEWORK_DIR, "variants", "tasmota") +def esp32_detect_flashsize(): + uploader = env.subst("$UPLOADER") + if not "upload" in COMMAND_LINE_TARGETS: + return "4MB",False + if not "esptool" in uploader: + return "4MB",False + else: + esptoolpy = join(platform.get_package_dir("tool-esptoolpy") or "", "esptool.py") + esptoolpy_flags = ["flash_id"] + esptoolpy_cmd = [env["PYTHONEXE"], esptoolpy] + esptoolpy_flags + try: + output = subprocess.run(esptoolpy_cmd, capture_output=True).stdout.splitlines() + for l in output: + if l.decode().startswith("Detected flash size: "): + size = (l.decode().split(": ")[1]) + print("Did get flash size:", size) + stored_flash_size_mb = env.BoardConfig().get("upload.flash_size") + stored_flash_size = int(stored_flash_size_mb.split("MB")[0]) * 0x100000 + detected_flash_size = int(size.split("MB")[0]) * 0x100000 + if detected_flash_size > stored_flash_size: + env.BoardConfig().update("upload.flash_size", size) + return size, True + return "4MB",False + except subprocess.CalledProcessError as exc: + print("Did get chip info failed with " + str(exc)) + return "4MB",False + +flash_size_from_esp, flash_size_was_overridden = esp32_detect_flashsize() + def patch_partitions_bin(size_string): partition_bin_path = join(env.subst("$BUILD_DIR"),"partitions.bin") with open(partition_bin_path, 'r+b') as file: @@ -71,15 +100,6 @@ def patch_partitions_bin(size_string): file.write(partition_data) print("New partition hash:",result.digest().hex()) -def esp32_detect_flashsize(): - if not "upload" in COMMAND_LINE_TARGETS: - return "4MB",False - size = env.get("TASMOTA_flash_size") - if size == None: - return "4MB",False - else: - return size,True - def esp32_create_chip_string(chip): tasmota_platform = env.subst("$BUILD_DIR").split(os.path.sep)[-1] tasmota_platform = tasmota_platform.split('-')[0] @@ -142,13 +162,11 @@ def esp32_copy_new_safeboot_bin(tasmota_platform,new_local_safeboot_fw): def esp32_create_combined_bin(source, target, env): #print("Generating combined binary for serial flashing") - # The offset from begin of the file where the app0 partition starts # This is defined in the partition .csv file # factory_offset = -1 # error code value - currently unused app_offset = 0x10000 # default value for "old" scheme fs_offset = -1 # error code value - flash_size_from_esp, flash_size_was_overridden = esp32_detect_flashsize() with open(env.BoardConfig().get("build.partitions")) as csv_file: print("Read partitions from ",env.BoardConfig().get("build.partitions")) @@ -188,14 +206,12 @@ def esp32_create_combined_bin(source, target, env): if not os.path.exists(variants_dir): os.makedirs(variants_dir) - if("safeboot" in firmware_name): + if "safeboot" in firmware_name: esp32_copy_new_safeboot_bin(tasmota_platform,firmware_name) else: esp32_fetch_safeboot_bin(tasmota_platform) flash_size = env.BoardConfig().get("upload.flash_size", "4MB") - if flash_size_was_overridden: - flash_size = flash_size_from_esp flash_freq = env.BoardConfig().get("build.f_flash", "40000000L") flash_freq = str(flash_freq).replace("L", "") flash_freq = str(int(int(flash_freq) / 1000000)) + "m" @@ -227,16 +243,15 @@ def esp32_create_combined_bin(source, target, env): cmd += [sect_adr, sect_file] # "main" firmware to app0 - mandatory, except we just built a new safeboot bin locally - if("safeboot" not in firmware_name): + if "safeboot" not in firmware_name: print(f" - {hex(app_offset)} | {firmware_name}") cmd += [hex(app_offset), firmware_name] else: print("Upload new safeboot binary only") -# if(fs_offset != -1): - upload_port = env.subst("$UPLOAD_PORT") - if("upload-tasmota.php" not in upload_port) and (fs_offset != -1): + upload_protocol = env.subst("$UPLOAD_PROTOCOL") + if(upload_protocol == "esptool") and (fs_offset != -1): fs_bin = join(env.subst("$BUILD_DIR"),"littlefs.bin") if exists(fs_bin): before_reset = env.BoardConfig().get("upload.before_reset", "default_reset") @@ -259,9 +274,9 @@ def esp32_create_combined_bin(source, target, env): ) print("Will use custom upload command for flashing operation to add file system defined for this build target.") - # print('Using esptool.py arguments: %s' % ' '.join(cmd)) - - esptool.main(cmd) + #print('Using esptool.py arguments: %s' % ' '.join(cmd)) + if("safeboot" not in firmware_name): + esptool.main(cmd) -env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) \ No newline at end of file +env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) diff --git a/platformio_tasmota32.ini b/platformio_tasmota32.ini index 2a640c215eff..c49c5e9a7ff4 100644 --- a/platformio_tasmota32.ini +++ b/platformio_tasmota32.ini @@ -47,7 +47,6 @@ lib_ignore = ArduinoOTA ESP32-HomeKit extra_scripts = pre:pio-tools/add_c_flags.py - ; pre:pio-tools/get_flash_size.py pre:pio-tools/gen-berry-structures.py post:pio-tools/post_esp32.py ${esp_defaults.extra_scripts} @@ -79,7 +78,7 @@ lib_ignore = ${esp32_defaults.lib_ignore} ccronexpr [core32] -platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.04/platform-espressif32.zip +platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.05/platform-espressif32.zip platform_packages = build_unflags = ${esp32_defaults.build_unflags} build_flags = ${esp32_defaults.build_flags} From 4fb02cd22e9da67a08caf5c6a6c011b1d0c7d1cb Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 22 Oct 2023 18:28:39 +0200 Subject: [PATCH 022/186] Arduino Core 3.0.0-alpha2 (#19818) --- platformio_tasmota_core3_env_sample.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio_tasmota_core3_env_sample.ini b/platformio_tasmota_core3_env_sample.ini index d1c63bfcfb62..8c3bf2c96ed2 100644 --- a/platformio_tasmota_core3_env_sample.ini +++ b/platformio_tasmota_core3_env_sample.ini @@ -22,7 +22,7 @@ ; tasmota32c6cdc-safeboot [core32_30] -platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.10/platform-espressif32.zip +platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.11/platform-espressif32.zip platform_packages = build_unflags = ${core32.build_unflags} From 4f9c7ada0485da6963fb5631ee46724da485214c Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Sun, 22 Oct 2023 21:30:36 +0200 Subject: [PATCH 023/186] Fix audio Arduino 3 (#19819) --- .../xdrv_42_0_i2s_0_lib_idf51.ino | 45 ++++++++++--------- .../xdrv_42_0_i2s_audio_idf51.ino | 2 +- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_0_lib_idf51.ino b/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_0_lib_idf51.ino index c931b9e0478a..4090d4a582bf 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_0_lib_idf51.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_0_lib_idf51.ino @@ -72,8 +72,8 @@ public: TasmotaI2S() { // set some defaults hertz = 16000; - bps = I2S_DATA_BIT_WIDTH_16BIT; - channels = 2; + bps = I2S_DATA_BIT_WIDTH_16BIT; // bps sent to consumeAudio (this is different from channels of I2S stream) + channels = 2; // number of channels sent to consumeAudio (this is different from channels of I2S stream) gainF2P6 = 32; // equivalent of 0.5 } @@ -146,7 +146,7 @@ public: inline bool getExclusive(void) const {return _exclusive; } inline uint8_t getTxMode(void) const { return _tx_mode; } - inline uint8_t getTxChannels(void) const { return channels; } + inline uint8_t getTxChannels(void) const { return _tx_channels; } inline bool getTxRunning(void) const { return _tx_running; } inline i2s_chan_handle_t getTxHandle(void) const { return _tx_handle; } #ifdef SOC_DAC_SUPPORTED @@ -174,7 +174,7 @@ public: _tx_configured = true; } } - inline void setTxChannels(uint8_t channels) { SetChannels(channels); } + inline void setTxChannels(uint8_t channels) { _tx_channels = channels; } inline void setTxRunning(bool running) { _tx_running = running; } inline void setRxMode(uint8_t mode) { _rx_mode = mode; } inline void setRxChannels(uint8_t channels) { _rx_channels = channels; } @@ -236,13 +236,14 @@ protected: // local copy of useful settings for audio // TX - bool _tx_configured = false; // true = configured, false = not configured - uint8_t _tx_mode = I2S_MODE_STD; // I2S_MODE_STD / I2S_MODE_PDM / I2S_MODE_TDM / I2S_MODE_DAC - uint8_t _tx_slot_mask = I2S_SLOT_NOCHANGE; - bool _tx_running = false; // true = enabled, false = disabled - // uint8_t _tx_channels = 2; // number of channels, 1 = mono, 2 = stereo -- `channels` + bool _tx_configured = false; // true = configured, false = not configured + uint8_t _tx_mode = I2S_MODE_STD; // I2S_MODE_STD / I2S_MODE_PDM / I2S_MODE_TDM / I2S_MODE_DAC + uint8_t _tx_slot_mask = I2S_SLOT_NOCHANGE; + bool _tx_running = false; // true = enabled, false = disabled + uint8_t _tx_channels = 2; // number of channels, 1 = mono, 2 = stereo -- `channels` i2s_chan_handle_t _tx_handle = nullptr; // I2S channel handle, automatically computed - uint8_t _tx_slot_config = I2S_SLOT_MSB;// I2S slot configuration + uint8_t _tx_slot_config = I2S_SLOT_MSB;// I2S slot configuration + uint8_t _tx_bps = 16; // bits per sample, 16 or 8 // RX bool _rx_configured = false; // true = configured, false = not configured @@ -253,6 +254,7 @@ protected: i2s_chan_handle_t _rx_handle = nullptr; // I2S channel handle, automatically computed uint8_t _rx_slot_config = I2S_SLOT_MSB;// I2S slot configuration uint16_t _rx_freq = 16000; // I2S Rx sampling frequency in Hz + uint8_t _rx_bps = 16; // bits per sample, 16 or 8 uint16_t _rx_gain = 0x10; // Microphone gain in Q12.4 format (0x10 = 1.0) int16_t _rx_dc_offset = 0x8000; // DC offset for PCM data, or 0x8000 if not set yet @@ -508,9 +510,11 @@ bool TasmotaI2S::startI2SChannel(bool tx, bool rx) { } // by default we configure for MSB 2 slots `I2S_STD_MSB_SLOT_DEFAULT_CONFIG` + i2s_slot_mode_t tx_slot_mode = (_tx_channels == 1) ? I2S_SLOT_MODE_MONO : I2S_SLOT_MODE_STEREO; + i2s_data_bit_width_t tx_data_bit_width = (_tx_bps == 8) ? I2S_DATA_BIT_WIDTH_8BIT : I2S_DATA_BIT_WIDTH_16BIT; i2s_std_config_t tx_std_cfg = { .clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(hertz), - .slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG((i2s_data_bit_width_t)bps, (i2s_slot_mode_t)channels), + .slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(tx_data_bit_width, tx_slot_mode), .gpio_cfg = { .mclk = _gpio_mclk, .bclk = _gpio_bclk, @@ -527,9 +531,9 @@ bool TasmotaI2S::startI2SChannel(bool tx, bool rx) { // change configuration if we are using PCM or PHILIPS if (_tx_slot_config == I2S_SLOT_PCM) { // PCM - tx_std_cfg.slot_cfg = I2S_STD_PCM_SLOT_DEFAULT_CONFIG((i2s_data_bit_width_t)bps, (i2s_slot_mode_t)channels); + tx_std_cfg.slot_cfg = I2S_STD_PCM_SLOT_DEFAULT_CONFIG(tx_data_bit_width, tx_slot_mode); } else if (_tx_slot_config == I2S_SLOT_PHILIPS) { // PHILIPS - tx_std_cfg.slot_cfg = I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG((i2s_data_bit_width_t)bps, (i2s_slot_mode_t)channels); + tx_std_cfg.slot_cfg = I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG(tx_data_bit_width, tx_slot_mode); } if (_tx_slot_mask != I2S_SLOT_NOCHANGE) { tx_std_cfg.slot_cfg.slot_mask = (i2s_std_slot_mask_t)_tx_slot_mask; } #if SOC_I2S_SUPPORTS_APLL @@ -577,10 +581,11 @@ bool TasmotaI2S::startI2SChannel(bool tx, bool rx) { if (rx) { gpio_num_t clk_gpio; - i2s_slot_mode_t slot_mode = (_rx_channels == 1) ? I2S_SLOT_MODE_MONO : I2S_SLOT_MODE_STEREO; - AddLog(LOG_LEVEL_DEBUG, "I2S: mic init rx_channels:%i rx_running:%i rx_handle:%p", slot_mode, _rx_running, _rx_handle); + i2s_slot_mode_t rx_slot_mode = (_rx_channels == 1) ? I2S_SLOT_MODE_MONO : I2S_SLOT_MODE_STEREO; + AddLog(LOG_LEVEL_DEBUG, "I2S: mic init rx_channels:%i rx_running:%i rx_handle:%p", rx_slot_mode, _rx_running, _rx_handle); i2s_chan_config_t rx_chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(_i2s_port, I2S_ROLE_MASTER); + i2s_data_bit_width_t rx_data_bit_width = (_rx_bps == 8) ? I2S_DATA_BIT_WIDTH_8BIT : I2S_DATA_BIT_WIDTH_16BIT; // change to 3 buffers of 512 samples rx_chan_cfg.dma_desc_num = 3; rx_chan_cfg.dma_frame_num = 512; @@ -597,7 +602,7 @@ bool TasmotaI2S::startI2SChannel(bool tx, bool rx) { i2s_pdm_rx_config_t rx_pdm_cfg = { .clk_cfg = I2S_PDM_RX_CLK_DEFAULT_CONFIG(_rx_freq), /* The default mono slot is the left slot (whose 'select pin' of the PDM microphone is pulled down) */ - .slot_cfg = I2S_PDM_RX_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_16BIT, (i2s_slot_mode_t)_rx_channels), + .slot_cfg = I2S_PDM_RX_SLOT_DEFAULT_CONFIG(rx_data_bit_width, rx_slot_mode), .gpio_cfg = { .clk = _gpio_ws, .din = _gpio_din, @@ -631,7 +636,7 @@ bool TasmotaI2S::startI2SChannel(bool tx, bool rx) { { i2s_std_config_t rx_std_cfg = { .clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(_rx_freq), - .slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_16BIT, slot_mode), + .slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(rx_data_bit_width, rx_slot_mode), .gpio_cfg = { .mclk = (gpio_num_t)Pin(GPIO_I2S_MCLK), .bclk = (gpio_num_t)Pin(GPIO_I2S_BCLK), @@ -649,7 +654,7 @@ bool TasmotaI2S::startI2SChannel(bool tx, bool rx) { err = i2s_channel_init_std_mode(_rx_handle, &rx_std_cfg); AddLog(LOG_LEVEL_DEBUG, "I2S: RX i2s_channel_init_std_mode err:%i", err); - AddLog(LOG_LEVEL_DEBUG, "I2S: RX channel in standard mode with 16 bit width on %i channel(s) initialized", slot_mode); + AddLog(LOG_LEVEL_DEBUG, "I2S: RX channel in standard mode with 16 bit width on %i channel(s) initialized", rx_slot_mode); if (err) { _rx_handle = nullptr; return false; @@ -713,8 +718,8 @@ uint32_t TasmotaI2S::startRx(void) { esp_err_t err = ESP_OK; gpio_num_t clk_gpio; - i2s_slot_mode_t slot_mode = (_rx_channels == 1) ? I2S_SLOT_MODE_MONO : I2S_SLOT_MODE_STEREO; - AddLog(LOG_LEVEL_DEBUG, "I2S: mic init rx_channels:%i rx_running:%i rx_handle:%p", slot_mode, _rx_running, _rx_handle); + i2s_slot_mode_t rx_slot_mode = (_rx_channels == 1) ? I2S_SLOT_MODE_MONO : I2S_SLOT_MODE_STEREO; + AddLog(LOG_LEVEL_DEBUG, "I2S: mic init rx_channels:%i rx_running:%i rx_handle:%p", rx_slot_mode, _rx_running, _rx_handle); if (!_rx_running) { err = i2s_channel_enable(_rx_handle); diff --git a/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_audio_idf51.ino b/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_audio_idf51.ino index 6263586d3d97..33dae7ec6847 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_audio_idf51.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_42_0_i2s_audio_idf51.ino @@ -963,7 +963,7 @@ void CmndI2SGain(void) { void CmndI2SSay(void) { if (XdrvMailbox.data_len > 0) { - if (I2SPrepareTx()) { + if (I2SPrepareTx() != I2S_OK) { ResponseCmndChar("I2S output not configured"); return; } else { From 1d5f55d3748162b87bcfad344626716ff5821f3d Mon Sep 17 00:00:00 2001 From: Barbudor Date: Mon, 23 Oct 2023 09:36:39 +0200 Subject: [PATCH 024/186] increase MAX_HUE_DEVICES to 32 (#19820) --- tasmota/include/tasmota.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/include/tasmota.h b/tasmota/include/tasmota.h index 708e015d9956..f3dc439c1db3 100644 --- a/tasmota/include/tasmota.h +++ b/tasmota/include/tasmota.h @@ -143,7 +143,7 @@ const uint8_t MAX_SWITCHES_TXT = 8; // Max number of switches user text const uint8_t MAX_SWITCHES_TXT = 28; // Max number of switches user text #endif // ESP32 -const uint8_t MAX_HUE_DEVICES = 15; // Max number of Philips Hue device per emulation +const uint8_t MAX_HUE_DEVICES = 32; // Max number of Philips Hue device per emulation const uint8_t MAX_ROTARIES = 2; // Max number of Rotary Encoders const char MQTT_TOKEN_PREFIX[] PROGMEM = "%prefix%"; // To be substituted by mqtt_prefix[x] From 84ced0fcab6f3af26602cd8fc23df5ba7bcc8c1f Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:32:39 +0200 Subject: [PATCH 025/186] Add ESP32 core v3 auto TasConsole USB or Serial connection by @staars --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + tasmota/include/tasconsole.h | 110 ++++++++++++++++++++++++++++++++++ tasmota/tasmota.ino | 111 ++++++++++++++++++++++++++++++++++- 4 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 tasmota/include/tasconsole.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 162127dd80ed..2c55cc9755db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file. - I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor - I2C bus2 support to LM75AD temperature sensor - Command ``GpioRead`` to show input state (#19810) +- ESP32 core v3 auto TasConsole USB or Serial connection by @staars ### Breaking Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index cd1fed94f6f4..37a9e5d40b4a 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -122,6 +122,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor - I2C bus2 support to LM75AD temperature sensor - Experimental support for ESP32-C2 and ESP32-C6 using Arduino core v3 +- ESP32 core v3 auto TasConsole USB or Serial connection by @staars ### Breaking Changed diff --git a/tasmota/include/tasconsole.h b/tasmota/include/tasconsole.h new file mode 100644 index 000000000000..ccb3ea93e9a7 --- /dev/null +++ b/tasmota/include/tasconsole.h @@ -0,0 +1,110 @@ +/* + tasconsole.h - ESP32 tasconsole driver for Tasmota + + SPDX-FileCopyrightText: 2023 Christian Baars (@staars) + + SPDX-License-Identifier: GPL-3.0-only +*/ + +#include + +class TASCONSOLE { + + struct Concept { + virtual ~Concept() = default; + virtual int available() = 0; + virtual void begin(uint32_t) = 0; + virtual void flush() = 0; + virtual size_t println() = 0; + virtual size_t print(char *) = 0; + virtual size_t printf(const char*, char *, const char*&, const char*&, const char*&) = 0; + virtual size_t printf(char *) = 0; + virtual size_t read() = 0; + virtual size_t setRxBufferSize(size_t) = 0; + }; + +public: + template + TASCONSOLE(T&& obj){ + object = std::make_unique>(std::forward(obj)); + } + + int available() { + return object->available(); + } + + void begin(uint32_t baud) { + object->begin(baud); + } + + void flush() { + object->flush(); + } + + size_t println() { + return object->println(); + } + + size_t print(char * string) { + return object->print(string); + } + + size_t printf(char *format) { + return object->printf(format); + } + + size_t printf(const char* a, char * b, const char*& c, const char*& d, const char*& f){ + return object->printf(a,b,c,d,f); + } + + size_t read() { + return object->read(); + } + + size_t setRxBufferSize(size_t rx_queue_len) { + return object->setRxBufferSize(rx_queue_len); + } + + template< typename T > + struct Model : Concept { + Model(T const& t) : object(t) {} + int available() override { + return object.available(); + } + + void begin(uint32_t baud) override { + object.begin(baud); + } + + void flush() override { + object.flush(); + } + + size_t println() override { + return object.println(); + } + size_t print(char * string) override { + return object.print(string); + } + + size_t printf(char *format) override { + return object.printf(format); + } + + size_t printf(const char* a, char * b, const char*& c, const char*& d, const char*& f) override { + return object.printf(a,b,c,d,f); + } + + size_t read() override { + return object.read(); + } + + size_t setRxBufferSize(size_t size) override { + return object.setRxBufferSize(size); + } + private: + T object; + }; + + std::unique_ptr object; +}; diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 39a48aff1e11..dfd56dc2b167 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -91,6 +91,14 @@ #endif // ESP32 #endif // USE_UFILESYS +#if ESP_IDF_VERSION_MAJOR >= 5 +#include "include/tasconsole.h" +#if SOC_USB_SERIAL_JTAG_SUPPORTED +#include "hal/usb_serial_jtag_ll.h" +#include "esp_private/rtc_clk.h" +#endif // SOC_USB_SERIAL_JTAG_SUPPORTED +#endif // ESP_IDF_VERSION_MAJOr + // Structs #include "include/tasmota_types.h" @@ -198,6 +206,45 @@ struct XDRVMAILBOX { WiFiUDP PortUdp; // UDP Syslog and Alexa #ifdef ESP32 +#if ESP_IDF_VERSION_MAJOR >= 5 + +/* +#if CONFIG_IDF_TARGET_ESP32C3 || // support USB via HWCDC using JTAG interface + CONFIG_IDF_TARGET_ESP32C6 || // support USB via HWCDC using JTAG interface + CONFIG_IDF_TARGET_ESP32S2 || // support USB via USBCDC + CONFIG_IDF_TARGET_ESP32S3 // support USB via HWCDC using JTAG interface or USBCDC +*/ +#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 + +//#if CONFIG_TINYUSB_CDC_ENABLED // This define is not recognized here so use USE_USB_CDC_CONSOLE +#ifdef USE_USB_CDC_CONSOLE +//#warning **** TasConsole use USB **** +bool tasconsole_serial = false; + +#if ARDUINO_USB_MODE +//#warning **** TasConsole ARDUINO_USB_MODE **** +TASCONSOLE TasConsole{USBSerial}; // ESP32C3/C6/S3 embedded USB using JTAG interface +//#warning **** TasConsole uses HWCDC **** +#else // No ARDUINO_USB_MODE +#include "USB.h" +#include "USBCDC.h" +TASCONSOLE TasConsole{USBSerial}; // ESP32Sx embedded USB interface +//#warning **** TasConsole uses USBCDC **** +#endif // ARDUINO_USB_MODE + +#else // No USE_USB_CDC_CONSOLE +TASCONSOLE TasConsole{Serial}; +bool tasconsole_serial = true; +//#warning **** TasConsole uses Serial **** +#endif // USE_USB_CDC_CONSOLE +#else // No ESP32C3, S2 or S3 +TASCONSOLE TasConsole{Serial}; +bool tasconsole_serial = true; +//#warning **** TasConsole uses Serial **** +#endif // ESP32C3, S2 or S3 + +#else // ESP_IDF_VERSION_MAJOR < 5 + /* #if CONFIG_IDF_TARGET_ESP32C3 || // support USB via HWCDC using JTAG interface CONFIG_IDF_TARGET_ESP32C6 || // support USB via HWCDC using JTAG interface @@ -235,6 +282,8 @@ bool tasconsole_serial = true; //#warning **** TasConsole uses Serial **** #endif // ESP32C3, S2 or S3 +#endif // ESP_IDF_VERSION_MAJOR >= 5 + #else // No ESP32 HardwareSerial TasConsole = Serial; // Only serial interface #endif // ESP32 @@ -478,11 +527,64 @@ void setup(void) { Settings = (TSettings*)malloc(sizeof(TSettings)); } +#ifdef ESP32 +#if ESP_IDF_VERSION_MAJOR >= 5 + +#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 +#ifdef USE_USB_CDC_CONSOLE + bool is_connected_to_USB = false; + +#if SOC_USB_SERIAL_JTAG_SUPPORTED // Not S2 + rtc_clk_bbpll_add_consumer(); // Maybe unneeded + usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SOF); + usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_INTR_SOF); + // First check if USB cable is connected - maybe add a new SetOption to prevent this + for (uint32_t i = 0; i < 1000; i++) { // Allow the host to send at least one SOF packet, 1ms should be enough but let's be very conservative here - maybe unneeded + is_connected_to_USB = ((usb_serial_jtag_ll_get_intraw_mask() & USB_SERIAL_JTAG_INTR_SOF) != 0); + if (is_connected_to_USB) { break; } + delay(1); + } + rtc_clk_bbpll_remove_consumer(); +#endif // SOC_USB_SERIAL_JTAG_SUPPORTED + + if (is_connected_to_USB) { + TasConsole.setRxBufferSize(INPUT_BUFFER_SIZE); + // TasConsole.setTxBufferSize(INPUT_BUFFER_SIZE); + TasConsole.begin(115200); // Will always be 115200 bps +#if !ARDUINO_USB_MODE + USB.begin(); // This needs a serial console with DTR/DSR support +#endif // No ARDUINO_USB_MODE + TasConsole.println(); + AddLog(LOG_LEVEL_INFO, PSTR("CMD: Using USB CDC")); + } else { + // Init command serial console preparing for AddLog use + Serial.begin(TasmotaGlobal.baudrate); + Serial.println(); + TasConsole = Serial; // Fallback + tasconsole_serial = true; + AddLog(LOG_LEVEL_INFO, PSTR("CMD: Fall back to serial port, no SOF packet detected on USB port")); + } +#else // No USE_USB_CDC_CONSOLE + // Init command serial console preparing for AddLog use + Serial.begin(TasmotaGlobal.baudrate); + Serial.println(); +// Serial.setRxBufferSize(INPUT_BUFFER_SIZE); // Default is 256 chars + TasConsole = Serial; +#endif // USE_USB_CDC_CONSOLE +#else // No ESP32C3, S2 or S3 + // Init command serial console preparing for AddLog use + Serial.begin(TasmotaGlobal.baudrate); + Serial.println(); +// Serial.setRxBufferSize(INPUT_BUFFER_SIZE); // Default is 256 chars + TasConsole = Serial; +#endif // ESP32C3, S2 or S3 + +#else // ESP_IDF_VERSION_MAJOR < 5 + // Init command console (either serial or USB) preparing for AddLog use Serial.begin(TasmotaGlobal.baudrate); Serial.println(); // Serial.setRxBufferSize(INPUT_BUFFER_SIZE); // Default is 256 chars -#ifdef ESP32 #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 #ifdef USE_USB_CDC_CONSOLE TasConsole.setRxBufferSize(INPUT_BUFFER_SIZE); @@ -499,7 +601,14 @@ void setup(void) { #else // No ESP32C3, S2 or S3 TasConsole = Serial; #endif // ESP32C3, S2 or S3 + +#endif // ESP_IDF_VERSION_MAJOR >= 5 + #else // No ESP32 + // Init command serial console preparing for AddLog use + Serial.begin(TasmotaGlobal.baudrate); + Serial.println(); +// Serial.setRxBufferSize(INPUT_BUFFER_SIZE); // Default is 256 chars TasConsole = Serial; #endif // ESP32 From 5c395ffc06a89a3b54a74480293977dd6d76e996 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:41:36 +0200 Subject: [PATCH 026/186] Fix core 3 S2 USB --- tasmota/tasmota.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index dfd56dc2b167..7b4c20a49f67 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -532,8 +532,8 @@ void setup(void) { #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 #ifdef USE_USB_CDC_CONSOLE - bool is_connected_to_USB = false; + bool is_connected_to_USB = false; #if SOC_USB_SERIAL_JTAG_SUPPORTED // Not S2 rtc_clk_bbpll_add_consumer(); // Maybe unneeded usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SOF); @@ -545,6 +545,8 @@ void setup(void) { delay(1); } rtc_clk_bbpll_remove_consumer(); +#else + is_connected_to_USB = true; // S2 #endif // SOC_USB_SERIAL_JTAG_SUPPORTED if (is_connected_to_USB) { From 84eaae572c8026e33e88ad399463f180c49a54b9 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 24 Oct 2023 17:00:11 +0200 Subject: [PATCH 027/186] Fix core 3 S2 USB --- tasmota/tasmota.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 7b4c20a49f67..bfd026f78099 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -228,6 +228,7 @@ TASCONSOLE TasConsole{USBSerial}; // ESP32C3/C6/S3 embedded USB using #else // No ARDUINO_USB_MODE #include "USB.h" #include "USBCDC.h" +USBCDC USBSerial; // ESP32Sx embedded USB interface TASCONSOLE TasConsole{USBSerial}; // ESP32Sx embedded USB interface //#warning **** TasConsole uses USBCDC **** #endif // ARDUINO_USB_MODE From d2b370ab44dc49c3562aa591b497b16c9460e223 Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:01:14 +0200 Subject: [PATCH 028/186] Fix Berry on old ESP32 (#19830) --- lib/libesp32/berry/src/be_vm.c | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/lib/libesp32/berry/src/be_vm.c b/lib/libesp32/berry/src/be_vm.c index b234308d0ce8..a9de9675f363 100644 --- a/lib/libesp32/berry/src/be_vm.c +++ b/lib/libesp32/berry/src/be_vm.c @@ -671,8 +671,17 @@ static void vm_exec(bvm *vm) if (var_isint(a) && var_isint(b)) { var_setint(dst, ibinop(-, a, b)); } else if (var_isnumber(a) && var_isnumber(b)) { +#if CONFIG_IDF_TARGET_ESP32 /* when running on ESP32 in IRAM, there is a bug in early chip revision */ + union bvaldata x, y; // TASMOTA workaround for ESP32 rev0 bug + x.i = a->v.i; + if (var_isint(a)) { x.r = (breal) x.i; } + y.i = b->v.i; + if (var_isint(b)) { y.r = (breal) y.i; } + var_setreal(dst, x.r - y.r); +#else // CONFIG_IDF_TARGET_ESP32 breal x = var2real(a), y = var2real(b); var_setreal(dst, x - y); +#endif // CONFIG_IDF_TARGET_ESP32 } else if (var_isinstance(a)) { ins_binop(vm, "-", ins); } else { @@ -685,8 +694,17 @@ static void vm_exec(bvm *vm) if (var_isint(a) && var_isint(b)) { var_setint(dst, ibinop(*, a, b)); } else if (var_isnumber(a) && var_isnumber(b)) { +#if CONFIG_IDF_TARGET_ESP32 /* when running on ESP32 in IRAM, there is a bug in early chip revision */ + union bvaldata x, y; // TASMOTA workaround for ESP32 rev0 bug + x.i = a->v.i; + if (var_isint(a)) { x.r = (breal) x.i; } + y.i = b->v.i; + if (var_isint(b)) { y.r = (breal) y.i; } + var_setreal(dst, x.r * y.r); +#else // CONFIG_IDF_TARGET_ESP32 breal x = var2real(a), y = var2real(b); var_setreal(dst, x * y); +#endif // CONFIG_IDF_TARGET_ESP32 } else if (var_isinstance(a)) { ins_binop(vm, "*", ins); } else { @@ -704,11 +722,23 @@ static void vm_exec(bvm *vm) var_setint(dst, x / y); } } else if (var_isnumber(a) && var_isnumber(b)) { +#if CONFIG_IDF_TARGET_ESP32 /* when running on ESP32 in IRAM, there is a bug in early chip revision */ + union bvaldata x, y; // TASMOTA workaround for ESP32 rev0 bug + x.i = a->v.i; + if (var_isint(a)) { x.r = (breal) x.i; } + y.i = b->v.i; + if (var_isint(b)) { y.r = (breal) y.i; } + if (y.r == cast(breal, 0)) { + vm_error(vm, "divzero_error", "division by zero"); + } + var_setreal(dst, x.r / y.r); +#else // CONFIG_IDF_TARGET_ESP32 breal x = var2real(a), y = var2real(b); if (y == cast(breal, 0)) { vm_error(vm, "divzero_error", "division by zero"); } var_setreal(dst, x / y); +#endif // CONFIG_IDF_TARGET_ESP32 } else if (var_isinstance(a)) { ins_binop(vm, "/", ins); } else { @@ -721,7 +751,16 @@ static void vm_exec(bvm *vm) if (var_isint(a) && var_isint(b)) { var_setint(dst, ibinop(%, a, b)); } else if (var_isnumber(a) && var_isnumber(b)) { +#if CONFIG_IDF_TARGET_ESP32 /* when running on ESP32 in IRAM, there is a bug in early chip revision */ + union bvaldata x, y; // TASMOTA workaround for ESP32 rev0 bug + x.i = a->v.i; + if (var_isint(a)) { x.r = (breal) x.i; } + y.i = b->v.i; + if (var_isint(b)) { y.r = (breal) y.i; } + var_setreal(dst, mathfunc(fmod)(x.r, y.r)); +#else // CONFIG_IDF_TARGET_ESP32 var_setreal(dst, mathfunc(fmod)(var_toreal(a), var_toreal(b))); +#endif // CONFIG_IDF_TARGET_ESP32 } else if (var_isinstance(a)) { ins_binop(vm, "%", ins); } else { From f45b55a18b17cffc95a780507ceb3ecfcb516705 Mon Sep 17 00:00:00 2001 From: Dellucifer <84488210+dellucifer@users.noreply.github.com> Date: Thu, 26 Oct 2023 21:34:34 +0530 Subject: [PATCH 029/186] Rectified Typos (#19841) * Rectified Typos * Update settings.json --- API.md | 2 +- CONTRIBUTING.md | 2 +- FIRMWARE.md | 2 +- info/xdrv_57_tasmesh.md | 2 +- pio-tools/espupload.py | 2 +- pio-tools/name-firmware.py | 2 +- tools/decode-status.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/API.md b/API.md index 3a7a24c78bf2..e12eea92e5f4 100644 --- a/API.md +++ b/API.md @@ -17,7 +17,7 @@ Callback Id | Bool | xdrv | xsns | xnrg | xlgt | Description ----------------------------|------|------|------|------|------|---------------------------------- FUNC_SETTINGS_OVERRIDE | | x | | | | Override start-up settings FUNC_PIN_STATE | x | 1 | 2 | | | At GPIO configuration -FUNC_I2C_INIT | | x | | | | Immediatly after I2C init +FUNC_I2C_INIT | | x | | | | Immediately after I2C init FUNC_MODULE_INIT | x | 3 | 1 | | 2 | Init module specific parameters FUNC_PRE_INIT | | 1 | 3 | 2 | | Once GPIO have been established FUNC_INIT | | 1 | 3 | 2 | | At end of initialisation diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7b15232be36e..ddb0768a5e89 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -99,7 +99,7 @@ To accept the CLA it is required to put a x between [ ] on `[ ] I accept the CLA **Why a CLA ?** -_"A Contributor Licence Agreement (CLA) is strongly recommended when accepting third party contributions to an open development project, such as an open source software project. In order to redistribute contributions, it is necessary to ensure that the project has the necessary rights to do so. A Contributor Licence Agreement is a lightweight agreement, signed by the copyright holder, that grants the necessary rights for the contribution to be redistributed as part of the project."_ [OSS Watch](http://oss-watch.ac.uk/resources/cla) +_"A Contributor License Agreement (CLA) is strongly recommended when accepting third party contributions to an open development project, such as an open source software project. In order to redistribute contributions, it is necessary to ensure that the project has the necessary rights to do so. A Contributor License Agreement is a lightweight agreement, signed by the copyright holder, that grants the necessary rights for the contribution to be redistributed as part of the project."_ [OSS Watch](http://oss-watch.ac.uk/resources/cla) A CLA is a legal document in which you state _you are entitled to contribute the code/documentation/translation to the project_ you’re contributing to and that _you are willing to have it used in distributions and derivative works_. This means that should there be any kind of legal issue in the future as to the origins and ownership of any particular piece of code, then that project has the necessary forms on file from the contributor(s) saying they were permitted to make this contribution. diff --git a/FIRMWARE.md b/FIRMWARE.md index f0e069a9a136..43f76f8d2815 100644 --- a/FIRMWARE.md +++ b/FIRMWARE.md @@ -27,7 +27,7 @@ See [CHANGELOG.md](https://github.com/arendst/Tasmota/blob/development/tasmota/C Unless your Tasmota powered device exhibits a problem or you need to make use of a feature that is not available in the Tasmota version currently installed on your device, leave your device alone - it works so don't make unnecessary changes! If the release version (i.e., the master branch) exhibits unexpected behaviour for your device and configuration, you should upgrade to the latest development version instead to see if your problem is resolved as some bugs in previous releases or development builds may already have been resolved. -If new commits have been merged and they compile successfuly, new binary files for every variant will be placed here https://github.com/arendst/Tasmota-firmware/tree/main/firmware (this URL address can NOT be used for OTA updates) It is important to note that these binaries are based on the current development codebase. These commits are tested as much as is possible and are typically quite stable. However, it is infeasible to test on the hundreds of different types of devices with all the available configuration options permitted. +If new commits have been merged and they compile successfully, new binary files for every variant will be placed here https://github.com/arendst/Tasmota-firmware/tree/main/firmware (this URL address can NOT be used for OTA updates) It is important to note that these binaries are based on the current development codebase. These commits are tested as much as is possible and are typically quite stable. However, it is infeasible to test on the hundreds of different types of devices with all the available configuration options permitted. Note that there is a chance, as with any upgrade, that the device may not function as expected. You must always account for the possibility that you may need to flash the device via the serial programming interface if the OTA upgrade fails. Even with the master release, you should always attempt to test the device or a similar prototype before upgrading a device which is in production or is hard to reach. And, as always, make a backup of the device configuration before beginning any firmware update. diff --git a/info/xdrv_57_tasmesh.md b/info/xdrv_57_tasmesh.md index 2da2fac191ff..ff7c3ee062cb 100644 --- a/info/xdrv_57_tasmesh.md +++ b/info/xdrv_57_tasmesh.md @@ -8,7 +8,7 @@ Automatic payload encryption is applied using the WiFi-password1 as the key. A m As ACK/NACK messages seem to be not reliable on both ESP-platforms, the method "send-and-pray" is used. -## Working priciple +## Working principle An ESP32 is needed as gateway/broker to connect the nodes (typically an ESP8266) to the WLAN. The ESP32 will receive the MQTT-topic of every node and subscribe to it as a proxy. If a MQTT-message in the form of 'cmnd/node_topic/...' is received, the broker will automatically send this to the referring node via ESP-NOW. diff --git a/pio-tools/espupload.py b/pio-tools/espupload.py index 8b0993a551ca..a25345e65083 100755 --- a/pio-tools/espupload.py +++ b/pio-tools/espupload.py @@ -20,7 +20,7 @@ Provides: Uploads binary file to OTA server. - Usually initated from http-uploader.py + Usually initiated from http-uploader.py Requirements: - Python diff --git a/pio-tools/name-firmware.py b/pio-tools/name-firmware.py index 43e595117a17..6b32b771fb1a 100644 --- a/pio-tools/name-firmware.py +++ b/pio-tools/name-firmware.py @@ -31,7 +31,7 @@ def bin_map_copy(source, target, env): # copy firmware.bin and map to final destination shutil.copy(firsttarget, bin_file) if env["PIOPLATFORM"] == "espressif32": - # the map file is needed later for fimrmware-metrics.py + # the map file is needed later for firmware-metrics.py shutil.copy(tasmotapiolib.get_source_map_path(env), map_file) if("safeboot" not in firmware_name): shutil.copy(factory, one_bin_file) diff --git a/tools/decode-status.py b/tools/decode-status.py index bc03d3604028..980f094678c0 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -90,7 +90,7 @@ "(Restart) Number of restarts to start detecting boot loop (default 1)", "(Light) RGB and White channel separation (default 0)", "(IR) Set the smallest sized UNKNOWN message packets we actually care about (default 6, max 255)", - "(CSE7766) Number of invalid power measurements before declaring it invalid allowing low load measurments (default 128)", + "(CSE7766) Number of invalid power measurements before declaring it invalid allowing low load measurements (default 128)", "(Button/Shutter) Ignore button change in seconds (default 0)", "(Wifi) Interval in seconds between gratuitous ARP requests (default 60)", "(Energy) Turn all power off at or above this temperature (default 90C)", From 0130ce972a32b75c4aab161d61c94419afdb6073 Mon Sep 17 00:00:00 2001 From: FransOv <57999223+FransOv@users.noreply.github.com> Date: Fri, 27 Oct 2023 17:34:49 +0200 Subject: [PATCH 030/186] Support of Winsum ZH03B sensor Dust particle sensor in xsns_18_pms5003.ino (#19850) * Update xsns_18_pms5003.ino The Winsum ZH03B sensor is quite similar to the Plantower PMS3003 sensor. The main difference is the response in passive mode. With these changes xsns_18_pms5003.ino can support the ZH03B sensor when PMS_MODEL_ZH03X is defined in the configuration file. * Update xsns_18_pms5003.ino --- .../tasmota_xsns_sensor/xsns_18_pms5003.ino | 103 ++++++++++++++++-- 1 file changed, 92 insertions(+), 11 deletions(-) diff --git a/tasmota/tasmota_xsns_sensor/xsns_18_pms5003.ino b/tasmota/tasmota_xsns_sensor/xsns_18_pms5003.ino index 9471d9c18d18..426b6e2861c5 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_18_pms5003.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_18_pms5003.ino @@ -27,6 +27,8 @@ * You can either support PMS3003 or PMS5003-7003 at one time. To enable the PMS3003 support * you must enable the define PMS_MODEL_PMS3003 on your configuration file. * For PMSx003T models that report temperature and humidity define PMS_MODEL_PMS5003T + * This module can also support de Winsen ZH03x series of dust particle sensors, + * To support those sensors, you must define PMS_MODEL_ZH03X in the confuguration file. \*********************************************************************************************/ #define XSNS_18 18 @@ -61,6 +63,15 @@ enum PmsCommands CMD_READ_DATA }; +#ifdef PMS_MODEL_ZH03X +const uint8_t kPmsCommands[][9] PROGMEM = { + // 0 1 2 3 4 5 6 7 8 + {0xFF, 0x01, 0x78, 0x40, 0x00, 0x00, 0x00, 0x00, 0x47}, // pms_set_active_mode + {0xFF, 0x01, 0xA7, 0x01, 0x00, 0x00, 0x00, 0x00, 0x57}, // pms_sleep + {0xFF, 0x01, 0xA7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58}, // pms_wake + {0xFF, 0x01, 0x78, 0x41, 0x00, 0x00, 0x00, 0x00, 0x46}, // pms_set_passive_mode + {0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79}}; // pms_passive_mode_read +#else const uint8_t kPmsCommands[][7] PROGMEM = { // 0 1 2 3 4 5 6 {0x42, 0x4D, 0xE1, 0x00, 0x01, 0x01, 0x71}, // pms_set_active_mode @@ -68,12 +79,13 @@ const uint8_t kPmsCommands[][7] PROGMEM = { {0x42, 0x4D, 0xE4, 0x00, 0x01, 0x01, 0x74}, // pms_wake {0x42, 0x4D, 0xE1, 0x00, 0x00, 0x01, 0x70}, // pms_set_passive_mode {0x42, 0x4D, 0xE2, 0x00, 0x00, 0x01, 0x71}}; // pms_passive_mode_read +#endif // PMS_MODEL_ZH03X struct pmsX003data { uint16_t framelen; uint16_t pm10_standard, pm25_standard, pm100_standard; uint16_t pm10_env, pm25_env, pm100_env; -#ifdef PMS_MODEL_PMS3003 +#if defined(PMS_MODEL_PMS3003) || defined(PMS_MODEL_ZH03X) uint16_t reserved1, reserved2, reserved3; #else uint16_t particles_03um, particles_05um, particles_10um, particles_25um; @@ -104,7 +116,7 @@ bool PmsReadData(void) while ((PmsSerial->peek() != 0x42) && PmsSerial->available()) { PmsSerial->read(); } -#ifdef PMS_MODEL_PMS3003 +#if defined(PMS_MODEL_PMS3003) || defined(PMS_MODEL_ZH03X) if (PmsSerial->available() < 24) { #else if (PmsSerial->available() < 32) { @@ -112,7 +124,7 @@ bool PmsReadData(void) return false; } -#ifdef PMS_MODEL_PMS3003 +#if defined(PMS_MODEL_PMS3003) || defined(PMS_MODEL_ZH03X) uint8_t buffer[24]; PmsSerial->readBytes(buffer, 24); #else @@ -122,14 +134,14 @@ bool PmsReadData(void) uint16_t sum = 0; PmsSerial->flush(); // Make room for another burst -#ifdef PMS_MODEL_PMS3003 +#if defined(PMS_MODEL_PMS3003) || defined(PMS_MODEL_ZH03X) AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, 24); #else AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, 32); #endif // PMS_MODEL_PMS3003 // get checksum ready -#ifdef PMS_MODEL_PMS3003 +#if defined(PMS_MODEL_PMS3003) || defined(PMS_MODEL_ZH03X) for (uint32_t i = 0; i < 22; i++) { #else for (uint32_t i = 0; i < 30; i++) { @@ -137,7 +149,7 @@ bool PmsReadData(void) sum += buffer[i]; } // The data comes in endian'd, this solves it so it works on all platforms -#ifdef PMS_MODEL_PMS3003 +#if defined(PMS_MODEL_PMS3003) || defined(PMS_MODEL_ZH03X) uint16_t buffer_u16[12]; for (uint32_t i = 0; i < 12; i++) { #else @@ -147,7 +159,8 @@ bool PmsReadData(void) buffer_u16[i] = buffer[2 + i*2 + 1]; buffer_u16[i] += (buffer[2 + i*2] << 8); } -#ifdef PMS_MODEL_PMS3003 + +#if defined(PMS_MODEL_PMS3003) || defined(PMS_MODEL_ZH03X) if (sum != buffer_u16[10]) { #else if (sum != buffer_u16[14]) { @@ -156,7 +169,7 @@ bool PmsReadData(void) return false; } -#ifdef PMS_MODEL_PMS3003 +#if defined(PMS_MODEL_PMS3003) || defined(PMS_MODEL_ZH03X) memcpy((void *)&pms_data, (void *)buffer_u16, 22); #else memcpy((void *)&pms_data, (void *)buffer_u16, 30); @@ -170,6 +183,60 @@ bool PmsReadData(void) return true; } +#ifdef PMS_MODEL_ZH03X +bool ZH03ReadDataPassive() // process the passive mode response of the ZH03x sensor +{ + if (! PmsSerial->available()) { + return false; + } + while ((PmsSerial->peek() != 0xFF) && PmsSerial->available()) { + PmsSerial->read(); + } + if (PmsSerial->available() < 9) { + return false; + } + uint8_t buffer[9]; + PmsSerial->readBytes(buffer, 9); + if (buffer[1] != 0x86) { + return false; + } + PmsSerial->flush(); // Make room for another burst + + AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, 9); + + uint8_t sum = 0; + for (uint32_t i = 1; i < 7; i++) { + sum += buffer[i]; + } + sum=(~sum)+1; + if (sum != buffer[8]) { + AddLog(LOG_LEVEL_DEBUG, PSTR("ZH03x: " D_CHECKSUM_FAILURE)); + return false; + } + + uint16_t buffer_u16[12]; + for (uint32_t i = 1; i < 4; i++) { + buffer_u16[i] = buffer[i*2 + 1]; + buffer_u16[i] += (buffer[i*2] << 8); + buffer_u16[i+3] = buffer[i*2 + 1]; // Direct and Environment values identical + buffer_u16[i+3] += (buffer[i*2] << 8); // Direct and Environment values identical + buffer_u16[0] = 20; // set dummy framelength + buffer_u16[11] = buffer[8]; // copy checksum + } + + memcpy((void *)&pms_data, (void *)buffer_u16, 22); + + Pms.valid = 10; + + if (!Pms.discovery_triggered) { + TasmotaGlobal.discovery_counter = 1; // Force discovery + Pms.discovery_triggered = true; + } + + return true; + +} +#endif // PMS_MODEL_ZH03X /*********************************************************************************************\ * Command Sensor18 @@ -227,7 +294,18 @@ void PmsSecond(void) // Every second } if (Pms.ready) { +#ifdef PMS_MODEL_ZH03X + bool validread; + if (Settings->pms_wake_interval >= MIN_INTERVAL_PERIOD) { + validread = ZH03ReadDataPassive(); // in passive mode, the response is different from the PMS sensors + } + else { + validread = PmsReadData(); // In active mode the rsponse is identical to the PMS sensors + } + if (validread) { +#else if (PmsReadData()) { +#endif // PMS_MODEL_ZH03X Pms.valid = 10; if (Settings->pms_wake_interval >= MIN_INTERVAL_PERIOD) { PmsSendCmd(CMD_SLEEP); @@ -276,7 +354,10 @@ void PmsInit(void) { void PmsShow(bool json) { if (Pms.valid) { char types[10]; -#ifdef PMS_MODEL_PMS3003 + +#ifdef PMS_MODEL_ZH03X + strcpy_P(types, PSTR("ZH03x")); +#elif defined(PMS_MODEL_PMS3003) strcpy_P(types, PSTR("PMS3003")); #elif defined(PMS_MODEL_PMS5003T) strcpy_P(types, PSTR("PMS5003T")); @@ -294,7 +375,7 @@ void PmsShow(bool json) { types, pms_data.pm10_standard, pms_data.pm25_standard, pms_data.pm100_standard, pms_data.pm10_env, pms_data.pm25_env, pms_data.pm100_env); -#ifndef PMS_MODEL_PMS3003 +#if !(defined(PMS_MODEL_PMS3003) || defined(PMS_MODEL_ZH03X)) ResponseAppend_P(PSTR(",\"PB0.3\":%d,\"PB0.5\":%d,\"PB1\":%d,\"PB2.5\":%d,"), pms_data.particles_03um, pms_data.particles_05um, pms_data.particles_10um, pms_data.particles_25um); #ifdef PMS_MODEL_PMS5003T @@ -321,7 +402,7 @@ void PmsShow(bool json) { WSContentSend_PD(HTTP_SNS_ENVIRONMENTAL_CONCENTRATION, types, "1", pms_data.pm10_env); WSContentSend_PD(HTTP_SNS_ENVIRONMENTAL_CONCENTRATION, types, "2.5", pms_data.pm25_env); WSContentSend_PD(HTTP_SNS_ENVIRONMENTAL_CONCENTRATION, types, "10", pms_data.pm100_env); -#ifndef PMS_MODEL_PMS3003 +#if !(defined(PMS_MODEL_PMS3003) || defined(PMS_MODEL_ZH03X)) WSContentSend_PD(HTTP_SNS_PARTICALS_BEYOND, types, "0.3", pms_data.particles_03um); WSContentSend_PD(HTTP_SNS_PARTICALS_BEYOND, types, "0.5", pms_data.particles_05um); WSContentSend_PD(HTTP_SNS_PARTICALS_BEYOND, types, "1", pms_data.particles_10um); From 18c56f92bb819600d311b95e640cfc9a4fb407a2 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 27 Oct 2023 17:42:38 +0200 Subject: [PATCH 031/186] Update change logs --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c55cc9755db..470fa3bdfdd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file. - I2C bus2 support to LM75AD temperature sensor - Command ``GpioRead`` to show input state (#19810) - ESP32 core v3 auto TasConsole USB or Serial connection by @staars +- Support for Winsen XH03x dust particle sensors using USE_PMS5003 and PMS_MODEL_ZH03X (#19850) ### Breaking Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 37a9e5d40b4a..92d6f5067d57 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -121,6 +121,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - I2C bus2 support to HYTxxx temperature and humidity sensor - I2C bus2 support to SI1145/6/7 Ultra violet index and light sensor - I2C bus2 support to LM75AD temperature sensor +- Support for Winsen XH03x dust particle sensors using USE_PMS5003 and PMS_MODEL_ZH03X [#19850](https://github.com/arendst/Tasmota/issues/19850) - Experimental support for ESP32-C2 and ESP32-C6 using Arduino core v3 - ESP32 core v3 auto TasConsole USB or Serial connection by @staars From dfa6f9a7714584289b97acdb5927c383c9c50e40 Mon Sep 17 00:00:00 2001 From: Andreas Ziemer Date: Sat, 28 Oct 2023 11:43:35 +0200 Subject: [PATCH 032/186] Update be_lexer.c (#19856) Added check for unterminated block comments --- lib/libesp32/berry/src/be_lexer.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/libesp32/berry/src/be_lexer.c b/lib/libesp32/berry/src/be_lexer.c index 8a038a507f21..b558a72ff875 100644 --- a/lib/libesp32/berry/src/be_lexer.c +++ b/lib/libesp32/berry/src/be_lexer.c @@ -260,6 +260,7 @@ static void skip_comment(blexer *lexer) { next(lexer); /* skip '#' */ if (lgetc(lexer) == '-') { /* mult-line comment */ + int lno = lexer->linenumber; int mark, c = 'x'; /* skip first '-' (#- ... -#) */ do { mark = c == '-'; @@ -269,6 +270,11 @@ static void skip_comment(blexer *lexer) } c = next(lexer); } while (!(mark && c == '#') && c != EOS); + if (c == EOS) { + char tmp[64]; + sprintf(tmp, "unterminated comment block started in line %d", lno); + be_lexerror(lexer, tmp); + } next(lexer); /* skip '#' */ } else { /* line comment */ while (!is_newline(lgetc(lexer)) && lgetc(lexer)) { From 75ec9da8a297223152f392b796c0f499339bade0 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 28 Oct 2023 13:15:31 +0200 Subject: [PATCH 033/186] Refactoring of storing safeboot bin (#19858) * Folder for storing safeboot is now configurable * Platform 2023.10.06 * Platform 2023.10.12 --- .gitignore | 2 ++ boards/esp32-fix.json | 2 +- boards/esp32.json | 2 +- boards/esp32_solo1.json | 2 +- boards/esp32c2.json | 2 +- boards/esp32c2_2M.json | 2 +- boards/esp32c3.json | 2 +- boards/esp32c3cdc.json | 2 +- boards/esp32c6.json | 2 +- boards/esp32c6cdc.json | 2 +- boards/esp32s2.json | 2 +- boards/esp32s2cdc.json | 2 +- boards/esp32s3-qio_opi.json | 2 +- boards/esp32s3-qio_qspi.json | 2 +- boards/esp32s3cdc-qio_opi.json | 2 +- boards/esp32s3cdc-qio_qspi.json | 2 +- pio-tools/post_esp32.py | 30 ++++++++++++++++++++----- platformio.ini | 1 + platformio_tasmota32.ini | 2 +- platformio_tasmota_core3_env_sample.ini | 3 ++- platformio_tasmota_env32.ini | 1 + tasmota/tasmota.ino | 2 +- 22 files changed, 48 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 78c2cfe2f902..dcc81a15dc63 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,8 @@ data unpacked_fs unpacked_boards tasmota/user_config_override.h +variants +variants3 build build_output/* firmware.map diff --git a/boards/esp32-fix.json b/boards/esp32-fix.json index a2a9bed87f68..8287019b8018 100644 --- a/boards/esp32-fix.json +++ b/boards/esp32-fix.json @@ -31,7 +31,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32-safeboot.bin" + "tasmota32-safeboot.bin" ] ] }, diff --git a/boards/esp32.json b/boards/esp32.json index 1e476569c569..4dd2a3602032 100644 --- a/boards/esp32.json +++ b/boards/esp32.json @@ -31,7 +31,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32-safeboot.bin" + "tasmota32-safeboot.bin" ] ] }, diff --git a/boards/esp32_solo1.json b/boards/esp32_solo1.json index 3bb85fe05447..f3d9913b0036 100644 --- a/boards/esp32_solo1.json +++ b/boards/esp32_solo1.json @@ -31,7 +31,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32solo1-safeboot.bin" + "tasmota32solo1-safeboot.bin" ] ] }, diff --git a/boards/esp32c2.json b/boards/esp32c2.json index 563a3357c15f..c61238f2f3a2 100644 --- a/boards/esp32c2.json +++ b/boards/esp32c2.json @@ -29,7 +29,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32c2-safeboot.bin" + "tasmota32c2-safeboot.bin" ] ] }, diff --git a/boards/esp32c2_2M.json b/boards/esp32c2_2M.json index 36f16ffe3432..00414399ac83 100644 --- a/boards/esp32c2_2M.json +++ b/boards/esp32c2_2M.json @@ -29,7 +29,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32c2-safeboot.bin" + "tasmota32c2-safeboot.bin" ] ] }, diff --git a/boards/esp32c3.json b/boards/esp32c3.json index b7f74c3e5a95..2bb2f7660614 100644 --- a/boards/esp32c3.json +++ b/boards/esp32c3.json @@ -29,7 +29,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32c3-safeboot.bin" + "tasmota32c3-safeboot.bin" ] ] }, diff --git a/boards/esp32c3cdc.json b/boards/esp32c3cdc.json index 3d280a73b4a9..711225bf66f6 100644 --- a/boards/esp32c3cdc.json +++ b/boards/esp32c3cdc.json @@ -29,7 +29,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32c3cdc-safeboot.bin" + "tasmota32c3cdc-safeboot.bin" ] ] }, diff --git a/boards/esp32c6.json b/boards/esp32c6.json index 57dd9b8f4d91..76e7620dbf92 100644 --- a/boards/esp32c6.json +++ b/boards/esp32c6.json @@ -29,7 +29,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32c6-safeboot.bin" + "tasmota32c6-safeboot.bin" ] ] }, diff --git a/boards/esp32c6cdc.json b/boards/esp32c6cdc.json index 17932b7a83bf..62147804ac81 100644 --- a/boards/esp32c6cdc.json +++ b/boards/esp32c6cdc.json @@ -29,7 +29,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32c6cdc-safeboot.bin" + "tasmota32c6cdc-safeboot.bin" ] ] }, diff --git a/boards/esp32s2.json b/boards/esp32s2.json index d13f2a855197..aa9efca8b31b 100644 --- a/boards/esp32s2.json +++ b/boards/esp32s2.json @@ -28,7 +28,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32s2-safeboot.bin" + "tasmota32s2-safeboot.bin" ] ] }, diff --git a/boards/esp32s2cdc.json b/boards/esp32s2cdc.json index bdd230d5cde6..fe5662174321 100644 --- a/boards/esp32s2cdc.json +++ b/boards/esp32s2cdc.json @@ -28,7 +28,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32s2cdc-safeboot.bin" + "tasmota32s2cdc-safeboot.bin" ] ] }, diff --git a/boards/esp32s3-qio_opi.json b/boards/esp32s3-qio_opi.json index 498534e610a4..4f2a06c4757d 100644 --- a/boards/esp32s3-qio_opi.json +++ b/boards/esp32s3-qio_opi.json @@ -31,7 +31,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32s3-safeboot.bin" + "tasmota32s3-safeboot.bin" ] ] }, diff --git a/boards/esp32s3-qio_qspi.json b/boards/esp32s3-qio_qspi.json index cdc6d70cac78..42b20a4bc9a7 100644 --- a/boards/esp32s3-qio_qspi.json +++ b/boards/esp32s3-qio_qspi.json @@ -31,7 +31,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32s3-safeboot.bin" + "tasmota32s3-safeboot.bin" ] ] }, diff --git a/boards/esp32s3cdc-qio_opi.json b/boards/esp32s3cdc-qio_opi.json index 67dae1a6e2fd..d7650b42f82c 100644 --- a/boards/esp32s3cdc-qio_opi.json +++ b/boards/esp32s3cdc-qio_opi.json @@ -41,7 +41,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32s3cdc-safeboot.bin" + "tasmota32s3cdc-safeboot.bin" ] ] }, diff --git a/boards/esp32s3cdc-qio_qspi.json b/boards/esp32s3cdc-qio_qspi.json index f37a47bb5b55..77c89f9aa7df 100644 --- a/boards/esp32s3cdc-qio_qspi.json +++ b/boards/esp32s3cdc-qio_qspi.json @@ -41,7 +41,7 @@ "flash_extra_images": [ [ "0x10000", - "variants/tasmota/tasmota32s3cdc-safeboot.bin" + "tasmota32s3cdc-safeboot.bin" ] ] }, diff --git a/pio-tools/post_esp32.py b/pio-tools/post_esp32.py index 0d1dff34efd0..8cbc2809ff2f 100644 --- a/pio-tools/post_esp32.py +++ b/pio-tools/post_esp32.py @@ -16,7 +16,7 @@ # - 0x1000 | ~\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\bin\bootloader_dout_40m.bin # - 0x8000 | ~\Tasmota\.pio\build\\partitions.bin # - 0xe000 | ~\.platformio\packages\framework-arduinoespressif32\tools\partitions\boot_app0.bin -# - 0x10000 | ~\.platformio/packages/framework-arduinoespressif32/variants/tasmota/\-safeboot.bin +# - 0x10000 | ~\Tasmota\/-safeboot.bin # - 0xe0000 | ~\Tasmota\.pio\build\/firmware.bin # - 0x3b0000| ~\Tasmota\.pio\build\/littlefs.bin @@ -37,6 +37,13 @@ sys.path.append(join(platform.get_package_dir("tool-esptoolpy"))) import esptool +variants_dir = env.BoardConfig().get("build.variants_dir", "") +variant = env.BoardConfig().get("build.variant", "") +sections = env.subst(env.get("FLASH_EXTRA_IMAGES")) +chip = env.get("BOARD_MCU") +mcu_build_variant = env.BoardConfig().get("build.variant", "").lower() + +# Copy safeboots firmwares in place when running in Github github_actions = os.getenv('GITHUB_ACTIONS') extra_flags = ''.join([element.replace("-D", " ") for element in env.BoardConfig().get("build.extra_flags", "")]) build_flags = ''.join([element.replace("-D", " ") for element in env.GetProjectOption("build_flags")]) @@ -45,16 +52,31 @@ FRAMEWORK_DIR = platform.get_package_dir("framework-arduino-solo1") if github_actions and os.path.exists("./firmware/firmware"): shutil.copytree("./firmware/firmware", "/home/runner/.platformio/packages/framework-arduino-solo1/variants/tasmota") + if variants_dir: + shutil.copytree("./firmware/firmware", variants_dir, dirs_exist_ok=True) elif "CORE32ITEAD" in extra_flags or "FRAMEWORK_ARDUINO_ITEAD" in build_flags: FRAMEWORK_DIR = platform.get_package_dir("framework-arduino-ITEAD") if github_actions and os.path.exists("./firmware/firmware"): shutil.copytree("./firmware/firmware", "/home/runner/.platformio/packages/framework-arduino-ITEAD/variants/tasmota") + if variants_dir: + shutil.copytree("./firmware/firmware", variants_dir, dirs_exist_ok=True) else: FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32") if github_actions and os.path.exists("./firmware/firmware"): shutil.copytree("./firmware/firmware", "/home/runner/.platformio/packages/framework-arduinoespressif32/variants/tasmota") + if variants_dir: + shutil.copytree("./firmware/firmware", variants_dir, dirs_exist_ok=True) + +# Copy pins_arduino.h to variants folder +if variants_dir: + mcu_build_variant_path = join(FRAMEWORK_DIR, "variants", mcu_build_variant, "pins_arduino.h") + custom_variant_build = join(env.subst("$PROJECT_DIR"), variants_dir , mcu_build_variant, "pins_arduino.h") + os.makedirs(join(env.subst("$PROJECT_DIR"), variants_dir , mcu_build_variant), exist_ok=True) + shutil.copy(mcu_build_variant_path, custom_variant_build) -variants_dir = join(FRAMEWORK_DIR, "variants", "tasmota") +if not variants_dir: + variants_dir = join(FRAMEWORK_DIR, "variants", "tasmota") + env.BoardConfig().update("build.variants_dir", variants_dir) def esp32_detect_flashsize(): uploader = env.subst("$UPLOADER") @@ -195,9 +217,7 @@ def esp32_create_combined_bin(source, target, env): new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.bin") - sections = env.subst(env.get("FLASH_EXTRA_IMAGES")) firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin") - chip = env.get("BOARD_MCU") tasmota_platform = esp32_create_chip_string(chip) if "-DUSE_USB_CDC_CONSOLE" in env.BoardConfig().get("build.extra_flags") and "cdc" not in tasmota_platform: @@ -274,8 +294,8 @@ def esp32_create_combined_bin(source, target, env): ) print("Will use custom upload command for flashing operation to add file system defined for this build target.") - #print('Using esptool.py arguments: %s' % ' '.join(cmd)) if("safeboot" not in firmware_name): + #print('Using esptool.py arguments: %s' % ' '.join(cmd)) esptool.main(cmd) diff --git a/platformio.ini b/platformio.ini index 5f55fe7f28ac..f45cd00f5d6c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,6 +32,7 @@ platform_packages = ${core.platform_packages} framework = arduino board = esp8266_1M board_build.filesystem = littlefs +board_build.variants_dir = variants/tasmota custom_unpack_dir = unpacked_littlefs build_unflags = ${core.build_unflags} build_flags = ${core.build_flags} diff --git a/platformio_tasmota32.ini b/platformio_tasmota32.ini index c49c5e9a7ff4..d1ee861fa18d 100644 --- a/platformio_tasmota32.ini +++ b/platformio_tasmota32.ini @@ -78,7 +78,7 @@ lib_ignore = ${esp32_defaults.lib_ignore} ccronexpr [core32] -platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.05/platform-espressif32.zip +platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.06/platform-espressif32.zip platform_packages = build_unflags = ${esp32_defaults.build_unflags} build_flags = ${esp32_defaults.build_flags} diff --git a/platformio_tasmota_core3_env_sample.ini b/platformio_tasmota_core3_env_sample.ini index 8c3bf2c96ed2..7c8a055e82b7 100644 --- a/platformio_tasmota_core3_env_sample.ini +++ b/platformio_tasmota_core3_env_sample.ini @@ -22,7 +22,7 @@ ; tasmota32c6cdc-safeboot [core32_30] -platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.11/platform-espressif32.zip +platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.12/platform-espressif32.zip platform_packages = build_unflags = ${core32.build_unflags} @@ -50,6 +50,7 @@ framework = ${common.framework} platform = ${core32_30.platform} platform_packages = ${core32_30.platform_packages} board_build.filesystem = ${common.board_build.filesystem} +board_build.variants_dir = variants/tasmota_ard3 custom_unpack_dir = ${common.custom_unpack_dir} board = esp32 monitor_speed = 115200 diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini index bea48c5a6482..5b62e0bc6886 100644 --- a/platformio_tasmota_env32.ini +++ b/platformio_tasmota_env32.ini @@ -4,6 +4,7 @@ platform = ${core32.platform} platform_packages = ${core32.platform_packages} board_build.filesystem = ${common.board_build.filesystem} custom_unpack_dir = ${common.custom_unpack_dir} +board_build.variants_dir = ${common.board_build.variants_dir} board = esp32 monitor_speed = ${common.monitor_speed} monitor_echo = ${common.monitor_echo} diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index bfd026f78099..fd980bef8ae2 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -223,7 +223,7 @@ bool tasconsole_serial = false; #if ARDUINO_USB_MODE //#warning **** TasConsole ARDUINO_USB_MODE **** -TASCONSOLE TasConsole{USBSerial}; // ESP32C3/C6/S3 embedded USB using JTAG interface +TASCONSOLE TasConsole{HWCDCSerial}; // ESP32C3/C6/S3 embedded USB using JTAG interface //#warning **** TasConsole uses HWCDC **** #else // No ARDUINO_USB_MODE #include "USB.h" From b65f32c5f3f3a080a9439ded193fd27d221232e7 Mon Sep 17 00:00:00 2001 From: Norbert Richter Date: Sat, 28 Oct 2023 14:07:49 +0200 Subject: [PATCH 034/186] Neopool enhancements for HA (#19857) * Add NeoPool hydrolysis setpoint and max * Add NeoPool command ``NPFiltrationSpeed`` * Change NeoPool topic ``Power`` to ``Powerunit`` * Add ``SO157`` for NeoPool output sensitive data --- CHANGELOG.md | 4 + tasmota/include/tasmota_types.h | 2 +- .../tasmota_xsns_sensor/xsns_83_neopool.ino | 92 ++++++++++++++++--- 3 files changed, 84 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 470fa3bdfdd8..90b789ae90d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,8 +16,12 @@ All notable changes to this project will be documented in this file. - Command ``GpioRead`` to show input state (#19810) - ESP32 core v3 auto TasConsole USB or Serial connection by @staars - Support for Winsen XH03x dust particle sensors using USE_PMS5003 and PMS_MODEL_ZH03X (#19850) +- NeoPool hydrolysis setpoint and max +- NeoPool command ``NPFiltrationSpeed`` to set non-standard filtration type speed +- NeoPool ``SetOption157`` to output sensitive data ### Breaking Changed +- NeoPool SENSOR topic ``Power`` renamed to ``Powerunit`` ### Changed - Prepare I2C drivers for bus2 support diff --git a/tasmota/include/tasmota_types.h b/tasmota/include/tasmota_types.h index a5fd504fe90b..7ed4dbab3b67 100755 --- a/tasmota/include/tasmota_types.h +++ b/tasmota/include/tasmota_types.h @@ -190,7 +190,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t berry_light_scheme : 1; // bit 8 (v12.5.0.3) - SetOption154 - (Berry) Handle berry led using RMT0 as additional WS2812 scheme uint32_t zcfallingedge : 1; // bit 9 (v13.0.0.1) - SetOption155 - (ZCDimmer) Enable rare falling Edge dimmer instead of leading edge uint32_t sen5x_passive_mode : 1; // bit 10 (v13.1.0.1) - SetOption156 - (Sen5x) Run in passive mode when there is another I2C master (e.g. Ikea Vindstyrka), i.e. do not set up Sen5x sensor, higher polling interval - uint32_t spare11 : 1; // bit 11 + uint32_t neopool_outputsensitive : 1; // bit 11 (v13.2.0.1) - SetOption157 - (NeoPool) Output sensitive data (1) uint32_t spare12 : 1; // bit 12 uint32_t spare13 : 1; // bit 13 uint32_t spare14 : 1; // bit 14 diff --git a/tasmota/tasmota_xsns_sensor/xsns_83_neopool.ino b/tasmota/tasmota_xsns_sensor/xsns_83_neopool.ino index 35d5c5b04332..a857ac7d9e68 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_83_neopool.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_83_neopool.ino @@ -662,6 +662,7 @@ NeoPoolResMBitfield neopool_resolution { #define D_NEOPOOL_JSON_FILTRATION_INTELLIGENT "Intelligent" #define D_NEOPOOL_JSON_FILTRATION_BACKWASH "Backwash" #define D_NEOPOOL_JSON_MODULES "Modules" +#define D_NEOPOOL_JSON_POWERUNIT "Powerunit" #define D_NEOPOOL_JSON_CHLORINE "Chlorine" #define D_NEOPOOL_JSON_CONDUCTIVITY "Conductivity" #define D_NEOPOOL_JSON_FILTRATION "Filtration" @@ -806,6 +807,14 @@ const char HTTP_SNS_NEOPOOL_STATUS_ACTIVE[] PROGMEM = "filter:invert(1)"; * 4 - Intelligent * 13 - Backwash * + * NPFiltrationSpeed {} + * (only available for non-standard filtration types) + * get/set manual filtration speed (speed = 1..3) + * get filtration speed if is omitted, otherwise set new speed + * 1 - low + * 2 - mid + * 3 - high + * * NPTime {