mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 22:48:10 +01:00
set Nextion protocol reparse mode (#5484)
This commit is contained in:
parent
eead33b6f2
commit
7e27e98bff
2 changed files with 26 additions and 0 deletions
|
@ -623,6 +623,13 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
|||
* @param True or false. Sleep=true to enter sleep mode or sleep=false to exit sleep mode.
|
||||
*/
|
||||
void sleep(bool sleep);
|
||||
/**
|
||||
* Sets Nextion Protocol Reparse mode between active or passive
|
||||
* @param True or false.
|
||||
* active_mode=true to enter active protocol reparse mode
|
||||
* active_mode=false to enter passive protocol reparse mode.
|
||||
*/
|
||||
void set_protocol_reparse_mode(bool active_mode);
|
||||
|
||||
// ========== INTERNAL METHODS ==========
|
||||
// (In most use cases you won't need these)
|
||||
|
|
|
@ -32,6 +32,25 @@ 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};
|
||||
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));
|
||||
}
|
||||
this->write_str("connect");
|
||||
this->write_array(to_send, sizeof(to_send));
|
||||
}
|
||||
|
||||
// Set Colors
|
||||
void Nextion::set_component_background_color(const char *component, uint32_t color) {
|
||||
this->add_no_result_to_queue_with_printf_("set_component_background_color", "%s.bco=%d", component, color);
|
||||
|
|
Loading…
Reference in a new issue