diff options
author | David A. Mellis <d.mellis@arduino.cc> | 2011-03-27 15:06:20 -0400 |
---|---|---|
committer | David A. Mellis <d.mellis@arduino.cc> | 2011-03-27 15:06:20 -0400 |
commit | ffe7bc53c1862866bf38e01174bd35d20632608c (patch) | |
tree | bf0e12629f37a0fa258b306ee7ba56a1358ac6be /cores/arduino/Print.cpp | |
parent | 99e642a26dc2a406cdfa2d43665f45749b63d5c8 (diff) |
Adding F("foo") syntax for flash strings.
Diffstat (limited to 'cores/arduino/Print.cpp')
-rwxr-xr-x | cores/arduino/Print.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp index 62d93a3..eac145f 100755 --- a/cores/arduino/Print.cpp +++ b/cores/arduino/Print.cpp @@ -43,6 +43,16 @@ void Print::write(const uint8_t *buffer, size_t size) write(*buffer++); } +void Print::print(const __FlashStringHelper *ifsh) +{ + const prog_char *p = (const prog_char *)ifsh; + while (1) { + unsigned char c = pgm_read_byte(p++); + if (c == 0) return; + write(c); + } +} + void Print::print(const String &s) { for (int i = 0; i < s.length(); i++) { @@ -101,10 +111,16 @@ void Print::print(double n, int digits) printFloat(n, digits); } +void Print::println(const __FlashStringHelper *ifsh) +{ + print(ifsh); + println(); +} + void Print::println(void) { print('\r'); - print('\n'); + print('\n'); } void Print::println(const String &s) |