mirror of
https://github.com/esphome/esphome.git
synced 2026-06-01 09:25:09 +08:00
[nextion] Replace std::deque queues with std::list (#15211)
This commit is contained in:
@@ -841,10 +841,10 @@ void Nextion::process_nextion_commands_() {
|
|||||||
|
|
||||||
if (this->max_q_age_ms_ > 0 && !this->nextion_queue_.empty() &&
|
if (this->max_q_age_ms_ > 0 && !this->nextion_queue_.empty() &&
|
||||||
ms - this->nextion_queue_.front()->queue_time > this->max_q_age_ms_) {
|
ms - this->nextion_queue_.front()->queue_time > this->max_q_age_ms_) {
|
||||||
for (size_t i = 0; i < this->nextion_queue_.size(); i++) {
|
for (auto it = this->nextion_queue_.begin(); it != this->nextion_queue_.end();) {
|
||||||
NextionComponentBase *component = this->nextion_queue_[i]->component;
|
NextionComponentBase *component = (*it)->component;
|
||||||
if (ms - this->nextion_queue_[i]->queue_time > this->max_q_age_ms_) {
|
if (ms - (*it)->queue_time > this->max_q_age_ms_) {
|
||||||
if (this->nextion_queue_[i]->queue_time == 0) {
|
if ((*it)->queue_time == 0) {
|
||||||
ESP_LOGD(TAG, "Remove old queue '%s':'%s' (t=0)", component->get_queue_type_string().c_str(),
|
ESP_LOGD(TAG, "Remove old queue '%s':'%s' (t=0)", component->get_queue_type_string().c_str(),
|
||||||
component->get_variable_name().c_str());
|
component->get_variable_name().c_str());
|
||||||
}
|
}
|
||||||
@@ -863,10 +863,8 @@ void Nextion::process_nextion_commands_() {
|
|||||||
delete component; // NOLINT(cppcoreguidelines-owning-memory)
|
delete component; // NOLINT(cppcoreguidelines-owning-memory)
|
||||||
}
|
}
|
||||||
|
|
||||||
delete this->nextion_queue_[i]; // NOLINT(cppcoreguidelines-owning-memory)
|
delete *it; // NOLINT(cppcoreguidelines-owning-memory)
|
||||||
|
it = this->nextion_queue_.erase(it);
|
||||||
this->nextion_queue_.erase(this->nextion_queue_.begin() + i);
|
|
||||||
i--;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <deque>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "esphome/components/display/display.h"
|
||||||
|
#include "esphome/components/display/display_color_utils.h"
|
||||||
|
#include "esphome/components/uart/uart.h"
|
||||||
#include "esphome/core/defines.h"
|
#include "esphome/core/defines.h"
|
||||||
#include "esphome/core/time.h"
|
#include "esphome/core/time.h"
|
||||||
|
|
||||||
#include "esphome/components/uart/uart.h"
|
|
||||||
#include "nextion_base.h"
|
#include "nextion_base.h"
|
||||||
#include "nextion_component.h"
|
#include "nextion_component.h"
|
||||||
#include "esphome/components/display/display.h"
|
|
||||||
#include "esphome/components/display/display_color_utils.h"
|
|
||||||
|
|
||||||
#ifdef USE_NEXTION_TFT_UPLOAD
|
#ifdef USE_NEXTION_TFT_UPLOAD
|
||||||
#ifdef USE_ESP32
|
#ifdef USE_ESP32
|
||||||
@@ -1391,8 +1391,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
|||||||
void process_pending_in_queue_();
|
void process_pending_in_queue_();
|
||||||
#endif // USE_NEXTION_COMMAND_SPACING
|
#endif // USE_NEXTION_COMMAND_SPACING
|
||||||
|
|
||||||
std::deque<NextionQueue *> nextion_queue_;
|
std::list<NextionQueue *> nextion_queue_;
|
||||||
std::deque<NextionQueue *> waveform_queue_;
|
std::list<NextionQueue *> waveform_queue_;
|
||||||
uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag);
|
uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag);
|
||||||
void all_components_send_state_(bool force_update = false);
|
void all_components_send_state_(bool force_update = false);
|
||||||
uint32_t comok_sent_ = 0;
|
uint32_t comok_sent_ = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user