diff --git a/CHANGELOG.md b/CHANGELOG.md index d1bb269de..864eda1c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,8 @@ All notable changes to this project will be documented in this file. - Support for Sonoff SPM v1.3.0 (#13447) - LVGL port `colorwheel` from LVGL 8 (#22244) - HASPmota `cpicker` and `msgbox` (#22244) -- Support for DALI 1 on ESP8266 -- Command ``DaliWeb 1`` to enable light control for broadcast address +- Support for DALI on ESP8266 +- Command ``DaliWeb 1`` to enable light control for DALI broadcast address ### Breaking Changed @@ -23,11 +23,13 @@ All notable changes to this project will be documented in this file. - ESP32 Range Extender compile error with core 3.0.0 (#22205) - HASPmota error when page '1' is not defined (#22220) - ESP32-S3 uDisplay force cache writes to RGB display (#22222) -- ESP32 Dali compile error with core 3.x (#22214) -- Dali received data decoding +- ESP32 DALI compile error with core 3.x (#22214) +- DALI received data decoding - ESP32 Ethernet using EthClockMode 3 (#22248) +- ESP32 disable SPI DMA for uDisplay (broken since esp-idf 5.3 (core 3.1.0)) (#22264) ### Removed +- Berry Zigbee removed test code (#22263) ## [14.2.0.5] 20240926 ### Added @@ -52,6 +54,10 @@ All notable changes to this project will be documented in this file. - ESP8266 experimental support for second I2C bus - Berry improve `int64` constructor (#22172) - MQTT warning if trying to connect without TLS on a port that normally uses TLS (#22175) +- Misubishi Electric HVAC Heat/Dry/Cool ISEE operation mode (#22216) +- Misubishi Electric HVAC Bridge to HomeBridge/Homekit locally (#22236) +- Misubishi Electric HVAC Air Direction Control (#22241) +- Misubishi Electric HVAC prohibit function (#22269) ### Changed - Refactored I2C drivers HTU21, BH1750, SHT3x, iAQ and HYT diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 2d6ad9844..10e2f87c2 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -117,12 +117,12 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ## Changelog v14.2.0.6 ### Added - Command ``SetOption69 1`` to enable Serial Bridge inverted Receive [#22000](https://github.com/arendst/Tasmota/issues/22000) -- Command ``DaliWeb 1`` to enable light control for broadcast address +- Command ``DaliWeb 1`` to enable light control for DALI broadcast address - HX711 optional calibration precision option on command ``Sensor34 2 `` where `` is 1 to 20 [#13983](https://github.com/arendst/Tasmota/issues/13983) - ESP8266 support for one-wire M1601 temperature sensor on DS18x20 GPIO [#21376](https://github.com/arendst/Tasmota/issues/21376) - ESP8266 support for I2C CLK on GPIO16 [#22199](https://github.com/arendst/Tasmota/issues/22199) - Support for I2C M5Unit (Mini)Scales using HX711 driver -- Support for DALI 1 on ESP8266 +- Support for DALI on ESP8266 - Support for RX8010 RTC as used in IOTTIMER [#21376](https://github.com/arendst/Tasmota/issues/21376) - Support for BL0906 up to 6 channel energy monitor as used in Athom EM2/EM6 [#22167](https://github.com/arendst/Tasmota/issues/22167) - Support for Sonoff SPM v1.3.0 [#13447](https://github.com/arendst/Tasmota/issues/13447) @@ -134,6 +134,10 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - Support nexus protocol and calculation of separation limit to rc-switch library [#21886](https://github.com/arendst/Tasmota/issues/21886) - KNX additional KnxTx functions and define KNX_USE_DPT9 [#22071](https://github.com/arendst/Tasmota/issues/22071) - SML multi TRX line [#22056](https://github.com/arendst/Tasmota/issues/22056) +- Misubishi Electric HVAC Heat/Dry/Cool ISEE operation mode [#22216](https://github.com/arendst/Tasmota/issues/22216) +- Misubishi Electric HVAC Bridge to HomeBridge/Homekit locally [#22236](https://github.com/arendst/Tasmota/issues/22236) +- Misubishi Electric HVAC Air Direction Control [#22241](https://github.com/arendst/Tasmota/issues/22241) +- Misubishi Electric HVAC prohibit function [#22269](https://github.com/arendst/Tasmota/issues/22269) - Zigbee Koenkk firmware 20240710 for Sonoff Zigbee ZBPro [#22076](https://github.com/arendst/Tasmota/issues/22076) - Berry Zigbee improvements to prepare Matter [#22083](https://github.com/arendst/Tasmota/issues/22083) - Berry virtual Energy driver [#22134](https://github.com/arendst/Tasmota/issues/22134) @@ -161,7 +165,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - HASPmota `delete` instead of `delete()` [#22245](https://github.com/arendst/Tasmota/issues/22245) ### Fixed -- Dali received data decoding +- DALI received data decoding - Compilation exception when metrics not found [#22170](https://github.com/arendst/Tasmota/issues/22170) - Crash when calling TasmotaSerial destructor when initialized with incorrect arguments [#22036](https://github.com/arendst/Tasmota/issues/22036) - Energy calculation [#20653](https://github.com/arendst/Tasmota/issues/20653) @@ -177,8 +181,9 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - Zigbee avoid disabling console serial on ESP32 and improved log messages [#22082](https://github.com/arendst/Tasmota/issues/22082) - Zigbee flashing CC2562P with latest firmware [#22117](https://github.com/arendst/Tasmota/issues/22117) - ESP32 Range Extender compile error with core 3.x [#22205](https://github.com/arendst/Tasmota/issues/22205) -- ESP32 Dali compile error with core 3.x [#22214](https://github.com/arendst/Tasmota/issues/22214) +- ESP32 DALI compile error with core 3.x [#22214](https://github.com/arendst/Tasmota/issues/22214) - ESP32 Ethernet using EthClockMode 3 [#22248](https://github.com/arendst/Tasmota/issues/22248) +- ESP32 disable SPI DMA for uDisplay (broken since esp-idf 5.3 (core 3.1.0)) [#22264](https://github.com/arendst/Tasmota/issues/22264) - Berry avoid `readbytes()` from crashing when file is too large [#22057](https://github.com/arendst/Tasmota/issues/22057) - Berry energy missing attributes [#22116](https://github.com/arendst/Tasmota/issues/22116) - Berry I2C to prepare M5Stack I2C STM32 based devices [#22143](https://github.com/arendst/Tasmota/issues/22143) @@ -196,3 +201,4 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ### Removed - ESP8266 Analog input support using energy driver as only one channel is available - Berry remove reuse of methods for interface-like code reuse #21500 [#22055](https://github.com/arendst/Tasmota/issues/22055) +- Berry Zigbee removed test code [#22263](https://github.com/arendst/Tasmota/issues/22263) diff --git a/lib/lib_display/UDisplay/uDisplay.cpp b/lib/lib_display/UDisplay/uDisplay.cpp index fe32897cb..4af702125 100755 --- a/lib/lib_display/UDisplay/uDisplay.cpp +++ b/lib/lib_display/UDisplay/uDisplay.cpp @@ -242,7 +242,7 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) { if (wire_n == 1) { wire = &Wire; } else { -#ifdef ESP32 +#if SOC_HP_I2C_NUM > 1 wire = &Wire1; #else wire = &Wire; @@ -599,6 +599,12 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) { case 'B': lvgl_param.flushlines = next_val(&lp1); lvgl_param.data = next_val(&lp1); + // temporary fix to disable DMA due to a problem in esp-idf 5.3 +#ifdef ESP32 +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0) + lvgl_param.use_dma = false; +#endif +#endif break; case 'M': rotmap_xmin = next_val(&lp1); @@ -630,7 +636,7 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) { if (ut_mode == 1) { ut_wire = &Wire; } else { -#ifdef ESP32 +#if SOC_HP_I2C_NUM > 1 ut_wire = &Wire1; #else ut_wire = &Wire; @@ -1070,7 +1076,7 @@ Renderer *uDisplay::Init(void) { if (wire_n == 0) { wire = &Wire; } -#ifdef ESP32 +#if SOC_HP_I2C_NUM > 1 if (wire_n == 1) { wire = &Wire1; } diff --git a/lib/lib_i2c/BM8563_RTC/src/BM8563.h b/lib/lib_i2c/BM8563_RTC/src/BM8563.h index dc7867b22..fbba8d752 100644 --- a/lib/lib_i2c/BM8563_RTC/src/BM8563.h +++ b/lib/lib_i2c/BM8563_RTC/src/BM8563.h @@ -24,11 +24,11 @@ typedef struct class BM8563 { public: BM8563(); - #ifdef ESP32 - void setBus(uint32_t _bus) { myWire = _bus ? &Wire1 : &Wire; }; - #else - void setBus(uint32_t _bus) { myWire = &Wire; }; - #endif +#if SOC_HP_I2C_NUM > 1 + void setBus(uint32_t _bus) { myWire = _bus ? &Wire1 : &Wire; }; +#else + void setBus(uint32_t _bus) { myWire = &Wire; }; +#endif void begin(void); void GetBm8563Time(void); diff --git a/lib/lib_i2c/MPU_accel/src/MPU_accel.h b/lib/lib_i2c/MPU_accel/src/MPU_accel.h index 7b522a836..f3f027a21 100755 --- a/lib/lib_i2c/MPU_accel/src/MPU_accel.h +++ b/lib/lib_i2c/MPU_accel/src/MPU_accel.h @@ -74,11 +74,11 @@ class MPU_accel { uint32_t model = 6886; // MPU model number public: MPU_accel(void) {}; - #ifdef ESP32 +#if SOC_HP_I2C_NUM > 1 void setBus(uint32_t _bus) { myWire = _bus ? &Wire1 : &Wire; }; - #else +#else void setBus(uint32_t _bus) { myWire = &Wire; }; - #endif +#endif int Init(void); uint32_t getModel(void) const { return model; } void getAccelAdc(int16_t* ax, int16_t* ay, int16_t* az); diff --git a/lib/libesp32/berry_tasmota/src/be_zigbee.c b/lib/libesp32/berry_tasmota/src/be_zigbee.c index 2471dac49..8c5956796 100644 --- a/lib/libesp32/berry_tasmota/src/be_zigbee.c +++ b/lib/libesp32/berry_tasmota/src/be_zigbee.c @@ -127,8 +127,8 @@ class be_class_zb_coord_ntv (scope: global, name: zb_coord_ntv, strings: weak) { abort, ctype_func(zc_abort) - test_attr, func(zigbee_test_attr) - test_msg, func(zigbee_test_msg) + // test_attr, func(zigbee_test_attr) + // test_msg, func(zigbee_test_msg) } @const_object_info_end */ diff --git a/tasmota/include/tasmota_globals.h b/tasmota/include/tasmota_globals.h index 2f51f860c..db8d24f0c 100644 --- a/tasmota/include/tasmota_globals.h +++ b/tasmota/include/tasmota_globals.h @@ -194,6 +194,13 @@ const char WIFI_HOSTNAME[] = WIFI_DEFAULT_HOSTNAME; // Override by user_confi #define ARDUINO_CORE_RELEASE ARDUINO_ESP32_RELEASE #endif // ARDUINO_ESP32_RELEASE +#ifdef USE_I2C_BUS2 // If defined for ESP8266 undefine first +#undef USE_I2C_BUS2 +#endif // USE_I2C_BUS2 +#if SOC_HP_I2C_NUM > 1 +#define USE_I2C_BUS2 // Redefine based on hardware support +#endif // SOC_HP_I2C_NUM + // Hardware has no ESP32 #undef USE_EXS_DIMMER #undef USE_ARMTRONIX_DIMMERS diff --git a/tasmota/include/tasmota_template.h b/tasmota/include/tasmota_template.h index 59f108fe1..053782636 100644 --- a/tasmota/include/tasmota_template.h +++ b/tasmota/include/tasmota_template.h @@ -198,7 +198,7 @@ enum UserSelectablePins { GPIO_ADE7953_RST, // ADE7953 Reset GPIO_NRG_MBS_TX, GPIO_NRG_MBS_RX, // Generic Energy Modbus device GPIO_ADE7953_CS, // ADE7953 SPI Chip Select - GPIO_DALI_RX, GPIO_DALI_TX, // Dali + GPIO_DALI_RX, GPIO_DALI_TX, // DALI GPIO_BP1658CJ_CLK, GPIO_BP1658CJ_DAT,// BP1658CJ GPIO_DINGTIAN_CLK, GPIO_DINGTIAN_SDI, GPIO_DINGTIAN_Q7, GPIO_DINGTIAN_PL, GPIO_DINGTIAN_RCK, // Dingtian relay board - 595's & 165's pins GPIO_LD2410_TX, GPIO_LD2410_RX, // HLK-LD2410 diff --git a/tasmota/include/tasmota_types.h b/tasmota/include/tasmota_types.h index a8936407e..e7fdbbf0e 100755 --- a/tasmota/include/tasmota_types.h +++ b/tasmota/include/tasmota_types.h @@ -289,7 +289,7 @@ typedef union { uint32_t influxdb_sensor : 1; // bit 10 (v11.0.0.5) - CMND_IFXSENSOR - Enable sensor support in addition to teleperiod support uint32_t ex_serbridge_console : 1; // bit 11 (v11.1.0.4) - (v14.1.0.2) Replaced by CMND_SSERIALMODE uint32_t telegram_disable_af : 1; // bit 12 (v14.0.0.2) - CMND_TMSTATE 6/7 - Disable Telegram auto-fingerprint fix - uint32_t dali_web : 1; // bit 13 (v14.2.0.6) - CMND_DALIWEB - Enable Dali web controls + uint32_t dali_web : 1; // bit 13 (v14.2.0.6) - CMND_DALIWEB - Enable DALI web controls uint32_t spare14 : 1; // bit 14 uint32_t spare15 : 1; // bit 15 uint32_t spare16 : 1; // bit 16 diff --git a/tasmota/tasmota_support/support_a_i2c.ino b/tasmota/tasmota_support/support_a_i2c.ino index 3b03a32c6..c857240cd 100644 --- a/tasmota/tasmota_support/support_a_i2c.ino +++ b/tasmota/tasmota_support/support_a_i2c.ino @@ -17,12 +17,6 @@ #endif // USE_I2C_BUS2_ESP8266 #endif // ESP8266 -#ifdef ESP32 -#if CONFIG_SOC_HP_I2C_NUM > 1 -#define USE_I2C_BUS2 -#endif // CONFIG_SOC_HP_I2C_NUM -#endif // ESP32 - const uint8_t I2C_RETRY_COUNTER = 3; struct I2Ct { @@ -69,7 +63,12 @@ bool I2cBegin(int sda, int scl, uint32_t bus, uint32_t frequency) { #endif // USE_I2C_BUS2_ESP8266 #endif // ESP8266 #ifdef ESP32 +#ifdef USE_I2C_BUS2 TwoWire& myWire = (0 == bus) ? Wire : Wire1; +#else + if (bus > 0) { return false; } + TwoWire& myWire = Wire; +#endif static bool reinit = false; if (reinit) { myWire.end(); } result = myWire.begin(sda, scl, frequency); diff --git a/tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino b/tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino index 0f6dbccb2..df86f9e6b 100755 --- a/tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino @@ -13160,7 +13160,7 @@ uint32_t script_i2c(uint8_t sel, uint16_t val, uint32_t val1) { switch (sel) { case 0: glob_script_mem.script_i2c_addr = val; -#ifdef ESP32 +#if defined(ESP32) && defined(USE_I2C_BUS2) if (val1 == 0) glob_script_mem.script_i2c_wire = &Wire; else glob_script_mem.script_i2c_wire = &Wire1; #else @@ -13209,7 +13209,7 @@ uint32_t script_i2c(uint8_t sel, uint16_t val, uint32_t val1) { glob_script_mem.script_i2c_wire->endTransmission(); break; case 14: - #ifdef ESP32 +#if defined(ESP32) && defined(USE_I2C_BUS2) Wire1.end(); Wire1.begin(val & 0x7f, val1); glob_script_mem.script_i2c_wire = &Wire1; @@ -13217,7 +13217,7 @@ uint32_t script_i2c(uint8_t sel, uint16_t val, uint32_t val1) { if (val & 128) { XsnsCall(FUNC_INIT); } - #endif +#endif break; } return rval; diff --git a/tasmota/tasmota_xdrv_driver/xdrv_13_display.ino b/tasmota/tasmota_xdrv_driver/xdrv_13_display.ino index 545040ef9..a7afe6d47 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_13_display.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_13_display.ino @@ -2442,6 +2442,28 @@ void Draw_RGB_Bitmap(char *file, uint16_t xp, uint16_t yp, uint8_t scale, bool i #ifdef ESP32 #ifdef JPEG_PICTS #define JPG_DEFSIZE 150000 +void Draw_jpeg(uint8_t *mem, uint16_t jpgsize, uint16_t xp, uint16_t yp, uint8_t scale) { + if (mem[0] == 0xff && mem[1] == 0xd8) { + uint16_t xsize; + uint16_t ysize; + get_jpeg_size(mem, jpgsize, &xsize, &ysize); + //AddLog(LOG_LEVEL_INFO, PSTR("Pict size %d - %d - %d"), xsize, ysize, jpgsize); + scale &= 3; + uint8_t fac = 1 << scale; + xsize /= fac; + ysize /= fac; + renderer->setAddrWindow(xp, yp, xp + xsize, yp + ysize); + uint8_t *rgbmem = (uint8_t *)special_malloc(xsize * ysize * 2); + if (rgbmem) { + //jpg2rgb565(mem, jpgsize, rgbmem, JPG_SCALE_NONE); + jpg2rgb565(mem, jpgsize, rgbmem, (jpg_scale_t)scale); + renderer->pushColors((uint16_t*)rgbmem, xsize * ysize, true); + free(rgbmem); + } + renderer->setAddrWindow(0, 0, 0, 0); + } +} + void Draw_JPG_from_URL(char *url, uint16_t xp, uint16_t yp, uint8_t scale) { uint8_t *mem = 0; WiFiClient http_client; @@ -2484,28 +2506,6 @@ void Draw_JPG_from_URL(char *url, uint16_t xp, uint16_t yp, uint8_t scale) { } if (mem) free(mem); } - -void Draw_jpeg(uint8_t *mem, uint16_t jpgsize, uint16_t xp, uint16_t yp, uint8_t scale) { - if (mem[0] == 0xff && mem[1] == 0xd8) { - uint16_t xsize; - uint16_t ysize; - get_jpeg_size(mem, jpgsize, &xsize, &ysize); - //AddLog(LOG_LEVEL_INFO, PSTR("Pict size %d - %d - %d"), xsize, ysize, jpgsize); - scale &= 3; - uint8_t fac = 1 << scale; - xsize /= fac; - ysize /= fac; - renderer->setAddrWindow(xp, yp, xp + xsize, yp + ysize); - uint8_t *rgbmem = (uint8_t *)special_malloc(xsize * ysize * 2); - if (rgbmem) { - //jpg2rgb565(mem, jpgsize, rgbmem, JPG_SCALE_NONE); - jpg2rgb565(mem, jpgsize, rgbmem, (jpg_scale_t)scale); - renderer->pushColors((uint16_t*)rgbmem, xsize * ysize, true); - free(rgbmem); - } - renderer->setAddrWindow(0, 0, 0, 0); - } -} #endif // JPEG_PICTS #endif // ESP32 diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_wire.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_wire.ino index 5cce357ee..9d57c0398 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_wire.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_wire.ino @@ -35,8 +35,10 @@ TwoWire & getWire(bvm *vm) { be_pop(vm, 1); if (1 == bus && TasmotaGlobal.i2c_enabled) { return Wire; +#ifdef USE_I2C_BUS2 } else if (2 == bus && TasmotaGlobal.i2c_enabled_2) { return Wire1; +#endif // USE_I2C_BUS2 } else { be_raise(vm, "configuration_error", "I2C bus not initiliazedd"); return *(TwoWire*)nullptr; diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_zigbee.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_zigbee.ino index d169629d7..139ca4805 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_zigbee.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_zigbee.ino @@ -601,38 +601,38 @@ extern "C" { } extern "C" { - int zigbee_test_attr(struct bvm *vm) { - int32_t mode = be_toint(vm, 2); - if (mode < 10) { - // - } else { - Z_attribute *a = new Z_attribute(); - if (mode == 10) { - a->setKeyId(1111, 2222); - a->setUInt(1337); - } else if (mode == 11) { - a->setKeyName("super_attribute"); - a->key_suffix = 2; - a->setFloat(3.14); - } else if (mode == 12) { - a->setKeyName("array"); - a->newJsonArray(); - a->val.arrval->add((int32_t)-1); - a->val.arrval->addStr("foo"); - a->val.arrval->addStr("bar"); - a->val.arrval->addStr("bar\"baz\'toto"); - } else if (mode == 13) { - a->setKeyName("list"); - a->newAttrList(); - Z_attribute &subattr1 = a->val.objval->addAttribute(10,20); - subattr1.setStr("sub1"); - Z_attribute &subattr2 = a->val.objval->addAttribute(11,21); - subattr2.setStr("sub2"); - } - zat_zcl_attribute(vm, a); - } - be_return(vm); - } +// int zigbee_test_attr(struct bvm *vm) { +// int32_t mode = be_toint(vm, 2); +// if (mode < 10) { +// // +// } else { +// Z_attribute *a = new Z_attribute(); +// if (mode == 10) { +// a->setKeyId(1111, 2222); +// a->setUInt(1337); +// } else if (mode == 11) { +// a->setKeyName("super_attribute"); +// a->key_suffix = 2; +// a->setFloat(3.14); +// } else if (mode == 12) { +// a->setKeyName("array"); +// a->newJsonArray(); +// a->val.arrval->add((int32_t)-1); +// a->val.arrval->addStr("foo"); +// a->val.arrval->addStr("bar"); +// a->val.arrval->addStr("bar\"baz\'toto"); +// } else if (mode == 13) { +// a->setKeyName("list"); +// a->newAttrList(); +// Z_attribute &subattr1 = a->val.objval->addAttribute(10,20); +// subattr1.setStr("sub1"); +// Z_attribute &subattr2 = a->val.objval->addAttribute(11,21); +// subattr2.setStr("sub2"); +// } +// zat_zcl_attribute(vm, a); +// } +// be_return(vm); +// } // Creates a zcl_attributes from Z_attribute_list @@ -651,18 +651,18 @@ extern "C" { } } - int zigbee_test_msg(struct bvm *vm) { - Z_attribute_list attr_list; + // int zigbee_test_msg(struct bvm *vm) { + // Z_attribute_list attr_list; - attr_list.lqi = 250; - Z_attribute &subattr1 = attr_list.addAttribute(10,20); - subattr1.setStr("sub1"); - Z_attribute &subattr2 = attr_list.addAttribute(11,21); - subattr2.setStr("sub2"); + // attr_list.lqi = 250; + // Z_attribute &subattr1 = attr_list.addAttribute(10,20); + // subattr1.setStr("sub1"); + // Z_attribute &subattr2 = attr_list.addAttribute(11,21); + // subattr2.setStr("sub2"); - zat_zcl_attribute_list(vm, 100, &attr_list); - be_return(vm); - } + // zat_zcl_attribute_list(vm, 100, &attr_list); + // be_return(vm); + // } } #endif // USE_ZIGBEE diff --git a/tasmota/tasmota_xdrv_driver/xdrv_75_dali.ino b/tasmota/tasmota_xdrv_driver/xdrv_75_dali.ino index 2215b115c..f59478848 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_75_dali.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_75_dali.ino @@ -19,14 +19,15 @@ -------------------------------------------------------------------------------------------- Version yyyymmdd Action Description -------------------------------------------------------------------------------------------- + 0.1.0.4 20241013 update - Fix intermittent bad send timing 0.1.0.3 20241010 update - Change DaliDimmer range from 0..254 to 0..100 - Add command DaliWeb 0|1 to enable persistent Web light controls 0.1.0.2 20241008 update - Better receive error detection - 0.1.0.1 20241007 update - To stablizie communication send Dali datagram twice like Busch-Jaeger does + 0.1.0.1 20241007 update - To stablizie communication send DALI datagram twice like Busch-Jaeger does - Change DaliPower 0..2 to act like Tasmota Power (Off, On, Toggle) - Keep last Dimmer value as default power on 0.1.0.0 20241006 rewrite - Add support for ESP8266 - - Fix decoding of received Dali 1 data + - Fix decoding of received DALI data - Refactor command `DaliPower 0..254` controlling Broadcast devices - Add command `DaliDimmer 0..254` controlling Broadcast devices 0.0.0.1 20221027 publish - Initial version @@ -55,16 +56,24 @@ #define DALI_DEBUG_PIN 4 #endif -#define BROADCAST_DP 0b11111110 // 0xFE = 254 +#define DALI_BROADCAST_DP 0b11111110 // 0xFE = 254 #define DALI_TOPIC "DALI" #define D_PRFX_DALI "Dali" const char kDALICommands[] PROGMEM = D_PRFX_DALI "|" // Prefix - "|" D_CMND_POWER "|" D_CMND_DIMMER "|Web"; + "|" D_CMND_POWER +#ifdef USE_LIGHT + "|Web" +#endif // USE_LIGHT + "|" D_CMND_DIMMER ; void (* const DALICommand[])(void) PROGMEM = { - &CmndDali, &CmndDaliPower, &CmndDaliDimmer, &CmndDaliWeb }; + &CmndDali, &CmndDaliPower, +#ifdef USE_LIGHT + &CmndDaliWeb, +#endif // USE_LIGHT + &CmndDaliDimmer }; struct DALI { uint32_t bit_time; @@ -75,8 +84,7 @@ struct DALI { uint8_t command; uint8_t dimmer; bool power; - bool input_ready; - bool set_power; + bool available; } *Dali = nullptr; /*********************************************************************************************\ @@ -95,7 +103,7 @@ void DaliDisableRxInterrupt(void) { void IRAM_ATTR DaliReceiveData(void); // Fix ESP8266 ISR not in IRAM! exception void DaliReceiveData(void) { - if (Dali->input_ready) { return; } // Skip if last input is not yet handled + if (Dali->available) { return; } // Skip if last input is not yet handled uint32_t wait = ESP.getCycleCount() + (Dali->bit_time / 2); int bit_state = 0; bool dali_read; @@ -120,7 +128,7 @@ void DaliReceiveData(void) { if (abs(bit_state) <= 2) { // Valid Manchester encoding including start and stop bits if (Dali->received_dali_data != received_dali_data) { // Skip duplicates Dali->received_dali_data = received_dali_data; - Dali->input_ready = true; // Valid data received + Dali->available = true; // Valid data received } } } @@ -141,16 +149,14 @@ void DaliSendDataOnce(uint16_t send_dali_data) { bool pin_value = bit_value ? LOW : HIGH; // Invert bit digitalWrite(Dali->pin_tx, (pin_value == DALI_OUT_INVERT) ? LOW : HIGH); wait += Dali->bit_time; // Auto roll-over - while (ESP.getCycleCount() < wait) { - optimistic_yield(1); - } + while (ESP.getCycleCount() < wait); } } void DaliSendData(uint8_t firstByte, uint8_t secondByte) { Dali->address = firstByte; Dali->command = secondByte; - if (BROADCAST_DP == firstByte) { + if (DALI_BROADCAST_DP == firstByte) { Dali->power = (secondByte); // State if (Dali->power) { Dali->dimmer = secondByte; // Value @@ -162,14 +168,16 @@ void DaliSendData(uint8_t firstByte, uint8_t secondByte) { DaliDisableRxInterrupt(); delay(3); // Settling time between forward and backward frame DaliSendDataOnce(send_dali_data); // Takes 14.5 ms - delay(14); // As used by Busch-Jaeger - DaliSendDataOnce(send_dali_data); // Takes 14.5 ms + if (DALI_BROADCAST_DP == firstByte) { + delay(14); // As used by Busch-Jaeger and suggested by DALI protocol (> 9.17 ms) + DaliSendDataOnce(send_dali_data); // Takes 14.7 ms + } delay(3); // Block response DaliEnableRxInterrupt(); } void DaliPower(uint8_t val) { - DaliSendData(BROADCAST_DP, val); + DaliSendData(DALI_BROADCAST_DP, val); } /***********************************************************/ @@ -187,35 +195,46 @@ void ResponseDali(void) { } void DaliInput(void) { - if (Dali->input_ready) { + if (Dali->available) { Dali->address = Dali->received_dali_data >> 8; Dali->command = Dali->received_dali_data; - if (BROADCAST_DP == Dali->address) { - uint8_t dimmer = changeUIntScale(Dali->dimmer, 0, 254, 0, 100); - uint8_t power = Dali->power; +#ifdef USE_LIGHT + if (DALI_BROADCAST_DP == Dali->address) { + uint8_t dimmer_old = changeUIntScale(Dali->dimmer, 0, 254, 0, 100); + uint8_t power_old = Dali->power; Dali->power = (Dali->command); // State if (Dali->power) { Dali->dimmer = Dali->command; // Value } if (Settings->sbflag1.dali_web) { // DaliWeb 1 - char scmnd[20]; uint8_t dimmer_new = changeUIntScale(Dali->dimmer, 0, 254, 0, 100); - if (power != Dali->power) { - ExecuteCommandPower(1, Dali->power, SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction + if (power_old != Dali->power) { + ExecuteCommandPower(LightDevice(), Dali->power, SRC_SWITCH); } - else if (dimmer != dimmer_new) { + else if (dimmer_old != dimmer_new) { + char scmnd[20]; snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), dimmer_new); ExecuteCommand(scmnd, SRC_SWITCH); } } } -// AddLog(LOG_LEVEL_DEBUG, PSTR("DLI: Received 0x%04X"), Dali->received_dali_data); if (!Settings->sbflag1.dali_web) { // DaliWeb 0 ResponseDali(); MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_PRFX_DALI)); } - Dali->input_ready = false; +#else + if (DALI_BROADCAST_DP == Dali->address) { + Dali->power = (Dali->command); // State + if (Dali->power) { + Dali->dimmer = Dali->command; // Value + } + } + ResponseDali(); + MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_PRFX_DALI)); +#endif // USE_LIGHT + + Dali->available = false; } } @@ -243,6 +262,7 @@ bool DaliInit(void) { DaliEnableRxInterrupt(); +#ifdef USE_LIGHT if (!Settings->sbflag1.dali_web) { // DaliWeb 0 return false; } @@ -250,8 +270,12 @@ bool DaliInit(void) { UpdateDevicesPresent(1); TasmotaGlobal.light_type = LT_SERIAL1; // Single channel return true; +#else + return false; +#endif // USE_LIGHT } +#ifdef USE_LIGHT bool DaliSetChannels(void) { if (Settings->sbflag1.dali_web) { // DaliWeb 1 uint8_t value = ((uint8_t*)XdrvMailbox.data)[0]; @@ -260,6 +284,7 @@ bool DaliSetChannels(void) { } return true; } +#endif // USE_LIGHT /*********************************************************************************************\ * Experimental - Not functioning @@ -298,7 +323,7 @@ bool DaliMqtt(void) { int DALIindex = 0; int ADRindex = 0; int CMDindex = 0; - uint8_t DALIaddr = BROADCAST_DP; + uint8_t DALIaddr = DALI_BROADCAST_DP; if (strcasecmp_P(items[cnt - 3], PSTR(DALI_TOPIC)) != 0) { // dali // cmnd @@ -355,7 +380,7 @@ bool DaliJsonParse(void) { int DALIindex = 0; int ADRindex = 0; int8_t DALIdim = -1; - uint8_t DALIaddr = BROADCAST_DP; + uint8_t DALIaddr = DALI_BROADCAST_DP; JsonParserToken val = root[PSTR("cmd")]; if (val) { @@ -426,6 +451,7 @@ void CmndDaliDimmer(void) { ResponseDali(); } +#ifdef USE_LIGHT void CmndDaliWeb(void) { // DaliWeb 0 - Disable GUI light controls // DaliWeb 1 - Enable GUI light controls @@ -435,6 +461,7 @@ void CmndDaliWeb(void) { } ResponseCmndStateText(Settings->sbflag1.dali_web); } +#endif // USE_LIGHT /*********************************************************************************************\ * Presentation @@ -465,9 +492,11 @@ bool Xdrv75(uint32_t function) { case FUNC_MQTT_DATA: result = DaliMqtt(); break; +#ifdef USE_LIGHT case FUNC_SET_CHANNELS: result = DaliSetChannels(); break; +#endif // USE_LIGHT case FUNC_JSON_APPEND: DaliShow(true); break; diff --git a/tasmota/tasmota_xdsp_display/xdsp_17_universal.ino b/tasmota/tasmota_xdsp_display/xdsp_17_universal.ino index f376ee8c2..5c19209fa 100644 --- a/tasmota/tasmota_xdsp_display/xdsp_17_universal.ino +++ b/tasmota/tasmota_xdsp_display/xdsp_17_universal.ino @@ -397,7 +397,7 @@ Renderer *Init_uDisplay(const char *desc) { if (!wire_n) { GT911_Touch_Init(&Wire, irq, rst, xs, ys); } -#ifdef ESP32 +#if defined(ESP32) && defined(USE_I2C_BUS2) else { GT911_Touch_Init(&Wire1, irq, rst, xs, ys); } @@ -414,7 +414,7 @@ Renderer *Init_uDisplay(const char *desc) { if (!wire_n) { FT5206_Touch_Init(Wire); } -#ifdef ESP32 +#if defined(ESP32) && defined(USE_I2C_BUS2) else { FT5206_Touch_Init(Wire1); } diff --git a/tasmota/tasmota_xsns_sensor/xsns_103_sen5x.ino b/tasmota/tasmota_xsns_sensor/xsns_103_sen5x.ino index be21ff1e9..7d014bd1a 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_103_sen5x.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_103_sen5x.ino @@ -75,7 +75,7 @@ void sen5x_Init(void) { sen5x = new SensirionI2CSen5x(); if (1 == usingI2cBus) { -#ifdef ESP32 +#if defined(ESP32) && defined(USE_I2C_BUS2) sen5x->begin(Wire1); #else sen5x->begin(Wire);