mirror of
https://github.com/esphome/esphome.git
synced 2025-10-30 14:43:51 +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:
@@ -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);
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user