From 75fd451fdb8ac77bd097ea45e352efda9987660d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 13 Oct 2026 09:56:38 -1000 Subject: [PATCH] [bl0939] Keep the init command table in flash --- esphome/components/bl0939/bl0939.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/esphome/components/bl0939/bl0939.cpp b/esphome/components/bl0939/bl0939.cpp index e8dc09abba7..54cd86003e6 100644 --- a/esphome/components/bl0939/bl0939.cpp +++ b/esphome/components/bl0939/bl0939.cpp @@ -20,7 +20,7 @@ static const uint8_t BL0939_REG_SOFT_RESET = 0x19; static const uint8_t BL0939_REG_USR_WRPROT = 0x1A; static const uint8_t BL0939_REG_TPS_CTRL = 0x1B; -const uint8_t BL0939_INIT[6][6] = { +static const uint8_t BL0939_INIT[6][6] PROGMEM = { // Reset to default {BL0939_WRITE_COMMAND, BL0939_REG_SOFT_RESET, 0x5A, 0x5A, 0x5A, 0x33}, // Enable User Operation Write @@ -66,8 +66,10 @@ void BL0939::update() { } void BL0939::setup() { - for (auto *i : BL0939_INIT) { - this->write_array(i, 6); + uint8_t cmd[sizeof(BL0939_INIT[0])]; + for (const auto *i : BL0939_INIT) { + progmem_memcpy(cmd, i, sizeof(cmd)); + this->write_array(cmd, sizeof(cmd)); delay(1); } this->flush();