From 023df9a6a2155aadb83127d961b58f9b9bb997c6 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 13 Oct 2026 10:54:37 -1000 Subject: [PATCH] Use PROGMEM_STRING_TABLE for the edge mode names --- .../components/pulse_counter/pulse_counter_sensor.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/esphome/components/pulse_counter/pulse_counter_sensor.cpp b/esphome/components/pulse_counter/pulse_counter_sensor.cpp index 54140fa80de..89676a01f36 100644 --- a/esphome/components/pulse_counter/pulse_counter_sensor.cpp +++ b/esphome/components/pulse_counter/pulse_counter_sensor.cpp @@ -1,5 +1,6 @@ #include "pulse_counter_sensor.h" #include "esphome/core/log.h" +#include "esphome/core/progmem.h" #ifdef HAS_PCNT #include @@ -11,8 +12,7 @@ namespace esphome::pulse_counter { ESPHOME_LOG_TAG(TAG, "pulse_counter"); -// Only passed to %s log arguments, which read flash directly on ESP8266 -static const char EDGE_MODE_TO_STRING[][10] PROGMEM = {"DISABLE", "INCREMENT", "DECREMENT"}; +PROGMEM_STRING_TABLE(EdgeModeStrings, "DISABLE", "INCREMENT", "DECREMENT"); #ifdef HAS_PCNT PulseCounterStorageBase *get_storage(bool hw_pcnt) { @@ -187,8 +187,9 @@ void PulseCounterSensor::dump_config() { " Rising Edge: %s\n" " Falling Edge: %s\n" " Filtering pulses shorter than %" PRIu32 " µs", - EDGE_MODE_TO_STRING[this->storage_.rising_edge_mode], - EDGE_MODE_TO_STRING[this->storage_.falling_edge_mode], this->storage_.filter_us); + LOG_STR_ARG(EdgeModeStrings::get_log_str(this->storage_.rising_edge_mode, 0)), + LOG_STR_ARG(EdgeModeStrings::get_log_str(this->storage_.falling_edge_mode, 0)), + this->storage_.filter_us); LOG_UPDATE_INTERVAL(this); }