mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-01 18:48:28 +02:00
Revert nextion clang-tidy changes (#2566)
This commit is contained in:
@@ -196,7 +196,7 @@ void Nextion::print_queue_members_() {
|
||||
ESP_LOGN(TAG, "print_queue_members_ (top 10) size %zu", this->nextion_queue_.size());
|
||||
ESP_LOGN(TAG, "*******************************************");
|
||||
int count = 0;
|
||||
for (auto &i : this->nextion_queue_) {
|
||||
for (auto *i : this->nextion_queue_) {
|
||||
if (count++ == 10)
|
||||
break;
|
||||
|
||||
@@ -257,9 +257,8 @@ bool Nextion::remove_from_q_(bool report_empty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto nb = std::move(this->nextion_queue_.front());
|
||||
this->nextion_queue_.pop_front();
|
||||
auto &component = nb->component;
|
||||
NextionQueue *nb = this->nextion_queue_.front();
|
||||
NextionComponentBase *component = nb->component;
|
||||
|
||||
ESP_LOGN(TAG, "Removing %s from the queue", component->get_variable_name().c_str());
|
||||
|
||||
@@ -267,8 +266,10 @@ bool Nextion::remove_from_q_(bool report_empty) {
|
||||
if (component->get_variable_name() == "sleep_wake") {
|
||||
this->is_sleeping_ = false;
|
||||
}
|
||||
delete component; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
}
|
||||
|
||||
delete nb; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
this->nextion_queue_.pop_front();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -357,7 +358,7 @@ void Nextion::process_nextion_commands_() {
|
||||
int index = 0;
|
||||
int found = -1;
|
||||
for (auto &nb : this->nextion_queue_) {
|
||||
auto &component = nb->component;
|
||||
NextionComponentBase *component = nb->component;
|
||||
|
||||
if (component->get_queue_type() == NextionQueueType::WAVEFORM_SENSOR) {
|
||||
ESP_LOGW(TAG, "Nextion reported invalid Waveform ID %d or Channel # %d was used!",
|
||||
@@ -368,6 +369,9 @@ void Nextion::process_nextion_commands_() {
|
||||
|
||||
found = index;
|
||||
|
||||
delete component; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
delete nb; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
|
||||
break;
|
||||
}
|
||||
++index;
|
||||
@@ -464,9 +468,8 @@ void Nextion::process_nextion_commands_() {
|
||||
break;
|
||||
}
|
||||
|
||||
auto nb = std::move(this->nextion_queue_.front());
|
||||
this->nextion_queue_.pop_front();
|
||||
auto &component = nb->component;
|
||||
NextionQueue *nb = this->nextion_queue_.front();
|
||||
NextionComponentBase *component = nb->component;
|
||||
|
||||
if (component->get_queue_type() != NextionQueueType::TEXT_SENSOR) {
|
||||
ESP_LOGE(TAG, "ERROR: Received string return but next in queue \"%s\" is not a text sensor",
|
||||
@@ -477,6 +480,9 @@ void Nextion::process_nextion_commands_() {
|
||||
component->set_state_from_string(to_process, true, false);
|
||||
}
|
||||
|
||||
delete nb; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
this->nextion_queue_.pop_front();
|
||||
|
||||
break;
|
||||
}
|
||||
// 0x71 0x01 0x02 0x03 0x04 0xFF 0xFF 0xFF
|
||||
@@ -505,9 +511,8 @@ void Nextion::process_nextion_commands_() {
|
||||
++dataindex;
|
||||
}
|
||||
|
||||
auto nb = std::move(this->nextion_queue_.front());
|
||||
this->nextion_queue_.pop_front();
|
||||
auto &component = nb->component;
|
||||
NextionQueue *nb = this->nextion_queue_.front();
|
||||
NextionComponentBase *component = nb->component;
|
||||
|
||||
if (component->get_queue_type() != NextionQueueType::SENSOR &&
|
||||
component->get_queue_type() != NextionQueueType::BINARY_SENSOR &&
|
||||
@@ -521,6 +526,9 @@ void Nextion::process_nextion_commands_() {
|
||||
component->set_state_from_int(value, true, false);
|
||||
}
|
||||
|
||||
delete nb; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
this->nextion_queue_.pop_front();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -682,7 +690,7 @@ void Nextion::process_nextion_commands_() {
|
||||
int index = 0;
|
||||
int found = -1;
|
||||
for (auto &nb : this->nextion_queue_) {
|
||||
auto &component = nb->component;
|
||||
auto component = nb->component;
|
||||
if (component->get_queue_type() == NextionQueueType::WAVEFORM_SENSOR) {
|
||||
size_t buffer_to_send = component->get_wave_buffer().size() < 255 ? component->get_wave_buffer().size()
|
||||
: 255; // ADDT command can only send 255
|
||||
@@ -699,6 +707,8 @@ void Nextion::process_nextion_commands_() {
|
||||
component->get_wave_buffer().begin() + buffer_to_send);
|
||||
}
|
||||
found = index;
|
||||
delete component; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
delete nb; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
break;
|
||||
}
|
||||
++index;
|
||||
@@ -727,7 +737,7 @@ void Nextion::process_nextion_commands_() {
|
||||
|
||||
if (!this->nextion_queue_.empty() && this->nextion_queue_.front()->queue_time + this->max_q_age_ms_ < ms) {
|
||||
for (int i = 0; i < this->nextion_queue_.size(); i++) {
|
||||
auto &component = this->nextion_queue_[i]->component;
|
||||
NextionComponentBase *component = this->nextion_queue_[i]->component;
|
||||
if (this->nextion_queue_[i]->queue_time + this->max_q_age_ms_ < ms) {
|
||||
if (this->nextion_queue_[i]->queue_time == 0)
|
||||
ESP_LOGD(TAG, "Removing old queue type \"%s\" name \"%s\" queue_time 0",
|
||||
@@ -744,8 +754,11 @@ void Nextion::process_nextion_commands_() {
|
||||
if (component->get_variable_name() == "sleep_wake") {
|
||||
this->is_sleeping_ = false;
|
||||
}
|
||||
delete component; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
}
|
||||
|
||||
delete this->nextion_queue_[i]; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
|
||||
this->nextion_queue_.erase(this->nextion_queue_.begin() + i);
|
||||
i--;
|
||||
|
||||
@@ -899,16 +912,18 @@ uint16_t Nextion::recv_ret_string_(std::string &response, uint32_t timeout, bool
|
||||
* @param variable_name Name for the queue
|
||||
*/
|
||||
void Nextion::add_no_result_to_queue_(const std::string &variable_name) {
|
||||
auto nextion_queue = make_unique<nextion::NextionQueue>();
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
nextion::NextionQueue *nextion_queue = new nextion::NextionQueue;
|
||||
|
||||
nextion_queue->component = make_unique<nextion::NextionComponentBase>();
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
nextion_queue->component = new nextion::NextionComponentBase;
|
||||
nextion_queue->component->set_variable_name(variable_name);
|
||||
|
||||
nextion_queue->queue_time = millis();
|
||||
|
||||
ESP_LOGN(TAG, "Add to queue type: NORESULT component %s", nextion_queue->component->get_variable_name().c_str());
|
||||
this->nextion_queue_.push_back(nextion_queue);
|
||||
|
||||
this->nextion_queue_.push_back(std::move(nextion_queue));
|
||||
ESP_LOGN(TAG, "Add to queue type: NORESULT component %s", nextion_queue->component->get_variable_name().c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -979,7 +994,7 @@ bool Nextion::add_no_result_to_queue_with_printf_(const std::string &variable_na
|
||||
* @param is_sleep_safe The command is safe to send when the Nextion is sleeping
|
||||
*/
|
||||
|
||||
void Nextion::add_no_result_to_queue_with_set(std::shared_ptr<NextionComponentBase> component, int state_value) {
|
||||
void Nextion::add_no_result_to_queue_with_set(NextionComponentBase *component, int state_value) {
|
||||
this->add_no_result_to_queue_with_set(component->get_variable_name(), component->get_variable_name_to_send(),
|
||||
state_value);
|
||||
}
|
||||
@@ -1007,8 +1022,7 @@ void Nextion::add_no_result_to_queue_with_set_internal_(const std::string &varia
|
||||
* @param state_value String value to set
|
||||
* @param is_sleep_safe The command is safe to send when the Nextion is sleeping
|
||||
*/
|
||||
void Nextion::add_no_result_to_queue_with_set(std::shared_ptr<NextionComponentBase> component,
|
||||
const std::string &state_value) {
|
||||
void Nextion::add_no_result_to_queue_with_set(NextionComponentBase *component, const std::string &state_value) {
|
||||
this->add_no_result_to_queue_with_set(component->get_variable_name(), component->get_variable_name_to_send(),
|
||||
state_value);
|
||||
}
|
||||
@@ -1028,11 +1042,12 @@ void Nextion::add_no_result_to_queue_with_set_internal_(const std::string &varia
|
||||
state_value.c_str());
|
||||
}
|
||||
|
||||
void Nextion::add_to_get_queue(std::shared_ptr<NextionComponentBase> component) {
|
||||
void Nextion::add_to_get_queue(NextionComponentBase *component) {
|
||||
if ((!this->is_setup() && !this->ignore_is_setup_))
|
||||
return;
|
||||
|
||||
auto nextion_queue = make_unique<nextion::NextionQueue>();
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
nextion::NextionQueue *nextion_queue = new nextion::NextionQueue;
|
||||
|
||||
nextion_queue->component = component;
|
||||
nextion_queue->queue_time = millis();
|
||||
@@ -1043,7 +1058,7 @@ void Nextion::add_to_get_queue(std::shared_ptr<NextionComponentBase> component)
|
||||
std::string command = "get " + component->get_variable_name_to_send();
|
||||
|
||||
if (this->send_command_(command)) {
|
||||
this->nextion_queue_.push_back(std::move(nextion_queue));
|
||||
this->nextion_queue_.push_back(nextion_queue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1055,13 +1070,15 @@ void Nextion::add_to_get_queue(std::shared_ptr<NextionComponentBase> component)
|
||||
* @param buffer_to_send The buffer size
|
||||
* @param buffer_size The buffer data
|
||||
*/
|
||||
void Nextion::add_addt_command_to_queue(std::shared_ptr<NextionComponentBase> component) {
|
||||
void Nextion::add_addt_command_to_queue(NextionComponentBase *component) {
|
||||
if ((!this->is_setup() && !this->ignore_is_setup_) || this->is_sleeping())
|
||||
return;
|
||||
|
||||
auto nextion_queue = make_unique<nextion::NextionQueue>();
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
nextion::NextionQueue *nextion_queue = new nextion::NextionQueue;
|
||||
|
||||
nextion_queue->component = std::make_shared<nextion::NextionComponentBase>();
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
nextion_queue->component = new nextion::NextionComponentBase;
|
||||
nextion_queue->queue_time = millis();
|
||||
|
||||
size_t buffer_to_send = component->get_wave_buffer_size() < 255 ? component->get_wave_buffer_size()
|
||||
@@ -1070,7 +1087,7 @@ void Nextion::add_addt_command_to_queue(std::shared_ptr<NextionComponentBase> co
|
||||
std::string command = "addt " + to_string(component->get_component_id()) + "," +
|
||||
to_string(component->get_wave_channel_id()) + "," + to_string(buffer_to_send);
|
||||
if (this->send_command_(command)) {
|
||||
this->nextion_queue_.push_back(std::move(nextion_queue));
|
||||
this->nextion_queue_.push_back(nextion_queue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user