From 89e0797657d2c08ba188e92f0e8e6fc2fcc22e25 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 30 Dec 2025 11:14:41 -1000 Subject: [PATCH] simple --- .../addressable_light/addressable_light_display.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/esphome/components/addressable_light/addressable_light_display.h b/esphome/components/addressable_light/addressable_light_display.h index 483bc687cf..53f8604b7d 100644 --- a/esphome/components/addressable_light/addressable_light_display.h +++ b/esphome/components/addressable_light/addressable_light_display.h @@ -2,7 +2,6 @@ #include "esphome/core/component.h" #include "esphome/core/color.h" -#include "esphome/core/string_ref.h" #include "esphome/components/display/display_buffer.h" #include "esphome/components/light/addressable_light.h" @@ -26,14 +25,13 @@ class AddressableLightDisplay : public display::DisplayBuffer { if (enabled_ && !enabled) { // enabled -> disabled // - Tell the parent light to refresh, effectively wiping the display. Also // restores the previous effect (if any). - if (this->last_effect_.has_value()) { - auto &ref = *this->last_effect_; - light_state_->make_call().set_effect(ref.c_str(), ref.size()).perform(); + if (this->last_effect_index_.has_value()) { + light_state_->make_call().set_effect(*this->last_effect_index_).perform(); } } else if (!enabled_ && enabled) { // disabled -> enabled - // - Save the current effect (pointer to rodata, valid for program lifetime). - this->last_effect_ = light_state_->get_effect_name_ref(); + // - Save the current effect index. + this->last_effect_index_ = light_state_->get_current_effect_index(); // - Disable any current effect. light_state_->make_call().set_effect(0).perform(); } @@ -60,7 +58,7 @@ class AddressableLightDisplay : public display::DisplayBuffer { int32_t width_; int32_t height_; std::vector addressable_light_buffer_; - optional last_effect_; + optional last_effect_index_; optional> pixel_mapper_f_; }; } // namespace addressable_light