forked from RobTillaart/Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintString.h
More file actions
50 lines (38 loc) · 813 Bytes
/
Copy pathPrintString.h
File metadata and controls
50 lines (38 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
//
// FILE: PrintString.h
// AUTHOR: Rob Tillaart
// VERSION: 0.2.0
// PURPOSE: Class that captures prints into a String
// DATE: 2017-12-09
// URL: https://github.com/RobTillaart/PrintString
//
// 0.1.0 2017-12-09 initial version
// 0.1.1 2020-04-26 added size
// 0.1.2 2020-06-19 fix library.json
// 0.2.0 2021-01-06 add Arduino-CI + unit test
#include "Arduino.h"
#include "Print.h"
#define PRINTSTRING_VERSION (F("0.2.0"))
class PrintString: public Print
{
public:
PrintString() {};
size_t write(uint8_t c)
{
buffer.concat(char(c));
return 1;
}
size_t size()
{
return buffer.length();
}
void clear()
{
buffer = "";
}
String getString() { return buffer; }
private:
String buffer;
};
// -- END OF FILE --