8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents eae8010 + 759ba27 commit 10a37cbCopy full SHA for 10a37cb
cores/esp8266/Print.cpp
@@ -104,11 +104,19 @@ size_t Print::printf_P(PGM_P format, ...) {
104
size_t Print::print(const __FlashStringHelper *ifsh) {
105
PGM_P p = reinterpret_cast<PGM_P>(ifsh);
106
107
+ char buff[128] __attribute__ ((aligned(4)));
108
+ auto len = strlen_P(p);
109
size_t n = 0;
- while (1) {
- uint8_t c = pgm_read_byte(p++);
110
- if (c == 0) break;
111
- n += write(c);
+ while (n < len) {
+ int to_write = std::min(sizeof(buff), len - n);
112
+ memcpy_P(buff, p, to_write);
113
+ auto written = write(buff, to_write);
114
+ n += written;
115
+ p += written;
116
+ if (!written) {
117
+ // Some error, write() should write at least 1 byte before returning
118
+ break;
119
+ }
120
}
121
return n;
122
0 commit comments