mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-09-12 09:36:59 +00:00
[GPS] Serial wrapper support including ESP32
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user