1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 22:24:26 +00:00

fix: change return type of build_lamp_list_from_list_str_ to std::vector<bool> and update related handling

This commit is contained in:
Oliver Kleinecke
2025-02-19 10:37:05 +01:00
parent 84694a6122
commit 3db334d5b2
2 changed files with 5 additions and 7 deletions

View File

@@ -267,10 +267,10 @@ bool DynamicLampComponent::add_timer(std::string lamp_list_str, bool timer_activ
return true;
}
LampList DynamicLampComponent::build_lamp_list_from_list_str_(std::string lamp_list_str) {
std::vector<bool> DynamicLampComponent::build_lamp_list_from_list_str_(std::string lamp_list_str) {
std::string delimiter = ",";
std::vector<uint8_t> lamp_list_vector = this->split_to_int_vector_(lamp_list_str, delimiter);
LampList lamp_list;
std::vector<bool> lamp_list;
memset(&lamp_list, 0, sizeof(lamp_list));
if (lamp_list_vector.size() > 16) {
ESP_LOGW(TAG, "Too many lamps in list, only 16 supported!");
@@ -294,9 +294,9 @@ void DynamicLampComponent::read_timers_to_log() {
if (this->active_lamps_[i].active) {
DynamicLampTimer timer;
this->fram_->read((2048), reinterpret_cast<unsigned char *>(&timer), 24);
LampList lamp_list = *reinterpret_cast<LampList *>(&timer.lamp_list);
std::vector<bool> lamp_list = *reinterpret_cast<std::vector<bool> *>(&timer.lamp_list);
for (uint8_t j = 0; j < 16; j++) {
if (lamp_list[j]) {
if (lamp_list[j] && this->active_lamps_[j].active) {
ESP_LOGV(TAG, "Timer found for lamp %s: %d, action: %d, hour: %d, minute: %d, monday: %d, tuesday: %d, wednesday: %d, thursday: %d, friday: %d, saturday: %d, sunday: %d",
this->active_lamps_[j].name, timer.active, timer.action, timer.hour, timer.minute, timer.monday, timer.tuesday,
timer.wednesday, timer.thursday, timer.friday, timer.saturday, timer.sunday);

View File

@@ -68,8 +68,6 @@ struct CombinedLamp {
bool used_outputs[16];
};
std::vector<bool> LampList {};
struct DynamicLampTimer {
unsigned char validation[3] = { 'D', 'L', 'T' };
uint8_t lamp_list[2];
@@ -121,7 +119,7 @@ class DynamicLampComponent : public Component {
uint8_t get_lamp_index_by_name_(std::string lamp_name);
std::array<bool, 16> get_lamp_outputs_by_name_(std::string lamp_name);
std::vector<uint8_t> split_to_int_vector_(const std::string& s, const std::string& delimiter);
LampList build_lamp_list_from_list_str_(std::string lamp_list_str);
std::vector<bool> build_lamp_list_from_list_str_(std::string lamp_list_str);
CombinedLamp active_lamps_[16];
LinkedOutput available_outputs_[16];