14 #ifdef USE_NEXTION_TFT_UPLOAD 17 #include <HTTPClient.h> 20 #include <ESP8266HTTPClient.h> 21 #include <WiFiClientSecure.h> 23 #elif defined(USE_ESP_IDF) 24 #include <esp_http_client.h> 25 #endif // ARDUINO vs USE_ESP_IDF 26 #endif // USE_NEXTION_TFT_UPLOAD 32 class NextionComponentBase;
36 static const std::string COMMAND_DELIMITER{
static_cast<char>(255), static_cast<char>(255),
static_cast<char>(255)};
525 void add_waveform_data(uint8_t component_id, uint8_t channel_number, uint8_t value);
542 void display_picture(uint16_t picture_id, uint16_t x_start, uint16_t y_start);
562 void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color);
581 void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height,
const char *color);
600 void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height,
Color color);
620 void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
639 void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2,
const char *color);
658 void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2,
Color color);
678 void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color);
697 void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height,
const char *color);
716 void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height,
Color color);
727 void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color);
737 void circle(uint16_t center_x, uint16_t center_y, uint16_t radius,
const char *color);
746 void circle(uint16_t center_x, uint16_t center_y, uint16_t radius,
Color color);
764 void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color);
781 void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius,
const char *color);
798 void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius,
Color color);
818 void qrcode(uint16_t x1, uint16_t y1,
const char *content, uint16_t size = 200, uint16_t background_color = 65535,
819 uint16_t foreground_color = 0, uint8_t logo_pic = -1, uint8_t border_width = 8);
842 void qrcode(uint16_t x1, uint16_t y1,
const char *content, uint16_t size,
844 uint8_t logo_pic = -1, uint8_t border_width = 8);
1045 void setup()
override;
1049 void loop()
override;
1070 #ifdef USE_NEXTION_TFT_UPLOAD 1096 bool upload_tft(uint32_t baud_rate = 0,
bool exit_reparse =
true);
1098 #endif // USE_NEXTION_TFT_UPLOAD 1163 int32_t state_value)
override;
1167 const std::string &state_value)
override;
1223 uint16_t
recv_ret_string_(std::string &response, uint32_t timeout,
bool recv_flag);
1254 __attribute__((format(printf, 3, 4)));
1258 __attribute__((format(printf, 3, 4)));
1261 const
std::
string &variable_name_to_send, int32_t state_value,
1262 bool is_sleep_safe = false);
1265 const
std::
string &variable_name_to_send,
1266 const
std::
string &state_value,
bool is_sleep_safe = false);
1270 #ifdef USE_NEXTION_TFT_UPLOAD 1275 #endif // USE_ESP8266 1291 #elif defined(USE_ESP_IDF) 1299 int upload_by_chunks_(esp_http_client_handle_t http_client, uint32_t &range_start);
1300 #endif // USE_ARDUINO vs USE_ESP_IDF 1316 #endif // USE_NEXTION_TFT_UPLOAD 1344 #ifdef NEXTION_PROTOCOL_LOG 1346 #endif // NEXTION_PROTOCOL_LOG 1347 void reset_(
bool reset_nextion =
true);
void goto_page(const char *page)
Show the page with a given name.
void set_nextion_rtc_time(ESPTime time)
Send the current time to the nextion display.
bool ignore_is_setup_
Sends commands ignoring of the Nextion has been setup.
const uint16_t startup_override_ms_
void all_components_send_state_(bool force_update=false)
CallbackManager< void(uint8_t)> page_callback_
CallbackManager< void()> sleep_callback_
void set_component_pic(const char *component, uint8_t pic_id)
Set the picture id of a component.
void set_component_picture(const char *component, uint8_t picture_id)
Set the picture of an image component.
void add_new_page_callback(std::function< void(uint8_t)> &&callback)
Add a callback to be notified when the nextion changes pages.
void add_waveform_data(uint8_t component_id, uint8_t channel_number, uint8_t value)
Add waveform data to a waveform component.
void set_start_up_page_internal(uint8_t start_up_page)
void add_wake_state_callback(std::function< void()> &&callback)
Add a callback to be notified of wake state changes.
bool send_command(const char *command)
Manually send a raw command to the display.
WiFiClient * get_wifi_client_()
void hide_component(const char *component) override
Hide a component.
bool send_command_printf(const char *format,...) __attribute__((format(printf
Manually send a raw formatted command to the display.
bool upload_tft(uint32_t baud_rate=0, bool exit_reparse=true)
Uploads the TFT file to the Nextion display.
void add_addt_command_to_queue(NextionComponentBase *component) override
Add addt command to the queue.
bool is_updating() override
Check if the TFT update process is currently running.
bool exit_reparse_on_start_
void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color)
Draw a circle outline.
void add_to_get_queue(NextionComponentBase *component) override
std::vector< NextionComponentBase * > touch_
optional< nextion_writer_t > writer_
void update_all_components()
bool void set_tft_url(const std::string &tft_url)
Set the tft file URL.
void set_component_position(const char *component, uint32_t x, uint32_t y)
Set the position of a component.
uint32_t get_free_heap_()
Returns the ESP Free Heap memory.
A more user-friendly version of struct tm from time.h.
void add_setup_state_callback(std::function< void()> &&callback)
Add a callback to be notified when the nextion completes its initialize setup.
bool sent_setup_commands_
void set_skip_connection_handshake(bool skip_handshake)
Sets whether the Nextion display should skip the connection handshake process.
CallbackManager< void()> buffer_overflow_callback_
const uint16_t max_q_age_ms_
bool send_command_(const std::string &command)
Manually send a raw command to the display and don't wait for an acknowledgement packet.
void set_component_vid(const char *component, uint8_t vid_id)
Set the video id of a component.
float get_setup_priority() const override
void set_wake_up_page_internal(uint8_t wake_up_page)
std::string serial_number_
void set_brightness(float brightness)
void register_binarysensor_component(NextionComponentBase *obj)
void register_touch_component(NextionComponentBase *obj)
void set_component_picc(const char *component, uint8_t pic_id)
Set the background picture id of component.
void sleep(bool sleep)
Sets Nextion mode between sleep and awake.
This class simplifies creating components that periodically check a state.
BearSSL::WiFiClientSecure * wifi_client_secure_
void disable_component_touch(const char *component)
Disable touch for a component.
CallbackManager< void(uint8_t, uint8_t, bool)> touch_callback_
bool upload_end_(bool successful)
Ends the upload process, restart Nextion and, if successful, restarts ESP.
void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color)
Draw a rectangle outline.
void add_buffer_overflow_event_callback(std::function< void()> &&callback)
Add a callback to be notified when the nextion reports a buffer overflow.
void set_exit_reparse_on_start(bool exit_reparse)
Sets if Nextion should exit the active reparse mode before the "connect" command is sent...
void show_component(const char *component) override
Show a component.
bool nextion_reports_is_setup_
void register_sensor_component(NextionComponentBase *obj)
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.
void add_sleep_state_callback(std::function< void()> &&callback)
Add a callback to be notified of sleep state changes.
void register_switch_component(NextionComponentBase *obj)
void set_component_pressed_background_color(const char *component, uint16_t color)
Set the pressed background 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_background_color(const char *component, uint16_t color)
Set the background color of a component.
void set_component_text_printf(const char *component, const char *format,...) __attribute__((format(printf
Set the text of a component to a formatted string.
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
void set_nextion_sensor_state(int queue_type, const std::string &name, float state)
Set the nextion sensor state object.
CallbackManager< void()> setup_callback_
bool set_protocol_reparse_mode(bool active_mode)
Sets the Nextion display's protocol reparse mode.
void set_nextion_text_state(const std::string &name, const std::string &state)
void set_wait_for_ack(bool wait_for_ack)
void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Draw a line on the screen.
void set_touch_sleep_timeout_internal(uint32_t touch_sleep_timeout)
std::deque< NextionQueue * > nextion_queue_
CallbackManager< void()> wake_callback_
void set_auto_wake_on_touch_internal(bool auto_wake_on_touch)
void set_component_text(const char *component, const char *text)
Set the text of a component to a static string.
void print_queue_members_()
uint32_t original_baud_rate_
void set_component_font_color(const char *component, uint16_t color)
Set the font color of a component.
void add_no_result_to_queue_(const std::string &variable_name)
std::deque< NextionQueue * > waveform_queue_
void set_component_font(const char *component, uint8_t font_id) override
Set the font id for a component.
std::string command_data_
enum esphome::EntityCategory __attribute__
void enable_component_touch(const char *component)
Enable touch for a component.
bool remove_from_q_(bool report_empty=true)
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 set_backlight_brightness(float brightness)
Set the brightness of the backlight.
std::string device_model_
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 soft_reset()
Softreset the Nextion.
bool add_no_result_to_queue_with_ignore_sleep_printf_(const std::string &variable_name, const char *format,...) __attribute__((format(printf
void register_textsensor_component(NextionComponentBase *obj)
void set_touch_sleep_timeout(uint16_t timeout)
Set the touch sleep timeout of the display.
std::vector< NextionComponentBase * > textsensortype_
void display_picture(uint16_t picture_id, uint16_t x_start, uint16_t y_start)
Display a picture at coordinates.
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 set_wake_up_page(uint8_t page_id=255)
Sets which page Nextion loads when exiting sleep mode.
std::vector< NextionComponentBase * > sensortype_
void dump_config() override
void remove_front_no_sensors_()
void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color)
Draw a filled circled.
void process_nextion_commands_()
std::vector< NextionComponentBase * > switchtype_
bool upload_first_chunk_sent_
WiFiClient * wifi_client_
void set_auto_wake_on_touch(bool auto_wake)
Sets if Nextion should auto-wake from sleep when touch press occurs.
Implementation of SPI Controller mode.
bool skip_connection_handshake_
void void set_component_value(const char *component, int32_t value)
Set the integer value of a component.
void set_start_up_page(uint8_t page_id=255)
Sets which page Nextion loads when connecting to ESPHome.
bool void add_no_result_to_queue_with_command_(const std::string &variable_name, const std::string &command)
void reset_(bool reset_nextion=true)
void set_exit_reparse_on_start_internal(bool exit_reparse_on_start)
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 update_components_by_prefix(const std::string &prefix)
std::string firmware_version_
void set_component_foreground_color(const char *component, uint16_t color)
Set the foreground 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_aph(const char *component, uint8_t aph)
Set the opaqueness (fading) of a component.
void set_component_pressed_font_color(const char *component, uint16_t color)
Set the pressed font color of a component.
size_t queue_size()
Retrieves the number of commands pending in the Nextion command queue.
void set_component_drag(const char *component, bool drag)
Set the drag availability of a component.
uint32_t touch_sleep_timeout_
void check_pending_waveform_()
uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag)
void add_no_result_to_queue_with_set(NextionComponentBase *component, int32_t state_value) override
void open_waveform_channel(uint8_t component_id, uint8_t channel_number, uint8_t value)
std::function< void(Nextion &)> nextion_writer_t
std::vector< NextionComponentBase * > binarysensortype_
void set_writer(const nextion_writer_t &writer)