1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-15 07:08:20 +00:00

fix: correct loop index in remove_lamp function and update return type of get_lamp_name in DynamicLampComponent

This commit is contained in:
Oliver Kleinecke 2025-02-19 22:42:17 +01:00
parent 2fd5fe2d49
commit ddcaac89b3
2 changed files with 3 additions and 4 deletions

View File

@ -161,8 +161,7 @@ void DynamicLampComponent::remove_lamp(std::string lamp_name) {
this->active_lamps_[i].used_outputs[j] = false; this->active_lamps_[i].used_outputs[j] = false;
} }
} }
for (uint8_t j = i; j < 24; j++) { for (uint8_t j = 0; j < 24; j++) {
this->active_lamps_[j] = this->active_lamps_[j + 1];
this->fram_->write((0x0000 + (i * 24) + j), { 0xff }, 1); this->fram_->write((0x0000 + (i * 24) + j), { 0xff }, 1);
} }
this->active_lamps_[i].active = false; this->active_lamps_[i].active = false;
@ -413,7 +412,7 @@ bool DynamicLampComponent::write_state_(uint8_t lamp_number, float state) {
return false; return false;
} }
unsigned char[16] DynamicLampComponent::get_lamp_name(uint8_t lamp_number) { unsigned char* DynamicLampComponent::get_lamp_name(uint8_t lamp_number) {
return this->active_lamps_[lamp_number].name; return this->active_lamps_[lamp_number].name;
} }

View File

@ -104,7 +104,7 @@ class DynamicLampComponent : public Component {
void set_save_mode(uint8_t save_mode); void set_save_mode(uint8_t save_mode);
void add_lamp(std::string name); void add_lamp(std::string name);
void remove_lamp(std::string name); void remove_lamp(std::string name);
unsigned char[16] get_lamp_name(uint8_t lamp_number); unsigned char* get_lamp_name(uint8_t lamp_number);
void add_output_to_lamp(std::string lamp_name, LinkedOutput *output); void add_output_to_lamp(std::string lamp_name, LinkedOutput *output);
void remove_output_from_lamp(std::string lamp_name, LinkedOutput *output); void remove_output_from_lamp(std::string lamp_name, LinkedOutput *output);
std::array<bool, 16> get_lamp_outputs(uint8_t lamp_number); std::array<bool, 16> get_lamp_outputs(uint8_t lamp_number);