mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 00:18:11 +01:00
Nextion - Review types (#6565)
This commit is contained in:
parent
39deb89108
commit
197f9d6d03
5 changed files with 183 additions and 111 deletions
|
@ -68,8 +68,8 @@ CONFIG_SCHEMA = (
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_TOUCH_SLEEP_TIMEOUT): cv.int_range(min=3, max=65535),
|
cv.Optional(CONF_TOUCH_SLEEP_TIMEOUT): cv.int_range(min=3, max=65535),
|
||||||
cv.Optional(CONF_WAKE_UP_PAGE): cv.positive_int,
|
cv.Optional(CONF_WAKE_UP_PAGE): cv.uint8_t,
|
||||||
cv.Optional(CONF_START_UP_PAGE): cv.positive_int,
|
cv.Optional(CONF_START_UP_PAGE): cv.uint8_t,
|
||||||
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,
|
cv.Optional(CONF_EXIT_REPARSE_ON_START, default=False): cv.boolean,
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,11 +138,11 @@ void Nextion::dump_config() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->wake_up_page_ != -1) {
|
if (this->wake_up_page_ != -1) {
|
||||||
ESP_LOGCONFIG(TAG, " Wake Up Page: %d", this->wake_up_page_);
|
ESP_LOGCONFIG(TAG, " Wake Up Page: %" PRId16, this->wake_up_page_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->start_up_page_ != -1) {
|
if (this->start_up_page_ != -1) {
|
||||||
ESP_LOGCONFIG(TAG, " Start Up Page: %d", this->start_up_page_);
|
ESP_LOGCONFIG(TAG, " Start Up Page: %" PRId16, this->start_up_page_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1024,23 +1024,23 @@ bool Nextion::add_no_result_to_queue_with_printf_(const std::string &variable_na
|
||||||
* @param is_sleep_safe The command is safe to send when the Nextion is sleeping
|
* @param is_sleep_safe The command is safe to send when the Nextion is sleeping
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Nextion::add_no_result_to_queue_with_set(NextionComponentBase *component, int state_value) {
|
void Nextion::add_no_result_to_queue_with_set(NextionComponentBase *component, int32_t state_value) {
|
||||||
this->add_no_result_to_queue_with_set(component->get_variable_name(), component->get_variable_name_to_send(),
|
this->add_no_result_to_queue_with_set(component->get_variable_name(), component->get_variable_name_to_send(),
|
||||||
state_value);
|
state_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::add_no_result_to_queue_with_set(const std::string &variable_name,
|
void Nextion::add_no_result_to_queue_with_set(const std::string &variable_name,
|
||||||
const std::string &variable_name_to_send, int state_value) {
|
const std::string &variable_name_to_send, int32_t state_value) {
|
||||||
this->add_no_result_to_queue_with_set_internal_(variable_name, variable_name_to_send, state_value);
|
this->add_no_result_to_queue_with_set_internal_(variable_name, variable_name_to_send, state_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::add_no_result_to_queue_with_set_internal_(const std::string &variable_name,
|
void Nextion::add_no_result_to_queue_with_set_internal_(const std::string &variable_name,
|
||||||
const std::string &variable_name_to_send, int state_value,
|
const std::string &variable_name_to_send, int32_t state_value,
|
||||||
bool is_sleep_safe) {
|
bool is_sleep_safe) {
|
||||||
if ((!this->is_setup() && !this->ignore_is_setup_) || (!is_sleep_safe && this->is_sleeping()))
|
if ((!this->is_setup() && !this->ignore_is_setup_) || (!is_sleep_safe && this->is_sleeping()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this->add_no_result_to_queue_with_ignore_sleep_printf_(variable_name, "%s=%d", variable_name_to_send.c_str(),
|
this->add_no_result_to_queue_with_ignore_sleep_printf_(variable_name, "%s=%" PRId32, variable_name_to_send.c_str(),
|
||||||
state_value);
|
state_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* This will set the `txt` property of the component `textview` to `Hello World`.
|
* This will set the `txt` property of the component `textview` to `Hello World`.
|
||||||
*/
|
*/
|
||||||
void set_component_text(const char *component, const char *text);
|
void set_component_text(const char *component, const char *text);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the text of a component to a formatted string
|
* Set the text of a component to a formatted string
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -66,6 +67,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* For example when `uptime_sensor` = 506, then, `The uptime is: 506` will be displayed.
|
* For example when `uptime_sensor` = 506, then, `The uptime is: 506` will be displayed.
|
||||||
*/
|
*/
|
||||||
void set_component_text_printf(const char *component, const char *format, ...) __attribute__((format(printf, 3, 4)));
|
void set_component_text_printf(const char *component, const char *format, ...) __attribute__((format(printf, 3, 4)));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the integer value of a component
|
* Set the integer value of a component
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -78,7 +80,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
*
|
*
|
||||||
* This will change the property `value` of the component `gauge` to 50.
|
* This will change the property `value` of the component `gauge` to 50.
|
||||||
*/
|
*/
|
||||||
void set_component_value(const char *component, int value);
|
void set_component_value(const char *component, int32_t value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the picture of an image component.
|
* Set the picture of an image component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -92,6 +95,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* This will change the image of the component `pic` to the image with ID `4`.
|
* This will change the image of the component `pic` to the image with ID `4`.
|
||||||
*/
|
*/
|
||||||
void set_component_picture(const char *component, uint8_t picture_id);
|
void set_component_picture(const char *component, uint8_t picture_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the background color of a component.
|
* Set the background color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -107,6 +111,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Nextion HMI colors.
|
* Nextion HMI colors.
|
||||||
*/
|
*/
|
||||||
void set_component_background_color(const char *component, uint16_t color);
|
void set_component_background_color(const char *component, uint16_t color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the background color of a component.
|
* Set the background color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -121,6 +126,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
||||||
*/
|
*/
|
||||||
void set_component_background_color(const char *component, const char *color);
|
void set_component_background_color(const char *component, const char *color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the background color of a component.
|
* Set the background color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -135,6 +141,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* This will change the background color of the component `button` to blue.
|
* This will change the background color of the component `button` to blue.
|
||||||
*/
|
*/
|
||||||
void set_component_background_color(const char *component, Color color) override;
|
void set_component_background_color(const char *component, Color color) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the pressed background color of a component.
|
* Set the pressed background color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -151,6 +158,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Nextion HMI colors.
|
* Nextion HMI colors.
|
||||||
*/
|
*/
|
||||||
void set_component_pressed_background_color(const char *component, uint16_t color);
|
void set_component_pressed_background_color(const char *component, uint16_t color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the pressed background color of a component.
|
* Set the pressed background color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -166,6 +174,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
||||||
*/
|
*/
|
||||||
void set_component_pressed_background_color(const char *component, const char *color);
|
void set_component_pressed_background_color(const char *component, const char *color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the pressed background color of a component.
|
* Set the pressed background color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -181,6 +190,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* is shown when the component is pressed.
|
* is shown when the component is pressed.
|
||||||
*/
|
*/
|
||||||
void set_component_pressed_background_color(const char *component, Color color) override;
|
void set_component_pressed_background_color(const char *component, Color color) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the foreground color of a component.
|
* Set the foreground color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -196,6 +206,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Nextion HMI colors.
|
* Nextion HMI colors.
|
||||||
*/
|
*/
|
||||||
void set_component_foreground_color(const char *component, uint16_t color);
|
void set_component_foreground_color(const char *component, uint16_t color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the foreground color of a component.
|
* Set the foreground color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -210,6 +221,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
||||||
*/
|
*/
|
||||||
void set_component_foreground_color(const char *component, const char *color);
|
void set_component_foreground_color(const char *component, const char *color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the foreground color of a component.
|
* Set the foreground color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -223,6 +235,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* This will change the foreground color of the component `button` to black.
|
* This will change the foreground color of the component `button` to black.
|
||||||
*/
|
*/
|
||||||
void set_component_foreground_color(const char *component, Color color) override;
|
void set_component_foreground_color(const char *component, Color color) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the pressed foreground color of a component.
|
* Set the pressed foreground color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -239,6 +252,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Nextion HMI colors.
|
* Nextion HMI colors.
|
||||||
*/
|
*/
|
||||||
void set_component_pressed_foreground_color(const char *component, uint16_t color);
|
void set_component_pressed_foreground_color(const char *component, uint16_t color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the pressed foreground color of a component.
|
* Set the pressed foreground color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -254,6 +268,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
||||||
*/
|
*/
|
||||||
void set_component_pressed_foreground_color(const char *component, const char *color);
|
void set_component_pressed_foreground_color(const char *component, const char *color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the pressed foreground color of a component.
|
* Set the pressed foreground color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -283,6 +298,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* This will change the picture id of the component `textview`.
|
* This will change the picture id of the component `textview`.
|
||||||
*/
|
*/
|
||||||
void set_component_pic(const char *component, uint8_t pic_id);
|
void set_component_pic(const char *component, uint8_t pic_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the background picture id of component.
|
* Set the background picture id of component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -312,6 +328,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Nextion HMI colors.
|
* Nextion HMI colors.
|
||||||
*/
|
*/
|
||||||
void set_component_font_color(const char *component, uint16_t color);
|
void set_component_font_color(const char *component, uint16_t color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the font color of a component.
|
* Set the font color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -326,6 +343,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
||||||
*/
|
*/
|
||||||
void set_component_font_color(const char *component, const char *color);
|
void set_component_font_color(const char *component, const char *color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the font color of a component.
|
* Set the font color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -339,6 +357,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* This will change the font color of the component `textview` to black.
|
* This will change the font color of the component `textview` to black.
|
||||||
*/
|
*/
|
||||||
void set_component_font_color(const char *component, Color color) override;
|
void set_component_font_color(const char *component, Color color) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the pressed font color of a component.
|
* Set the pressed font color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -354,6 +373,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Nextion HMI colors.
|
* Nextion HMI colors.
|
||||||
*/
|
*/
|
||||||
void set_component_pressed_font_color(const char *component, uint16_t color);
|
void set_component_pressed_font_color(const char *component, uint16_t color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the pressed font color of a component.
|
* Set the pressed font color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -368,6 +388,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
||||||
*/
|
*/
|
||||||
void set_component_pressed_font_color(const char *component, const char *color);
|
void set_component_pressed_font_color(const char *component, const char *color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the pressed font color of a component.
|
* Set the pressed font color of a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -381,6 +402,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* This will change the pressed font color of the component `button` to black.
|
* This will change the pressed font color of the component `button` to black.
|
||||||
*/
|
*/
|
||||||
void set_component_pressed_font_color(const char *component, Color color) override;
|
void set_component_pressed_font_color(const char *component, Color color) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the coordinates of a component on screen.
|
* Set the coordinates of a component on screen.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -394,7 +416,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
*
|
*
|
||||||
* This will move the position of the component `pic` to the x coordinate `55` and y coordinate `100`.
|
* This will move the position of the component `pic` to the x coordinate `55` and y coordinate `100`.
|
||||||
*/
|
*/
|
||||||
void set_component_coordinates(const char *component, int x, int y);
|
void set_component_coordinates(const char *component, uint16_t x, uint16_t y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the font id for a component.
|
* Set the font id for a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -408,6 +431,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Changes the font of the component named `textveiw`. Font IDs are set in the Nextion Editor.
|
* Changes the font of the component named `textveiw`. Font IDs are set in the Nextion Editor.
|
||||||
*/
|
*/
|
||||||
void set_component_font(const char *component, uint8_t font_id) override;
|
void set_component_font(const char *component, uint8_t font_id) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the current time to the nextion display.
|
* Send the current time to the nextion display.
|
||||||
* @param time The time instance to send (get this with id(my_time).now() ).
|
* @param time The time instance to send (get this with id(my_time).now() ).
|
||||||
|
@ -426,6 +450,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Switches to the page named `main`. Pages are named in the Nextion Editor.
|
* Switches to the page named `main`. Pages are named in the Nextion Editor.
|
||||||
*/
|
*/
|
||||||
void goto_page(const char *page);
|
void goto_page(const char *page);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the page with a given id.
|
* Show the page with a given id.
|
||||||
* @param page The id of the page.
|
* @param page The id of the page.
|
||||||
|
@ -438,6 +463,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Switches to the page named `main`. Pages are named in the Nextion Editor.
|
* Switches to the page named `main`. Pages are named in the Nextion Editor.
|
||||||
*/
|
*/
|
||||||
void goto_page(uint8_t page);
|
void goto_page(uint8_t page);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide a component.
|
* Hide a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -450,6 +476,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Hides the component named `button`.
|
* Hides the component named `button`.
|
||||||
*/
|
*/
|
||||||
void hide_component(const char *component) override;
|
void hide_component(const char *component) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a component.
|
* Show a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -462,6 +489,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Shows the component named `button`.
|
* Shows the component named `button`.
|
||||||
*/
|
*/
|
||||||
void show_component(const char *component) override;
|
void show_component(const char *component) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable touch for a component.
|
* Enable touch for a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -474,6 +502,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Enables touch for component named `button`.
|
* Enables touch for component named `button`.
|
||||||
*/
|
*/
|
||||||
void enable_component_touch(const char *component);
|
void enable_component_touch(const char *component);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable touch for a component.
|
* Disable touch for a component.
|
||||||
* @param component The component name.
|
* @param component The component name.
|
||||||
|
@ -486,14 +515,17 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Disables touch for component named `button`.
|
* Disables touch for component named `button`.
|
||||||
*/
|
*/
|
||||||
void disable_component_touch(const char *component);
|
void disable_component_touch(const char *component);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add waveform data to a waveform component
|
* Add waveform data to a waveform component
|
||||||
* @param component_id The integer component id.
|
* @param component_id The integer component id.
|
||||||
* @param channel_number The channel number to write to.
|
* @param channel_number The channel number to write to.
|
||||||
* @param value The value to write.
|
* @param value The value to write.
|
||||||
*/
|
*/
|
||||||
void add_waveform_data(int component_id, uint8_t channel_number, uint8_t value);
|
void add_waveform_data(uint8_t component_id, uint8_t channel_number, uint8_t value);
|
||||||
void open_waveform_channel(int component_id, uint8_t channel_number, uint8_t value);
|
|
||||||
|
void open_waveform_channel(uint8_t component_id, uint8_t channel_number, uint8_t value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a picture at coordinates.
|
* Display a picture at coordinates.
|
||||||
* @param picture_id The picture id.
|
* @param picture_id The picture id.
|
||||||
|
@ -507,7 +539,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
*
|
*
|
||||||
* Displays the picture who has the id `2` at the x coordinates `15` and y coordinates `25`.
|
* Displays the picture who has the id `2` at the x coordinates `15` and y coordinates `25`.
|
||||||
*/
|
*/
|
||||||
void display_picture(int picture_id, int x_start, int y_start);
|
void display_picture(uint16_t picture_id, uint16_t x_start, uint16_t y_start);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill a rectangle with a color.
|
* Fill a rectangle with a color.
|
||||||
* @param x1 The starting x coordinate.
|
* @param x1 The starting x coordinate.
|
||||||
|
@ -526,7 +559,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Use this [color picker](https://nodtem66.github.io/nextion-hmi-color-convert/index.html) to convert color codes to
|
* Use this [color picker](https://nodtem66.github.io/nextion-hmi-color-convert/index.html) to convert color codes to
|
||||||
* Nextion HMI colors.
|
* Nextion HMI colors.
|
||||||
*/
|
*/
|
||||||
void fill_area(int x1, int y1, int width, int height, uint16_t color);
|
void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill a rectangle with a color.
|
* Fill a rectangle with a color.
|
||||||
* @param x1 The starting x coordinate.
|
* @param x1 The starting x coordinate.
|
||||||
|
@ -544,7 +578,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* the red color.
|
* the red color.
|
||||||
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
||||||
*/
|
*/
|
||||||
void fill_area(int x1, int y1, int width, int height, const char *color);
|
void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, const char *color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill a rectangle with a color.
|
* Fill a rectangle with a color.
|
||||||
* @param x1 The starting x coordinate.
|
* @param x1 The starting x coordinate.
|
||||||
|
@ -562,7 +597,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Fills an area that starts at x coordinate `50` and y coordinate `50` with a height of `100` and width of `100` with
|
* Fills an area that starts at x coordinate `50` and y coordinate `50` with a height of `100` and width of `100` with
|
||||||
* blue color.
|
* blue color.
|
||||||
*/
|
*/
|
||||||
void fill_area(int x1, int y1, int width, int height, Color color);
|
void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, Color color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a line on the screen.
|
* Draw a line on the screen.
|
||||||
* @param x1 The starting x coordinate.
|
* @param x1 The starting x coordinate.
|
||||||
|
@ -581,7 +617,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Use this [color picker](https://nodtem66.github.io/nextion-hmi-color-convert/index.html) to convert color codes to
|
* Use this [color picker](https://nodtem66.github.io/nextion-hmi-color-convert/index.html) to convert color codes to
|
||||||
* Nextion HMI colors.
|
* Nextion HMI colors.
|
||||||
*/
|
*/
|
||||||
void line(int x1, int y1, int x2, int y2, uint16_t color);
|
void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a line on the screen.
|
* Draw a line on the screen.
|
||||||
* @param x1 The starting x coordinate.
|
* @param x1 The starting x coordinate.
|
||||||
|
@ -599,7 +636,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* `75` with the blue color.
|
* `75` with the blue color.
|
||||||
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
||||||
*/
|
*/
|
||||||
void line(int x1, int y1, int x2, int y2, const char *color);
|
void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char *color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a line on the screen.
|
* Draw a line on the screen.
|
||||||
* @param x1 The starting x coordinate.
|
* @param x1 The starting x coordinate.
|
||||||
|
@ -617,7 +655,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Makes a line that starts at x coordinate `50` and y coordinate `50` and ends at x coordinate `75` and y coordinate
|
* Makes a line that starts at x coordinate `50` and y coordinate `50` and ends at x coordinate `75` and y coordinate
|
||||||
* `75` with blue color.
|
* `75` with blue color.
|
||||||
*/
|
*/
|
||||||
void line(int x1, int y1, int x2, int y2, Color color);
|
void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, Color color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a rectangle outline.
|
* Draw a rectangle outline.
|
||||||
* @param x1 The starting x coordinate.
|
* @param x1 The starting x coordinate.
|
||||||
|
@ -636,7 +675,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Use this [color picker](https://nodtem66.github.io/nextion-hmi-color-convert/index.html) to convert color codes to
|
* Use this [color picker](https://nodtem66.github.io/nextion-hmi-color-convert/index.html) to convert color codes to
|
||||||
* Nextion HMI colors.
|
* Nextion HMI colors.
|
||||||
*/
|
*/
|
||||||
void rectangle(int x1, int y1, int width, int height, uint16_t color);
|
void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a rectangle outline.
|
* Draw a rectangle outline.
|
||||||
* @param x1 The starting x coordinate.
|
* @param x1 The starting x coordinate.
|
||||||
|
@ -654,7 +694,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* length of `50` with the blue color.
|
* length of `50` with the blue color.
|
||||||
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
||||||
*/
|
*/
|
||||||
void rectangle(int x1, int y1, int width, int height, const char *color);
|
void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, const char *color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a rectangle outline.
|
* Draw a rectangle outline.
|
||||||
* @param x1 The starting x coordinate.
|
* @param x1 The starting x coordinate.
|
||||||
|
@ -672,7 +713,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Makes a outline of a rectangle that starts at x coordinate `25` and y coordinate `35` and has a width of `40` and a
|
* Makes a outline of a rectangle that starts at x coordinate `25` and y coordinate `35` and has a width of `40` and a
|
||||||
* length of `50` with blue color.
|
* length of `50` with blue color.
|
||||||
*/
|
*/
|
||||||
void rectangle(int x1, int y1, int width, int height, Color color);
|
void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, Color color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a circle outline
|
* Draw a circle outline
|
||||||
* @param center_x The center x coordinate.
|
* @param center_x The center x coordinate.
|
||||||
|
@ -682,7 +724,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Use this [color picker](https://nodtem66.github.io/nextion-hmi-color-convert/index.html) to convert color codes to
|
* Use this [color picker](https://nodtem66.github.io/nextion-hmi-color-convert/index.html) to convert color codes to
|
||||||
* Nextion HMI colors.
|
* Nextion HMI colors.
|
||||||
*/
|
*/
|
||||||
void circle(int center_x, int center_y, int radius, uint16_t color);
|
void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a circle outline
|
* Draw a circle outline
|
||||||
* @param center_x The center x coordinate.
|
* @param center_x The center x coordinate.
|
||||||
|
@ -691,7 +734,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* @param color The color to draw with (as a string).
|
* @param color The color to draw with (as a string).
|
||||||
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
||||||
*/
|
*/
|
||||||
void circle(int center_x, int center_y, int radius, const char *color);
|
void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, const char *color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a circle outline
|
* Draw a circle outline
|
||||||
* @param center_x The center x coordinate.
|
* @param center_x The center x coordinate.
|
||||||
|
@ -699,7 +743,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* @param radius The circle radius.
|
* @param radius The circle radius.
|
||||||
* @param color The color to draw with (as Color).
|
* @param color The color to draw with (as Color).
|
||||||
*/
|
*/
|
||||||
void circle(int center_x, int center_y, int radius, Color color);
|
void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, Color color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a filled circled.
|
* Draw a filled circled.
|
||||||
* @param center_x The center x coordinate.
|
* @param center_x The center x coordinate.
|
||||||
|
@ -716,7 +761,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Use this [color picker](https://nodtem66.github.io/nextion-hmi-color-convert/index.html) to convert color codes to
|
* Use this [color picker](https://nodtem66.github.io/nextion-hmi-color-convert/index.html) to convert color codes to
|
||||||
* Nextion HMI colors.
|
* Nextion HMI colors.
|
||||||
*/
|
*/
|
||||||
void filled_circle(int center_x, int center_y, int radius, uint16_t color);
|
void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a filled circled.
|
* Draw a filled circled.
|
||||||
* @param center_x The center x coordinate.
|
* @param center_x The center x coordinate.
|
||||||
|
@ -732,7 +778,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Makes a filled circle at the x coordinate `25` and y coordinate `25` with a radius of `10` with the blue color.
|
* Makes a filled circle at the x coordinate `25` and y coordinate `25` with a radius of `10` with the blue color.
|
||||||
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
* Use [Nextion Instruction Set](https://nextion.tech/instruction-set/#s5) for a list of Nextion HMI colors constants.
|
||||||
*/
|
*/
|
||||||
void filled_circle(int center_x, int center_y, int radius, const char *color);
|
void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, const char *color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a filled circled.
|
* Draw a filled circled.
|
||||||
* @param center_x The center x coordinate.
|
* @param center_x The center x coordinate.
|
||||||
|
@ -748,7 +795,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
*
|
*
|
||||||
* Makes a filled circle at the x coordinate `25` and y coordinate `25` with a radius of `10` with blue color.
|
* Makes a filled circle at the x coordinate `25` and y coordinate `25` with a radius of `10` with blue color.
|
||||||
*/
|
*/
|
||||||
void filled_circle(int center_x, int center_y, int radius, Color color);
|
void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, Color color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a QR code in the screen
|
* Draws a QR code in the screen
|
||||||
|
@ -768,8 +815,9 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
*
|
*
|
||||||
* Draws a QR code with a Wi-Fi network credentials starting at the given coordinates (25,25).
|
* Draws a QR code with a Wi-Fi network credentials starting at the given coordinates (25,25).
|
||||||
*/
|
*/
|
||||||
void qrcode(int x1, int y1, const char *content, int size = 200, uint16_t background_color = 65535,
|
void qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size = 200, uint16_t background_color = 65535,
|
||||||
uint16_t foreground_color = 0, int logo_pic = -1, uint8_t border_width = 8);
|
uint16_t foreground_color = 0, uint8_t logo_pic = -1, uint8_t border_width = 8);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a QR code in the screen
|
* Draws a QR code in the screen
|
||||||
* @param x1 The top left x coordinate to start the QR code.
|
* @param x1 The top left x coordinate to start the QR code.
|
||||||
|
@ -791,8 +839,9 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Draws a QR code with a Wi-Fi network credentials starting at the given coordinates (25,25) with size of 150px in
|
* Draws a QR code with a Wi-Fi network credentials starting at the given coordinates (25,25) with size of 150px in
|
||||||
* red on a blue background.
|
* red on a blue background.
|
||||||
*/
|
*/
|
||||||
void qrcode(int x1, int y1, const char *content, int size, Color background_color = Color(255, 255, 255),
|
void qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size,
|
||||||
Color foreground_color = Color(0, 0, 0), int logo_pic = -1, uint8_t border_width = 8);
|
Color background_color = Color(255, 255, 255), Color foreground_color = Color(0, 0, 0),
|
||||||
|
uint8_t logo_pic = -1, uint8_t border_width = 8);
|
||||||
|
|
||||||
/** Set the brightness of the backlight.
|
/** Set the brightness of the backlight.
|
||||||
*
|
*
|
||||||
|
@ -806,6 +855,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Changes the brightness of the display to 30%.
|
* Changes the brightness of the display to 30%.
|
||||||
*/
|
*/
|
||||||
void set_backlight_brightness(float brightness);
|
void set_backlight_brightness(float brightness);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the touch sleep timeout of the display.
|
* Set the touch sleep timeout of the display.
|
||||||
* @param timeout Timeout in seconds.
|
* @param timeout Timeout in seconds.
|
||||||
|
@ -819,6 +869,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* `thup`.
|
* `thup`.
|
||||||
*/
|
*/
|
||||||
void set_touch_sleep_timeout(uint16_t timeout);
|
void set_touch_sleep_timeout(uint16_t timeout);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets which page Nextion loads when exiting sleep mode. Note this can be set even when Nextion is in sleep mode.
|
* Sets which page Nextion loads when exiting sleep mode. Note this can be set even when Nextion is in sleep mode.
|
||||||
* @param page_id The page id, from 0 to the lage page in Nextion. Set 255 (not set to any existing page) to
|
* @param page_id The page id, from 0 to the lage page in Nextion. Set 255 (not set to any existing page) to
|
||||||
|
@ -832,6 +883,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* The display will wake up to page 2.
|
* The display will wake up to page 2.
|
||||||
*/
|
*/
|
||||||
void set_wake_up_page(uint8_t page_id = 255);
|
void set_wake_up_page(uint8_t page_id = 255);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets which page Nextion loads when connecting to ESPHome.
|
* Sets which page Nextion loads when connecting to ESPHome.
|
||||||
* @param page_id The page id, from 0 to the lage page in Nextion. Set 255 (not set to any existing page) to
|
* @param page_id The page id, from 0 to the lage page in Nextion. Set 255 (not set to any existing page) to
|
||||||
|
@ -859,6 +911,7 @@ 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
|
* 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
|
* @param exit_reparse True or false. When exit_reparse is true, the exit reparse command
|
||||||
|
@ -872,11 +925,13 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* The display will be requested to leave active reparse mode before setup.
|
* The display will be requested to leave active reparse mode before setup.
|
||||||
*/
|
*/
|
||||||
void set_exit_reparse_on_start(bool exit_reparse);
|
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.
|
||||||
*/
|
*/
|
||||||
void sleep(bool sleep);
|
void sleep(bool sleep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the Nextion display's protocol reparse mode.
|
* @brief Sets the Nextion display's protocol reparse mode.
|
||||||
*
|
*
|
||||||
|
@ -928,7 +983,6 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
* Set the tft file URL. https seems problematic with arduino..
|
* Set the tft file URL. https seems problematic with arduino..
|
||||||
*/
|
*/
|
||||||
void set_tft_url(const std::string &tft_url) { this->tft_url_ = tft_url; }
|
void set_tft_url(const std::string &tft_url) { this->tft_url_ = tft_url; }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -992,9 +1046,9 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
void set_nextion_sensor_state(NextionQueueType queue_type, const std::string &name, float state);
|
void set_nextion_sensor_state(NextionQueueType queue_type, const std::string &name, float state);
|
||||||
void set_nextion_text_state(const std::string &name, const std::string &state);
|
void set_nextion_text_state(const std::string &name, const std::string &state);
|
||||||
|
|
||||||
void add_no_result_to_queue_with_set(NextionComponentBase *component, int state_value) override;
|
void add_no_result_to_queue_with_set(NextionComponentBase *component, int32_t state_value) override;
|
||||||
void add_no_result_to_queue_with_set(const std::string &variable_name, const std::string &variable_name_to_send,
|
void add_no_result_to_queue_with_set(const std::string &variable_name, const std::string &variable_name_to_send,
|
||||||
int state_value) override;
|
int32_t state_value) override;
|
||||||
|
|
||||||
void add_no_result_to_queue_with_set(NextionComponentBase *component, const std::string &state_value) override;
|
void add_no_result_to_queue_with_set(NextionComponentBase *component, const std::string &state_value) override;
|
||||||
void add_no_result_to_queue_with_set(const std::string &variable_name, const std::string &variable_name_to_send,
|
void add_no_result_to_queue_with_set(const std::string &variable_name, const std::string &variable_name_to_send,
|
||||||
|
@ -1070,8 +1124,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
void process_serial_();
|
void process_serial_();
|
||||||
bool is_updating_ = false;
|
bool is_updating_ = false;
|
||||||
uint32_t touch_sleep_timeout_ = 0;
|
uint32_t touch_sleep_timeout_ = 0;
|
||||||
int wake_up_page_ = -1;
|
int16_t wake_up_page_ = -1;
|
||||||
int start_up_page_ = -1;
|
int16_t start_up_page_ = -1;
|
||||||
bool auto_wake_on_touch_ = true;
|
bool auto_wake_on_touch_ = true;
|
||||||
bool exit_reparse_on_start_ = false;
|
bool exit_reparse_on_start_ = false;
|
||||||
|
|
||||||
|
@ -1089,7 +1143,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
__attribute__((format(printf, 3, 4)));
|
__attribute__((format(printf, 3, 4)));
|
||||||
|
|
||||||
void add_no_result_to_queue_with_set_internal_(const std::string &variable_name,
|
void add_no_result_to_queue_with_set_internal_(const std::string &variable_name,
|
||||||
const std::string &variable_name_to_send, int state_value,
|
const std::string &variable_name_to_send, int32_t state_value,
|
||||||
bool is_sleep_safe = false);
|
bool is_sleep_safe = false);
|
||||||
|
|
||||||
void add_no_result_to_queue_with_set_internal_(const std::string &variable_name,
|
void add_no_result_to_queue_with_set_internal_(const std::string &variable_name,
|
||||||
|
@ -1099,13 +1153,21 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
void check_pending_waveform_();
|
void check_pending_waveform_();
|
||||||
|
|
||||||
#ifdef USE_NEXTION_TFT_UPLOAD
|
#ifdef USE_NEXTION_TFT_UPLOAD
|
||||||
|
uint32_t content_length_ = 0;
|
||||||
|
int tft_size_ = 0;
|
||||||
|
uint32_t original_baud_rate_ = 0;
|
||||||
|
bool upload_first_chunk_sent_ = false;
|
||||||
|
|
||||||
|
std::string tft_url_;
|
||||||
|
uint8_t *transfer_buffer_{nullptr};
|
||||||
|
size_t transfer_buffer_size_;
|
||||||
|
|
||||||
#ifdef USE_ESP8266
|
#ifdef USE_ESP8266
|
||||||
WiFiClient *wifi_client_{nullptr};
|
WiFiClient *wifi_client_{nullptr};
|
||||||
BearSSL::WiFiClientSecure *wifi_client_secure_{nullptr};
|
BearSSL::WiFiClientSecure *wifi_client_secure_{nullptr};
|
||||||
WiFiClient *get_wifi_client_();
|
WiFiClient *get_wifi_client_();
|
||||||
#endif
|
#endif
|
||||||
int content_length_ = 0;
|
|
||||||
int tft_size_ = 0;
|
|
||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
/**
|
/**
|
||||||
* will request chunk_size chunks from the web server
|
* will request chunk_size chunks from the web server
|
||||||
|
@ -1178,13 +1240,6 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
|
|
||||||
void remove_front_no_sensors_();
|
void remove_front_no_sensors_();
|
||||||
|
|
||||||
#ifdef USE_NEXTION_TFT_UPLOAD
|
|
||||||
std::string tft_url_;
|
|
||||||
uint8_t *transfer_buffer_{nullptr};
|
|
||||||
size_t transfer_buffer_size_;
|
|
||||||
bool upload_first_chunk_sent_ = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NEXTION_PROTOCOL_LOG
|
#ifdef NEXTION_PROTOCOL_LOG
|
||||||
void print_queue_members_();
|
void print_queue_members_();
|
||||||
#endif
|
#endif
|
||||||
|
@ -1192,8 +1247,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||||
|
|
||||||
std::string command_data_;
|
std::string command_data_;
|
||||||
bool is_connected_ = false;
|
bool is_connected_ = false;
|
||||||
uint32_t startup_override_ms_ = 8000;
|
const uint16_t startup_override_ms_ = 8000;
|
||||||
uint32_t max_q_age_ms_ = 8000;
|
const uint16_t max_q_age_ms_ = 8000;
|
||||||
uint32_t started_ms_ = 0;
|
uint32_t started_ms_ = 0;
|
||||||
bool sent_setup_commands_ = false;
|
bool sent_setup_commands_ = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,9 +24,9 @@ class NextionBase;
|
||||||
|
|
||||||
class NextionBase {
|
class NextionBase {
|
||||||
public:
|
public:
|
||||||
virtual void add_no_result_to_queue_with_set(NextionComponentBase *component, int state_value) = 0;
|
virtual void add_no_result_to_queue_with_set(NextionComponentBase *component, int32_t state_value) = 0;
|
||||||
virtual void add_no_result_to_queue_with_set(const std::string &variable_name,
|
virtual void add_no_result_to_queue_with_set(const std::string &variable_name,
|
||||||
const std::string &variable_name_to_send, int state_value) = 0;
|
const std::string &variable_name_to_send, int32_t state_value) = 0;
|
||||||
|
|
||||||
virtual void add_no_result_to_queue_with_set(NextionComponentBase *component, const std::string &state_value) = 0;
|
virtual void add_no_result_to_queue_with_set(NextionComponentBase *component, const std::string &state_value) = 0;
|
||||||
virtual void add_no_result_to_queue_with_set(const std::string &variable_name,
|
virtual void add_no_result_to_queue_with_set(const std::string &variable_name,
|
||||||
|
|
|
@ -144,11 +144,11 @@ void Nextion::set_component_pressed_font_color(const char *component, Color colo
|
||||||
|
|
||||||
// Set picture
|
// Set picture
|
||||||
void Nextion::set_component_pic(const char *component, uint8_t pic_id) {
|
void Nextion::set_component_pic(const char *component, uint8_t pic_id) {
|
||||||
this->add_no_result_to_queue_with_printf_("set_component_pic", "%s.pic=%d", component, pic_id);
|
this->add_no_result_to_queue_with_printf_("set_component_pic", "%s.pic=%" PRIu8, component, pic_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::set_component_picc(const char *component, uint8_t pic_id) {
|
void Nextion::set_component_picc(const char *component, uint8_t pic_id) {
|
||||||
this->add_no_result_to_queue_with_printf_("set_component_pic", "%s.picc=%d", component, pic_id);
|
this->add_no_result_to_queue_with_printf_("set_component_pic", "%s.picc=%" PRIu8, component, pic_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::set_component_text_printf(const char *component, const char *format, ...) {
|
void Nextion::set_component_text_printf(const char *component, const char *format, ...) {
|
||||||
|
@ -179,7 +179,7 @@ void Nextion::set_auto_wake_on_touch(bool auto_wake) {
|
||||||
|
|
||||||
// General Component
|
// General Component
|
||||||
void Nextion::set_component_font(const char *component, uint8_t font_id) {
|
void Nextion::set_component_font(const char *component, uint8_t font_id) {
|
||||||
this->add_no_result_to_queue_with_printf_("set_component_font", "%s.font=%d", component, font_id);
|
this->add_no_result_to_queue_with_printf_("set_component_font", "%s.font=%" PRIu8, component, font_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::hide_component(const char *component) {
|
void Nextion::hide_component(const char *component) {
|
||||||
|
@ -199,113 +199,130 @@ void Nextion::disable_component_touch(const char *component) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::set_component_picture(const char *component, uint8_t picture_id) {
|
void Nextion::set_component_picture(const char *component, uint8_t picture_id) {
|
||||||
this->add_no_result_to_queue_with_printf_("set_component_picture", "%s.pic=%d", component, picture_id);
|
this->add_no_result_to_queue_with_printf_("set_component_picture", "%s.pic=%" PRIu8, component, picture_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::set_component_text(const char *component, const char *text) {
|
void Nextion::set_component_text(const char *component, const char *text) {
|
||||||
this->add_no_result_to_queue_with_printf_("set_component_text", "%s.txt=\"%s\"", component, text);
|
this->add_no_result_to_queue_with_printf_("set_component_text", "%s.txt=\"%s\"", component, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::set_component_value(const char *component, int value) {
|
void Nextion::set_component_value(const char *component, int32_t value) {
|
||||||
this->add_no_result_to_queue_with_printf_("set_component_value", "%s.val=%d", component, value);
|
this->add_no_result_to_queue_with_printf_("set_component_value", "%s.val=%" PRId32, component, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::add_waveform_data(int component_id, uint8_t channel_number, uint8_t value) {
|
void Nextion::add_waveform_data(uint8_t component_id, uint8_t channel_number, uint8_t value) {
|
||||||
this->add_no_result_to_queue_with_printf_("add_waveform_data", "add %d,%u,%u", component_id, channel_number, value);
|
this->add_no_result_to_queue_with_printf_("add_waveform_data", "add %" PRIu8 ",%" PRIu8 ",%" PRIu8, component_id,
|
||||||
|
channel_number, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::open_waveform_channel(int component_id, uint8_t channel_number, uint8_t value) {
|
void Nextion::open_waveform_channel(uint8_t component_id, uint8_t channel_number, uint8_t value) {
|
||||||
this->add_no_result_to_queue_with_printf_("open_waveform_channel", "addt %d,%u,%u", component_id, channel_number,
|
this->add_no_result_to_queue_with_printf_("open_waveform_channel", "addt %" PRIu8 ",%" PRIu8 ",%" PRIu8, component_id,
|
||||||
value);
|
channel_number, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::set_component_coordinates(const char *component, int x, int y) {
|
void Nextion::set_component_coordinates(const char *component, uint16_t x, uint16_t y) {
|
||||||
this->add_no_result_to_queue_with_printf_("set_component_coordinates command 1", "%s.xcen=%d", component, x);
|
this->add_no_result_to_queue_with_printf_("set_component_coordinates command 1", "%s.xcen=%" PRIu16, component, x);
|
||||||
this->add_no_result_to_queue_with_printf_("set_component_coordinates command 2", "%s.ycen=%d", component, y);
|
this->add_no_result_to_queue_with_printf_("set_component_coordinates command 2", "%s.ycen=%" PRIu16, component, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drawing
|
// Drawing
|
||||||
void Nextion::display_picture(int picture_id, int x_start, int y_start) {
|
void Nextion::display_picture(uint16_t picture_id, uint16_t x_start, uint16_t y_start) {
|
||||||
this->add_no_result_to_queue_with_printf_("display_picture", "pic %d, %d, %d", x_start, y_start, picture_id);
|
this->add_no_result_to_queue_with_printf_("display_picture", "pic %" PRIu16 ", %" PRIu16 ", %" PRIu16, x_start,
|
||||||
|
y_start, picture_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::fill_area(int x1, int y1, int width, int height, uint16_t color) {
|
void Nextion::fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color) {
|
||||||
this->add_no_result_to_queue_with_printf_("fill_area", "fill %d,%d,%d,%d,%" PRIu16, x1, y1, width, height, color);
|
this->add_no_result_to_queue_with_printf_(
|
||||||
|
"fill_area", "fill %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16, x1, y1, width, height, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::fill_area(int x1, int y1, int width, int height, const char *color) {
|
void Nextion::fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, const char *color) {
|
||||||
this->add_no_result_to_queue_with_printf_("fill_area", "fill %d,%d,%d,%d,%s", x1, y1, width, height, color);
|
this->add_no_result_to_queue_with_printf_("fill_area", "fill %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%s", x1,
|
||||||
|
y1, width, height, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::fill_area(int x1, int y1, int width, int height, Color color) {
|
void Nextion::fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, Color color) {
|
||||||
this->add_no_result_to_queue_with_printf_("fill_area", "fill %d,%d,%d,%d,%d", x1, y1, width, height,
|
this->add_no_result_to_queue_with_printf_("fill_area",
|
||||||
display::ColorUtil::color_to_565(color));
|
"fill %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16, x1, y1,
|
||||||
|
width, height, display::ColorUtil::color_to_565(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::line(int x1, int y1, int x2, int y2, uint16_t color) {
|
void Nextion::line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) {
|
||||||
this->add_no_result_to_queue_with_printf_("line", "line %d,%d,%d,%d,%" PRIu16, x1, y1, x2, y2, color);
|
this->add_no_result_to_queue_with_printf_("line", "line %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16, x1,
|
||||||
|
y1, x2, y2, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::line(int x1, int y1, int x2, int y2, const char *color) {
|
void Nextion::line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char *color) {
|
||||||
this->add_no_result_to_queue_with_printf_("line", "line %d,%d,%d,%d,%s", x1, y1, x2, y2, color);
|
this->add_no_result_to_queue_with_printf_("line", "line %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%s", x1, y1,
|
||||||
|
x2, y2, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::line(int x1, int y1, int x2, int y2, Color color) {
|
void Nextion::line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, Color color) {
|
||||||
this->add_no_result_to_queue_with_printf_("line", "line %d,%d,%d,%d,%d", x1, y1, x2, y2,
|
this->add_no_result_to_queue_with_printf_("line", "line %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16, x1,
|
||||||
display::ColorUtil::color_to_565(color));
|
y1, x2, y2, display::ColorUtil::color_to_565(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::rectangle(int x1, int y1, int width, int height, uint16_t color) {
|
void Nextion::rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color) {
|
||||||
this->add_no_result_to_queue_with_printf_("draw", "draw %d,%d,%d,%d,%" PRIu16, x1, y1, x1 + width, y1 + height,
|
this->add_no_result_to_queue_with_printf_("draw", "draw %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16, x1,
|
||||||
|
y1, static_cast<uint16_t>(x1 + width), static_cast<uint16_t>(y1 + height),
|
||||||
color);
|
color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::rectangle(int x1, int y1, int width, int height, const char *color) {
|
void Nextion::rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, const char *color) {
|
||||||
this->add_no_result_to_queue_with_printf_("draw", "draw %d,%d,%d,%d,%s", x1, y1, x1 + width, y1 + height, color);
|
this->add_no_result_to_queue_with_printf_("draw", "draw %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%s", x1, y1,
|
||||||
|
static_cast<uint16_t>(x1 + width), static_cast<uint16_t>(y1 + height),
|
||||||
|
color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::rectangle(int x1, int y1, int width, int height, Color color) {
|
void Nextion::rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, Color color) {
|
||||||
this->add_no_result_to_queue_with_printf_("draw", "draw %d,%d,%d,%d,%d", x1, y1, x1 + width, y1 + height,
|
this->add_no_result_to_queue_with_printf_("draw", "draw %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16, x1,
|
||||||
|
y1, static_cast<uint16_t>(x1 + width), static_cast<uint16_t>(y1 + height),
|
||||||
display::ColorUtil::color_to_565(color));
|
display::ColorUtil::color_to_565(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::circle(int center_x, int center_y, int radius, uint16_t color) {
|
void Nextion::circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color) {
|
||||||
this->add_no_result_to_queue_with_printf_("cir", "cir %d,%d,%d,%" PRIu16, center_x, center_y, radius, color);
|
this->add_no_result_to_queue_with_printf_("cir", "cir %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16, center_x,
|
||||||
|
center_y, radius, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::circle(int center_x, int center_y, int radius, const char *color) {
|
void Nextion::circle(uint16_t center_x, uint16_t center_y, uint16_t radius, const char *color) {
|
||||||
this->add_no_result_to_queue_with_printf_("cir", "cir %d,%d,%d,%s", center_x, center_y, radius, color);
|
this->add_no_result_to_queue_with_printf_("cir", "cir %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%s", center_x, center_y,
|
||||||
|
radius, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::circle(int center_x, int center_y, int radius, Color color) {
|
void Nextion::circle(uint16_t center_x, uint16_t center_y, uint16_t radius, Color color) {
|
||||||
this->add_no_result_to_queue_with_printf_("cir", "cir %d,%d,%d,%d", center_x, center_y, radius,
|
this->add_no_result_to_queue_with_printf_("cir", "cir %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16, center_x,
|
||||||
display::ColorUtil::color_to_565(color));
|
center_y, radius, display::ColorUtil::color_to_565(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::filled_circle(int center_x, int center_y, int radius, uint16_t color) {
|
void Nextion::filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color) {
|
||||||
this->add_no_result_to_queue_with_printf_("cirs", "cirs %d,%d,%d,%" PRIu16, center_x, center_y, radius, color);
|
this->add_no_result_to_queue_with_printf_("cirs", "cirs %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16, center_x,
|
||||||
|
center_y, radius, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::filled_circle(int center_x, int center_y, int radius, const char *color) {
|
void Nextion::filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, const char *color) {
|
||||||
this->add_no_result_to_queue_with_printf_("cirs", "cirs %d,%d,%d,%s", center_x, center_y, radius, color);
|
this->add_no_result_to_queue_with_printf_("cirs", "cirs %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%s", center_x, center_y,
|
||||||
|
radius, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::filled_circle(int center_x, int center_y, int radius, Color color) {
|
void Nextion::filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, Color color) {
|
||||||
this->add_no_result_to_queue_with_printf_("cirs", "cirs %d,%d,%d,%d", center_x, center_y, radius,
|
this->add_no_result_to_queue_with_printf_("cirs", "cirs %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16, center_x,
|
||||||
display::ColorUtil::color_to_565(color));
|
center_y, radius, display::ColorUtil::color_to_565(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::qrcode(int x1, int y1, const char *content, int size, uint16_t background_color,
|
void Nextion::qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size, uint16_t background_color,
|
||||||
uint16_t foreground_color, int logo_pic, uint8_t border_width) {
|
uint16_t foreground_color, uint8_t logo_pic, uint8_t border_width) {
|
||||||
this->add_no_result_to_queue_with_printf_("qrcode", "qrcode %d,%d,%d,%d,%d,%d,%d,\"%s\"", x1, y1, size,
|
|
||||||
background_color, foreground_color, logo_pic, border_width, content);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Nextion::qrcode(int x1, int y1, const char *content, int size, Color background_color, Color foreground_color,
|
|
||||||
int logo_pic, uint8_t border_width) {
|
|
||||||
this->add_no_result_to_queue_with_printf_(
|
this->add_no_result_to_queue_with_printf_(
|
||||||
"qrcode", "qrcode %d,%d,%d,%d,%d,%d,%d,\"%s\"", x1, y1, size, display::ColorUtil::color_to_565(background_color),
|
"qrcode", "qrcode %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu8 ",%" PRIu8 ",\"%s\"", x1,
|
||||||
display::ColorUtil::color_to_565(foreground_color), logo_pic, border_width, content);
|
y1, size, background_color, foreground_color, logo_pic, border_width, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Nextion::qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size, Color background_color,
|
||||||
|
Color foreground_color, uint8_t logo_pic, uint8_t border_width) {
|
||||||
|
this->add_no_result_to_queue_with_printf_(
|
||||||
|
"qrcode", "qrcode %" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu8 ",%" PRIu8 ",\"%s\"", x1,
|
||||||
|
y1, size, display::ColorUtil::color_to_565(background_color), display::ColorUtil::color_to_565(foreground_color),
|
||||||
|
logo_pic, border_width, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nextion::set_nextion_rtc_time(ESPTime time) {
|
void Nextion::set_nextion_rtc_time(ESPTime time) {
|
||||||
|
|
Loading…
Reference in a new issue