mirror of
https://github.com/esphome/esphome.git
synced 2025-10-03 10:32:21 +01:00
Nextion - Review set_protocol_reparse_mode() (#6567)
This commit is contained in:
@@ -36,22 +36,23 @@ void Nextion::sleep(bool sleep) {
|
||||
// End sleep safe commands
|
||||
|
||||
// Protocol reparse mode
|
||||
void Nextion::set_protocol_reparse_mode(bool active_mode) {
|
||||
const uint8_t to_send[3] = {0xFF, 0xFF, 0xFF};
|
||||
bool Nextion::set_protocol_reparse_mode(bool active_mode) {
|
||||
ESP_LOGV(TAG, "Set Nextion protocol reparse mode: %s", YESNO(active_mode));
|
||||
this->ignore_is_setup_ = true; // if not in reparse mode setup will fail, so it should be ignored
|
||||
bool all_commands_sent = true;
|
||||
if (active_mode) { // Sets active protocol reparse mode
|
||||
this->write_str(
|
||||
"recmod=1"); // send_command_ cannot be used as Nextion might not be setup if incorrect reparse mode
|
||||
this->write_array(to_send, sizeof(to_send));
|
||||
} else { // Sets passive protocol reparse mode
|
||||
this->write_str("DRAKJHSUYDGBNCJHGJKSHBDN"); // To exit active reparse mode this sequence must be sent
|
||||
this->write_array(to_send, sizeof(to_send));
|
||||
this->write_str("recmod=0"); // Sending recmode=0 twice is recommended
|
||||
this->write_array(to_send, sizeof(to_send));
|
||||
this->write_str("recmod=0");
|
||||
this->write_array(to_send, sizeof(to_send));
|
||||
all_commands_sent &= this->send_command_("recmod=1");
|
||||
} else { // Sets passive protocol reparse mode
|
||||
all_commands_sent &=
|
||||
this->send_command_("DRAKJHSUYDGBNCJHGJKSHBDN"); // To exit active reparse mode this sequence must be sent
|
||||
all_commands_sent &= this->send_command_("recmod=0"); // Sending recmode=0 twice is recommended
|
||||
all_commands_sent &= this->send_command_("recmod=0");
|
||||
}
|
||||
this->write_str("connect");
|
||||
this->write_array(to_send, sizeof(to_send));
|
||||
if (!this->nextion_reports_is_setup_) { // No need to connect if is already setup
|
||||
all_commands_sent &= this->send_command_("connect");
|
||||
}
|
||||
this->ignore_is_setup_ = false;
|
||||
return all_commands_sent;
|
||||
}
|
||||
void Nextion::set_exit_reparse_on_start(bool exit_reparse) { this->exit_reparse_on_start_ = exit_reparse; }
|
||||
|
||||
|
Reference in New Issue
Block a user