From c71a43c3a699394b571b8a3c72de38f7ce358367 Mon Sep 17 00:00:00 2001 From: Gijs Noorlander Date: Mon, 18 Dec 2017 22:02:53 +0100 Subject: [PATCH] Reduce iRAM usage for plugins using SoftwareSerial (#631) * [addLib] Added SoftwareSerial library Added latest version from: https://github.com/plerup/espsoftwareserial * [renLib] Renamed files to avoid conflicts with existing code * [renLib] Changed include according to rename * [renLib] Renamed all occurences and includes and removed unused pins Renamed to make sure all plugins use the 'new' ESPeasySoftwareSerial. Also added pinToIndex function to reduce memory footprint with about 150 Bytes, as described in issue #630 * [unused pins] Adjust indices in object list Forgot to change the indices in the object list of SoftwareSerial * Simple patch for timeouts As mentioned in this issue: https://github.com/plerup/espsoftwareserial/issues/54 * [SoftSerial] Set ObjList static Set the object list static to share all SoftwareSerial iRAM used as described in #630 * [revertLib] Revert to old version lib, since new version uses more iram Just to test with old version, originally available in 2.3.0 library, to see if memory usage improves. * [test] Reduce number of ports to 1 and lower buffer size to 18 for MHZ19 Just as a test, to see what happens to the iRAM usage, lower the number of concurrent softserial ports to 1. Also the default buffer size = 64 Bytes. The MH-Z19 sensor can do with less, since a response will be up to 9 bytes, a 18-byte buffer allows for 2 messages to be stored. * Enable usage of up to 10 concurrent softserial and reduce variable sizes Re-enable use of up to 10 concurrent software serials. Also reduce the variable sizes to smaller ranges. (e.g. uint8 instead of int) * [test] Limit number of concurrent software serial devices Earlier tests show the amount of iRAM used is somewhat related to the maximum number of allowed software serial ports. In this test it is set to 3 and they are assigned through first come first served a slot. --- lib/SerialDevices/SensorSerial.cpp | 14 +- lib/SerialDevices/SensorSerial.h | 4 +- lib/SoftwareSerial/ESPeasySoftwareSerial.cpp | 241 ++++++++++++++++++ lib/SoftwareSerial/ESPeasySoftwareSerial.h | 78 ++++++ lib/SoftwareSerial/README.md | 11 + .../examples/swsertest/swsertest.ino | 27 ++ lib/SoftwareSerial/keywords.txt | 31 +++ lib/SoftwareSerial/library.json | 15 ++ lib/SoftwareSerial/library.properties | 9 + src/_P049_MHZ19.ino | 6 +- src/_P052_SenseAir.ino | 6 +- src/_P053_PMSx003.ino | 6 +- src/_P065_DRF0299_MP3.ino | 6 +- src/_P071_Kamstrup401.ino | 4 +- 14 files changed, 435 insertions(+), 23 deletions(-) create mode 100644 lib/SoftwareSerial/ESPeasySoftwareSerial.cpp create mode 100644 lib/SoftwareSerial/ESPeasySoftwareSerial.h create mode 100644 lib/SoftwareSerial/README.md create mode 100644 lib/SoftwareSerial/examples/swsertest/swsertest.ino create mode 100644 lib/SoftwareSerial/keywords.txt create mode 100644 lib/SoftwareSerial/library.json create mode 100644 lib/SoftwareSerial/library.properties diff --git a/lib/SerialDevices/SensorSerial.cpp b/lib/SerialDevices/SensorSerial.cpp index 3b271e2f4..a79b100ea 100644 --- a/lib/SerialDevices/SensorSerial.cpp +++ b/lib/SerialDevices/SensorSerial.cpp @@ -26,7 +26,7 @@ #include -SensorSerial::SensorSerial(int receivePin, int transmitPin, bool inverse_logic, unsigned int buffSize) : SoftwareSerial(receivePin, transmitPin, inverse_logic, buffSize) +SensorSerial::SensorSerial(int receivePin, int transmitPin, bool inverse_logic, unsigned int buffSize) : ESPeasySoftwareSerial(receivePin, transmitPin, inverse_logic, buffSize) { //boolean sws = isValidGPIOpin(receivePin); _hw = receivePin < 0; @@ -37,7 +37,7 @@ void SensorSerial::begin(long speed) if (_hw) Serial.begin(speed); else - SoftwareSerial::begin(speed); + ESPeasySoftwareSerial::begin(speed); } int SensorSerial::peek() @@ -45,7 +45,7 @@ int SensorSerial::peek() if (_hw) return Serial.peek(); else - return SoftwareSerial::peek(); + return ESPeasySoftwareSerial::peek(); } size_t SensorSerial::write(uint8_t byte) @@ -53,7 +53,7 @@ size_t SensorSerial::write(uint8_t byte) if (_hw) return Serial.write(byte); else - return SoftwareSerial::write(byte); + return ESPeasySoftwareSerial::write(byte); } int SensorSerial::read() @@ -61,7 +61,7 @@ int SensorSerial::read() if (_hw) return Serial.read(); else - return SoftwareSerial::read(); + return ESPeasySoftwareSerial::read(); } int SensorSerial::available() @@ -69,7 +69,7 @@ int SensorSerial::available() if (_hw) return Serial.available(); else - return SoftwareSerial::available(); + return ESPeasySoftwareSerial::available(); } void SensorSerial::flush() @@ -77,5 +77,5 @@ void SensorSerial::flush() if (_hw) Serial.flush(); else - SoftwareSerial::flush(); + ESPeasySoftwareSerial::flush(); } diff --git a/lib/SerialDevices/SensorSerial.h b/lib/SerialDevices/SensorSerial.h index 5fbedeca0..30485bb3d 100644 --- a/lib/SerialDevices/SensorSerial.h +++ b/lib/SerialDevices/SensorSerial.h @@ -27,9 +27,9 @@ #define _SENSORSERIAL_H_ #include "Arduino.h" -#include +#include -class SensorSerial : public SoftwareSerial +class SensorSerial : public ESPeasySoftwareSerial { public: SensorSerial(int receivePin, int transmitPin = -1, bool inverse_logic = false, unsigned int buffSize = 64); diff --git a/lib/SoftwareSerial/ESPeasySoftwareSerial.cpp b/lib/SoftwareSerial/ESPeasySoftwareSerial.cpp new file mode 100644 index 000000000..9e0dacedf --- /dev/null +++ b/lib/SoftwareSerial/ESPeasySoftwareSerial.cpp @@ -0,0 +1,241 @@ +/* + +ESPeasySoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266. +Copyright (c) 2015-2016 Peter Lerup. All rights reserved. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#include + +// The Arduino standard GPIO routines are not enough, +// must use some from the Espressif SDK as well +extern "C" { +#include "gpio.h" +} + +#include + +#define MAX_PIN 15 +#define USABLE_PINS 10 +#define NR_CONCURRENT_SOFT_SERIALS 3 + +// As the Arduino attachInterrupt has no parameter, lists of objects +// and callbacks corresponding to each possible GPIO pins have to be defined +static ESPeasySoftwareSerial *ObjList[NR_CONCURRENT_SOFT_SERIALS]; +static uint8_t PinControllerMap[NR_CONCURRENT_SOFT_SERIALS]={}; // Zero all elements + +void ICACHE_RAM_ATTR sws_isr_0() { ObjList[0]->rxRead(); }; +void ICACHE_RAM_ATTR sws_isr_1() { ObjList[1]->rxRead(); }; +void ICACHE_RAM_ATTR sws_isr_2() { ObjList[2]->rxRead(); }; +/*void ICACHE_RAM_ATTR sws_isr_3() { ObjList[3]->rxRead(); }; +void ICACHE_RAM_ATTR sws_isr_4() { ObjList[4]->rxRead(); }; +void ICACHE_RAM_ATTR sws_isr_5() { ObjList[5]->rxRead(); }; +// Pin 6 to 11 can not be used +void ICACHE_RAM_ATTR sws_isr_12() { ObjList[6]->rxRead(); }; +void ICACHE_RAM_ATTR sws_isr_13() { ObjList[7]->rxRead(); }; +void ICACHE_RAM_ATTR sws_isr_14() { ObjList[8]->rxRead(); }; +void ICACHE_RAM_ATTR sws_isr_15() { ObjList[9]->rxRead(); }; +*/ + +static void (*ISRList[NR_CONCURRENT_SOFT_SERIALS])() = { + sws_isr_0, + sws_isr_1, + sws_isr_2 /*, + sws_isr_3, + sws_isr_4, + sws_isr_5, + // Pin 6 to 11 can not be used + sws_isr_12, + sws_isr_13, + sws_isr_14, + sws_isr_15 + */ +}; + +ESPeasySoftwareSerial::ESPeasySoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic, uint16_t buffSize) { + m_rxValid = m_txValid = m_txEnableValid = false; + m_buffer = NULL; + m_invert = inverse_logic; + if (isValidGPIOpin(receivePin)) { + m_rxPin = receivePin; + m_buffSize = buffSize; + m_buffer = (uint8_t*)malloc(m_buffSize); + if (m_buffer != NULL) { + m_rxValid = true; + m_inPos = m_outPos = 0; + pinMode(m_rxPin, INPUT); + const uint8_t index = pinToIndex(m_rxPin); + if (index == NR_CONCURRENT_SOFT_SERIALS) { + return; // Not possible to add software Serial. + } + ObjList[index] = this; + enableRx(true); + } + } + if (isValidGPIOpin(transmitPin)) { + m_txValid = true; + m_txPin = transmitPin; + pinMode(m_txPin, OUTPUT); + digitalWrite(m_txPin, !m_invert); + } + // Default speed + begin(9600); +} + +ESPeasySoftwareSerial::~ESPeasySoftwareSerial() { + enableRx(false); + if (m_rxValid) { + const uint8_t index = pinToIndex(m_rxPin); + if (index < NR_CONCURRENT_SOFT_SERIALS) { + PinControllerMap[index] = 0; + ObjList[index] = NULL; + } + } + if (m_buffer) + free(m_buffer); +} + +bool ESPeasySoftwareSerial::isValidGPIOpin(uint8_t pin) { + if (pin >= 0 && pin <= 5) { + return true; + } + if (pin >= 12 && pin <= MAX_PIN) { + return true; + } + return false; +} + +uint8_t ESPeasySoftwareSerial::pinToIndex(uint8_t pin) { + // Pin will be stored in the map, only "1" will be added, + // to allow simple initialize to 0 and still use GPIO-0. + const uint8_t stored_pin = pin + 1; + for (unsigned i = 0; i < NR_CONCURRENT_SOFT_SERIALS; ++i) { + if (PinControllerMap[i] == stored_pin) return i; + } + // Not found, add as first free option. + for (unsigned i = 0; i < NR_CONCURRENT_SOFT_SERIALS; ++i) { + if (PinControllerMap[i] == 0) { + PinControllerMap[i] = stored_pin; + return i; + } + } + // No more controllers available. + return NR_CONCURRENT_SOFT_SERIALS; +} + +void ESPeasySoftwareSerial::begin(long speed) { + // Use getCycleCount() loop to get as exact timing as possible + m_bitTime = ESP.getCpuFreqMHz()*1000000/speed; +} + +void ESPeasySoftwareSerial::setTransmitEnablePin(uint8_t transmitEnablePin) { + if (isValidGPIOpin(transmitEnablePin)) { + m_txEnableValid = true; + m_txEnablePin = transmitEnablePin; + pinMode(m_txEnablePin, OUTPUT); + digitalWrite(m_txEnablePin, LOW); + } else { + m_txEnableValid = false; + } +} + +void ESPeasySoftwareSerial::enableRx(bool on) { + if (m_rxValid) { + if (on) { + attachInterrupt(m_rxPin, ISRList[pinToIndex(m_rxPin)], m_invert ? RISING : FALLING); + } else { + detachInterrupt(m_rxPin); + } + } +} + +int ESPeasySoftwareSerial::read() { + if (!m_rxValid || (m_inPos == m_outPos)) return -1; + uint8_t ch = m_buffer[m_outPos]; + m_outPos = (m_outPos+1) % m_buffSize; + return ch; +} + +int ESPeasySoftwareSerial::available() { + if (!m_rxValid) return 0; + int avail = m_inPos - m_outPos; + if (avail < 0) avail += m_buffSize; + return avail; +} + +#define WAIT { while (ESP.getCycleCount()-start < wait); wait += m_bitTime; } + +size_t ESPeasySoftwareSerial::write(uint8_t b) { + if (!m_txValid) return 0; + + if (m_invert) b = ~b; + // Disable interrupts in order to get a clean transmit + cli(); + if (m_txEnableValid) digitalWrite(m_txEnablePin, HIGH); + unsigned long wait = m_bitTime; + digitalWrite(m_txPin, HIGH); + unsigned long start = ESP.getCycleCount(); + // Start bit; + digitalWrite(m_txPin, LOW); + WAIT; + for (int i = 0; i < 8; i++) { + digitalWrite(m_txPin, (b & 1) ? HIGH : LOW); + WAIT; + b >>= 1; + } + // Stop bit + digitalWrite(m_txPin, HIGH); + WAIT; + if (m_txEnableValid) digitalWrite(m_txEnablePin, LOW); + sei(); + return 1; +} + +void ESPeasySoftwareSerial::flush() { + m_inPos = m_outPos = 0; +} + +int ESPeasySoftwareSerial::peek() { + if (!m_rxValid || (m_inPos == m_outPos)) return -1; + return m_buffer[m_outPos]; +} + +void ICACHE_RAM_ATTR ESPeasySoftwareSerial::rxRead() { + // Advance the starting point for the samples but compensate for the + // initial delay which occurs before the interrupt is delivered + unsigned long wait = m_bitTime + m_bitTime/3 - 500; + unsigned long start = ESP.getCycleCount(); + uint8_t rec = 0; + for (uint8_t i = 0; i < 8; i++) { + WAIT; + rec >>= 1; + if (digitalRead(m_rxPin)) + rec |= 0x80; + } + if (m_invert) rec = ~rec; + // Stop bit + WAIT; + // Store the received value in the buffer unless we have an overflow + uint16_t next = (m_inPos+1) % m_buffSize; + if (next != m_inPos) { + m_buffer[m_inPos] = rec; + m_inPos = next; + } + // Must clear this bit in the interrupt register, + // it gets set even when interrupts are disabled + GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1 << m_rxPin); +} diff --git a/lib/SoftwareSerial/ESPeasySoftwareSerial.h b/lib/SoftwareSerial/ESPeasySoftwareSerial.h new file mode 100644 index 000000000..8e19b1bc1 --- /dev/null +++ b/lib/SoftwareSerial/ESPeasySoftwareSerial.h @@ -0,0 +1,78 @@ +/* +ESPeasySoftwareSerial.h + +ESPeasySoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266. +Copyright (c) 2015-2016 Peter Lerup. All rights reserved. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library 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 +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#ifndef ESPeasySoftwareSerial_h +#define ESPeasySoftwareSerial_h + +#include +#include + + +// This class is compatible with the corresponding AVR one, +// the constructor however has an optional rx buffer size. +// Speed up to 115200 can be used. + + +class ESPeasySoftwareSerial : public Stream +{ +public: + ESPeasySoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false, uint16_t buffSize = 64); + virtual ~ESPeasySoftwareSerial(); + + void begin(long speed); + void setTransmitEnablePin(uint8_t transmitEnablePin); + + int peek(); + + virtual size_t write(uint8_t byte); + virtual int read(); + virtual int available(); + virtual void flush(); + operator bool() {return m_rxValid || m_txValid;} + + // Disable or enable interrupts on the rx pin + void enableRx(bool on); + + void rxRead(); + + using Print::write; + +private: + bool isValidGPIOpin(uint8_t pin); + uint8_t pinToIndex(uint8_t pin); + + // Member variables + uint8_t m_rxPin, m_txPin, m_txEnablePin; + bool m_rxValid, m_txValid, m_txEnableValid; + bool m_invert; + unsigned long m_bitTime; + uint16_t m_inPos, m_outPos; + uint16_t m_buffSize; + uint8_t *m_buffer; + +}; + +// If only one tx or rx wanted then use this as parameter for the unused pin +#define SW_SERIAL_UNUSED_PIN -1 + + +#endif diff --git a/lib/SoftwareSerial/README.md b/lib/SoftwareSerial/README.md new file mode 100644 index 000000000..23897a081 --- /dev/null +++ b/lib/SoftwareSerial/README.md @@ -0,0 +1,11 @@ +# EspESPeasySoftwareSerial + +Implementation of the Arduino software serial library for the ESP8266 + +Same functionality as the corresponding AVR library but several instances can be active at the same time. +Speed up to 115200 baud is supported. The constructor also has an optional input buffer size. + +Please note that due to the fact that the ESP always have other activities ongoing, there will be some inexactness in interrupt +timings. This may lead to bit errors when having heavy data traffic in high baud rates. + + diff --git a/lib/SoftwareSerial/examples/swsertest/swsertest.ino b/lib/SoftwareSerial/examples/swsertest/swsertest.ino new file mode 100644 index 000000000..b5e2d7293 --- /dev/null +++ b/lib/SoftwareSerial/examples/swsertest/swsertest.ino @@ -0,0 +1,27 @@ + +#include + +ESPeasySoftwareSerial swSer(14, 12, false, 256); + +void setup() { + Serial.begin(115200); + swSer.begin(115200); + + Serial.println("\nSoftware serial test started"); + + for (char ch = ' '; ch <= 'z'; ch++) { + swSer.write(ch); + } + swSer.println(""); + +} + +void loop() { + while (swSer.available() > 0) { + Serial.write(swSer.read()); + } + while (Serial.available() > 0) { + swSer.write(Serial.read()); + } + +} diff --git a/lib/SoftwareSerial/keywords.txt b/lib/SoftwareSerial/keywords.txt new file mode 100644 index 000000000..76a6ed78f --- /dev/null +++ b/lib/SoftwareSerial/keywords.txt @@ -0,0 +1,31 @@ +####################################### +# Syntax Coloring Map for ESPeasySoftwareSerial +# (esp8266) +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +ESPeasySoftwareSerial KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +begin KEYWORD2 +read KEYWORD2 +write KEYWORD2 +available KEYWORD2 +flush KEYWORD2 +overflow KEYWORD2 +peek KEYWORD2 +listen KEYWORD2 +end KEYWORD2 +isListening KEYWORD2 +stopListening KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### + diff --git a/lib/SoftwareSerial/library.json b/lib/SoftwareSerial/library.json new file mode 100644 index 000000000..82b826f0a --- /dev/null +++ b/lib/SoftwareSerial/library.json @@ -0,0 +1,15 @@ +{ + "name": "EspESPeasySoftwareSerial", + "version": "3.3.1", + "keywords": [ + "serial", "io", "softwareserial" + ], + "description": "Implementation of the Arduino software serial for ESP8266. Adjusted to reduce memory footprint for ESPeasy", + "repository": + { + "type": "git", + "url": "https://github.com/plerup/espsoftwareserial" + }, + "frameworks": "arduino", + "platforms": "espressif8266" +} diff --git a/lib/SoftwareSerial/library.properties b/lib/SoftwareSerial/library.properties new file mode 100644 index 000000000..e202a3e2f --- /dev/null +++ b/lib/SoftwareSerial/library.properties @@ -0,0 +1,9 @@ +name=ESPeasySoftwareSerial +version=1.0 +author=Peter Lerup +maintainer=Peter Lerup +sentence=Implementation of the Arduino software serial for ESP8266. +paragraph= +category=Signal Input/Output +url= +architectures=esp8266 diff --git a/src/_P049_MHZ19.ino b/src/_P049_MHZ19.ino index 5890b765f..6678c0fe6 100644 --- a/src/_P049_MHZ19.ino +++ b/src/_P049_MHZ19.ino @@ -28,8 +28,8 @@ boolean Plugin_049_init = false; boolean Plugin_049_ABC_Disable = false; boolean Plugin_049_ABC_MustApply = false; -#include -SoftwareSerial *Plugin_049_SoftSerial; +#include +ESPeasySoftwareSerial *Plugin_049_SoftSerial; // 9-bytes CMD PPM read command byte mhzCmdReadPPM[9] = {0xFF,0x01,0x86,0x00,0x00,0x00,0x00,0x00,0x79}; @@ -179,7 +179,7 @@ boolean Plugin_049(byte function, struct EventStruct *event, String& string) // No guarantee the correct state is active on the sensor after reboot. Plugin_049_ABC_MustApply = true; } - Plugin_049_SoftSerial = new SoftwareSerial(Settings.TaskDevicePin1[event->TaskIndex], Settings.TaskDevicePin2[event->TaskIndex]); + Plugin_049_SoftSerial = new ESPeasySoftwareSerial(Settings.TaskDevicePin1[event->TaskIndex], Settings.TaskDevicePin2[event->TaskIndex], false, 18); Plugin_049_SoftSerial->begin(9600); addLog(LOG_LEVEL_INFO, F("MHZ19: Init OK ")); diff --git a/src/_P052_SenseAir.ino b/src/_P052_SenseAir.ino index 72512187e..9806788fd 100644 --- a/src/_P052_SenseAir.ino +++ b/src/_P052_SenseAir.ino @@ -24,8 +24,8 @@ boolean Plugin_052_init = false; -#include -SoftwareSerial *Plugin_052_SoftSerial; +#include +ESPeasySoftwareSerial *Plugin_052_SoftSerial; boolean Plugin_052(byte function, struct EventStruct *event, String& string) { @@ -103,7 +103,7 @@ boolean Plugin_052(byte function, struct EventStruct *event, String& string) case PLUGIN_INIT: { Plugin_052_init = true; - Plugin_052_SoftSerial = new SoftwareSerial(Settings.TaskDevicePin1[event->TaskIndex], + Plugin_052_SoftSerial = new ESPeasySoftwareSerial(Settings.TaskDevicePin1[event->TaskIndex], Settings.TaskDevicePin2[event->TaskIndex]); success = true; break; diff --git a/src/_P053_PMSx003.ino b/src/_P053_PMSx003.ino index bdcb10cd2..979534180 100644 --- a/src/_P053_PMSx003.ino +++ b/src/_P053_PMSx003.ino @@ -10,7 +10,7 @@ #ifdef PLUGIN_BUILD_TESTING -#include +#include #define PLUGIN_053 #define PLUGIN_ID_053 53 @@ -22,7 +22,7 @@ #define PMSx003_SIG2 0X4d #define PMSx003_SIZE 32 -SoftwareSerial *swSerial = NULL; +ESPeasySoftwareSerial *swSerial = NULL; boolean Plugin_053_init = false; boolean values_received = false; @@ -171,7 +171,7 @@ boolean Plugin_053(byte function, struct EventStruct *event, String& string) { log = F("PMSx003: using software serial"); addLog(LOG_LEVEL_INFO, log); - swSerial = new SoftwareSerial(rxPin, txPin); + swSerial = new ESPeasySoftwareSerial(rxPin, txPin); swSerial->begin(9600); swSerial->flush(); } diff --git a/src/_P065_DRF0299_MP3.ino b/src/_P065_DRF0299_MP3.ino index 8f9a26a5b..f9a59bd98 100644 --- a/src/_P065_DRF0299_MP3.ino +++ b/src/_P065_DRF0299_MP3.ino @@ -33,7 +33,7 @@ #define PLUGIN_NAME_065 "Notify - DFPlayer-Mini MP3 [TESTING]" #define PLUGIN_VALUENAME1_065 "" -#include +#include #ifndef CONFIG #define CONFIG(n) (Settings.TaskDevicePluginConfig[event->TaskIndex][n]) @@ -42,7 +42,7 @@ #define PIN(n) (Settings.TaskDevicePin[n][event->TaskIndex]) #endif -SoftwareSerial* Plugin_065_SoftSerial = NULL; +ESPeasySoftwareSerial* Plugin_065_SoftSerial = NULL; boolean Plugin_065(byte function, struct EventStruct *event, String& string) @@ -106,7 +106,7 @@ boolean Plugin_065(byte function, struct EventStruct *event, String& string) #pragma GCC diagnostic pop - Plugin_065_SoftSerial = new SoftwareSerial(-1, PIN(0)); // no RX, only TX + Plugin_065_SoftSerial = new ESPeasySoftwareSerial(-1, PIN(0)); // no RX, only TX Plugin_065_SoftSerial->begin(9600); diff --git a/src/_P071_Kamstrup401.ino b/src/_P071_Kamstrup401.ino index 903f47511..c98746466 100644 --- a/src/_P071_Kamstrup401.ino +++ b/src/_P071_Kamstrup401.ino @@ -11,7 +11,7 @@ #ifdef PLUGIN_BUILD_TESTING -#include +#include #define PLUGIN_071 #define PLUGIN_ID_071 071 #define PLUGIN_NAME_071 "Communication - Kamstrup Multical 401 [TESTING]" @@ -71,7 +71,7 @@ boolean Plugin_071(byte function, struct EventStruct *event, String& string) PIN_KAMSER_RX = Settings.TaskDevicePin1[event->TaskIndex]; PIN_KAMSER_TX = Settings.TaskDevicePin2[event->TaskIndex]; - SoftwareSerial kamSer(PIN_KAMSER_RX, PIN_KAMSER_TX, false); // Initialize serial + ESPeasySoftwareSerial kamSer(PIN_KAMSER_RX, PIN_KAMSER_TX, false); // Initialize serial pinMode(PIN_KAMSER_RX,INPUT); pinMode(PIN_KAMSER_TX,OUTPUT);