From f065d74293a5717a3638bbbf830daa0af35c17f5 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 12 Jan 2024 13:57:31 +0100 Subject: [PATCH] Add support for HardwareSerial invert (#15461) --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp | 7 ++++--- lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f455a6d5a..90c881e1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. ### Added - Berry `debug.caller` (#20470) - GPIO Viewer user selection of assets website now defaults to `https://ota.tasmota.com/tasmota|tasmota32/gpio_viewer/assets` +- Support for HardwareSerial invert (#15461) ### Breaking Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 4ad43ade1..965134b73 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -126,6 +126,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - NeoPool hydrolysis FL1 and Redox flag [#20258](https://github.com/arendst/Tasmota/issues/20258) - Support negative power on BL0942 using index 5..8 [#20322](https://github.com/arendst/Tasmota/issues/20322) - Support for pipsolar inverter [#20408](https://github.com/arendst/Tasmota/issues/20408) +- Support for HardwareSerial invert [#15461](https://github.com/arendst/Tasmota/issues/15461) - ESP32 used UART information - ESP32 experimental support GPIOViewer when ``define USE_ESP32_GPIO_VIEWER`` is enabled - Berry GPIO viewer initial version using async webserver [#20416](https://github.com/arendst/Tasmota/issues/20416) diff --git a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp b/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp index 9bdfb9733..3dd33b95e 100644 --- a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp +++ b/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp @@ -46,11 +46,12 @@ static uint32_t tasmota_serial_uart_bitmap = 0; // Assigned UARTs #endif // ESP32 -TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback, int nwmode, int buffer_size) { +TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback, int nwmode, int buffer_size, bool invert) { m_valid = false; m_hardserial = false; m_hardswap = false; m_overflow = false; + m_invert = invert; m_data_bits = 8; m_stop_bits = 1; m_nwmode = nwmode; @@ -155,7 +156,7 @@ bool TasmotaSerial::freeUart(void) { } void TasmotaSerial::Esp32Begin(void) { - TSerial->begin(m_speed, m_config, m_rx_pin, m_tx_pin); + TSerial->begin(m_speed, m_config, m_rx_pin, m_tx_pin, m_invert); // For low bit rate, below 9600, set the Full RX threshold at 10 bytes instead of the default 120 if (m_speed <= 9600) { // At 9600, 10 chars are ~10ms @@ -219,7 +220,7 @@ bool TasmotaSerial::begin(uint32_t speed, uint32_t config) { } #ifdef ESP8266 Serial.flush(); - Serial.begin(speed, (SerialConfig)config); + Serial.begin(speed, (SerialConfig)config, SERIAL_FULL, m_tx_pin, m_invert); if (m_hardswap) { Serial.swap(); } diff --git a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h b/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h index 2f9be0963..66caa4102 100644 --- a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h +++ b/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h @@ -37,7 +37,7 @@ class TasmotaSerial : public Stream { public: - TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback = 0, int nwmode = 0, int buffer_size = TM_SERIAL_BUFFER_SIZE); + TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback = 0, int nwmode = 0, int buffer_size = TM_SERIAL_BUFFER_SIZE, bool invert = false); virtual ~TasmotaSerial(); void setTransmitEnablePin(int tx_enable_pin); @@ -102,6 +102,7 @@ class TasmotaSerial : public Stream { bool m_overflow; bool m_high_speed = false; bool m_very_high_speed = false; // above 100000 bauds + bool m_invert; uint8_t *m_buffer = nullptr; #ifdef ESP32 uint32_t m_speed;