mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-09-12 01:24:04 +00:00
* [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.
82 lines
2.1 KiB
C++
82 lines
2.1 KiB
C++
/*-------------------------------------------------------------------------
|
|
Arduino library to ...
|
|
|
|
Written by Jochen Krapf,
|
|
contributions by ... and other members of the open
|
|
source community.
|
|
|
|
-------------------------------------------------------------------------
|
|
This file is part of the MechInputs library.
|
|
|
|
MechInputs 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 3 of
|
|
the License, or (at your option) any later version.
|
|
|
|
MechInputs 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 MechInputs. If not, see
|
|
<http://www.gnu.org/licenses/>.
|
|
-------------------------------------------------------------------------*/
|
|
|
|
#include <SensorSerial.h>
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
void SensorSerial::begin(long speed)
|
|
{
|
|
if (_hw)
|
|
Serial.begin(speed);
|
|
else
|
|
ESPeasySoftwareSerial::begin(speed);
|
|
}
|
|
|
|
int SensorSerial::peek()
|
|
{
|
|
if (_hw)
|
|
return Serial.peek();
|
|
else
|
|
return ESPeasySoftwareSerial::peek();
|
|
}
|
|
|
|
size_t SensorSerial::write(uint8_t byte)
|
|
{
|
|
if (_hw)
|
|
return Serial.write(byte);
|
|
else
|
|
return ESPeasySoftwareSerial::write(byte);
|
|
}
|
|
|
|
int SensorSerial::read()
|
|
{
|
|
if (_hw)
|
|
return Serial.read();
|
|
else
|
|
return ESPeasySoftwareSerial::read();
|
|
}
|
|
|
|
int SensorSerial::available()
|
|
{
|
|
if (_hw)
|
|
return Serial.available();
|
|
else
|
|
return ESPeasySoftwareSerial::available();
|
|
}
|
|
|
|
void SensorSerial::flush()
|
|
{
|
|
if (_hw)
|
|
Serial.flush();
|
|
else
|
|
ESPeasySoftwareSerial::flush();
|
|
}
|