Skip to content

Commit 44b5096

Browse files
committed
Backported Print class from ide-1.5.x branch
Close #1951
1 parent fb8e439 commit 44b5096

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

hardware/arduino/cores/arduino/Print.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ size_t Print::write(const uint8_t *buffer, size_t size)
4141

4242
size_t Print::print(const __FlashStringHelper *ifsh)
4343
{
44-
const char PROGMEM *p = (const char PROGMEM *)ifsh;
44+
PGM_P p = reinterpret_cast<PGM_P>(ifsh);
4545
size_t n = 0;
4646
while (1) {
4747
unsigned char c = pgm_read_byte(p++);
@@ -53,11 +53,7 @@ size_t Print::print(const __FlashStringHelper *ifsh)
5353

5454
size_t Print::print(const String &s)
5555
{
56-
size_t n = 0;
57-
for (uint16_t i = 0; i < s.length(); i++) {
58-
n += write(s[i]);
59-
}
60-
return n;
56+
return write(s.c_str(), s.length());
6157
}
6258

6359
size_t Print::print(const char str[])

hardware/arduino/cores/arduino/Print.h

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class Print
5151
return write((const uint8_t *)str, strlen(str));
5252
}
5353
virtual size_t write(const uint8_t *buffer, size_t size);
54+
size_t write(const char *buffer, size_t size) {
55+
return write((const uint8_t *)buffer, size);
56+
}
5457

5558
size_t print(const __FlashStringHelper *);
5659
size_t print(const String &);

0 commit comments

Comments
 (0)