mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-08 17:02:26 +03:00
PgmSpace working
PSTR() and F() macros correctly place string into flash memory relying on PROGMEM PROGMEM uses ICACHE_RODATA_ATTR Print and String classes fixed up str* classes fixed up
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
|
||||
Modified 23 November 2006 by David A. Mellis
|
||||
Modified December 2014 by Ivan Grokhotkov
|
||||
Modified May 2015 by Michael C. Miller - esp8266 progmem support
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -42,6 +43,18 @@ size_t ICACHE_FLASH_ATTR Print::write(const uint8_t *buffer, size_t size) {
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t ICACHE_FLASH_ATTR Print::print(const __FlashStringHelper *ifsh) {
|
||||
PGM_P p = reinterpret_cast<PGM_P>(ifsh);
|
||||
|
||||
size_t n = 0;
|
||||
while (1) {
|
||||
uint8_t c = pgm_read_byte(p++);
|
||||
if (c == 0) break;
|
||||
n += write(c);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t ICACHE_FLASH_ATTR Print::print(const String &s) {
|
||||
return write(s.c_str(), s.length());
|
||||
}
|
||||
@ -92,6 +105,12 @@ size_t ICACHE_FLASH_ATTR Print::print(double n, int digits) {
|
||||
return printFloat(n, digits);
|
||||
}
|
||||
|
||||
size_t ICACHE_FLASH_ATTR Print::println(const __FlashStringHelper *ifsh) {
|
||||
size_t n = print(ifsh);
|
||||
n += println();
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t ICACHE_FLASH_ATTR Print::print(const Printable& x) {
|
||||
return x.printTo(*this);
|
||||
}
|
||||
|
Reference in New Issue
Block a user