Use PROGMEM_STRING_TABLE for the edge mode names

This commit is contained in:
J. Nick Koston
2026-10-13 10:54:37 -10:00
parent 84b381270f
commit 023df9a6a2
@@ -1,5 +1,6 @@
#include "pulse_counter_sensor.h"
#include "esphome/core/log.h"
#include "esphome/core/progmem.h"
#ifdef HAS_PCNT
#include <driver/gpio.h>
@@ -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);
}