mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 08:28:12 +01:00
Nextion - Do not refresh sensors while updating (#6566)
This commit is contained in:
parent
5a093acbf5
commit
39deb89108
7 changed files with 32 additions and 8 deletions
|
@ -27,7 +27,7 @@ void NextionBinarySensor::process_touch(uint8_t page_id, uint8_t component_id, b
|
||||||
}
|
}
|
||||||
|
|
||||||
void NextionBinarySensor::update() {
|
void NextionBinarySensor::update() {
|
||||||
if (!this->nextion_->is_setup())
|
if (!this->nextion_->is_setup() || this->nextion_->is_updating())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this->variable_name_.empty()) // This is a touch component
|
if (this->variable_name_.empty()) // This is a touch component
|
||||||
|
@ -37,7 +37,7 @@ void NextionBinarySensor::update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NextionBinarySensor::set_state(bool state, bool publish, bool send_to_nextion) {
|
void NextionBinarySensor::set_state(bool state, bool publish, bool send_to_nextion) {
|
||||||
if (!this->nextion_->is_setup())
|
if (!this->nextion_->is_setup() || this->nextion_->is_updating())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this->component_id_ == 0) // This is a legacy touch component
|
if (this->component_id_ == 0) // This is a legacy touch component
|
||||||
|
|
|
@ -1137,5 +1137,7 @@ void Nextion::set_writer(const nextion_writer_t &writer) { this->writer_ = write
|
||||||
ESPDEPRECATED("set_wait_for_ack(bool) is deprecated and has no effect", "v1.20")
|
ESPDEPRECATED("set_wait_for_ack(bool) is deprecated and has no effect", "v1.20")
|
||||||
void Nextion::set_wait_for_ack(bool wait_for_ack) { ESP_LOGE(TAG, "This command is deprecated"); }
|
void Nextion::set_wait_for_ack(bool wait_for_ack) { ESP_LOGE(TAG, "This command is deprecated"); }
|
||||||
|
|
||||||
|
bool Nextion::is_updating() { return this->is_updating_; }
|
||||||
|
|
||||||
} // namespace nextion
|
} // namespace nextion
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
|
@ -1031,6 +1031,26 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
*/
|
*/
|
||||||
size_t queue_size() { return this->nextion_queue_.size(); }
|
size_t queue_size() { return this->nextion_queue_.size(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if the TFT update process is currently running.
|
||||||
|
*
|
||||||
|
* This method provides a way to determine if the Nextion display is in the
|
||||||
|
* process of updating its TFT firmware. When a TFT update is in progress,
|
||||||
|
* certain operations or commands may be restricted or could interfere with the
|
||||||
|
* update process. By checking the state of the update process, the system can
|
||||||
|
* make informed decisions about performing actions that involve communication
|
||||||
|
* with the Nextion display.
|
||||||
|
*
|
||||||
|
* @return true if the TFT update process is active, indicating that the Nextion
|
||||||
|
* display is currently updating its firmware. This implies that caution
|
||||||
|
* should be taken with commands sent to the display to avoid interrupting
|
||||||
|
* the update process.
|
||||||
|
* @return false if the TFT update process is not active, indicating that the Nextion
|
||||||
|
* display is not currently updating its firmware and is in a normal operational
|
||||||
|
* state, ready to receive and process commands as usual.
|
||||||
|
*/
|
||||||
|
bool is_updating() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::deque<NextionQueue *> nextion_queue_;
|
std::deque<NextionQueue *> nextion_queue_;
|
||||||
std::deque<NextionQueue *> waveform_queue_;
|
std::deque<NextionQueue *> waveform_queue_;
|
||||||
|
|
|
@ -48,6 +48,8 @@ class NextionBase {
|
||||||
virtual void show_component(const char *component) = 0;
|
virtual void show_component(const char *component) = 0;
|
||||||
virtual void hide_component(const char *component) = 0;
|
virtual void hide_component(const char *component) = 0;
|
||||||
|
|
||||||
|
virtual bool is_updating() { return false; }
|
||||||
|
|
||||||
bool is_sleeping() { return this->is_sleeping_; }
|
bool is_sleeping() { return this->is_sleeping_; }
|
||||||
bool is_setup() { return this->is_setup_; }
|
bool is_setup() { return this->is_setup_; }
|
||||||
bool is_detected() { return this->is_detected_; }
|
bool is_detected() { return this->is_detected_; }
|
||||||
|
|
|
@ -30,7 +30,7 @@ void NextionSensor::add_to_wave_buffer(float state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NextionSensor::update() {
|
void NextionSensor::update() {
|
||||||
if (!this->nextion_->is_setup())
|
if (!this->nextion_->is_setup() || this->nextion_->is_updating())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this->wave_chan_id_ == UINT8_MAX) {
|
if (this->wave_chan_id_ == UINT8_MAX) {
|
||||||
|
@ -45,7 +45,7 @@ void NextionSensor::update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NextionSensor::set_state(float state, bool publish, bool send_to_nextion) {
|
void NextionSensor::set_state(float state, bool publish, bool send_to_nextion) {
|
||||||
if (!this->nextion_->is_setup())
|
if (!this->nextion_->is_setup() || this->nextion_->is_updating())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (std::isnan(state))
|
if (std::isnan(state))
|
||||||
|
|
|
@ -18,13 +18,13 @@ void NextionSwitch::process_bool(const std::string &variable_name, bool on) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NextionSwitch::update() {
|
void NextionSwitch::update() {
|
||||||
if (!this->nextion_->is_setup())
|
if (!this->nextion_->is_setup() || this->nextion_->is_updating())
|
||||||
return;
|
return;
|
||||||
this->nextion_->add_to_get_queue(this);
|
this->nextion_->add_to_get_queue(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NextionSwitch::set_state(bool state, bool publish, bool send_to_nextion) {
|
void NextionSwitch::set_state(bool state, bool publish, bool send_to_nextion) {
|
||||||
if (!this->nextion_->is_setup())
|
if (!this->nextion_->is_setup() || this->nextion_->is_updating())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (send_to_nextion) {
|
if (send_to_nextion) {
|
||||||
|
|
|
@ -16,13 +16,13 @@ void NextionTextSensor::process_text(const std::string &variable_name, const std
|
||||||
}
|
}
|
||||||
|
|
||||||
void NextionTextSensor::update() {
|
void NextionTextSensor::update() {
|
||||||
if (!this->nextion_->is_setup())
|
if (!this->nextion_->is_setup() || this->nextion_->is_updating())
|
||||||
return;
|
return;
|
||||||
this->nextion_->add_to_get_queue(this);
|
this->nextion_->add_to_get_queue(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NextionTextSensor::set_state(const std::string &state, bool publish, bool send_to_nextion) {
|
void NextionTextSensor::set_state(const std::string &state, bool publish, bool send_to_nextion) {
|
||||||
if (!this->nextion_->is_setup())
|
if (!this->nextion_->is_setup() || this->nextion_->is_updating())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (send_to_nextion) {
|
if (send_to_nextion) {
|
||||||
|
|
Loading…
Reference in a new issue