ESPHome 2026.3.0
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_ESP32
17#include <esp_http_client.h>
18#elif defined(USE_ESP8266)
19#include <ESP8266HTTPClient.h>
20#include <WiFiClientSecure.h>
21#endif // USE_ESP32 vs USE_ESP8266
22#endif // USE_NEXTION_TFT_UPLOAD
23
24namespace esphome {
25namespace nextion {
26
27class Nextion;
28class NextionComponentBase;
29
31
32static const std::string COMMAND_DELIMITER{static_cast<char>(255), static_cast<char>(255), static_cast<char>(255)};
33
34#ifdef USE_NEXTION_COMMAND_SPACING
36 public:
41 explicit NextionCommandPacer(uint8_t initial_spacing = 0) : spacing_ms_(initial_spacing) {}
42
47 void set_spacing(uint8_t spacing_ms) { spacing_ms_ = spacing_ms; }
48
53 uint8_t get_spacing() const { return spacing_ms_; }
54
59 bool can_send() const { return (millis() - last_command_time_) >= spacing_ms_; }
60
64 void mark_sent() { last_command_time_ = millis(); }
65
66 private:
67 uint8_t spacing_ms_;
68 uint32_t last_command_time_{0};
69};
70#endif // USE_NEXTION_COMMAND_SPACING
71
72class Nextion : public NextionBase, public PollingComponent, public uart::UARTDevice {
73 public:
74#ifdef USE_NEXTION_MAX_COMMANDS_PER_LOOP
82 inline void set_max_commands_per_loop(uint16_t value) { this->max_commands_per_loop_ = value; }
83
88 inline uint16_t get_max_commands_per_loop() const { return this->max_commands_per_loop_; }
89#endif // USE_NEXTION_MAX_COMMANDS_PER_LOOP
90#ifdef USE_NEXTION_MAX_QUEUE_SIZE
95 inline void set_max_queue_size(size_t size) { this->max_queue_size_ = size; }
96
101 inline size_t get_max_queue_size() const { return this->max_queue_size_; }
102#endif // USE_NEXTION_MAX_QUEUE_SIZE
103
104#ifdef USE_NEXTION_COMMAND_SPACING
109 void set_command_spacing(uint32_t spacing_ms) { this->command_pacer_.set_spacing(spacing_ms); }
110#endif // USE_NEXTION_COMMAND_SPACING
111
124 void set_component_text(const char *component, const char *text);
125
141 void set_component_text_printf(const char *component, const char *format, ...) __attribute__((format(printf, 3, 4)));
142
155 void set_component_value(const char *component, int32_t value);
156
169 void set_component_picture(const char *component, uint8_t picture_id) { set_component_picc(component, picture_id); };
170
185 void set_component_background_color(const char *component, uint16_t color);
186
200 void set_component_background_color(const char *component, const char *color);
201
215 void set_component_background_color(const char *component, Color color) override;
216
232 void set_component_pressed_background_color(const char *component, uint16_t color);
233
248 void set_component_pressed_background_color(const char *component, const char *color);
249
264 void set_component_pressed_background_color(const char *component, Color color) override;
265
280 void set_component_foreground_color(const char *component, uint16_t color);
281
295 void set_component_foreground_color(const char *component, const char *color);
296
309 void set_component_foreground_color(const char *component, Color color) override;
310
326 void set_component_pressed_foreground_color(const char *component, uint16_t color);
327
342 void set_component_pressed_foreground_color(const char *component, const char *color);
343
358 void set_component_pressed_foreground_color(const char *component, Color color) override;
359
372 void set_component_pic(const char *component, uint16_t pic_id);
373
386 void set_component_picc(const char *component, uint16_t pic_id);
387
402 void set_component_font_color(const char *component, uint16_t color);
403
417 void set_component_font_color(const char *component, const char *color);
418
431 void set_component_font_color(const char *component, Color color) override;
432
447 void set_component_pressed_font_color(const char *component, uint16_t color);
448
462 void set_component_pressed_font_color(const char *component, const char *color);
463
476 void set_component_pressed_font_color(const char *component, Color color) override;
477
491 void set_component_coordinates(const char *component, uint16_t x, uint16_t y);
492
505 void set_component_font(const char *component, uint8_t font_id) override;
506
511 void set_nextion_rtc_time(ESPTime time);
512
524 void goto_page(const char *page);
525
537 void goto_page(uint8_t page);
538
554 void set_component_visibility(const char *component, bool show) override;
555
567 void hide_component(const char *component) override;
568
580 void show_component(const char *component) override;
581
593 void enable_component_touch(const char *component);
594
606 void disable_component_touch(const char *component);
607
614 void add_waveform_data(uint8_t component_id, uint8_t channel_number, uint8_t value);
615
616 void open_waveform_channel(uint8_t component_id, uint8_t channel_number, uint8_t value);
617
631 void display_picture(uint16_t picture_id, uint16_t x_start, uint16_t y_start);
632
651 void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color);
652
670 void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, const char *color);
671
689 void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, Color color);
690
709 void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
710
728 void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char *color);
729
747 void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, Color color);
748
767 void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color);
768
786 void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, const char *color);
787
805 void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, Color color);
806
816 void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color);
817
826 void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, const char *color);
827
835 void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, Color color);
836
853 void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color);
854
870 void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, const char *color);
871
887 void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, Color color);
888
907 void qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size = 200, uint16_t background_color = 65535,
908 uint16_t foreground_color = 0, int32_t logo_pic = -1, uint8_t border_width = 8);
909
931 void qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size,
932 Color background_color = Color(255, 255, 255), Color foreground_color = Color(0, 0, 0),
933 int32_t logo_pic = -1, uint8_t border_width = 8);
934
946 void set_backlight_brightness(float brightness);
947
952 void sleep(bool sleep);
953
973
974 // ======== Nextion Intelligent Series ========
975
990 void set_component_vid(const char *component, uint8_t vid_id);
991
1006 void set_component_drag(const char *component, bool drag);
1007
1022 void set_component_aph(const char *component, uint8_t aph);
1023
1040
1041 // ========== INTERNAL METHODS ==========
1042 // (In most use cases you won't need these)
1043 void register_touch_component(NextionComponentBase *obj) { this->touch_.push_back(obj); }
1048
1049 void setup() override;
1050 void set_brightness(float brightness) { this->brightness_ = brightness; }
1051 void update() override;
1052 void loop() override;
1053 void set_writer(const nextion_writer_t &writer);
1054
1055 // This function has been deprecated
1056 void set_wait_for_ack(bool wait_for_ack);
1057
1063 bool send_command(const char *command);
1064
1071 bool send_command_printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
1072
1073#ifdef USE_NEXTION_TFT_UPLOAD
1078 void set_tft_upload_http_timeout(uint16_t timeout_ms) { this->tft_upload_http_timeout_ = timeout_ms; }
1079
1080#ifdef USE_ESP32
1093#endif // USE_ESP32
1094
1099 void set_tft_upload_http_retries(uint8_t retries) { this->tft_upload_http_retries_ = retries; }
1100
1104 void set_tft_url(const std::string &tft_url) { this->tft_url_ = tft_url; }
1105
1126 bool upload_tft(uint32_t baud_rate = 0, bool exit_reparse = true);
1127
1128#endif // USE_NEXTION_TFT_UPLOAD
1129
1130 void dump_config() override;
1131
1135 void soft_reset();
1136
1141 void add_sleep_state_callback(std::function<void()> &&callback);
1142
1147 void add_wake_state_callback(std::function<void()> &&callback);
1148
1153 void add_setup_state_callback(std::function<void()> &&callback);
1154
1159 void add_new_page_callback(std::function<void(uint8_t)> &&callback);
1160
1165 void add_touch_event_callback(std::function<void(uint8_t, uint8_t, bool)> &&callback);
1166
1171 void add_buffer_overflow_event_callback(std::function<void()> &&callback);
1172
1173 void update_all_components();
1174
1187 void set_nextion_sensor_state(int queue_type, const std::string &name, float state);
1188 void set_nextion_sensor_state(NextionQueueType queue_type, const std::string &name, float state);
1189 void set_nextion_text_state(const std::string &name, const std::string &state);
1190
1191 void add_no_result_to_queue_with_set(NextionComponentBase *component, int32_t state_value) override;
1192 void add_no_result_to_queue_with_set(const std::string &variable_name, const std::string &variable_name_to_send,
1193 int32_t state_value) override;
1194
1195 void add_no_result_to_queue_with_set(NextionComponentBase *component, const std::string &state_value) override;
1196 void add_no_result_to_queue_with_set(const std::string &variable_name, const std::string &variable_name_to_send,
1197 const std::string &state_value) override;
1198
1200
1202
1203 void update_components_by_prefix(const std::string &prefix);
1204
1238 void set_touch_sleep_timeout(uint16_t touch_sleep_timeout = 0);
1239
1252 void set_wake_up_page(uint8_t wake_up_page = 255);
1253
1254#ifdef USE_NEXTION_CONF_START_UP_PAGE
1267 void set_start_up_page(uint8_t start_up_page = 255) { this->start_up_page_ = start_up_page; }
1268#endif // USE_NEXTION_CONF_START_UP_PAGE
1269
1282 void set_auto_wake_on_touch(bool auto_wake_on_touch);
1283
1297 size_t queue_size() { return this->nextion_queue_.size(); }
1298
1317 bool is_updating() override;
1318
1336 bool is_connected() { return this->connection_state_.is_connected_; }
1337
1342 inline void set_max_queue_age(uint16_t age_ms) { this->max_q_age_ms_ = age_ms; }
1343
1348 inline uint16_t get_max_queue_age() const { return this->max_q_age_ms_; }
1349
1354 inline void set_startup_override_ms(uint16_t timeout_ms) { this->startup_override_ms_ = timeout_ms; }
1355
1360 inline uint16_t get_startup_override_ms() const { return this->startup_override_ms_; }
1361
1362 protected:
1363#ifdef USE_NEXTION_MAX_COMMANDS_PER_LOOP
1365#endif // USE_NEXTION_MAX_COMMANDS_PER_LOOP
1366#ifdef USE_NEXTION_MAX_QUEUE_SIZE
1368#endif // USE_NEXTION_MAX_QUEUE_SIZE
1369
1370#ifdef USE_NEXTION_COMMAND_SPACING
1372
1384#endif // USE_NEXTION_COMMAND_SPACING
1385
1386 std::deque<NextionQueue *> nextion_queue_;
1387 std::deque<NextionQueue *> waveform_queue_;
1388 uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag);
1389 void all_components_send_state_(bool force_update = false);
1391 bool remove_from_q_(bool report_empty = true);
1392
1399 struct {
1400 uint8_t is_connected_ : 1;
1402 uint8_t ignore_is_setup_ : 1;
1404 uint8_t is_updating_ : 1;
1406 uint8_t reserved_ : 2;
1408
1410 void process_serial_();
1412 uint8_t wake_up_page_ = 255;
1413#ifdef USE_NEXTION_CONF_START_UP_PAGE
1414 uint8_t start_up_page_ = 255;
1415#endif // USE_NEXTION_CONF_START_UP_PAGE
1417
1422 bool send_command_(const std::string &command);
1423 void add_no_result_to_queue_(const std::string &variable_name);
1424 bool add_no_result_to_queue_with_ignore_sleep_printf_(const std::string &variable_name, const char *format, ...)
1425 __attribute__((format(printf, 3, 4)));
1426 void add_no_result_to_queue_with_command_(const std::string &variable_name, const std::string &command);
1427
1428#ifdef USE_NEXTION_COMMAND_SPACING
1442 void add_no_result_to_queue_with_pending_command_(const std::string &variable_name, const std::string &command);
1443#endif // USE_NEXTION_COMMAND_SPACING
1444
1445 bool add_no_result_to_queue_with_printf_(const std::string &variable_name, const char *format, ...)
1446 __attribute__((format(printf, 3, 4)));
1447
1448 void add_no_result_to_queue_with_set_internal_(const std::string &variable_name,
1449 const std::string &variable_name_to_send, int32_t state_value,
1450 bool is_sleep_safe = false);
1451
1452 void add_no_result_to_queue_with_set_internal_(const std::string &variable_name,
1453 const std::string &variable_name_to_send,
1454 const std::string &state_value, bool is_sleep_safe = false);
1455
1457
1458#ifdef USE_NEXTION_TFT_UPLOAD
1459#ifdef USE_ESP8266
1460 WiFiClient *wifi_client_{nullptr};
1461 BearSSL::WiFiClientSecure *wifi_client_secure_{nullptr};
1462 WiFiClient *get_wifi_client_();
1463#endif // USE_ESP8266
1464 std::string tft_url_;
1466 int tft_size_ = 0;
1471
1472#ifdef USE_ESP32
1474
1482 int upload_by_chunks_(esp_http_client_handle_t http_client, uint32_t &range_start);
1483#elif defined(USE_ARDUINO)
1491 int upload_by_chunks_(HTTPClient &http_client, uint32_t &range_start);
1492#endif // USE_ESP32 vs USE_ARDUINO
1493
1500 bool upload_end_(bool successful);
1501
1502#endif // USE_NEXTION_TFT_UPLOAD
1503
1504 bool check_connect_();
1505
1506 std::vector<NextionComponentBase *> touch_;
1507 std::vector<NextionComponentBase *> switchtype_;
1508 std::vector<NextionComponentBase *> sensortype_;
1509 std::vector<NextionComponentBase *> textsensortype_;
1510 std::vector<NextionComponentBase *> binarysensortype_;
1515 CallbackManager<void(uint8_t, uint8_t, bool)> touch_callback_{};
1517
1519 optional<float> brightness_;
1520
1521#ifdef USE_NEXTION_CONFIG_DUMP_DEVICE_INFO
1522 std::string device_model_;
1524 std::string serial_number_;
1525 std::string flash_size_;
1526#endif // USE_NEXTION_CONFIG_DUMP_DEVICE_INFO
1527
1529
1530#ifdef NEXTION_PROTOCOL_LOG
1531 void print_queue_members_();
1532#endif // NEXTION_PROTOCOL_LOG
1533 void reset_(bool reset_nextion = true);
1534
1535 std::string command_data_;
1537
1538 uint16_t startup_override_ms_ = 8000;
1539 uint16_t max_q_age_ms_ = 8000;
1540};
1541
1542} // namespace nextion
1543} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:538
void set_spacing(uint8_t spacing_ms)
Set the minimum time between commands.
Definition nextion.h:47
uint8_t get_spacing() const
Get current command spacing.
Definition nextion.h:53
bool can_send() const
Check if enough time has passed to send next command.
Definition nextion.h:59
void mark_sent()
Mark a command as sent, updating the timing.
Definition nextion.h:64
NextionCommandPacer(uint8_t initial_spacing=0)
Creates command pacer with initial spacing.
Definition nextion.h:41
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:225
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:1506
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:1507
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:237
std::vector< NextionComponentBase * > binarysensortype_
Definition nextion.h:1510
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
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.
uint16_t max_q_age_ms_
Maximum age for queue items in ms.
Definition nextion.h:1539
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:27
size_t get_max_queue_size() const
Get the maximum allowed queue size.
Definition nextion.h:101
uint8_t tft_upload_http_retries_
HTTP retry count (default: 5)
Definition nextion.h:1470
void set_max_queue_size(size_t size)
Set the maximum allowed queue size.
Definition nextion.h:95
std::vector< NextionComponentBase * > textsensortype_
Definition nextion.h:1509
void set_max_commands_per_loop(uint16_t value)
Set the maximum number of commands to process in each loop iteration.
Definition nextion.h:82
uint8_t auto_wake_on_touch_
Display should wake automatically on touch (default: true)
Definition nextion.h:1405
CallbackManager< void(uint8_t)> page_callback_
Definition nextion.h:1514
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:1050
void set_component_text(const char *component, const char *text)
Set the text of a component to a static string.
void set_tft_upload_http_retries(uint8_t retries)
Set the number of HTTP retries for TFT upload requests.
Definition nextion.h:1099
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:1522
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:952
void set_start_up_page(uint8_t start_up_page=255)
Sets which page Nextion loads when connecting to ESPHome.
Definition nextion.h:1267
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:1523
void set_nextion_sensor_state(int queue_type, const std::string &name, float state)
Set the nextion sensor state object.
Definition nextion.cpp:900
void add_addt_command_to_queue(NextionComponentBase *component) override
Add addt command to the queue.
Definition nextion.cpp:1272
uint16_t get_startup_override_ms() const
Get the startup override timeout.
Definition nextion.h:1360
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:1047
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:229
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:1364
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:1518
uint16_t startup_override_ms_
Timeout before forcing setup complete.
Definition nextion.h:1538
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:1232
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:1404
bool send_command_printf(const char *format,...) __attribute__((format(printf
Manually send a raw formatted command to the display.
Definition nextion.cpp:270
void setup() override
Definition nextion.cpp:13
void set_max_queue_age(uint16_t age_ms)
Set the maximum age for queue items.
Definition nextion.h:1342
WiFiClient * wifi_client_
Definition nextion.h:1460
void set_component_picture(const char *component, uint8_t picture_id)
Set the picture of an image component.
Definition nextion.h:169
bool void set_tft_upload_http_timeout(uint16_t timeout_ms)
Set the HTTP timeout for TFT upload requests.
Definition nextion.h:1078
std::deque< NextionQueue * > nextion_queue_
Definition nextion.h:1386
void loop() override
Definition nextion.cpp:311
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:382
bool upload_tft(uint32_t baud_rate=0, bool exit_reparse=true)
Uploads the TFT file to the Nextion display.
uint16_t tft_upload_http_timeout_
HTTP timeout in ms (default: 4.5s)
Definition nextion.h:1469
void set_component_pic(const char *component, uint16_t pic_id)
Set the picture id of a component.
bool set_protocol_reparse_mode(bool active_mode)
Sets the Nextion display's protocol reparse mode.
std::vector< NextionComponentBase * > sensortype_
Definition nextion.h:1508
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:1185
BearSSL::WiFiClientSecure * wifi_client_secure_
Definition nextion.h:1461
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:1401
void set_component_picc(const char *component, uint16_t pic_id)
Set the background picture id of component.
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:1148
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:1511
void hide_component(const char *component) override
Hide a component.
std::string command_data_
Definition nextion.h:1535
void set_component_position(const char *component, uint32_t x, uint32_t y)
Set the position of a component.
uint16_t get_max_queue_age() const
Get the maximum age for queue items.
Definition nextion.h:1348
optional< float > brightness_
Definition nextion.h:1519
CallbackManager< void()> wake_callback_
Definition nextion.h:1513
void add_sleep_state_callback(std::function< void()> &&callback)
Add a callback to be notified of sleep state changes.
Definition nextion.cpp:217
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:1312
uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag)
Definition nextion.cpp:991
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:1043
void set_startup_override_ms(uint16_t timeout_ms)
Set the startup override timeout.
Definition nextion.h:1354
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:1406
void set_wait_for_ack(bool wait_for_ack)
void register_switch_component(NextionComponentBase *obj)
Definition nextion.h:1044
void set_tft_upload_watchdog_timeout(uint32_t timeout_ms)
Set the watchdog timeout during TFT upload.
Definition nextion.h:1092
size_t queue_size()
Retrieves the number of commands pending in the Nextion command queue.
Definition nextion.h:1297
bool send_command(const char *command)
Manually send a raw command to the display.
Definition nextion.cpp:259
std::string serial_number_
Definition nextion.h:1524
CallbackManager< void()> sleep_callback_
Definition nextion.h:1512
void set_tft_url(const std::string &tft_url)
Set the tft file URL.
Definition nextion.h:1104
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:1402
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:1080
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:1336
void reset_(bool reset_nextion=true)
Definition nextion.cpp:137
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, int32_t logo_pic=-1, uint8_t border_width=8)
Draws a QR code in the screen.
void process_pending_in_queue_()
Process any commands in the queue that are pending due to command spacing.
Definition nextion.cpp:365
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:1047
CallbackManager< void(uint8_t, uint8_t, bool)> touch_callback_
Definition nextion.h:1515
void register_binarysensor_component(NextionComponentBase *obj)
Definition nextion.h:1045
uint16_t get_max_commands_per_loop() const
Get the current maximum number of commands allowed per loop iteration.
Definition nextion.h:88
void dump_config() override
Definition nextion.cpp:147
void set_command_spacing(uint32_t spacing_ms)
Set the command spacing for the display.
Definition nextion.h:109
NextionCommandPacer command_pacer_
Definition nextion.h:1371
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:941
std::deque< NextionQueue * > waveform_queue_
Definition nextion.h:1387
bool add_no_result_to_queue_with_ignore_sleep_printf_(const std::string &variable_name, const char *format,...) __attribute__((format(printf
Definition nextion.cpp:1122
void update() override
Definition nextion.cpp:208
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:1400
void add_wake_state_callback(std::function< void()> &&callback)
Add a callback to be notified of wake state changes.
Definition nextion.cpp:221
CallbackManager< void()> buffer_overflow_callback_
Definition nextion.h:1516
void show_component(const char *component) override
Show a component.
void set_writer(const nextion_writer_t &writer)
Definition nextion.cpp:1310
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:1095
void register_sensor_component(NextionComponentBase *obj)
Definition nextion.h:1046
void add_no_result_to_queue_with_set(NextionComponentBase *component, int32_t state_value) override
Definition nextion.cpp:1175
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:233
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:972
uint32_t tft_upload_watchdog_timeout_
WDT timeout in ms (0 = no adjustment)
Definition nextion.h:1473
uint8_t nextion_reports_is_setup_
Nextion has reported successful initialization.
Definition nextion.h:1403
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:2
bool active_mode
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
const char int line
Definition log.h:74
const char int const __FlashStringHelper * format
Definition log.h:74
size_t size
Definition helpers.h:929
uint32_t IRAM_ATTR HOT millis()
Definition core.cpp:26
static void uint32_t
A more user-friendly version of struct tm from time.h.
Definition time.h:21
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6