-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathpatching_print.txt
35 lines (24 loc) · 972 Bytes
/
patching_print.txt
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
To use the F("...") inline "flash string" notation with Print::print() and
Print::println(), a small patch needs to be added to the core Print.h file.
This patch effectively tells the Print class that the Flash library objects
all support a print method, and that calling, for example
Serial.print(obj);
is simply an alias for calling
obj.print(Serial);
To insert the patch, first insert this code near the top of Print.h, just
before the declaration of class Print:
#define ARDUINO_CORE_PRINTABLE_SUPPORT
class Print;
class _Printable
{
public:
virtual void print(Print &stream) const = 0;
};
Then, inside the body of the Print class, add these lines, defining two
new methods:
void print(const _Printable &obj) { obj.print(*this); }
void println(const _Printable &obj) { obj.print(*this); println(); }
That's it!
If you have correctly patched the file, the flash_inline_strings.pde
example should compile and work correctly.
Mikal