From a621eff2494319f76f6aa11fdeb509110006d2cb Mon Sep 17 00:00:00 2001 From: Hashem Zavvari Date: Thu, 20 May 2021 21:15:22 +0430 Subject: [PATCH] Update NeoSWSerial.cpp 1- In line 138, rxPin input mode changed to INPUT_PULLUP for cancel noise. 2- In lin 268, peek method added. --- src/NeoSWSerial.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/NeoSWSerial.cpp b/src/NeoSWSerial.cpp index ce8edfe..a1e5bf7 100644 --- a/src/NeoSWSerial.cpp +++ b/src/NeoSWSerial.cpp @@ -135,7 +135,7 @@ void NeoSWSerial::listen() if (listener) listener->ignore(); - pinMode(rxPin, INPUT); + pinMode(rxPin, INPUT_PULLUP); rxBitMask = digitalPinToBitMask( rxPin ); rxPort = portInputRegister( digitalPinToPort( rxPin ) ); @@ -268,6 +268,17 @@ int NeoSWSerial::available() //---------------------------------------------------------------------------- +int NeoSWSerial::peek(void) +{ + if (rxHead == rxTail) { + return -1; + } else { + return rxBuffer[rxTail]; + } +} // peek + +//---------------------------------------------------------------------------- + int NeoSWSerial::read() { if (rxHead == rxTail) return -1;