use configurable length for buffer
This commit is contained in:
parent
803f94fe63
commit
55d02cd4d0
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "SerialReader",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.0",
|
||||
"description": "Helper class for reading Serial input, without blocking",
|
||||
"repository":
|
||||
{
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
template <size_t bufferLength>
|
||||
class SerialReader {
|
||||
static const int bufferLength = 50;
|
||||
char buffer[bufferLength];
|
||||
|
||||
public:
|
||||
@ -12,8 +12,8 @@ public:
|
||||
}
|
||||
|
||||
int readLine(HardwareSerial &serial) {
|
||||
static int pos = 0;
|
||||
int rpos;
|
||||
static size_t pos = 0;
|
||||
size_t rpos;
|
||||
int readCh;
|
||||
|
||||
for (int i = 0, avail = serial.available(); i < avail && (readCh = serial.read()) > 0; i++) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user