[GPS] Serial wrapper support including ESP32

This commit is contained in:
TD-er
2018-12-22 02:10:02 +01:00
parent 70c0d10687
commit c1e13a0392
27 changed files with 411 additions and 268 deletions
+17 -31
View File
@@ -25,57 +25,43 @@
#include <SensorSerial.h>
#ifdef ESP32
SensorSerial::SensorSerial(int receivePin, int transmitPin, bool inverse_logic, unsigned int buffSize) :
ESPeasySerial(receivePin, transmitPin, inverse_logic)
{}
#endif
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;
}
#ifdef ESP8266
SensorSerial::SensorSerial(int receivePin, int transmitPin, bool inverse_logic, unsigned int buffSize) :
ESPeasySerial(receivePin, transmitPin, inverse_logic, buffSize)
{}
#endif
void SensorSerial::begin(long speed)
{
if (_hw)
Serial.begin(speed);
else
ESPeasySoftwareSerial::begin(speed);
void SensorSerial::begin(long speed) {
ESPeasySerial::begin(speed);
}
int SensorSerial::peek()
{
if (_hw)
return Serial.peek();
else
return ESPeasySoftwareSerial::peek();
return ESPeasySerial::peek();
}
size_t SensorSerial::write(uint8_t byte)
{
if (_hw)
return Serial.write(byte);
else
return ESPeasySoftwareSerial::write(byte);
return ESPeasySerial::write(byte);
}
int SensorSerial::read()
{
if (_hw)
return Serial.read();
else
return ESPeasySoftwareSerial::read();
return ESPeasySerial::read();
}
int SensorSerial::available()
{
if (_hw)
return Serial.available();
else
return ESPeasySoftwareSerial::available();
return ESPeasySerial::available();
}
void SensorSerial::flush()
{
if (_hw)
Serial.flush();
else
ESPeasySoftwareSerial::flush();
ESPeasySerial::flush();
}