diff --git a/CHANGELOG.md b/CHANGELOG.md index f0b2180bb..aa1129879 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,8 @@ All notable changes to this project will be documented in this file. ### Added - Support for ESP32 Two-Wire Automotive Interface (TWAI) or Controller Area Network (CAN) busses - Support for Senseair S88 CO2 sensor (#22733) -- TasmotaLED change dynamically the number of pixels -- Expand `Pixels` with reverse, height and alternate +- ESP32 TasmotaLED change dynamically the number of pixels (#22754) +- ESP32 expand `Pixels` with reverse, height and alternate (#22755) ### Breaking Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index d1870b275..50372761c 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -120,6 +120,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - Support for PCF85063 RTC [#22727](https://github.com/arendst/Tasmota/issues/22727) - Support for Senseair S88 CO2 sensor [#22733](https://github.com/arendst/Tasmota/issues/22733) - Support for ESP32 Two-Wire Automotive Interface (TWAI) or Controller Area Network (CAN) busses +- ESP32 TasmotaLED change dynamically the number of pixels [#22754](https://github.com/arendst/Tasmota/issues/22754) +- ESP32 expand `Pixels` with reverse, height and alternate [#22755](https://github.com/arendst/Tasmota/issues/22755) - Berry `animate.crenel` primitive [#22673](https://github.com/arendst/Tasmota/issues/22673) - Berry scroll to Leds_matrix [#22693](https://github.com/arendst/Tasmota/issues/22693) - Berry add unicode encoding to string parsing [#22713](https://github.com/arendst/Tasmota/issues/22713) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_91_esp32_twai.ino b/tasmota/tasmota_xdrv_driver/xdrv_91_esp32_twai.ino index 817c92ffd..96aad3802 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_91_esp32_twai.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_91_esp32_twai.ino @@ -22,6 +22,8 @@ * - See example below. * - When executed by `preinit.be` it allows to configure the TWAI driver mode and speed * + * For more information see https://tasmota.github.io/docs/TWAI/ + * * Supported command: * TwaiSend[] [[[[[[[[],],],],],],],] * TwaiSend[] {"ID":,["DATA":[[[[[[[],],],],],],],]]} @@ -67,147 +69,43 @@ struct TWAIs { \*********************************************************************************************/ /* -file twai.be contents: +file twai_minimal.be contents: class twai_cls - var active, pressure_next # (bool, bool) - var twai_speed, twai_mode # (int, int) - var am012_status, am014_substatus, am024_power # (int, int, int) - var dz_am012_status, dz_am014_substatus # (int, int) - var pressure, setpoint, flow_temp # (float, float, float) - var dz_pressure, dz_flow_temp # (float, float) + var twai_speed, twai_mode # (int, int) def init() - self.twai_speed = 7 # 0 = 25K, 1 = 50K, 2 = 100K, 3 = 125K, 4 = 250K, 5 = 500K, 6 = 800K, 7 = 1Mbits + self.twai_speed = 4 # 0 = 25K, 1 = 50K, 2 = 100K, 3 = 125K, 4 = 250K, 5 = 500K, 6 = 800K, 7 = 1Mbits self.twai_mode = 2 # 0 = TWAI_MODE_NORMAL, 1 = TWAI_MODE_NO_ACK, 2 = TWAI_MODE_LISTEN_ONLY - self.active = 0 - self.am012_status = 0 - self.am014_substatus = 0 - self.dz_am012_status = 0 - self.dz_am014_substatus = 0 - self.am024_power = 0 - self.pressure_next = 0 - self.pressure = 0 - self.dz_pressure = 0 - self.setpoint = 0 - self.flow_temp = 0 - self.dz_flow_temp = 0 end #---------------------------------------------------------------------------------------------- Allow TWAI driver configuration on restart (if this file is installed by preinit.be) ----------------------------------------------------------------------------------------------# - def config(bus) -# if bus != 1 return nil end # Exit if not my bus + def config(bus) # This function name (config) is called by the TWAI driver! return self.twai_mode << 3 | self.twai_speed # Initial configure TWAI driver end #---------------------------------------------------------------------------------------------- - This example decodes Remeha Calenta Ace CAN-bus messages and sends it to predefined Domoticz idx + This example decodes nothing but allows for the driver to show message logging in log level 4 ----------------------------------------------------------------------------------------------# - def decode(param, ident, data1, data2) + def decode(param, ident, data1, data2) # This function name (decode) is called by the TWAI driver! var bus = param & 0xF # Bus number (1..3) -# if bus != 1 return nil end # Exit if not my bus var len = param >> 4 & 0xF # Number of data bytes (0..8) var extended = ident >> 31 & 0x1 # Extended identifier flag (0..1) - if extended == 1 return nil end # Remeha uses 11-bit Standard Frame Format var id = ident & 0x1fffffff - if id == 0x076 # Incremental counter from 0 to 255 -# tasmota.log(f"RMH: 0x{id:03x} Count {data1}", 3) -# elif id == 0x080 # Heartbeat every second - elif id == 0x100 # Date and Time - var epoch = 441763200 + (data2 * 24 * 60 * 60) + (data1 / 1000) -# tasmota.log(f"RMH: 0x{id:03x} Time {tasmota.time_str(epoch)}", 3) - elif id == 0x1C1 # Many different data1/2 - if data1 & 0x00ffffff == 0x503f41 # Next time it's pressure - self.pressure_next = 1 - elif self.pressure_next == 1 - self.pressure = (data2 & 0xff00)/2560.0 # This must be pressure - self.pressure_next = 0 - end - elif id == 0x382 - self.am024_power = data1 & 0xff # Relative power - self.setpoint = (data1 & 0xffff00)/25600.0 # Setpoint -# tasmota.log(f"RMH: 0x{id:03x} Busy {self.am024_power}%, Setpoint {self.setpoint}", 3) - elif id == 0x282 - self.flow_temp = (data1 & 0xffff00)/25600.0 -# tasmota.log(f"RMH: 0x{id:03x} DHW temp {self.flow_temp}", 3) - elif id == 0x481 # Status information - self.am012_status = data1 & 0xff - self.am014_substatus = (data1 & 0xff00)/256 - else - return - end - self.active = 1 # At least one valid decode - end - #---------------------------------------------------------------------------------------------- - Add sensor value to teleperiod - ----------------------------------------------------------------------------------------------# - def json_append() - if !self.active return nil end # Exit if never decoded something - import string - var msg = string.format(",\"Calenta\":{\"AM012\":%i,\"AM014\":%i,\"Pressure\":%.1f,\"Setpoint\":%.1f,\"Flow\":%.1f}", - self.am012_status, self.am014_substatus, self.pressure, self.setpoint, self.flow_temp) - tasmota.response_append(msg) - end - - #---------------------------------------------------------------------------------------------- - Perform action just after teleperiod (not used) - ----------------------------------------------------------------------------------------------# -# def after_teleperiod() - #---------------------------------------------------------------------------------------------- - Perform action every second - - As many datagrams can occur sending at teleperiod time takes too long - Also only send if changed to reduce TWAI wait time - ----------------------------------------------------------------------------------------------# - def every_second() - if self.dz_pressure != self.pressure - tasmota.cmd('_DzSend1 523,' .. self.pressure) # Send pressure to Domoticz - end - self.dz_pressure = self.pressure - - if self.dz_flow_temp != self.flow_temp - tasmota.cmd('_DzSend1 526,' .. self.flow_temp) # Send flow temp to Domoticz - end - self.dz_flow_temp = self.flow_temp - - if self.dz_am012_status != self.am012_status - tasmota.cmd('_DzSend1 536,' .. self.am012_status) # Send status to Domoticz - end - self.dz_am012_status = self.am012_status - - if self.dz_am014_substatus != self.am014_substatus - tasmota.cmd('_DzSend1 537,' .. self.am014_substatus) # Send substatus to Domoticz - end - self.dz_am014_substatus = self.am014_substatus - end - - #---------------------------------------------------------------------------------------------- - Display sensor value in the web UI - ----------------------------------------------------------------------------------------------# - def web_sensor() - if !self.active return nil end # Exit if never decoded something - import string - var msg = string.format("{s}AM012/AM014 State{m}%i/%i{e}".. - "{s}AM024 Relative Power{m}%i %%{e}".. - "{s}Pressure{m}%.1f{e}".. - "{s}Setpoint Temperature{m}%.1f{e}".. - "{s}Flow Temperature{m}%.1f{e}", - self.am012_status, self.am014_substatus, self.am024_power, self.pressure, self.setpoint, self.flow_temp) - tasmota.web_send_decimal(msg) end end -twai = twai_cls() +twai = twai_cls() # This class name (twai) is used by the TWAI driver! tasmota.add_driver(twai) // ******************************************************************************************* file preinit.be contents: -load('twai.be') +load('twai_minimal.be') */ /*********************************************************************************************\