Change TasmotaSerial library from v3.2.0 to v3.3.0

Change TasmotaSerial library from v3.2.0 to v3.3.0
This commit is contained in:
Theo Arends 2021-03-02 11:44:06 +01:00
parent 185c46e81a
commit 2057912276
9 changed files with 24 additions and 20 deletions

View File

@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
### Changed
- TuyaMcu dimmer timeout (#11121)
- TasmotaSerial library from v3.2.0 to v3.3.0
### Fixed
- Refactor acceleration function for shutter stepper and servo (#11088)

View File

@ -87,6 +87,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
### Changed
- TuyaMcu dimmer timeout [#11121](https://github.com/arendst/Tasmota/issues/11121)
- TasmotaSerial library from v3.2.0 to v3.3.0
### Fixed
- Refactor acceleration function for shutter stepper and servo [#11088](https://github.com/arendst/Tasmota/issues/11088)

View File

@ -1,6 +1,6 @@
{
"name": "TasmotaSerial",
"version": "3.2.0",
"version": "3.3.0",
"keywords": [
"serial", "io", "TasmotaSerial"
],

View File

@ -1,5 +1,5 @@
name=TasmotaSerial
version=3.2.0
version=3.3.0
author=Theo Arends
maintainer=Theo Arends <theo@arends.com>
sentence=Implementation of software serial with hardware serial fallback for ESP8266 and ESP32.

View File

@ -109,16 +109,27 @@ bool TasmotaSerial::isValidGPIOpin(int pin) {
return (pin >= -1 && pin <= 5) || (pin >= 12 && pin <= 15);
}
bool TasmotaSerial::begin(long speed, int stop_bits) {
m_stop_bits = ((stop_bits -1) &1) +1;
bool TasmotaSerial::begin(uint32_t speed, uint32_t config) {
if (config > 2) {
// Legacy support where software serial fakes two stop bits if either stop bits is 2 or parity is not None
m_stop_bits = ((config &0x30) >> 5) +1;
if ((1 == m_stop_bits) && (config &0x03)) {
m_stop_bits++;
}
} else {
m_stop_bits = ((config -1) &1) +1;
#ifdef ESP8266
config = (2 == m_stop_bits) ? (uint32_t)SERIAL_8N2 : (uint32_t)SERIAL_8N1;
#endif // ESP8266
#ifdef ESP32
config = (2 == m_stop_bits) ? SERIAL_8N2 : SERIAL_8N1;
#endif // ESP32
}
if (m_hardserial) {
#ifdef ESP8266
Serial.flush();
if (2 == m_stop_bits) {
Serial.begin(speed, SERIAL_8N2);
} else {
Serial.begin(speed, SERIAL_8N1);
}
Serial.begin(speed, (SerialConfig)config);
if (m_hardswap) {
Serial.swap();
}
@ -131,11 +142,7 @@ bool TasmotaSerial::begin(long speed, int stop_bits) {
m_uart = tasmota_serial_index;
tasmota_serial_index--;
TSerial = new HardwareSerial(m_uart);
if (2 == m_stop_bits) {
TSerial->begin(speed, SERIAL_8N2, m_rx_pin, m_tx_pin);
} else {
TSerial->begin(speed, SERIAL_8N1, m_rx_pin, m_tx_pin);
}
TSerial->begin(speed, config, m_rx_pin, m_tx_pin);
if (serial_buffer_size > 256) {
TSerial->setRxBufferSize(serial_buffer_size);
}
@ -154,10 +161,6 @@ bool TasmotaSerial::begin(long speed, int stop_bits) {
return m_valid;
}
bool TasmotaSerial::begin(void) {
return begin(TM_SERIAL_BAUDRATE);
}
bool TasmotaSerial::hardwareSerial(void) {
#ifdef ESP8266
return m_hardserial;

View File

@ -40,8 +40,7 @@ class TasmotaSerial : public Stream {
TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback = 0, int nwmode = 0, int buffer_size = TM_SERIAL_BUFFER_SIZE);
virtual ~TasmotaSerial();
bool begin(long speed, int stop_bits = 1);
bool begin(void);
bool begin(uint32_t speed = TM_SERIAL_BAUDRATE, uint32_t config = SERIAL_8N1);
bool hardwareSerial(void);
int peek(void);