1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-04 20:32:21 +01:00
This commit is contained in:
J. Nick Koston
2025-09-03 22:05:21 -05:00
parent ea01cc598b
commit da9a7c41d1
2 changed files with 13 additions and 5 deletions

View File

@@ -6,3 +6,14 @@
#ifdef USE_ARDUINO
#include <Arduino.h>
#endif
// Portable PROGMEM string macro
// On ESP8266, PSTR() stores strings in flash memory
// On other platforms, it's a no-op
#ifndef ESPHOME_PSTR
#ifdef USE_ESP8266
#define ESPHOME_PSTR(x) PSTR(x)
#else
#define ESPHOME_PSTR(x) (x)
#endif
#endif

View File

@@ -76,11 +76,8 @@ async def register_component(var, config):
"Error while finding name of component, please report this", exc_info=e
)
if name is not None:
# On ESP8266, store component source strings in PROGMEM to save RAM
if CORE.is_esp8266:
add(var.set_component_source(RawExpression(f'PSTR("{name}")')))
else:
add(var.set_component_source(name))
# Use ESPHOME_PSTR macro which stores strings in PROGMEM on ESP8266, no-op on other platforms
add(var.set_component_source(RawExpression(f'ESPHOME_PSTR("{name}")')))
add(App.register_component(var))
return var