Line | |
---|
1 | #include "Buffer.h"
|
---|
2 | #include "Arduino.h"
|
---|
3 |
|
---|
4 | Buffer::Buffer() {
|
---|
5 | }
|
---|
6 |
|
---|
7 | Buffer::Buffer(uint8_t* buf, size_t size) {
|
---|
8 | this->add(buf,size);
|
---|
9 | }
|
---|
10 | bool Buffer::available() {
|
---|
11 | return this->pos < this->length;
|
---|
12 | }
|
---|
13 |
|
---|
14 | uint8_t Buffer::next() {
|
---|
15 | if (this->available()) {
|
---|
16 | return this->buffer[this->pos++];
|
---|
17 | }
|
---|
18 | return 0;
|
---|
19 | }
|
---|
20 |
|
---|
21 | void Buffer::reset() {
|
---|
22 | this->pos = 0;
|
---|
23 | }
|
---|
24 |
|
---|
25 | void Buffer::add(uint8_t* buf, size_t size) {
|
---|
26 | uint16_t i = 0;
|
---|
27 | for (;i<size;i++) {
|
---|
28 | this->buffer[this->length++] = buf[i];
|
---|
29 | }
|
---|
30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.