ESPHome 2025.12.0-dev
Loading...
Searching...
No Matches
nextion.h
Go to the documentation of this file.
1#pragma once
2
3#include <deque>
4#include <vector>
5
7#include "esphome/core/time.h"
8
10#include "nextion_base.h"
11#include "nextion_component.h"
14
15#ifdef USE_NEXTION_TFT_UPLOAD
16#ifdef USE_ARDUINO
17#ifdef USE_ESP32
18#include <HTTPClient.h>
19#endif // USE_ESP32
20#ifdef USE_ESP8266
21#include <ESP8266HTTPClient.h>
22#include <WiFiClientSecure.h>
23#endif // USE_ESP8266
24#elif defined(USE_ESP_IDF)
25#include <esp_http_client.h>
26#endif // ARDUINO vs USE_ESP_IDF
27#endif // USE_NEXTION_TFT_UPLOAD
28
29namespace esphome {
30namespace nextion {
31
32class Nextion;
33class NextionComponentBase;
34
36
37static const std::string COMMAND_DELIMITER{static_cast<char>(255), static_cast<char>(255), static_cast<char>(255)};
38
39#ifdef USE_NEXTION_COMMAND_SPACING
41 public:
46 explicit NextionCommandPacer(uint8_t initial_spacing = 0) : spacing_ms_(initial_spacing) {}
47
52 void set_spacing(uint8_t spacing_ms) { spacing_ms_ = spacing_ms; }
53
58 uint8_t get_spacing() const { return spacing_ms_; }
59
64 bool can_send() const { return (millis() - last_command_time_) >= spacing_ms_; }
65
69 void mark_sent() { last_command_time_ = millis(); }
70
71 private:
72 uint8_t spacing_ms_;
73 uint32_t last_command_time_{0};
74};
75#endif // USE_NEXTION_COMMAND_SPACING
76
77class Nextion : public NextionBase, public PollingComponent, public uart::UARTDevice {
78 public:
79#ifdef USE_NEXTION_MAX_COMMANDS_PER_LOOP
87 inline void set_max_commands_per_loop(uint16_t value) { this->max_commands_per_loop_ = value; }
88
93 inline uint16_t get_max_commands_per_loop() const { return this->max_commands_per_loop_; }
94#endif // USE_NEXTION_MAX_COMMANDS_PER_LOOP
95#ifdef USE_NEXTION_MAX_QUEUE_SIZE
100 inline void set_max_queue_size(size_t size) { this->max_queue_size_ = size; }
101
106 inline size_t get_max_queue_size() const { return this->max_queue_size_; }
107#endif // USE_NEXTION_MAX_QUEUE_SIZE
108
109#ifdef USE_NEXTION_COMMAND_SPACING
114 void set_command_spacing(uint32_t spacing_ms) { this->command_pacer_.set_spacing(spacing_ms); }
115#endif // USE_NEXTION_COMMAND_SPACING
116
129 void set_component_text(const char *component, const char *text);
130
146 void set_component_text_printf(const char *component, const char *format, ...) __attribute__((format(printf, 3, 4)));
147
160 void set_component_value(const char *component, int32_t value);
161
174 void set_component_picture(const char *component, uint8_t picture_id);
175
190 void set_component_background_color(const char *component, uint16_t color);
191
205 void set_component_background_color(const char *component, const char *color);
206
220 void set_component_background_color(const char *component, Color color) override;
221
237 void set_component_pressed_background_color(const char *component, uint16_t color);
238
253 void set_component_pressed_background_color(const char *component, const char *color);
254
269 void set_component_pressed_background_color(const char *component, Color color) override;
270
285 void set_component_foreground_color(const char *component, uint16_t color);
286
300 void set_component_foreground_color(const char *component, const char *color);
301
314 void set_component_foreground_color(const char *component, Color color) override;
315
331 void set_component_pressed_foreground_color(const char *component, uint16_t color);
332
347 void set_component_pressed_foreground_color(const char *component, const char *color);
348
363 void set_component_pressed_foreground_color(const char *component, Color color) override;
364
377 void set_component_pic(const char *component, uint8_t pic_id);
378
391 void set_component_picc(const char *component, uint8_t pic_id);
392
407 void set_component_font_color(const char *component, uint16_t color);
408
422 void set_component_font_color(const char *component, const char *color);
423
436 void set_component_font_color(const char *component, Color color) override;
437
452 void set_component_pressed_font_color(const char *component, uint16_t color);
453
467 void set_component_pressed_font_color(const char *component, const char *color);
468
481 void set_component_pressed_font_color(const char *component, Color color) override;
482
496 void set_component_coordinates(const char *component, uint16_t x, uint16_t y);
497
510 void set_component_font(const char *component, uint8_t font_id) override;
511
516 void set_nextion_rtc_time(ESPTime time);
517
529 void goto_page(const char *page);
530
542 void goto_page(uint8_t page);
543
559 void set_component_visibility(const char *component, bool show) override;
560
572 void hide_component(const char *component) override;
573
585 void show_component(const char *component) override;
586
598 void enable_component_touch(const char *component);
599
611 void disable_component_touch(const char *component);
612
619 void add_waveform_data(uint8_t component_id, uint8_t channel_number, uint8_t value);
620
621 void open_waveform_channel(uint8_t component_id, uint8_t channel_number, uint8_t value);
622
636 void display_picture(uint16_t picture_id, uint16_t x_start, uint16_t y_start);
637
656 void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color);
657
675 void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, const char *color);
676
694 void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, Color color);
695
714 void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
715
733 void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char *color);
734
752 void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, Color color);
753
772 void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color);
773
791 void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, const char *color);
792
810 void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, Color color);
811
821 void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color);
822
831 void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, const char *color);
832
840 void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, Color color);
841
858 void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color);
859
875 void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, const char *color);
876
892 void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, Color color);
893
912 void qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size = 200, uint16_t background_color = 65535,
913 uint16_t foreground_color = 0, uint8_t logo_pic = -1, uint8_t border_width = 8);
914
936 void qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size,
937 Color background_color = Color(255, 255, 255), Color foreground_color = Color(0, 0, 0),
938 uint8_t logo_pic = -1, uint8_t border_width = 8);
939
951 void set_backlight_brightness(float brightness);
952
957 void sleep(bool sleep);
958
978
979 // ======== Nextion Intelligent Series ========
980
995 void set_component_vid(const char *component, uint8_t vid_id);
996
1011 void set_component_drag(const char *component, bool drag);
1012
1027 void set_component_aph(const char *component, uint8_t aph);
1028
1044 void set_component_position(const char *component, uint32_t x, uint32_t y);
1045
1046 // ========== INTERNAL METHODS ==========
1047 // (In most use cases you won't need these)
1048 void register_touch_component(NextionComponentBase *obj) { this->touch_.push_back(obj); }
1053
1054 void setup() override;
1055 void set_brightness(float brightness) { this->brightness_ = brightness; }
1056 float get_setup_priority() const override;
1057 void update() override;
1058 void loop() override;
1059 void set_writer(const nextion_writer_t &writer);
1060
1061 // This function has been deprecated
1062 void set_wait_for_ack(bool wait_for_ack);
1063
1069 bool send_command(const char *command);
1070
1077 bool send_command_printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
1078
1079#ifdef USE_NEXTION_TFT_UPLOAD
1083 void set_tft_url(const std::string &tft_url) { this->tft_url_ = tft_url; }
1084
1105 bool upload_tft(uint32_t baud_rate = 0, bool exit_reparse = true);
1106
1107#endif // USE_NEXTION_TFT_UPLOAD
1108
1109 void dump_config() override;
1110
1114 void soft_reset();
1115
1120 void add_sleep_state_callback(std::function<void()> &&callback);
1121
1126 void add_wake_state_callback(std::function<void()> &&callback);
1127
1132 void add_setup_state_callback(std::function<void()> &&callback);
1133
1138 void add_new_page_callback(std::function<void(uint8_t)> &&callback);
1139
1144 void add_touch_event_callback(std::function<void(uint8_t, uint8_t, bool)> &&callback);
1145
1150 void add_buffer_overflow_event_callback(std::function<void()> &&callback);
1151
1152 void update_all_components();
1153
1166 void set_nextion_sensor_state(int queue_type, const std::string &name, float state);
1167 void set_nextion_sensor_state(NextionQueueType queue_type, const std::string &name, float state);
1168 void set_nextion_text_state(const std::string &name, const std::string &state);
1169
1170 void add_no_result_to_queue_with_set(NextionComponentBase *component, int32_t state_value) override;
1171 void add_no_result_to_queue_with_set(const std::string &variable_name, const std::string &variable_name_to_send,
1172 int32_t state_value) override;
1173
1174 void add_no_result_to_queue_with_set(NextionComponentBase *component, const std::string &state_value) override;
1175 void add_no_result_to_queue_with_set(const std::string &variable_name, const std::string &variable_name_to_send,
1176 const std::string &state_value) override;
1177
1179
1181
1182 void update_components_by_prefix(const std::string &prefix);
1183
1217 void set_touch_sleep_timeout(uint16_t touch_sleep_timeout = 0);
1218
1231 void set_wake_up_page(uint8_t wake_up_page = 255);
1232
1233#ifdef USE_NEXTION_CONF_START_UP_PAGE
1246 void set_start_up_page(uint8_t start_up_page = 255) { this->start_up_page_ = start_up_page; }
1247#endif // USE_NEXTION_CONF_START_UP_PAGE
1248
1261 void set_auto_wake_on_touch(bool auto_wake_on_touch);
1262
1276 size_t queue_size() { return this->nextion_queue_.size(); }
1277
1296 bool is_updating() override;
1297
1315 bool is_connected() { return this->connection_state_.is_connected_; }
1316
1317 protected:
1318#ifdef USE_NEXTION_MAX_COMMANDS_PER_LOOP
1320#endif // USE_NEXTION_MAX_COMMANDS_PER_LOOP
1321#ifdef USE_NEXTION_MAX_QUEUE_SIZE
1323#endif // USE_NEXTION_MAX_QUEUE_SIZE
1324
1325#ifdef USE_NEXTION_COMMAND_SPACING
1327
1339#endif // USE_NEXTION_COMMAND_SPACING
1340
1341 std::deque<NextionQueue *> nextion_queue_;
1342 std::deque<NextionQueue *> waveform_queue_;
1343 uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag);
1344 void all_components_send_state_(bool force_update = false);
1345 uint32_t comok_sent_ = 0;
1346 bool remove_from_q_(bool report_empty = true);
1347
1354 struct {
1355 uint8_t is_connected_ : 1;
1357 uint8_t ignore_is_setup_ : 1;
1359 uint8_t is_updating_ : 1;
1361 uint8_t reserved_ : 2;
1363
1365 void process_serial_();
1367 uint8_t wake_up_page_ = 255;
1368#ifdef USE_NEXTION_CONF_START_UP_PAGE
1369 uint8_t start_up_page_ = 255;
1370#endif // USE_NEXTION_CONF_START_UP_PAGE
1372
1377 bool send_command_(const std::string &command);
1378 void add_no_result_to_queue_(const std::string &variable_name);
1379 bool add_no_result_to_queue_with_ignore_sleep_printf_(const std::string &variable_name, const char *format, ...)
1380 __attribute__((format(printf, 3, 4)));
1381 void add_no_result_to_queue_with_command_(const std::string &variable_name, const std::string &command);
1382
1383#ifdef USE_NEXTION_COMMAND_SPACING
1397 void add_no_result_to_queue_with_pending_command_(const std::string &variable_name, const std::string &command);
1398#endif // USE_NEXTION_COMMAND_SPACING
1399
1400 bool add_no_result_to_queue_with_printf_(const std::string &variable_name, const char *format, ...)
1401 __attribute__((format(printf, 3, 4)));
1402
1403 void add_no_result_to_queue_with_set_internal_(const std::string &variable_name,
1404 const std::string &variable_name_to_send, int32_t state_value,
1405 bool is_sleep_safe = false);
1406
1407 void add_no_result_to_queue_with_set_internal_(const std::string &variable_name,
1408 const std::string &variable_name_to_send,
1409 const std::string &state_value, bool is_sleep_safe = false);
1410
1412
1413#ifdef USE_NEXTION_TFT_UPLOAD
1414#ifdef USE_ESP8266
1415 WiFiClient *wifi_client_{nullptr};
1416 BearSSL::WiFiClientSecure *wifi_client_secure_{nullptr};
1417 WiFiClient *get_wifi_client_();
1418#endif // USE_ESP8266
1419 std::string tft_url_;
1420 uint32_t content_length_ = 0;
1421 int tft_size_ = 0;
1424
1425#ifdef USE_ARDUINO
1433 int upload_by_chunks_(HTTPClient &http_client, uint32_t &range_start);
1434#elif defined(USE_ESP_IDF)
1442 int upload_by_chunks_(esp_http_client_handle_t http_client, uint32_t &range_start);
1443#endif // USE_ARDUINO vs USE_ESP_IDF
1444
1451 bool upload_end_(bool successful);
1452
1457 uint32_t get_free_heap_();
1458
1459#endif // USE_NEXTION_TFT_UPLOAD
1460
1461 bool check_connect_();
1462
1463 std::vector<NextionComponentBase *> touch_;
1464 std::vector<NextionComponentBase *> switchtype_;
1465 std::vector<NextionComponentBase *> sensortype_;
1466 std::vector<NextionComponentBase *> textsensortype_;
1467 std::vector<NextionComponentBase *> binarysensortype_;
1472 CallbackManager<void(uint8_t, uint8_t, bool)> touch_callback_{};
1474
1477
1478#ifdef USE_NEXTION_CONFIG_DUMP_DEVICE_INFO
1479 std::string device_model_;
1481 std::string serial_number_;
1482 std::string flash_size_;
1483#endif // USE_NEXTION_CONFIG_DUMP_DEVICE_INFO
1484
1486
1487#ifdef NEXTION_PROTOCOL_LOG
1488 void print_queue_members_();
1489#endif // NEXTION_PROTOCOL_LOG
1490 void reset_(bool reset_nextion = true);
1491
1492 std::string command_data_;
1493 const uint16_t startup_override_ms_ = 8000;
1494 const uint16_t max_q_age_ms_ = 8000;
1495 uint32_t started_ms_ = 0;
1496};
1497
1498} // namespace nextion
1499} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:437
void set_spacing(uint8_t spacing_ms)
Set the minimum time between commands.
Definition nextion.h:52
uint8_t get_spacing() const
Get current command spacing.
Definition nextion.h:58
bool can_send() const
Check if enough time has passed to send next command.
Definition nextion.h:64
void mark_sent()
Mark a command as sent, updating the timing.
Definition nextion.h:69
NextionCommandPacer(uint8_t initial_spacing=0)
Creates command pacer with initial spacing.
Definition nextion.h:46
void add_setup_state_callback(std::function< void()> &&callback)
Add a callback to be notified when the nextion completes its initialize setup.
Definition nextion.cpp:212
void set_component_font_color(const char *component, uint16_t color)
Set the font color of a component.
std::vector< NextionComponentBase * > touch_
Definition nextion.h:1463
void open_waveform_channel(uint8_t component_id, uint8_t channel_number, uint8_t value)
void set_component_visibility(const char *component, bool show) override
Set the visibility of a component.
std::vector< NextionComponentBase * > switchtype_
Definition nextion.h:1464
void set_component_drag(const char *component, bool drag)
Set the drag availability of a component.
void add_buffer_overflow_event_callback(std::function< void()> &&callback)
Add a callback to be notified when the nextion reports a buffer overflow.
Definition nextion.cpp:224
std::vector< NextionComponentBase * > binarysensortype_
Definition nextion.h:1467
uint32_t get_free_heap_()
Returns the ESP Free Heap memory.
void set_component_foreground_color(const char *component, uint16_t color)
Set the foreground color of a component.
void set_component_font(const char *component, uint8_t font_id) override
Set the font id for a component.
const uint16_t max_q_age_ms_
Definition nextion.h:1494
const uint16_t startup_override_ms_
Definition nextion.h:1493
bool send_command_(const std::string &command)
Manually send a raw command to the display and don't wait for an acknowledgement packet.
Definition nextion.cpp:26
size_t get_max_queue_size() const
Get the maximum allowed queue size.
Definition nextion.h:106
void set_max_queue_size(size_t size)
Set the maximum allowed queue size.
Definition nextion.h:100
std::vector< NextionComponentBase * > textsensortype_
Definition nextion.h:1466
void set_max_commands_per_loop(uint16_t value)
Set the maximum number of commands to process in each loop iteration.
Definition nextion.h:87
uint8_t auto_wake_on_touch_
Display should wake automatically on touch (default: true)
Definition nextion.h:1360
CallbackManager< void(uint8_t)> page_callback_
Definition nextion.h:1471
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_brightness(float brightness)
Definition nextion.h:1055
void set_component_text(const char *component, const char *text)
Set the text of a component to a static string.
struct esphome::nextion::Nextion::@144 connection_state_
Status flags for Nextion display state management.
void set_wake_up_page(uint8_t wake_up_page=255)
Sets which page Nextion loads when exiting sleep mode.
std::string device_model_
Definition nextion.h:1479
void set_nextion_rtc_time(ESPTime time)
Send the current time to the nextion display.
void all_components_send_state_(bool force_update=false)
Definition nextion.cpp:937
void set_start_up_page(uint8_t start_up_page=255)
Sets which page Nextion loads when connecting to ESPHome.
Definition nextion.h:1246
void set_component_pressed_foreground_color(const char *component, uint16_t color)
Set the pressed foreground color of a component.
std::string firmware_version_
Definition nextion.h:1480
void set_nextion_sensor_state(int queue_type, const std::string &name, float state)
Set the nextion sensor state object.
Definition nextion.cpp:885
void add_addt_command_to_queue(NextionComponentBase *component) override
Add addt command to the queue.
Definition nextion.cpp:1257
void soft_reset()
Softreset the Nextion.
void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color)
Draw a filled circled.
void register_textsensor_component(NextionComponentBase *obj)
Definition nextion.h:1052
void add_new_page_callback(std::function< void(uint8_t)> &&callback)
Add a callback to be notified when the nextion changes pages.
Definition nextion.cpp:216
void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color)
Draw a circle outline.
uint16_t max_commands_per_loop_
Definition nextion.h:1319
void enable_component_touch(const char *component)
Enable touch for a component.
void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color)
Draw a rectangle outline.
nextion_writer_t writer_
Definition nextion.h:1475
void add_to_get_queue(NextionComponentBase *component) override
Queue a GET command for a component that expects a response from the Nextion display.
Definition nextion.cpp:1217
void void set_component_value(const char *component, int32_t value)
Set the integer value of a component.
uint8_t is_updating_
TFT firmware update is currently in progress.
Definition nextion.h:1359
bool send_command_printf(const char *format,...) __attribute__((format(printf
Manually send a raw formatted command to the display.
Definition nextion.cpp:257
void setup() override
Definition nextion.cpp:12
WiFiClient * wifi_client_
Definition nextion.h:1415
void set_component_picture(const char *component, uint8_t picture_id)
Set the picture of an image component.
void set_component_picc(const char *component, uint8_t pic_id)
Set the background picture id of component.
std::deque< NextionQueue * > nextion_queue_
Definition nextion.h:1341
void loop() override
Definition nextion.cpp:298
void set_auto_wake_on_touch(bool auto_wake_on_touch)
Sets if Nextion should auto-wake from sleep when touch press occurs.
bool remove_from_q_(bool report_empty=true)
Definition nextion.cpp:368
bool upload_tft(uint32_t baud_rate=0, bool exit_reparse=true)
Uploads the TFT file to the Nextion display.
bool set_protocol_reparse_mode(bool active_mode)
Sets the Nextion display's protocol reparse mode.
std::vector< NextionComponentBase * > sensortype_
Definition nextion.h:1465
bool upload_end_(bool successful)
Ends the upload process, restart Nextion and, if successful, restarts ESP.
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)
Definition nextion.cpp:1170
BearSSL::WiFiClientSecure * wifi_client_secure_
Definition nextion.h:1416
void set_component_coordinates(const char *component, uint16_t x, uint16_t y)
Set the coordinates of a component on screen.
uint8_t sent_setup_commands_
Initial setup commands have been sent.
Definition nextion.h:1356
void sleep(bool sleep)
Sets Nextion mode between sleep and awake.
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.
Definition nextion.cpp:1133
void set_touch_sleep_timeout(uint16_t touch_sleep_timeout=0)
Set the touch sleep timeout of the display using the thsp command.
CallbackManager< void()> setup_callback_
Definition nextion.h:1468
void hide_component(const char *component) override
Hide a component.
std::string command_data_
Definition nextion.h:1492
void set_component_position(const char *component, uint32_t x, uint32_t y)
Set the position of a component.
optional< float > brightness_
Definition nextion.h:1476
CallbackManager< void()> wake_callback_
Definition nextion.h:1470
void add_sleep_state_callback(std::function< void()> &&callback)
Add a callback to be notified of sleep state changes.
Definition nextion.cpp:204
bool void set_tft_url(const std::string &tft_url)
Set the tft file URL.
Definition nextion.h:1083
void add_waveform_data(uint8_t component_id, uint8_t channel_number, uint8_t value)
Add waveform data to a waveform component.
void disable_component_touch(const char *component)
Disable touch for a component.
bool is_updating() override
Check if the TFT update process is currently running.
Definition nextion.cpp:1296
uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag)
Definition nextion.cpp:976
void set_component_pressed_font_color(const char *component, uint16_t color)
Set the pressed font color of a component.
void register_touch_component(NextionComponentBase *obj)
Definition nextion.h:1048
void goto_page(const char *page)
Show the page with a given name.
uint8_t reserved_
Reserved bits for future flag additions.
Definition nextion.h:1361
void set_wait_for_ack(bool wait_for_ack)
void register_switch_component(NextionComponentBase *obj)
Definition nextion.h:1049
size_t queue_size()
Retrieves the number of commands pending in the Nextion command queue.
Definition nextion.h:1276
bool send_command(const char *command)
Manually send a raw command to the display.
Definition nextion.cpp:246
std::string serial_number_
Definition nextion.h:1481
void set_component_pic(const char *component, uint8_t pic_id)
Set the picture id of a component.
CallbackManager< void()> sleep_callback_
Definition nextion.h:1469
void set_component_pressed_background_color(const char *component, uint16_t color)
Set the pressed background color of a component.
uint8_t ignore_is_setup_
Temporarily ignore setup state for special operations.
Definition nextion.h:1357
float get_setup_priority() const override
Definition nextion.cpp:194
void set_component_vid(const char *component, uint8_t vid_id)
Set the video id of a component.
bool void add_no_result_to_queue_with_command_(const std::string &variable_name, const std::string &command)
Definition nextion.cpp:1065
void set_component_background_color(const char *component, uint16_t color)
Set the background color of a component.
bool is_connected()
Check if the Nextion display is successfully connected.
Definition nextion.h:1315
void reset_(bool reset_nextion=true)
Definition nextion.cpp:136
void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Draw a line on the screen.
void process_pending_in_queue_()
Process any commands in the queue that are pending due to command spacing.
Definition nextion.cpp:351
void add_no_result_to_queue_(const std::string &variable_name)
Add a command to the Nextion queue that expects no response.
Definition nextion.cpp:1032
CallbackManager< void(uint8_t, uint8_t, bool)> touch_callback_
Definition nextion.h:1472
void register_binarysensor_component(NextionComponentBase *obj)
Definition nextion.h:1050
uint16_t get_max_commands_per_loop() const
Get the current maximum number of commands allowed per loop iteration.
Definition nextion.h:93
void dump_config() override
Definition nextion.cpp:146
void set_command_spacing(uint32_t spacing_ms)
Set the command spacing for the display.
Definition nextion.h:114
NextionCommandPacer command_pacer_
Definition nextion.h:1326
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_nextion_text_state(const std::string &name, const std::string &state)
Definition nextion.cpp:926
std::deque< NextionQueue * > waveform_queue_
Definition nextion.h:1342
bool add_no_result_to_queue_with_ignore_sleep_printf_(const std::string &variable_name, const char *format,...) __attribute__((format(printf
Definition nextion.cpp:1107
void update() override
Definition nextion.cpp:195
void display_picture(uint16_t picture_id, uint16_t x_start, uint16_t y_start)
Display a picture at coordinates.
uint8_t is_connected_
Connection established with Nextion display.
Definition nextion.h:1355
void add_wake_state_callback(std::function< void()> &&callback)
Add a callback to be notified of wake state changes.
Definition nextion.cpp:208
CallbackManager< void()> buffer_overflow_callback_
Definition nextion.h:1473
void show_component(const char *component) override
Show a component.
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 set_writer(const nextion_writer_t &writer)
Definition nextion.cpp:1294
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 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.
Definition nextion.cpp:1080
void register_sensor_component(NextionComponentBase *obj)
Definition nextion.h:1051
void add_no_result_to_queue_with_set(NextionComponentBase *component, int32_t state_value) override
Definition nextion.cpp:1160
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.
Definition nextion.cpp:220
void set_component_aph(const char *component, uint8_t aph)
Set the opaqueness (fading) of a component.
void update_components_by_prefix(const std::string &prefix)
Definition nextion.cpp:957
uint8_t nextion_reports_is_setup_
Nextion has reported successful initialization.
Definition nextion.h:1358
void set_backlight_brightness(float brightness)
Set the brightness of the backlight.
struct @65::@66 __attribute__
const Component * component
Definition component.cpp:37
bool state
Definition fan.h:0
bool active_mode
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint32_t IRAM_ATTR HOT millis()
Definition core.cpp:30
A more user-friendly version of struct tm from time.h.
Definition time.h:15
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6