Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit d988189

Browse files
authored
v1.2.0
### Releases v1.2.0 1. Add better debug feature. 2. Optimize code and examples to reduce RAM usage 3. Add Table of Contents
1 parent 0cf9906 commit d988189

28 files changed

+3416
-1180
lines changed

Packages_Patches/hardware/teensy/avr/boards.txt

Lines changed: 1589 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
Stream.h - base class for character-based streams.
3+
Copyright (c) 2010 David A. Mellis. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#ifndef Stream_h
21+
#define Stream_h
22+
23+
#include <inttypes.h>
24+
#include "Print.h"
25+
26+
class Stream : public Print
27+
{
28+
public:
29+
constexpr Stream() : _timeout(1000), read_error(0) {}
30+
virtual int available() = 0;
31+
virtual int read() = 0;
32+
virtual int peek() = 0;
33+
34+
void setTimeout(unsigned long timeout);
35+
bool find(const char *target);
36+
bool find(const uint8_t *target) { return find ((const char *)target); }
37+
bool find(const String &target) { return find(target.c_str()); }
38+
bool find(const char *target, size_t length);
39+
bool find(const uint8_t *target, size_t length) { return find ((const char *)target, length); }
40+
bool find(const String &target, size_t length) { return find(target.c_str(), length); }
41+
bool findUntil(const char *target, const char *terminator);
42+
bool findUntil(const uint8_t *target, const char *terminator) { return findUntil((const char *)target, terminator); }
43+
bool findUntil(const String &target, const char *terminator) { return findUntil(target.c_str(), terminator); }
44+
bool findUntil(const char *target, const String &terminator) { return findUntil(target, terminator.c_str()); }
45+
bool findUntil(const String &target, const String &terminator) { return findUntil(target.c_str(), terminator.c_str()); }
46+
bool findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen);
47+
bool findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen) {return findUntil((const char *)target, targetLen, terminate, termLen); }
48+
bool findUntil(const String &target, size_t targetLen, const char *terminate, size_t termLen);
49+
bool findUntil(const char *target, size_t targetLen, const String &terminate, size_t termLen);
50+
bool findUntil(const String &target, size_t targetLen, const String &terminate, size_t termLen);
51+
long parseInt();
52+
long parseInt(char skipChar);
53+
float parseFloat();
54+
float parseFloat(char skipChar);
55+
size_t readBytes(char *buffer, size_t length);
56+
size_t readBytes(uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
57+
size_t readBytesUntil(char terminator, char *buffer, size_t length);
58+
size_t readBytesUntil(char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); }
59+
String readString(size_t max = 120);
60+
String readStringUntil(char terminator, size_t max = 120);
61+
int getReadError() { return read_error; }
62+
void clearReadError() { setReadError(0); }
63+
protected:
64+
void setReadError(int err = 1) { read_error = err; }
65+
unsigned long _timeout;
66+
67+
// KH
68+
int timedRead();
69+
//////
70+
71+
private:
72+
char read_error;
73+
74+
//int timedRead();
75+
76+
int timedPeek();
77+
int peekNextDigit();
78+
};
79+
80+
#endif
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
Stream.h - base class for character-based streams.
3+
Copyright (c) 2010 David A. Mellis. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#ifndef Stream_h
21+
#define Stream_h
22+
23+
#include <inttypes.h>
24+
#include "Print.h"
25+
26+
class Stream : public Print
27+
{
28+
public:
29+
constexpr Stream() : _timeout(1000), read_error(0) {}
30+
virtual int available() = 0;
31+
virtual int read() = 0;
32+
virtual int peek() = 0;
33+
34+
void setTimeout(unsigned long timeout);
35+
bool find(const char *target);
36+
bool find(const uint8_t *target) { return find ((const char *)target); }
37+
bool find(const String &target) { return find(target.c_str()); }
38+
bool find(const char *target, size_t length);
39+
bool find(const uint8_t *target, size_t length) { return find ((const char *)target, length); }
40+
bool find(const String &target, size_t length) { return find(target.c_str(), length); }
41+
bool findUntil(const char *target, const char *terminator);
42+
bool findUntil(const uint8_t *target, const char *terminator) { return findUntil((const char *)target, terminator); }
43+
bool findUntil(const String &target, const char *terminator) { return findUntil(target.c_str(), terminator); }
44+
bool findUntil(const char *target, const String &terminator) { return findUntil(target, terminator.c_str()); }
45+
bool findUntil(const String &target, const String &terminator) { return findUntil(target.c_str(), terminator.c_str()); }
46+
bool findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen);
47+
bool findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen) {return findUntil((const char *)target, targetLen, terminate, termLen); }
48+
bool findUntil(const String &target, size_t targetLen, const char *terminate, size_t termLen);
49+
bool findUntil(const char *target, size_t targetLen, const String &terminate, size_t termLen);
50+
bool findUntil(const String &target, size_t targetLen, const String &terminate, size_t termLen);
51+
long parseInt();
52+
long parseInt(char skipChar);
53+
float parseFloat();
54+
float parseFloat(char skipChar);
55+
size_t readBytes(char *buffer, size_t length);
56+
size_t readBytes(uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
57+
size_t readBytesUntil(char terminator, char *buffer, size_t length);
58+
size_t readBytesUntil(char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); }
59+
String readString(size_t max = 120);
60+
String readStringUntil(char terminator, size_t max = 120);
61+
int getReadError() { return read_error; }
62+
void clearReadError() { setReadError(0); }
63+
protected:
64+
void setReadError(int err = 1) { read_error = err; }
65+
unsigned long _timeout;
66+
67+
// KH
68+
int timedRead();
69+
//////
70+
71+
private:
72+
char read_error;
73+
74+
//int timedRead();
75+
76+
int timedPeek();
77+
int peekNextDigit();
78+
};
79+
80+
#endif

0 commit comments

Comments
 (0)