mirror of
https://github.com/esphome/esphome.git
synced 2024-12-19 16:07:47 +01:00
Nextion exit reparse mode on startup (#5868)
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
This commit is contained in:
parent
be07463fbd
commit
f026f49415
@ -29,6 +29,7 @@ CONF_BACKGROUND_PRESSED_COLOR = "background_pressed_color"
|
|||||||
CONF_FOREGROUND_COLOR = "foreground_color"
|
CONF_FOREGROUND_COLOR = "foreground_color"
|
||||||
CONF_FOREGROUND_PRESSED_COLOR = "foreground_pressed_color"
|
CONF_FOREGROUND_PRESSED_COLOR = "foreground_pressed_color"
|
||||||
CONF_FONT_ID = "font_id"
|
CONF_FONT_ID = "font_id"
|
||||||
|
CONF_EXIT_REPARSE_ON_START = "exit_reparse_on_start"
|
||||||
|
|
||||||
|
|
||||||
def NextionName(value):
|
def NextionName(value):
|
||||||
|
@ -21,6 +21,7 @@ from .base_component import (
|
|||||||
CONF_WAKE_UP_PAGE,
|
CONF_WAKE_UP_PAGE,
|
||||||
CONF_START_UP_PAGE,
|
CONF_START_UP_PAGE,
|
||||||
CONF_AUTO_WAKE_ON_TOUCH,
|
CONF_AUTO_WAKE_ON_TOUCH,
|
||||||
|
CONF_EXIT_REPARSE_ON_START,
|
||||||
)
|
)
|
||||||
|
|
||||||
CODEOWNERS = ["@senexcrenshaw"]
|
CODEOWNERS = ["@senexcrenshaw"]
|
||||||
@ -69,6 +70,7 @@ CONFIG_SCHEMA = (
|
|||||||
cv.Optional(CONF_WAKE_UP_PAGE): cv.positive_int,
|
cv.Optional(CONF_WAKE_UP_PAGE): cv.positive_int,
|
||||||
cv.Optional(CONF_START_UP_PAGE): cv.positive_int,
|
cv.Optional(CONF_START_UP_PAGE): cv.positive_int,
|
||||||
cv.Optional(CONF_AUTO_WAKE_ON_TOUCH, default=True): cv.boolean,
|
cv.Optional(CONF_AUTO_WAKE_ON_TOUCH, default=True): cv.boolean,
|
||||||
|
cv.Optional(CONF_EXIT_REPARSE_ON_START, default=False): cv.boolean,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.extend(cv.polling_component_schema("5s"))
|
.extend(cv.polling_component_schema("5s"))
|
||||||
@ -106,9 +108,10 @@ async def to_code(config):
|
|||||||
if CONF_START_UP_PAGE in config:
|
if CONF_START_UP_PAGE in config:
|
||||||
cg.add(var.set_start_up_page_internal(config[CONF_START_UP_PAGE]))
|
cg.add(var.set_start_up_page_internal(config[CONF_START_UP_PAGE]))
|
||||||
|
|
||||||
if CONF_AUTO_WAKE_ON_TOUCH in config:
|
|
||||||
cg.add(var.set_auto_wake_on_touch_internal(config[CONF_AUTO_WAKE_ON_TOUCH]))
|
cg.add(var.set_auto_wake_on_touch_internal(config[CONF_AUTO_WAKE_ON_TOUCH]))
|
||||||
|
|
||||||
|
cg.add(var.set_exit_reparse_on_start_internal(config[CONF_EXIT_REPARSE_ON_START]))
|
||||||
|
|
||||||
await display.register_display(var, config)
|
await display.register_display(var, config)
|
||||||
|
|
||||||
for conf in config.get(CONF_ON_SETUP, []):
|
for conf in config.get(CONF_ON_SETUP, []):
|
||||||
|
@ -48,6 +48,9 @@ bool Nextion::check_connect_() {
|
|||||||
|
|
||||||
this->ignore_is_setup_ = true;
|
this->ignore_is_setup_ = true;
|
||||||
this->send_command_("boguscommand=0"); // bogus command. needed sometimes after updating
|
this->send_command_("boguscommand=0"); // bogus command. needed sometimes after updating
|
||||||
|
if (this->exit_reparse_on_start_) {
|
||||||
|
this->send_command_("DRAKJHSUYDGBNCJHGJKSHBDN");
|
||||||
|
}
|
||||||
this->send_command_("connect");
|
this->send_command_("connect");
|
||||||
|
|
||||||
this->comok_sent_ = millis();
|
this->comok_sent_ = millis();
|
||||||
@ -127,7 +130,8 @@ void Nextion::dump_config() {
|
|||||||
ESP_LOGCONFIG(TAG, " Firmware Version: %s", this->firmware_version_.c_str());
|
ESP_LOGCONFIG(TAG, " Firmware Version: %s", this->firmware_version_.c_str());
|
||||||
ESP_LOGCONFIG(TAG, " Serial Number: %s", this->serial_number_.c_str());
|
ESP_LOGCONFIG(TAG, " Serial Number: %s", this->serial_number_.c_str());
|
||||||
ESP_LOGCONFIG(TAG, " Flash Size: %s", this->flash_size_.c_str());
|
ESP_LOGCONFIG(TAG, " Flash Size: %s", this->flash_size_.c_str());
|
||||||
ESP_LOGCONFIG(TAG, " Wake On Touch: %s", this->auto_wake_on_touch_ ? "True" : "False");
|
ESP_LOGCONFIG(TAG, " Wake On Touch: %s", YESNO(this->auto_wake_on_touch_));
|
||||||
|
ESP_LOGCONFIG(TAG, " Exit reparse: %s", YESNO(this->exit_reparse_on_start_));
|
||||||
|
|
||||||
if (this->touch_sleep_timeout_ != 0) {
|
if (this->touch_sleep_timeout_ != 0) {
|
||||||
ESP_LOGCONFIG(TAG, " Touch Timeout: %" PRIu32, this->touch_sleep_timeout_);
|
ESP_LOGCONFIG(TAG, " Touch Timeout: %" PRIu32, this->touch_sleep_timeout_);
|
||||||
@ -248,6 +252,7 @@ void Nextion::loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->set_auto_wake_on_touch(this->auto_wake_on_touch_);
|
this->set_auto_wake_on_touch(this->auto_wake_on_touch_);
|
||||||
|
this->set_exit_reparse_on_start(this->exit_reparse_on_start_);
|
||||||
|
|
||||||
if (this->touch_sleep_timeout_ != 0) {
|
if (this->touch_sleep_timeout_ != 0) {
|
||||||
this->set_touch_sleep_timeout(this->touch_sleep_timeout_);
|
this->set_touch_sleep_timeout(this->touch_sleep_timeout_);
|
||||||
|
@ -815,6 +815,19 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
|||||||
* The display will wake up by touch.
|
* The display will wake up by touch.
|
||||||
*/
|
*/
|
||||||
void set_auto_wake_on_touch(bool auto_wake);
|
void set_auto_wake_on_touch(bool auto_wake);
|
||||||
|
/**
|
||||||
|
* Sets if Nextion should exit the active reparse mode before the "connect" command is sent
|
||||||
|
* @param exit_reparse True or false. When exit_reparse is true, the exit reparse command
|
||||||
|
* will be sent before requesting the connection from Nextion.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* ```cpp
|
||||||
|
* it.set_exit_reparse_on_start(true);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The display will be requested to leave active reparse mode before setup.
|
||||||
|
*/
|
||||||
|
void set_exit_reparse_on_start(bool exit_reparse);
|
||||||
/**
|
/**
|
||||||
* Sets Nextion mode between sleep and awake
|
* Sets Nextion mode between sleep and awake
|
||||||
* @param True or false. Sleep=true to enter sleep mode or sleep=false to exit sleep mode.
|
* @param True or false. Sleep=true to enter sleep mode or sleep=false to exit sleep mode.
|
||||||
@ -943,6 +956,9 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
|||||||
void set_wake_up_page_internal(uint8_t wake_up_page) { this->wake_up_page_ = wake_up_page; }
|
void set_wake_up_page_internal(uint8_t wake_up_page) { this->wake_up_page_ = wake_up_page; }
|
||||||
void set_start_up_page_internal(uint8_t start_up_page) { this->start_up_page_ = start_up_page; }
|
void set_start_up_page_internal(uint8_t start_up_page) { this->start_up_page_ = start_up_page; }
|
||||||
void set_auto_wake_on_touch_internal(bool auto_wake_on_touch) { this->auto_wake_on_touch_ = auto_wake_on_touch; }
|
void set_auto_wake_on_touch_internal(bool auto_wake_on_touch) { this->auto_wake_on_touch_ = auto_wake_on_touch; }
|
||||||
|
void set_exit_reparse_on_start_internal(bool exit_reparse_on_start) {
|
||||||
|
this->exit_reparse_on_start_ = exit_reparse_on_start;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::deque<NextionQueue *> nextion_queue_;
|
std::deque<NextionQueue *> nextion_queue_;
|
||||||
@ -966,6 +982,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
|||||||
int wake_up_page_ = -1;
|
int wake_up_page_ = -1;
|
||||||
int start_up_page_ = -1;
|
int start_up_page_ = -1;
|
||||||
bool auto_wake_on_touch_ = true;
|
bool auto_wake_on_touch_ = true;
|
||||||
|
bool exit_reparse_on_start_ = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manually send a raw command to the display and don't wait for an acknowledgement packet.
|
* Manually send a raw command to the display and don't wait for an acknowledgement packet.
|
||||||
|
@ -53,6 +53,7 @@ void Nextion::set_protocol_reparse_mode(bool active_mode) {
|
|||||||
this->write_str("connect");
|
this->write_str("connect");
|
||||||
this->write_array(to_send, sizeof(to_send));
|
this->write_array(to_send, sizeof(to_send));
|
||||||
}
|
}
|
||||||
|
void Nextion::set_exit_reparse_on_start(bool exit_reparse) { this->exit_reparse_on_start_ = exit_reparse; }
|
||||||
|
|
||||||
// Set Colors - Background
|
// Set Colors - Background
|
||||||
void Nextion::set_component_background_color(const char *component, uint16_t color) {
|
void Nextion::set_component_background_color(const char *component, uint16_t color) {
|
||||||
|
Loading…
Reference in New Issue
Block a user