aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2014-05-24 00:13:07 +0200
committerCristian Maglie <c.maglie@bug.st>2014-05-24 00:13:07 +0200
commitf3e78a4a2920665b45b964049db3ebed9b8f1dc7 (patch)
treec5c0d29a8bb3e0b4cd73fc2c91c82941be29bdce
parentc16768565b4ea62a06d21fa6d5cb0cbb0af902fa (diff)
Backported Print class from ide-1.5.x branch
Close #1951
-rwxr-xr-xcores/arduino/Print.cpp8
-rwxr-xr-xcores/arduino/Print.h3
2 files changed, 5 insertions, 6 deletions
diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp
index 53961ec..5df5630 100755
--- a/cores/arduino/Print.cpp
+++ b/cores/arduino/Print.cpp
@@ -41,7 +41,7 @@ size_t Print::write(const uint8_t *buffer, size_t size)
size_t Print::print(const __FlashStringHelper *ifsh)
{
- const char PROGMEM *p = (const char PROGMEM *)ifsh;
+ PGM_P p = reinterpret_cast<PGM_P>(ifsh);
size_t n = 0;
while (1) {
unsigned char c = pgm_read_byte(p++);
@@ -53,11 +53,7 @@ size_t Print::print(const __FlashStringHelper *ifsh)
size_t Print::print(const String &s)
{
- size_t n = 0;
- for (uint16_t i = 0; i < s.length(); i++) {
- n += write(s[i]);
- }
- return n;
+ return write(s.c_str(), s.length());
}
size_t Print::print(const char str[])
diff --git a/cores/arduino/Print.h b/cores/arduino/Print.h
index dc76150..7b53aa4 100755
--- a/cores/arduino/Print.h
+++ b/cores/arduino/Print.h
@@ -51,6 +51,9 @@ class Print
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
+ size_t write(const char *buffer, size_t size) {
+ return write((const uint8_t *)buffer, size);
+ }
size_t print(const __FlashStringHelper *);
size_t print(const String &);