set Nextion protocol reparse mode (#5484)

This commit is contained in:
Edward Firmo 2023-10-23 21:02:57 +02:00 committed by GitHub
parent eead33b6f2
commit 7e27e98bff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -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)

View File

@ -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);