mirror of
https://github.com/esphome/esphome.git
synced 2025-09-04 12:22:20 +01:00
Revert "[esp8266] Store component source strings in PROGMEM to save RAM"
This reverts commit ea01cc598b
.
This commit is contained in:
@@ -12,9 +12,6 @@
|
||||
#ifdef USE_RUNTIME_STATS
|
||||
#include "esphome/components/runtime_stats/runtime_stats.h"
|
||||
#endif
|
||||
#ifdef USE_ESP8266
|
||||
#include <pgmspace.h>
|
||||
#endif
|
||||
|
||||
namespace esphome {
|
||||
|
||||
@@ -188,19 +185,7 @@ void Component::call() {
|
||||
const char *Component::get_component_source() const {
|
||||
if (this->component_source_ == nullptr)
|
||||
return "<unknown>";
|
||||
#ifdef USE_ESP8266
|
||||
// On ESP8266, component_source_ is stored in PROGMEM
|
||||
// We need a static buffer to hold the string when read from flash
|
||||
// Since this is only used for logging, a single shared buffer is fine
|
||||
static char buffer[64]; // Component names are typically short
|
||||
|
||||
// Copy from PROGMEM to buffer
|
||||
strncpy_P(buffer, this->component_source_, sizeof(buffer) - 1);
|
||||
buffer[sizeof(buffer) - 1] = '\0'; // Ensure null termination
|
||||
return buffer;
|
||||
#else
|
||||
return this->component_source_;
|
||||
#endif
|
||||
}
|
||||
bool Component::should_warn_of_blocking(uint32_t blocking_time) {
|
||||
if (blocking_time > this->warn_if_blocking_over_) {
|
||||
|
@@ -9,7 +9,7 @@ from esphome.const import (
|
||||
)
|
||||
from esphome.core import CORE, ID, coroutine
|
||||
from esphome.coroutine import FakeAwaitable
|
||||
from esphome.cpp_generator import RawExpression, add, get_variable
|
||||
from esphome.cpp_generator import add, get_variable
|
||||
from esphome.cpp_types import App
|
||||
from esphome.types import ConfigFragmentType, ConfigType
|
||||
from esphome.util import Registry, RegistryEntry
|
||||
@@ -76,11 +76,7 @@ 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))
|
||||
add(var.set_component_source(name))
|
||||
|
||||
add(App.register_component(var))
|
||||
return var
|
||||
|
Reference in New Issue
Block a user