From 4c15abad294379d30e1ddc9dc950c67ac75373cd Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 13 Oct 2026 17:36:35 -1000 Subject: [PATCH] [cc1101] Keep the modulation name table in flash --- esphome/components/cc1101/cc1101.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/esphome/components/cc1101/cc1101.cpp b/esphome/components/cc1101/cc1101.cpp index 94d89b899d3..defa520b58a 100644 --- a/esphome/components/cc1101/cc1101.cpp +++ b/esphome/components/cc1101/cc1101.cpp @@ -2,6 +2,7 @@ #include "cc1101pa.h" #include "esphome/core/helpers.h" #include "esphome/core/log.h" +#include "esphome/core/progmem.h" #include #include @@ -14,6 +15,9 @@ namespace esphome::cc1101 { ESPHOME_LOG_TAG(TAG, "cc1101"); static constexpr size_t TX_FIFO_SIZE = 64; +// MDMCFG2 MOD_FORMAT values +PROGMEM_STRING_TABLE(ModulationStrings, "2-FSK", "GFSK", "UNUSED", "ASK/OOK", "4-FSK", "UNUSED", "UNUSED", "MSK"); + static void split_float(float value, int mbits, uint8_t &e, uint32_t &m) { int e_tmp; float m_tmp = std::frexp(value, &e_tmp); @@ -238,8 +242,6 @@ void CC1101Component::loop() { } void CC1101Component::dump_config() { - static const char *const MODULATION_NAMES[] = {"2-FSK", "GFSK", "UNUSED", "ASK/OOK", - "4-FSK", "UNUSED", "UNUSED", "MSK"}; int32_t freq = static_cast(this->state_.FREQ2 << 16 | this->state_.FREQ1 << 8 | this->state_.FREQ0) * XTAL_FREQUENCY / (1 << 16); float symbol_rate = (((256.0f + this->state_.DRATE_M) * (1 << this->state_.DRATE_E)) / (1 << 28)) * XTAL_FREQUENCY; @@ -253,8 +255,9 @@ void CC1101Component::dump_config() { " Symbol Rate: %.0f baud\n" " Filter Bandwidth: %.1f Hz\n" " Output Power: %.1f dBm", - this->chip_id_, freq, this->state_.CHANNR, MODULATION_NAMES[this->state_.MOD_FORMAT & 0x07], - symbol_rate, bw, this->output_power_effective_); + this->chip_id_, freq, this->state_.CHANNR, + LOG_STR_ARG(ModulationStrings::get_log_str(this->state_.MOD_FORMAT & 0x07, 0)), symbol_rate, bw, + this->output_power_effective_); LOG_PIN(" CS Pin: ", this->cs_); }