ESPHome 2025.7.1
|
#include <nextion.h>
Public Member Functions | |
void | set_max_commands_per_loop (uint16_t value) |
Set the maximum number of commands to process in each loop iteration. | |
uint16_t | get_max_commands_per_loop () const |
Get the current maximum number of commands allowed per loop iteration. | |
void | set_max_queue_size (size_t size) |
Set the maximum allowed queue size. | |
size_t | get_max_queue_size () const |
Get the maximum allowed queue size. | |
void | set_command_spacing (uint32_t spacing_ms) |
Set the command spacing for the display. | |
void | set_component_text (const char *component, const char *text) |
Set the text of a component to a static string. | |
void | set_component_text_printf (const char *component, const char *format,...) __attribute__((format(printf |
Set the text of a component to a formatted string. | |
void void | set_component_value (const char *component, int32_t value) |
Set the integer value of a component. | |
void | set_component_picture (const char *component, uint8_t picture_id) |
Set the picture of an image component. | |
void | set_component_background_color (const char *component, uint16_t color) |
Set the background color of a component. | |
void | set_component_background_color (const char *component, const char *color) |
Set the background color of a component. | |
void | set_component_background_color (const char *component, Color color) override |
Set the background color of a component. | |
void | set_component_pressed_background_color (const char *component, uint16_t color) |
Set the pressed background color of a component. | |
void | set_component_pressed_background_color (const char *component, const char *color) |
Set the pressed background color of a component. | |
void | set_component_pressed_background_color (const char *component, Color color) override |
Set the pressed background color of a component. | |
void | set_component_foreground_color (const char *component, uint16_t color) |
Set the foreground color of a component. | |
void | set_component_foreground_color (const char *component, const char *color) |
Set the foreground color of a component. | |
void | set_component_foreground_color (const char *component, Color color) override |
Set the foreground color of a component. | |
void | set_component_pressed_foreground_color (const char *component, uint16_t color) |
Set the pressed foreground color of a component. | |
void | set_component_pressed_foreground_color (const char *component, const char *color) |
Set the pressed foreground color of a component. | |
void | set_component_pressed_foreground_color (const char *component, Color color) override |
Set the pressed foreground color of a component. | |
void | set_component_pic (const char *component, uint8_t pic_id) |
Set the picture id of a component. | |
void | set_component_picc (const char *component, uint8_t pic_id) |
Set the background picture id of component. | |
void | set_component_font_color (const char *component, uint16_t color) |
Set the font color of a component. | |
void | set_component_font_color (const char *component, const char *color) |
Set the font color of a component. | |
void | set_component_font_color (const char *component, Color color) override |
Set the font color of a component. | |
void | set_component_pressed_font_color (const char *component, uint16_t color) |
Set the pressed font color of a component. | |
void | set_component_pressed_font_color (const char *component, const char *color) |
Set the pressed font color of a component. | |
void | set_component_pressed_font_color (const char *component, Color color) override |
Set the pressed font color of a component. | |
void | set_component_coordinates (const char *component, uint16_t x, uint16_t y) |
Set the coordinates of a component on screen. | |
void | set_component_font (const char *component, uint8_t font_id) override |
Set the font id for a component. | |
void | set_nextion_rtc_time (ESPTime time) |
Send the current time to the nextion display. | |
void | goto_page (const char *page) |
Show the page with a given name. | |
void | goto_page (uint8_t page) |
Show the page with a given id. | |
void | hide_component (const char *component) override |
Hide a component. | |
void | show_component (const char *component) override |
Show a component. | |
void | enable_component_touch (const char *component) |
Enable touch for a component. | |
void | disable_component_touch (const char *component) |
Disable touch for a component. | |
void | add_waveform_data (uint8_t component_id, uint8_t channel_number, uint8_t value) |
Add waveform data to a waveform component. | |
void | open_waveform_channel (uint8_t component_id, uint8_t channel_number, uint8_t value) |
void | display_picture (uint16_t picture_id, uint16_t x_start, uint16_t y_start) |
Display a picture at coordinates. | |
void | fill_area (uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color) |
Fill a rectangle with a 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. | |
void | fill_area (uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, Color color) |
Fill a rectangle with a color. | |
void | line (uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) |
Draw a line on the screen. | |
void | line (uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char *color) |
Draw a line on the screen. | |
void | line (uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, Color color) |
Draw a line on the screen. | |
void | rectangle (uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color) |
Draw a rectangle outline. | |
void | rectangle (uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, const char *color) |
Draw a rectangle outline. | |
void | rectangle (uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, Color color) |
Draw a rectangle outline. | |
void | circle (uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color) |
Draw a circle outline. | |
void | circle (uint16_t center_x, uint16_t center_y, uint16_t radius, const char *color) |
Draw a circle outline. | |
void | circle (uint16_t center_x, uint16_t center_y, uint16_t radius, Color color) |
Draw a circle outline. | |
void | filled_circle (uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color) |
Draw a filled circled. | |
void | filled_circle (uint16_t center_x, uint16_t center_y, uint16_t radius, const char *color) |
Draw a filled circled. | |
void | filled_circle (uint16_t center_x, uint16_t center_y, uint16_t radius, Color color) |
Draw a filled circled. | |
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, uint8_t logo_pic=-1, uint8_t border_width=8) |
Draws a QR code in the screen. | |
void | qrcode (uint16_t x1, uint16_t y1, const char *content, uint16_t size, Color background_color=Color(255, 255, 255), Color foreground_color=Color(0, 0, 0), uint8_t logo_pic=-1, uint8_t border_width=8) |
Draws a QR code in the screen. | |
void | set_backlight_brightness (float brightness) |
Set the brightness of the backlight. | |
void | sleep (bool sleep) |
Sets Nextion mode between sleep and awake. | |
bool | set_protocol_reparse_mode (bool active_mode) |
Sets the Nextion display's protocol reparse mode. | |
void | set_component_vid (const char *component, uint8_t vid_id) |
Set the video id of a component. | |
void | set_component_drag (const char *component, bool drag) |
Set the drag availability of a component. | |
void | set_component_aph (const char *component, uint8_t aph) |
Set the opaqueness (fading) of a component. | |
void | set_component_position (const char *component, uint32_t x, uint32_t y) |
Set the position of a component. | |
void | register_touch_component (NextionComponentBase *obj) |
void | register_switch_component (NextionComponentBase *obj) |
void | register_binarysensor_component (NextionComponentBase *obj) |
void | register_sensor_component (NextionComponentBase *obj) |
void | register_textsensor_component (NextionComponentBase *obj) |
void | setup () override |
void | set_brightness (float brightness) |
float | get_setup_priority () const override |
void | update () override |
void | loop () override |
void | set_writer (const nextion_writer_t &writer) |
void | set_wait_for_ack (bool wait_for_ack) |
bool | send_command (const char *command) |
Manually send a raw command to the display. | |
bool | send_command_printf (const char *format,...) __attribute__((format(printf |
Manually send a raw formatted command to the display. | |
bool void | set_tft_url (const std::string &tft_url) |
Set the tft file URL. | |
bool | upload_tft (uint32_t baud_rate=0, bool exit_reparse=true) |
Uploads the TFT file to the Nextion display. | |
void | dump_config () override |
void | soft_reset () |
Softreset the Nextion. | |
void | add_sleep_state_callback (std::function< void()> &&callback) |
Add a callback to be notified of sleep state changes. | |
void | add_wake_state_callback (std::function< void()> &&callback) |
Add a callback to be notified of wake state changes. | |
void | add_setup_state_callback (std::function< void()> &&callback) |
Add a callback to be notified when the nextion completes its initialize setup. | |
void | add_new_page_callback (std::function< void(uint8_t)> &&callback) |
Add a callback to be notified when the nextion changes pages. | |
void | add_touch_event_callback (std::function< void(uint8_t, uint8_t, bool)> &&callback) |
Add a callback to be notified when Nextion has a touch event. | |
void | add_buffer_overflow_event_callback (std::function< void()> &&callback) |
Add a callback to be notified when the nextion reports a buffer overflow. | |
void | update_all_components () |
void | set_nextion_sensor_state (int queue_type, const std::string &name, float state) |
Set the nextion sensor state object. | |
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 | 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, 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 (const std::string &variable_name, const std::string &variable_name_to_send, const std::string &state_value) override |
void | add_to_get_queue (NextionComponentBase *component) override |
Queue a GET command for a component that expects a response from the Nextion display. | |
void | add_addt_command_to_queue (NextionComponentBase *component) override |
Add addt command to the queue. | |
void | update_components_by_prefix (const std::string &prefix) |
void | set_touch_sleep_timeout (uint16_t touch_sleep_timeout=0) |
Set the touch sleep timeout of the display using the thsp command. | |
void | set_wake_up_page (uint8_t wake_up_page=255) |
Sets which page Nextion loads when exiting sleep mode. | |
void | set_start_up_page (uint8_t start_up_page=255) |
Sets which page Nextion loads when connecting to ESPHome. | |
void | set_auto_wake_on_touch (bool auto_wake_on_touch) |
Sets if Nextion should auto-wake from sleep when touch press occurs. | |
size_t | queue_size () |
Retrieves the number of commands pending in the Nextion command queue. | |
bool | is_updating () override |
Check if the TFT update process is currently running. | |
bool | is_connected () |
Check if the Nextion display is successfully connected. | |
![]() | |
bool | is_sleeping () |
bool | is_setup () |
bool | is_detected () |
![]() | |
PollingComponent () | |
PollingComponent (uint32_t update_interval) | |
Initialize this polling component with the given update interval in ms. | |
virtual void | set_update_interval (uint32_t update_interval) |
Manually set the update interval in ms for this polling object. | |
void | call_setup () override |
virtual uint32_t | get_update_interval () const |
Get the update interval in ms of this sensor. | |
void | start_poller () |
void | stop_poller () |
![]() | |
float | get_actual_setup_priority () const |
void | set_setup_priority (float priority) |
virtual float | get_loop_priority () const |
priority of loop(). | |
void | call () |
virtual void | on_shutdown () |
virtual void | on_safe_shutdown () |
virtual bool | teardown () |
Called during teardown to allow component to gracefully finish operations. | |
virtual void | on_powerdown () |
Called after teardown is complete to power down hardware. | |
uint8_t | get_component_state () const |
void | reset_to_construction_state () |
Reset this component back to the construction state to allow setup to run again. | |
bool | is_in_loop_state () const |
Check if this component has completed setup and is in the loop state. | |
virtual void | mark_failed () |
Mark this component as failed. | |
void | mark_failed (const char *message) |
void | disable_loop () |
Disable this component's loop. | |
void | enable_loop () |
Enable this component's loop. | |
void | enable_loop_soon_any_context () |
Thread and ISR-safe version of enable_loop() that can be called from any context. | |
bool | is_failed () const |
bool | is_ready () const |
virtual bool | can_proceed () |
bool | status_has_warning () const |
bool | status_has_error () const |
void | status_set_warning (const char *message="unspecified") |
void | status_set_error (const char *message="unspecified") |
void | status_clear_warning () |
void | status_clear_error () |
void | status_momentary_warning (const std::string &name, uint32_t length=5000) |
void | status_momentary_error (const std::string &name, uint32_t length=5000) |
bool | has_overridden_loop () const |
void | set_component_source (const char *source) |
Set where this component was loaded from for some debug messages. | |
const char * | get_component_source () const |
Get the integration where this component was declared as a string. | |
bool | should_warn_of_blocking (uint32_t blocking_time) |
![]() | |
UARTDevice ()=default | |
UARTDevice (UARTComponent *parent) | |
void | set_uart_parent (UARTComponent *parent) |
void | write_byte (uint8_t data) |
void | write_array (const uint8_t *data, size_t len) |
void | write_array (const std::vector< uint8_t > &data) |
template<size_t N> | |
void | write_array (const std::array< uint8_t, N > &data) |
void | write_str (const char *str) |
bool | read_byte (uint8_t *data) |
bool | peek_byte (uint8_t *data) |
bool | read_array (uint8_t *data, size_t len) |
template<size_t N> | |
optional< std::array< uint8_t, N > > | read_array () |
int | available () |
void | flush () |
int | read () |
size_t | write (uint8_t data) |
int | peek () |
void | check_uart_settings (uint32_t baud_rate, uint8_t stop_bits=1, UARTParityOptions parity=UART_CONFIG_PARITY_NONE, uint8_t data_bits=8) |
Check that the configuration of the UART bus matches the provided values and otherwise print a warning. | |
Protected Member Functions | |
void | process_pending_in_queue_ () |
Process any commands in the queue that are pending due to command spacing. | |
uint16_t | recv_ret_string_ (std::string &response, uint32_t timeout, bool recv_flag) |
void | all_components_send_state_ (bool force_update=false) |
bool | remove_from_q_ (bool report_empty=true) |
void | process_nextion_commands_ () |
void | process_serial_ () |
bool | send_command_ (const std::string &command) |
Manually send a raw command to the display and don't wait for an acknowledgement packet. | |
void | add_no_result_to_queue_ (const std::string &variable_name) |
Add a command to the Nextion queue that expects no response. | |
bool | add_no_result_to_queue_with_ignore_sleep_printf_ (const std::string &variable_name, const char *format,...) __attribute__((format(printf |
bool void | add_no_result_to_queue_with_command_ (const std::string &variable_name, const std::string &command) |
void | add_no_result_to_queue_with_pending_command_ (const std::string &variable_name, const std::string &command) |
Add a command to the Nextion queue with a pending command for retry. | |
bool | add_no_result_to_queue_with_printf_ (const std::string &variable_name, const char *format,...) __attribute__((format(printf |
Sends a formatted command to the nextion. | |
bool void | add_no_result_to_queue_with_set_internal_ (const std::string &variable_name, const std::string &variable_name_to_send, int32_t state_value, bool is_sleep_safe=false) |
void | add_no_result_to_queue_with_set_internal_ (const std::string &variable_name, const std::string &variable_name_to_send, const std::string &state_value, bool is_sleep_safe=false) |
void | check_pending_waveform_ () |
WiFiClient * | get_wifi_client_ () |
int | upload_by_chunks_ (HTTPClient &http_client, uint32_t &range_start) |
will request chunk_size chunks from the web server and send each to the nextion | |
int | upload_by_chunks_ (esp_http_client_handle_t http_client, uint32_t &range_start) |
will request 4096 bytes chunks from the web server and send each to Nextion | |
bool | upload_end_ (bool successful) |
Ends the upload process, restart Nextion and, if successful, restarts ESP. | |
uint32_t | get_free_heap_ () |
Returns the ESP Free Heap memory. | |
bool | check_connect_ () |
void | remove_front_no_sensors_ () |
void | print_queue_members_ () |
void | reset_ (bool reset_nextion=true) |
![]() | |
virtual void | call_loop () |
virtual void | call_dump_config () |
void | set_interval (const std::string &name, uint32_t interval, std::function< void()> &&f) |
Set an interval function with a unique name. | |
void | set_interval (const char *name, uint32_t interval, std::function< void()> &&f) |
Set an interval function with a const char* name. | |
void | set_interval (uint32_t interval, std::function< void()> &&f) |
bool | cancel_interval (const std::string &name) |
Cancel an interval function. | |
bool | cancel_interval (const char *name) |
void | set_retry (const std::string &name, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f) |
Set an retry function with a unique name. | |
void | set_retry (uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f) |
bool | cancel_retry (const std::string &name) |
Cancel a retry function. | |
void | set_timeout (const std::string &name, uint32_t timeout, std::function< void()> &&f) |
Set a timeout function with a unique name. | |
void | set_timeout (const char *name, uint32_t timeout, std::function< void()> &&f) |
Set a timeout function with a const char* name. | |
void | set_timeout (uint32_t timeout, std::function< void()> &&f) |
bool | cancel_timeout (const std::string &name) |
Cancel a timeout function. | |
bool | cancel_timeout (const char *name) |
void | defer (const std::string &name, std::function< void()> &&f) |
Defer a callback to the next loop() call. | |
void | defer (const char *name, std::function< void()> &&f) |
Defer a callback to the next loop() call with a const char* name. | |
void | defer (std::function< void()> &&f) |
Defer a callback to the next loop() call. | |
bool | cancel_defer (const std::string &name) |
Cancel a defer callback using the specified name, name must not be empty. | |
Protected Attributes | ||
uint16_t | max_commands_per_loop_ {1000} | |
size_t | max_queue_size_ {0} | |
NextionCommandPacer | command_pacer_ {0} | |
std::deque< NextionQueue * > | nextion_queue_ | |
std::deque< NextionQueue * > | waveform_queue_ | |
uint32_t | comok_sent_ = 0 | |
struct { | ||
uint8_t is_connected_: 1 | ||
Connection established with Nextion display. More... | ||
uint8_t sent_setup_commands_: 1 | ||
Initial setup commands have been sent. More... | ||
uint8_t ignore_is_setup_: 1 | ||
Temporarily ignore setup state for special operations. More... | ||
uint8_t nextion_reports_is_setup_: 1 | ||
Nextion has reported successful initialization. More... | ||
uint8_t is_updating_: 1 | ||
TFT firmware update is currently in progress. More... | ||
uint8_t auto_wake_on_touch_: 1 | ||
Display should wake automatically on touch (default: true) More... | ||
uint8_t reserved_: 2 | ||
Reserved bits for future flag additions. More... | ||
} | connection_state_ | |
Status flags for Nextion display state management. | ||
uint16_t | touch_sleep_timeout_ = 0 | |
uint8_t | wake_up_page_ = 255 | |
uint8_t | start_up_page_ = 255 | |
bool | auto_wake_on_touch_ = true | |
WiFiClient * | wifi_client_ {nullptr} | |
BearSSL::WiFiClientSecure * | wifi_client_secure_ {nullptr} | |
std::string | tft_url_ | |
uint32_t | content_length_ = 0 | |
int | tft_size_ = 0 | |
uint32_t | original_baud_rate_ = 0 | |
bool | upload_first_chunk_sent_ = false | |
std::vector< NextionComponentBase * > | touch_ | |
std::vector< NextionComponentBase * > | switchtype_ | |
std::vector< NextionComponentBase * > | sensortype_ | |
std::vector< NextionComponentBase * > | textsensortype_ | |
std::vector< NextionComponentBase * > | binarysensortype_ | |
CallbackManager< void()> | setup_callback_ {} | |
CallbackManager< void()> | sleep_callback_ {} | |
CallbackManager< void()> | wake_callback_ {} | |
CallbackManager< void(uint8_t)> | page_callback_ {} | |
CallbackManager< void(uint8_t, uint8_t, bool)> | touch_callback_ {} | |
CallbackManager< void()> | buffer_overflow_callback_ {} | |
optional< nextion_writer_t > | writer_ | |
optional< float > | brightness_ | |
std::string | device_model_ | |
std::string | firmware_version_ | |
std::string | serial_number_ | |
std::string | flash_size_ | |
std::string | command_data_ | |
const uint16_t | startup_override_ms_ = 8000 | |
const uint16_t | max_q_age_ms_ = 8000 | |
uint32_t | started_ms_ = 0 | |
![]() | ||
bool | is_setup_ = false | |
bool | is_sleeping_ = false | |
bool | is_detected_ = false | |
![]() | ||
uint32_t | update_interval_ | |
![]() | ||
const char * | component_source_ {nullptr} | |
uint16_t | warn_if_blocking_over_ {WARN_IF_BLOCKING_OVER_MS} | |
Warn if blocked for this many ms (max 65.5s) | ||
uint8_t | component_state_ {0x00} | |
State of this component - each bit has a purpose: Bits 0-1: Component state (0x00=CONSTRUCTION, 0x01=SETUP, 0x02=LOOP, 0x03=FAILED) Bit 2: STATUS_LED_WARNING Bit 3: STATUS_LED_ERROR Bits 4-7: Unused - reserved for future expansion (50% of the bits are free) | ||
volatile bool | pending_enable_loop_ {false} | |
ISR-safe flag for enable_loop_soon_any_context. | ||
![]() | ||
UARTComponent * | parent_ {nullptr} | |
|
overridevirtual |
Add addt command to the queue.
component_id | The waveform component id |
wave_chan_id | The waveform channel to send it to |
buffer_to_send | The buffer size |
buffer_size | The buffer data |
Implements esphome::nextion::NextionBase.
Definition at line 1255 of file nextion.cpp.
void esphome::nextion::Nextion::add_buffer_overflow_event_callback | ( | std::function< void()> && | callback | ) |
Add a callback to be notified when the nextion reports a buffer overflow.
callback | The void() callback. |
Definition at line 224 of file nextion.cpp.
void esphome::nextion::Nextion::add_new_page_callback | ( | std::function< void(uint8_t)> && | callback | ) |
Add a callback to be notified when the nextion changes pages.
callback | The void(std::string) callback. |
Definition at line 216 of file nextion.cpp.
|
protected |
Add a command to the Nextion queue that expects no response.
This is typically used for write-only operations such as variable assignments or component updates where no return value or acknowledgment is expected from the display.
If the max_queue_size
limit is configured and reached, the command will be skipped.
variable_name | Name of the variable or component associated with the command. |
Definition at line 1030 of file nextion.cpp.
|
protected |
variable_name | Variable name for the queue |
command |
Definition at line 1063 of file nextion.cpp.
|
protected |
Definition at line 1105 of file nextion.cpp.
|
protected |
Add a command to the Nextion queue with a pending command for retry.
This method creates a queue entry for a command that was blocked by command spacing. The command string is stored in the queue item's pending_command field so it can be retried later when spacing allows. This ensures commands are not lost when sent too quickly.
If the max_queue_size limit is configured and reached, the command will be dropped.
variable_name | Name of the variable or component associated with the command |
command | The actual command string to be sent when spacing allows |
Definition at line 1078 of file nextion.cpp.
|
protected |
Sends a formatted command to the nextion.
variable_name | Variable name for the queue |
format | The printf-style command format, like "vis %s,0" |
... | The format arguments |
Definition at line 1131 of file nextion.cpp.
|
overridevirtual |
Implements esphome::nextion::NextionBase.
Definition at line 1190 of file nextion.cpp.
|
overridevirtual |
Implements esphome::nextion::NextionBase.
Definition at line 1163 of file nextion.cpp.
|
overridevirtual |
variable_name | Variable name for the queue |
variable_name_to_send | Variable name for the left of the command |
state_value | String value to set |
is_sleep_safe | The command is safe to send when the Nextion is sleeping |
Implements esphome::nextion::NextionBase.
Definition at line 1186 of file nextion.cpp.
|
overridevirtual |
variable_name | Variable name for the queue |
variable_name_to_send | Variable name for the left of the command |
state_value | Value to set |
is_sleep_safe | The command is safe to send when the Nextion is sleeping |
Implements esphome::nextion::NextionBase.
Definition at line 1158 of file nextion.cpp.
|
protected |
Definition at line 1196 of file nextion.cpp.
|
protected |
Definition at line 1168 of file nextion.cpp.
void esphome::nextion::Nextion::add_setup_state_callback | ( | std::function< void()> && | callback | ) |
Add a callback to be notified when the nextion completes its initialize setup.
callback | The void() callback. |
Definition at line 212 of file nextion.cpp.
void esphome::nextion::Nextion::add_sleep_state_callback | ( | std::function< void()> && | callback | ) |
Add a callback to be notified of sleep state changes.
callback | The void() callback. |
Definition at line 204 of file nextion.cpp.
|
overridevirtual |
Queue a GET command for a component that expects a response from the Nextion display.
This method is used for querying values such as sensor states, text content, or switch status. The component will be added to the Nextion queue only if the display is already set up, the queue has not reached the configured maximum size (if set), and the command is sent successfully.
component | Pointer to the Nextion component that will handle the response. |
Implements esphome::nextion::NextionBase.
Definition at line 1215 of file nextion.cpp.
void esphome::nextion::Nextion::add_touch_event_callback | ( | std::function< void(uint8_t, uint8_t, bool)> && | callback | ) |
Add a callback to be notified when Nextion has a touch event.
callback | The void() callback. |
Definition at line 220 of file nextion.cpp.
void esphome::nextion::Nextion::add_wake_state_callback | ( | std::function< void()> && | callback | ) |
Add a callback to be notified of wake state changes.
callback | The void() callback. |
Definition at line 208 of file nextion.cpp.
void esphome::nextion::Nextion::add_waveform_data | ( | uint8_t | component_id, |
uint8_t | channel_number, | ||
uint8_t | value ) |
Add waveform data to a waveform component.
component_id | The integer component id. |
channel_number | The channel number to write to. |
value | The value to write. |
Definition at line 232 of file nextion_commands.cpp.
|
protected |
Definition at line 935 of file nextion.cpp.
|
protected |
Definition at line 47 of file nextion.cpp.
|
protected |
Definition at line 1275 of file nextion.cpp.
void esphome::nextion::Nextion::circle | ( | uint16_t | center_x, |
uint16_t | center_y, | ||
uint16_t | radius, | ||
Color | color ) |
Draw a circle outline.
center_x | The center x coordinate. |
center_y | The center y coordinate. |
radius | The circle radius. |
color | The color to draw with (as Color). |
Definition at line 312 of file nextion_commands.cpp.
void esphome::nextion::Nextion::circle | ( | uint16_t | center_x, |
uint16_t | center_y, | ||
uint16_t | radius, | ||
const char * | color ) |
Draw a circle outline.
center_x | The center x coordinate. |
center_y | The center y coordinate. |
radius | The circle radius. |
color | The color to draw with (as a string). Use Nextion Instruction Set for a list of Nextion HMI colors constants. |
Definition at line 307 of file nextion_commands.cpp.
void esphome::nextion::Nextion::circle | ( | uint16_t | center_x, |
uint16_t | center_y, | ||
uint16_t | radius, | ||
uint16_t | color ) |
Draw a circle outline.
center_x | The center x coordinate. |
center_y | The center y coordinate. |
radius | The circle radius. |
color | The color to draw with (number). Use this color picker to convert color codes to Nextion HMI colors. |
Definition at line 302 of file nextion_commands.cpp.
void esphome::nextion::Nextion::disable_component_touch | ( | const char * | component | ) |
Disable touch for a component.
component | The component name. |
Example:
Disables touch for component named button
.
Definition at line 216 of file nextion_commands.cpp.
void esphome::nextion::Nextion::display_picture | ( | uint16_t | picture_id, |
uint16_t | x_start, | ||
uint16_t | y_start ) |
Display a picture at coordinates.
picture_id | The picture id. |
x1 | The x coordinate. |
y1 | The y coordniate. |
Example:
Displays the picture who has the id 2
at the x coordinates 15
and y coordinates 25
.
Definition at line 248 of file nextion_commands.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 146 of file nextion.cpp.
void esphome::nextion::Nextion::enable_component_touch | ( | const char * | component | ) |
Enable touch for a component.
component | The component name. |
Example:
Enables touch for component named button
.
Definition at line 212 of file nextion_commands.cpp.
void esphome::nextion::Nextion::fill_area | ( | uint16_t | x1, |
uint16_t | y1, | ||
uint16_t | width, | ||
uint16_t | height, | ||
Color | color ) |
Fill a rectangle with a color.
x1 | The starting x coordinate. |
y1 | The starting y coordinate. |
width | The width to draw. |
height | The height to draw. |
color | The color to draw with (as Color). |
Example:
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.
Definition at line 263 of file nextion_commands.cpp.
void esphome::nextion::Nextion::fill_area | ( | uint16_t | x1, |
uint16_t | y1, | ||
uint16_t | width, | ||
uint16_t | height, | ||
const char * | color ) |
Fill a rectangle with a color.
x1 | The starting x coordinate. |
y1 | The starting y coordinate. |
width | The width to draw. |
height | The height to draw. |
color | The color to draw with (as a string). |
Example:
Fills an area that starts at x coordinate 50
and y coordinate 50
with a height of 100
and width of 100
with the red color. Use Nextion Instruction Set for a list of Nextion HMI colors constants.
Definition at line 258 of file nextion_commands.cpp.
void esphome::nextion::Nextion::fill_area | ( | uint16_t | x1, |
uint16_t | y1, | ||
uint16_t | width, | ||
uint16_t | height, | ||
uint16_t | color ) |
Fill a rectangle with a color.
x1 | The starting x coordinate. |
y1 | The starting y coordinate. |
width | The width to draw. |
height | The height to draw. |
color | The color to draw with (number). |
Example:
Fills an area that starts at x coordinate 50
and y coordinate 50
with a height of 100
and width of 100
with the red color. Use this color picker to convert color codes to Nextion HMI colors.
Definition at line 253 of file nextion_commands.cpp.
void esphome::nextion::Nextion::filled_circle | ( | uint16_t | center_x, |
uint16_t | center_y, | ||
uint16_t | radius, | ||
Color | color ) |
Draw a filled circled.
center_x | The center x coordinate. |
center_y | The center y coordinate. |
radius | The circle radius. |
color | The color to draw with (as Color). |
Example:
Makes a filled circle at the x coordinate 25
and y coordinate 25
with a radius of 10
with blue color.
Definition at line 327 of file nextion_commands.cpp.
void esphome::nextion::Nextion::filled_circle | ( | uint16_t | center_x, |
uint16_t | center_y, | ||
uint16_t | radius, | ||
const char * | color ) |
Draw a filled circled.
center_x | The center x coordinate. |
center_y | The center y coordinate. |
radius | The circle radius. |
color | The color to draw with (as a string). |
Example:
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 for a list of Nextion HMI colors constants.
Definition at line 322 of file nextion_commands.cpp.
void esphome::nextion::Nextion::filled_circle | ( | uint16_t | center_x, |
uint16_t | center_y, | ||
uint16_t | radius, | ||
uint16_t | color ) |
Draw a filled circled.
center_x | The center x coordinate. |
center_y | The center y coordinate. |
radius | The circle radius. |
color | The color to draw with (number). |
Example:
Makes a filled circle at the x coordinate 25
and y coordinate 25
with a radius of 10
with the red color. Use this color picker to convert color codes to Nextion HMI colors.
Definition at line 317 of file nextion_commands.cpp.
|
inlineprotected |
Returns the ESP Free Heap memory.
This is framework independent.
Definition at line 24 of file nextion_upload_arduino.cpp.
|
inline |
|
inline |
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 194 of file nextion.cpp.
|
protected |
Definition at line 339 of file nextion_upload_arduino.cpp.
void esphome::nextion::Nextion::goto_page | ( | const char * | page | ) |
Show the page with a given name.
page | The name of the page. |
Example:
Switches to the page named main
. Pages are named in the Nextion Editor.
Definition at line 183 of file nextion_commands.cpp.
void esphome::nextion::Nextion::goto_page | ( | uint8_t | page | ) |
Show the page with a given id.
page | The id of the page. |
Example:
Switches to the page named main
. Pages are named in the Nextion Editor.
Definition at line 184 of file nextion_commands.cpp.
|
overridevirtual |
Hide a component.
component | The component name. |
Example:
Hides the component named button
.
Implements esphome::nextion::NextionBase.
Definition at line 204 of file nextion_commands.cpp.
|
inline |
Check if the Nextion display is successfully connected.
This method returns whether a successful connection has been established with the Nextion display. A connection is considered established when:
The connection status is particularly useful when:
|
overridevirtual |
Check if the TFT update process is currently running.
This method provides a way to determine if the Nextion display is in the process of updating its TFT firmware. When a TFT update is in progress, certain operations or commands may be restricted or could interfere with the update process. By checking the state of the update process, the system can make informed decisions about performing actions that involve communication with the Nextion display.
Reimplemented from esphome::nextion::NextionBase.
Definition at line 1297 of file nextion.cpp.
void esphome::nextion::Nextion::line | ( | uint16_t | x1, |
uint16_t | y1, | ||
uint16_t | x2, | ||
uint16_t | y2, | ||
Color | color ) |
Draw a line on the screen.
x1 | The starting x coordinate. |
y1 | The starting y coordinate. |
x2 | The ending x coordinate. |
y2 | The ending y coordinate. |
color | The color to draw with (as Color). |
Example:
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.
Definition at line 279 of file nextion_commands.cpp.
void esphome::nextion::Nextion::line | ( | uint16_t | x1, |
uint16_t | y1, | ||
uint16_t | x2, | ||
uint16_t | y2, | ||
const char * | color ) |
Draw a line on the screen.
x1 | The starting x coordinate. |
y1 | The starting y coordinate. |
x2 | The ending x coordinate. |
y2 | The ending y coordinate. |
color | The color to draw with (as a string). |
Example:
Makes a line that starts at x coordinate 50
and y coordinate 50
and ends at x coordinate 75
and y coordinate 75
with the blue color. Use Nextion Instruction Set for a list of Nextion HMI colors constants.
Definition at line 274 of file nextion_commands.cpp.
void esphome::nextion::Nextion::line | ( | uint16_t | x1, |
uint16_t | y1, | ||
uint16_t | x2, | ||
uint16_t | y2, | ||
uint16_t | color ) |
Draw a line on the screen.
x1 | The starting x coordinate. |
y1 | The starting y coordinate. |
x2 | The ending x coordinate. |
y2 | The ending y coordinate. |
color | The color to draw with (number). |
Example:
Makes a line that starts at x coordinate 50
and y coordinate 50
and ends at x coordinate 75
and y coordinate 75
with the red color. Use this color picker to convert color codes to Nextion HMI colors.
Definition at line 269 of file nextion_commands.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 298 of file nextion.cpp.
void esphome::nextion::Nextion::open_waveform_channel | ( | uint8_t | component_id, |
uint8_t | channel_number, | ||
uint8_t | value ) |
Definition at line 237 of file nextion_commands.cpp.
|
protected |
Definition at line 279 of file nextion.cpp.
|
protected |
Definition at line 404 of file nextion.cpp.
|
protected |
Process any commands in the queue that are pending due to command spacing.
This method checks if the first item in the nextion_queue_ has a pending command that was previously blocked by command spacing. If spacing now allows and a pending command exists, it attempts to send the command. Once successfully sent, the pending command is cleared and the queue item continues normal processing.
Called from loop() to retry sending commands that were delayed by spacing.
Definition at line 349 of file nextion.cpp.
|
protected |
Definition at line 395 of file nextion.cpp.
void esphome::nextion::Nextion::qrcode | ( | uint16_t | x1, |
uint16_t | y1, | ||
const char * | content, | ||
uint16_t | size, | ||
Color | background_color = Color(255, 255, 255), | ||
Color | foreground_color = Color(0, 0, 0), | ||
uint8_t | logo_pic = -1, | ||
uint8_t | border_width = 8 ) |
Draws a QR code in the screen.
x1 | The top left x coordinate to start the QR code. |
y1 | The top left y coordinate to start the QR code. |
content | The content of the QR code (as a plain text - Nextion will generate the QR code). |
size | The size (in pixels) for the QR code. Defaults to 200px. |
background_color | The background color to draw with (as Color). Defaults to 65535 (white). |
foreground_color | The foreground color to draw with (as Color). Defaults to 0 (black). |
logo_pic | The picture id for the logo in the center of the QR code. Defaults to -1 (no logo). |
border_width | The border width (in pixels) for the QR code. Defaults to 8px. |
Example:
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.
Definition at line 339 of file nextion_commands.cpp.
void esphome::nextion::Nextion::qrcode | ( | uint16_t | x1, |
uint16_t | y1, | ||
const char * | content, | ||
uint16_t | size = 200, | ||
uint16_t | background_color = 65535, | ||
uint16_t | foreground_color = 0, | ||
uint8_t | logo_pic = -1, | ||
uint8_t | border_width = 8 ) |
Draws a QR code in the screen.
x1 | The top left x coordinate to start the QR code. |
y1 | The top left y coordinate to start the QR code. |
content | The content of the QR code (as a plain text - Nextion will generate the QR code). |
size | The size (in pixels) for the QR code. Defaults to 200px. |
background_color | The background color to draw with (as rgb565 integer). Defaults to 65535 (white). |
foreground_color | The foreground color to draw with (as rgb565 integer). Defaults to 0 (black). |
logo_pic | The picture id for the logo in the center of the QR code. Defaults to -1 (no logo). |
border_width | The border width (in pixels) for the QR code. Defaults to 8px. |
Example:
Draws a QR code with a Wi-Fi network credentials starting at the given coordinates (25,25).
Definition at line 332 of file nextion_commands.cpp.
|
inline |
Retrieves the number of commands pending in the Nextion command queue.
This function returns the current count of commands that have been queued but not yet processed for the Nextion display. The Nextion command queue is used to store commands that are sent to the Nextion display for various operations like updating the display, changing interface elements, or other interactive features. A larger queue size might indicate a higher processing time or potential delays in command execution. This function is useful for monitoring the command flow and managing the execution efficiency of the Nextion display interface.
void esphome::nextion::Nextion::rectangle | ( | uint16_t | x1, |
uint16_t | y1, | ||
uint16_t | width, | ||
uint16_t | height, | ||
Color | color ) |
Draw a rectangle outline.
x1 | The starting x coordinate. |
y1 | The starting y coordinate. |
width | The width of the rectangle. |
height | The height of the rectangle. |
color | The color to draw with (as Color). |
Example:
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.
Definition at line 296 of file nextion_commands.cpp.
void esphome::nextion::Nextion::rectangle | ( | uint16_t | x1, |
uint16_t | y1, | ||
uint16_t | width, | ||
uint16_t | height, | ||
const char * | color ) |
Draw a rectangle outline.
x1 | The starting x coordinate. |
y1 | The starting y coordinate. |
width | The width of the rectangle. |
height | The height of the rectangle. |
color | The color to draw with (as a string). |
Example:
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 the blue color. Use Nextion Instruction Set for a list of Nextion HMI colors constants.
Definition at line 290 of file nextion_commands.cpp.
void esphome::nextion::Nextion::rectangle | ( | uint16_t | x1, |
uint16_t | y1, | ||
uint16_t | width, | ||
uint16_t | height, | ||
uint16_t | color ) |
Draw a rectangle outline.
x1 | The starting x coordinate. |
y1 | The starting y coordinate. |
width | The width of the rectangle. |
height | The height of the rectangle. |
color | The color to draw with (number). |
Example:
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 the red color. Use this color picker to convert color codes to Nextion HMI colors.
Definition at line 284 of file nextion_commands.cpp.
|
protected |
Definition at line 974 of file nextion.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
protected |
Definition at line 366 of file nextion.cpp.
|
protected |
|
protected |
Definition at line 136 of file nextion.cpp.
bool esphome::nextion::Nextion::send_command | ( | const char * | command | ) |
Manually send a raw command to the display.
command | The pcommand, like "page 0" |
Definition at line 246 of file nextion.cpp.
|
protected |
Manually send a raw command to the display and don't wait for an acknowledgement packet.
command | The command to write, for example "vis b0,0". |
Definition at line 26 of file nextion.cpp.
bool esphome::nextion::Nextion::send_command_printf | ( | const char * | format, |
... ) |
Manually send a raw formatted command to the display.
format | The printf-style command format, like "vis %s,0" |
... | The format arguments |
Definition at line 257 of file nextion.cpp.
void esphome::nextion::Nextion::set_auto_wake_on_touch | ( | bool | auto_wake_on_touch | ) |
Sets if Nextion should auto-wake from sleep when touch press occurs.
auto_wake_on_touch | True or false. When auto_wake is true and Nextion is in sleep mode, the first touch will only trigger the auto wake mode and not trigger a Touch Event. |
Example:
The display will wake up by touch.
Definition at line 194 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_backlight_brightness | ( | float | brightness | ) |
Set the brightness of the backlight.
brightness | The brightness percentage from 0 to 1.0. |
Example:
Changes the brightness of the display to 30%.
Definition at line 186 of file nextion_commands.cpp.
|
inline |
|
inline |
void esphome::nextion::Nextion::set_component_aph | ( | const char * | component, |
uint8_t | aph ) |
Set the opaqueness (fading) of a component.
component | The component name. |
aph | An integer between 0 and 127 related to the opaqueness/fading level. |
Example:
This will set the opaqueness level of the component textview
to 64.
Note: Requires Nextion Intelligent series display.
Definition at line 163 of file nextion_commands.cpp.
|
overridevirtual |
Set the background color of a component.
component | The component name. |
color | The color (as Color). |
Example:
This will change the background color of the component button
to blue.
Implements esphome::nextion::NextionBase.
Definition at line 68 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_background_color | ( | const char * | component, |
const char * | color ) |
Set the background color of a component.
component | The component name. |
color | The color (as a string). |
Example:
This will change the background color of the component button
to red. Use Nextion Instruction Set for a list of Nextion HMI colors constants.
Definition at line 64 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_background_color | ( | const char * | component, |
uint16_t | color ) |
Set the background color of a component.
component | The component name. |
color | The color (as a uint16_t). |
Example:
This will change the background color of the component button
to red. Use this color picker to convert color codes to Nextion HMI colors.
Definition at line 60 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_coordinates | ( | const char * | component, |
uint16_t | x, | ||
uint16_t | y ) |
Set the coordinates of a component on screen.
component | The component name. |
x | The x coordinate. |
y | The y coordinate. |
Example:
This will move the position of the component pic
to the x coordinate 55
and y coordinate 100
.
Definition at line 242 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_drag | ( | const char * | component, |
bool | drag ) |
Set the drag availability of a component.
component | The component name. |
drag | False: Drag not available, True: Drag available. |
Example:
This will enable drag to the component textview
.
Note: Requires Nextion Intelligent series display.
Definition at line 159 of file nextion_commands.cpp.
|
overridevirtual |
Set the font id for a component.
component | The component name. |
font_id | The ID of the font (number). |
Example:
Changes the font of the component named textveiw
. Font IDs are set in the Nextion Editor.
Implements esphome::nextion::NextionBase.
Definition at line 200 of file nextion_commands.cpp.
|
overridevirtual |
Set the font color of a component.
component | The component name. |
color | The color (as Color). |
Example:
This will change the font color of the component textview
to black.
Implements esphome::nextion::NextionBase.
Definition at line 126 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_font_color | ( | const char * | component, |
const char * | color ) |
Set the font color of a component.
component | The component name. |
color | The color (as a string). |
Example:
This will change the font color of the component textview
to a red color. Use Nextion Instruction Set for a list of Nextion HMI colors constants.
Definition at line 122 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_font_color | ( | const char * | component, |
uint16_t | color ) |
Set the font color of a component.
component | The component name. |
color | The color (as a uint16_t). |
Example:
This will change the font color of the component textview
to a red color. Use this color picker to convert color codes to Nextion HMI colors.
Definition at line 118 of file nextion_commands.cpp.
|
overridevirtual |
Set the foreground color of a component.
component | The component name. |
color | The color (as Color). |
Example:
This will change the foreground color of the component button
to black.
Implements esphome::nextion::NextionBase.
Definition at line 97 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_foreground_color | ( | const char * | component, |
const char * | color ) |
Set the foreground color of a component.
component | The component name. |
color | The color (as a string). |
Example:
This will change the foreground color of the component button
to red. Use Nextion Instruction Set for a list of Nextion HMI colors constants.
Definition at line 93 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_foreground_color | ( | const char * | component, |
uint16_t | color ) |
Set the foreground color of a component.
component | The component name. |
color | The color (as a uint16_t). |
Example:
This will change the foreground color of the component button
to red. Use this color picker to convert color codes to Nextion HMI colors.
Definition at line 89 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_pic | ( | const char * | component, |
uint8_t | pic_id ) |
Set the picture id of a component.
component | The component name. |
pic_id | The picture ID. |
Example:
This will change the picture id of the component textview
.
Definition at line 146 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_picc | ( | const char * | component, |
uint8_t | pic_id ) |
Set the background picture id of component.
component | The component name. |
pic_id | The picture ID. |
Example:
This will change the background picture id of the component textview
.
Definition at line 150 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_picture | ( | const char * | component, |
uint8_t | picture_id ) |
Set the picture of an image component.
component | The component name. |
value | The picture id. |
Example:
This will change the image of the component pic
to the image with ID 4
.
Definition at line 220 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_position | ( | const char * | component, |
uint32_t | x, | ||
uint32_t | y ) |
Set the position of a component.
component | The component name. |
x | The new X (horizontal) coordinate for the component. |
y | The new Y (vertical) coordinate for the component. |
Example:
This will move the component textview
to the column 64 of row 35 of the display.
Note: Requires Nextion Intelligent series display.
Definition at line 167 of file nextion_commands.cpp.
|
overridevirtual |
Set the pressed background color of a component.
component | The component name. |
color | The color (as Color). |
Example:
This will change the pressed background color of the component button
to red. This is the background color that is shown when the component is pressed.
Implements esphome::nextion::NextionBase.
Definition at line 83 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_pressed_background_color | ( | const char * | component, |
const char * | color ) |
Set the pressed background color of a component.
component | The component name. |
color | The color (as a string). |
Example:
This will change the pressed background color of the component button
to red. This is the background color that is shown when the component is pressed. Use Nextion Instruction Set for a list of Nextion HMI colors constants.
Definition at line 79 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_pressed_background_color | ( | const char * | component, |
uint16_t | color ) |
Set the pressed background color of a component.
component | The component name. |
color | The color (as a uint16_t). |
Example:
This will change the pressed background color of the component button
to red. This is the background color that is shown when the component is pressed. Use this color picker to convert color codes to Nextion HMI colors.
Definition at line 74 of file nextion_commands.cpp.
|
overridevirtual |
Set the pressed font color of a component.
component | The component name. |
color | The color (as Color). |
Example:
This will change the pressed font color of the component button
to black.
Implements esphome::nextion::NextionBase.
Definition at line 140 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_pressed_font_color | ( | const char * | component, |
const char * | color ) |
Set the pressed font color of a component.
component | The component name. |
color | The color (as a string). |
Example:
This will change the pressed font color of the component button
to a red color. Use Nextion Instruction Set for a list of Nextion HMI colors constants.
Definition at line 136 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_pressed_font_color | ( | const char * | component, |
uint16_t | color ) |
Set the pressed font color of a component.
component | The component name. |
color | The color (as a uint16_t). |
Example:
This will change the pressed font color of the component button
to a red. Use this color picker to convert color codes to Nextion HMI colors.
Definition at line 132 of file nextion_commands.cpp.
|
overridevirtual |
Set the pressed foreground color of a component.
component | The component name. |
color | The color (as Color). |
Example:
This will change the pressed foreground color of the component button
to blue. This is the foreground color that is shown when the component is pressed.
Implements esphome::nextion::NextionBase.
Definition at line 112 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_pressed_foreground_color | ( | const char * | component, |
const char * | color ) |
Set the pressed foreground color of a component.
component | The component name. |
color | The color (as a string). |
Example:
This will change the pressed foreground color of the component button
to red. This is the foreground color that is shown when the component is pressed. Use Nextion Instruction Set for a list of Nextion HMI colors constants.
Definition at line 108 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_pressed_foreground_color | ( | const char * | component, |
uint16_t | color ) |
Set the pressed foreground color of a component.
component | The component name. |
color | The color (as a uint16_t). |
Example:
This will change the pressed foreground color of the component button
to red. This is the foreground color that is shown when the component is pressed. Use this color picker to convert color codes to Nextion HMI colors.
Definition at line 103 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_text | ( | const char * | component, |
const char * | text ) |
Set the text of a component to a static string.
component | The component name. |
text | The static text to set. |
Example:
This will set the txt
property of the component textview
to Hello World
.
Definition at line 224 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_text_printf | ( | const char * | component, |
const char * | format, | ||
... ) |
Set the text of a component to a formatted string.
component | The component name. |
format | The printf-style format string. |
... | The arguments to the format. |
Example:
This will change the text on the component named textview
to The uptime is:
Then the value of uptime_sensor
. with zero decimals of accuracy (whole number). For example when uptime_sensor
= 506, then, The uptime is: 506
will be displayed.
Definition at line 172 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_value | ( | const char * | component, |
int32_t | value ) |
Set the integer value of a component.
component | The component name. |
value | The value to set. |
Example:
This will change the property value
of the component gauge
to 50.
Definition at line 228 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_component_vid | ( | const char * | component, |
uint8_t | vid_id ) |
Set the video id of a component.
component | The component name. |
vid_id | The video ID. |
Example:
This will change the video id of the component textview
.
Note: Requires Nextion Intelligent series display.
Definition at line 155 of file nextion_commands.cpp.
|
inline |
Set the maximum number of commands to process in each loop iteration.
value | Maximum number of commands (default: 20) |
Limiting the number of commands per loop helps prevent stack overflows when a large number of commands are queued at once, especially during boot.
|
inline |
void esphome::nextion::Nextion::set_nextion_rtc_time | ( | ESPTime | time | ) |
Send the current time to the nextion display.
time | The time instance to send (get this with id(my_time).now() ). |
Definition at line 347 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_nextion_sensor_state | ( | int | queue_type, |
const std::string & | name, | ||
float | state ) |
Set the nextion sensor state object.
[in] | queue_type | Index of NextionQueueType. |
[in] | name | Component/variable name. |
[in] | state | State to set. |
Definition at line 883 of file nextion.cpp.
void esphome::nextion::Nextion::set_nextion_sensor_state | ( | NextionQueueType | queue_type, |
const std::string & | name, | ||
float | state ) |
Definition at line 887 of file nextion.cpp.
void esphome::nextion::Nextion::set_nextion_text_state | ( | const std::string & | name, |
const std::string & | state ) |
Definition at line 924 of file nextion.cpp.
bool esphome::nextion::Nextion::set_protocol_reparse_mode | ( | bool | active_mode | ) |
Sets the Nextion display's protocol reparse mode.
This function toggles the Nextion display's protocol reparse mode between active and passive. In active mode, the display actively parses incoming data. In passive mode, it does not parse data unless specifically instructed to do so. This is useful for managing how the Nextion display interprets incoming commands, especially during initialization or in scenarios where precise control over command processing is needed.
active_mode | A boolean value indicating the desired reparse mode.
|
Definition at line 40 of file nextion_commands.cpp.
|
inline |
Sets which page Nextion loads when connecting to ESPHome.
start_up_page | The page id, from 0 to the last page in Nextion. Set 255 (not set to any existing page) to wakes up to current page. |
Example:
The display will go to page 2 when it establishes a connection to ESPHome.
|
inline |
void esphome::nextion::Nextion::set_touch_sleep_timeout | ( | uint16_t | touch_sleep_timeout = 0 | ) |
Set the touch sleep timeout of the display using the thsp
command.
Sets internal No-touch-then-sleep timer to specified value in seconds. Nextion will auto-enter sleep mode if and when this timer expires.
touch_sleep_timeout | Timeout in seconds. Range: 3 to 65535 seconds (minimum 3 seconds, maximum ~18 hours 12 minutes 15 seconds) Use 0 to disable touch sleep timeout. |
thsp
is set, it will persist until reboot or reset. The Nextion device needs to exit sleep mode to issue thsp=0
to disable sleep on no touch.thup
(auto wake on touch). See set_auto_wake_on_touch() to configure wake behavior.Example:
Related Nextion instruction: thsp=<value>
Definition at line 18 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_wait_for_ack | ( | bool | wait_for_ack | ) |
void esphome::nextion::Nextion::set_wake_up_page | ( | uint8_t | wake_up_page = 255 | ) |
Sets which page Nextion loads when exiting sleep mode.
Note this can be set even when Nextion is in sleep mode.
wake_up_page | The page id, from 0 to the last page in Nextion. Set 255 (not set to any existing page) to wakes up to current page. |
Example:
The display will wake up to page 2.
Definition at line 13 of file nextion_commands.cpp.
void esphome::nextion::Nextion::set_writer | ( | const nextion_writer_t & | writer | ) |
Definition at line 1292 of file nextion.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 12 of file nextion.cpp.
|
overridevirtual |
Show a component.
component | The component name. |
Example:
Shows the component named button
.
Implements esphome::nextion::NextionBase.
Definition at line 208 of file nextion_commands.cpp.
void esphome::nextion::Nextion::sleep | ( | bool | sleep | ) |
Sets Nextion mode between sleep and awake.
True | or false. Sleep=true to enter sleep mode or sleep=false to exit sleep mode. |
Definition at line 29 of file nextion_commands.cpp.
void esphome::nextion::Nextion::soft_reset | ( | ) |
Softreset the Nextion.
Definition at line 11 of file nextion_commands.cpp.
|
overridevirtual |
Implements esphome::PollingComponent.
Definition at line 195 of file nextion.cpp.
void esphome::nextion::Nextion::update_all_components | ( | ) |
Definition at line 228 of file nextion.cpp.
void esphome::nextion::Nextion::update_components_by_prefix | ( | const std::string & | prefix | ) |
Definition at line 955 of file nextion.cpp.
|
protected |
will request 4096 bytes chunks from the web server and send each to Nextion
esp_http_client_handle_t | http_client HTTP client handler. |
int | range_start Position of next byte to transfer. |
Definition at line 22 of file nextion_upload_idf.cpp.
|
protected |
will request chunk_size chunks from the web server and send each to the nextion
HTTPClient | http_client HTTP client handler. |
int | range_start Position of next byte to transfer. |
Definition at line 32 of file nextion_upload_arduino.cpp.
|
protected |
Ends the upload process, restart Nextion and, if successful, restarts ESP.
bool | url successful True: Transfer completed successfuly, False: Transfer failed. |
Definition at line 11 of file nextion_upload.cpp.
bool esphome::nextion::Nextion::upload_tft | ( | uint32_t | baud_rate = 0, |
bool | exit_reparse = true ) |
Uploads the TFT file to the Nextion display.
This function initiates the upload of a TFT file to the Nextion display. Users can specify a target baud rate for the transfer. If the provided baud rate is not supported by Nextion, the function defaults to using the current baud rate set for the display. If no baud rate is specified (or if 0 is passed), the current baud rate is used.
Supported baud rates are: 2400, 4800, 9600, 19200, 31250, 38400, 57600, 115200, 230400, 250000, 256000, 512000 and 921600. Selecting a baud rate supported by both the Nextion display and the host hardware is essential for ensuring a successful upload process.
baud_rate | The desired baud rate for the TFT file transfer, specified as an unsigned 32-bit integer. If the specified baud rate is not supported, or if 0 is passed, the function will use the current baud rate. The default value is 0, which implies using the current baud rate. |
exit_reparse | If true, the function exits reparse mode before uploading the TFT file. This parameter defaults to true, ensuring that the display is ready to receive and apply the new TFT file without needing to manually reset or reconfigure. Exiting reparse mode is recommended for most upload scenarios to ensure the display properly processes the uploaded file command. |
Definition at line 150 of file nextion_upload_arduino.cpp.
uint8_t esphome::nextion::Nextion::auto_wake_on_touch_ |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
struct { ... } esphome::nextion::Nextion::connection_state_ |
Status flags for Nextion display state management.
Uses bitfields to pack multiple boolean states into a single byte, saving 5 bytes of RAM compared to individual bool variables. Zero-initialized status flags (all start as false)
|
protected |
|
protected |
|
protected |
|
protected |
uint8_t esphome::nextion::Nextion::ignore_is_setup_ |
uint8_t esphome::nextion::Nextion::is_connected_ |
uint8_t esphome::nextion::Nextion::is_updating_ |
|
protected |
|
protected |
|
protected |
|
protected |
uint8_t esphome::nextion::Nextion::nextion_reports_is_setup_ |
|
protected |
|
protected |
uint8_t esphome::nextion::Nextion::reserved_ |
|
protected |
uint8_t esphome::nextion::Nextion::sent_setup_commands_ |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |