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 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)};
529 void fill_area(
int x1,
int y1,
int width,
int height, uint16_t color);
547 void fill_area(
int x1,
int y1,
int width,
int height,
const char *color);
565 void fill_area(
int x1,
int y1,
int width,
int height,
Color color);
584 void line(
int x1,
int y1,
int x2,
int y2, uint16_t color);
602 void line(
int x1,
int y1,
int x2,
int y2,
const char *color);
620 void line(
int x1,
int y1,
int x2,
int y2,
Color color);
639 void rectangle(
int x1,
int y1,
int width,
int height, uint16_t color);
657 void rectangle(
int x1,
int y1,
int width,
int height,
const char *color);
675 void rectangle(
int x1,
int y1,
int width,
int height,
Color color);
685 void circle(
int center_x,
int center_y,
int radius, uint16_t color);
694 void circle(
int center_x,
int center_y,
int radius,
const char *color);
702 void circle(
int center_x,
int center_y,
int radius,
Color color);
719 void filled_circle(
int center_x,
int center_y,
int radius, uint16_t color);
735 void filled_circle(
int center_x,
int center_y,
int radius,
const char *color);
771 void qrcode(
int x1,
int y1,
const char *content,
int size = 200, uint16_t background_color = 65535,
772 uint16_t foreground_color = 0,
int logo_pic = -1, uint8_t border_width = 8);
794 void qrcode(
int x1,
int y1,
const char *content,
int size,
Color background_color =
Color(255, 255, 255),
795 Color foreground_color =
Color(0, 0, 0),
int logo_pic = -1, uint8_t border_width = 8);
896 void setup()
override;
900 void loop()
override;
914 #ifdef USE_NEXTION_TFT_UPLOAD 985 int state_value)
override;
989 const std::string &state_value)
override;
1025 uint16_t
recv_ret_string_(std::string &response, uint32_t timeout,
bool recv_flag);
1053 __attribute__((format(printf, 3, 4)));
1057 __attribute__((format(printf, 3, 4)));
1060 const
std::
string &variable_name_to_send,
int state_value,
1061 bool is_sleep_safe = false);
1064 const
std::
string &variable_name_to_send,
1065 const
std::
string &state_value,
bool is_sleep_safe = false);
1069 #ifdef USE_NEXTION_TFT_UPLOAD 1104 #elif defined(USE_ESP_IDF) 1112 int upload_range(
const std::string &url,
int range_start);
1120 #endif // ARDUINO vs ESP-IDF 1122 #endif // USE_NEXTION_TFT_UPLOAD 1149 #ifdef USE_NEXTION_TFT_UPLOAD 1156 #ifdef NEXTION_PROTOCOL_LOG 1159 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.
int upload_range(const std::string &url, int range_start)
will request 4096 bytes chunks from the web server and send each to Nextion
void all_components_send_state_(bool force_update=false)
CallbackManager< void(uint8_t)> page_callback_
CallbackManager< void()> sleep_callback_
void set_protocol_reparse_mode(bool active_mode)
Sets Nextion Protocol Reparse mode between active or passive.
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 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.
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.
void add_no_result_to_queue_with_set(NextionComponentBase *component, int state_value) override
void add_addt_command_to_queue(NextionComponentBase *component) override
Add addt command to the queue.
bool exit_reparse_on_start_
uint32_t startup_override_ms_
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.
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_
int upload_by_chunks_(HTTPClient *http, int range_start)
will request chunk_size chunks from the web server and send each to the nextion
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_coordinates(const char *component, int x, int y)
Set the coordinates of a component on screen.
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 void add_no_result_to_queue_with_set_internal_(const std::string &variable_name, const std::string &variable_name_to_send, int state_value, bool is_sleep_safe=false)
bool upload_end_(bool successful)
Ends the upload process, restart Nextion and, if successful, restarts ESP.
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.
void void set_component_value(const char *component, int value)
Set the integer value of a component.
void filled_circle(int center_x, int center_y, int radius, uint16_t color)
Draw a filled circled.
bool upload_end(bool successful)
Ends the upload process, restart Nextion and, if successful, restarts ESP.
bool nextion_reports_is_setup_
void open_waveform_channel(int component_id, uint8_t channel_number, uint8_t value)
bool upload_with_range_(uint32_t range_start, uint32_t range_end)
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 add_waveform_data(int component_id, uint8_t channel_number, uint8_t value)
Add waveform data to a waveform component.
void fill_area(int x1, int y1, int width, int height, uint16_t color)
Fill a rectangle with a color.
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.
void set_nextion_sensor_state(int queue_type, const std::string &name, float state)
Set the nextion sensor state object.
CallbackManager< void()> setup_callback_
void set_nextion_text_state(const std::string &name, const std::string &state)
void set_wait_for_ack(bool wait_for_ack)
void set_touch_sleep_timeout_internal(uint32_t touch_sleep_timeout)
std::deque< NextionQueue * > nextion_queue_
CallbackManager< void()> wake_callback_
void display_picture(int picture_id, int x_start, int y_start)
Display a picture at coordinates.
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_()
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)
uint8_t * transfer_buffer_
void set_backlight_brightness(float brightness)
Set the brightness of the backlight.
std::string device_model_
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_
bool upload_tft()
Upload the tft file and soft reset Nextion.
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 qrcode(int x1, int y1, const char *content, int size=200, uint16_t background_color=65535, uint16_t foreground_color=0, int logo_pic=-1, uint8_t border_width=8)
Draws a QR code in the screen.
void process_nextion_commands_()
std::vector< NextionComponentBase * > switchtype_
bool upload_from_buffer_(const uint8_t *file_buf, size_t buf_size)
start update tft file to nextion.
void rectangle(int x1, int y1, int width, int height, uint16_t color)
Draw a rectangle outline.
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.
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
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 update_components_by_prefix(const std::string &prefix)
std::string firmware_version_
size_t transfer_buffer_size_
void set_component_foreground_color(const char *component, uint16_t color)
Set the foreground color 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.
uint32_t touch_sleep_timeout_
void check_pending_waveform_()
uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag)
void circle(int center_x, int center_y, int radius, uint16_t color)
Draw a circle outline.
std::function< void(Nextion &)> nextion_writer_t
std::vector< NextionComponentBase * > binarysensortype_
void set_writer(const nextion_writer_t &writer)
void line(int x1, int y1, int x2, int y2, uint16_t color)
Draw a line on the screen.