ESPHome 2026.5.0-dev
Loading...
Searching...
No Matches
nextion.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4#include <vector>
5
11#include "esphome/core/time.h"
12
13#ifdef USE_NEXTION_WAVEFORM
15#endif // USE_NEXTION_WAVEFORM
16
17#include "nextion_base.h"
18#include "nextion_component.h"
19
20#ifdef USE_NEXTION_TFT_UPLOAD
21#ifdef USE_ESP32
22#include <esp_http_client.h>
23#elif defined(USE_ESP8266)
24#include <ESP8266HTTPClient.h>
25#include <WiFiClientSecure.h>
26#endif // USE_ESP32 vs USE_ESP8266
27#endif // USE_NEXTION_TFT_UPLOAD
28
29namespace esphome::nextion {
30
31class Nextion;
32class NextionComponentBase;
33
35
36#ifdef USE_NEXTION_COMMAND_SPACING
38 public:
43 explicit NextionCommandPacer(uint8_t initial_spacing = 0) : spacing_ms_(initial_spacing) {}
44
49 void set_spacing(uint8_t spacing_ms) { spacing_ms_ = spacing_ms; }
50
55 uint8_t get_spacing() const { return spacing_ms_; }
56
63 bool can_send(uint32_t now) const { return (now - last_command_time_) >= spacing_ms_; }
64
71 void mark_sent(uint32_t now) { last_command_time_ = now; }
72
73 private:
74 uint8_t spacing_ms_;
75 uint32_t last_command_time_{0};
76};
77#endif // USE_NEXTION_COMMAND_SPACING
78
79class Nextion : public NextionBase, public PollingComponent, public uart::UARTDevice {
80 public:
81#ifdef USE_NEXTION_MAX_COMMANDS_PER_LOOP
89 inline void set_max_commands_per_loop(uint16_t value) { this->max_commands_per_loop_ = value; }
90
95 inline uint16_t get_max_commands_per_loop() const { return this->max_commands_per_loop_; }
96#endif // USE_NEXTION_MAX_COMMANDS_PER_LOOP
97#ifdef USE_NEXTION_MAX_QUEUE_SIZE
102 inline void set_max_queue_size(size_t size) { this->max_queue_size_ = size; }
103
108 inline size_t get_max_queue_size() const { return this->max_queue_size_; }
109#endif // USE_NEXTION_MAX_QUEUE_SIZE
110
111#ifdef USE_NEXTION_COMMAND_SPACING
116 void set_command_spacing(uint32_t spacing_ms) { this->command_pacer_.set_spacing(spacing_ms); }
117#endif // USE_NEXTION_COMMAND_SPACING
118
131 void set_component_text(const char *component, const char *text);
132
148 void set_component_text_printf(const char *component, const char *format, ...) __attribute__((format(printf, 3, 4)));
149
162 void set_component_value(const char *component, int32_t value);
163
176 void set_component_picture(const char *component, uint8_t picture_id) { set_component_picc(component, picture_id); };
177
192 void set_component_background_color(const char *component, uint16_t color);
193
207 void set_component_background_color(const char *component, const char *color);
208
222 void set_component_background_color(const char *component, Color color) override;
223
239 void set_component_pressed_background_color(const char *component, uint16_t color);
240
255 void set_component_pressed_background_color(const char *component, const char *color);
256
271 void set_component_pressed_background_color(const char *component, Color color) override;
272
287 void set_component_foreground_color(const char *component, uint16_t color);
288
302 void set_component_foreground_color(const char *component, const char *color);
303
316 void set_component_foreground_color(const char *component, Color color) override;
317
333 void set_component_pressed_foreground_color(const char *component, uint16_t color);
334
349 void set_component_pressed_foreground_color(const char *component, const char *color);
350
365 void set_component_pressed_foreground_color(const char *component, Color color) override;
366
379 void set_component_pic(const char *component, uint16_t pic_id);
380
393 void set_component_picc(const char *component, uint16_t pic_id);
394
409 void set_component_font_color(const char *component, uint16_t color);
410
424 void set_component_font_color(const char *component, const char *color);
425
438 void set_component_font_color(const char *component, Color color) override;
439
454 void set_component_pressed_font_color(const char *component, uint16_t color);
455
469 void set_component_pressed_font_color(const char *component, const char *color);
470
483 void set_component_pressed_font_color(const char *component, Color color) override;
484
498 void set_component_coordinates(const char *component, uint16_t x, uint16_t y);
499
512 void set_component_font(const char *component, uint8_t font_id) override;
513
518 void set_nextion_rtc_time(ESPTime time);
519
531 void goto_page(const char *page);
532
544 void goto_page(uint8_t page);
545
561 void set_component_visibility(const char *component, bool show) override;
562
574 void hide_component(const char *component) override;
575
587 void show_component(const char *component) override;
588
600 void enable_component_touch(const char *component);
601
613 void disable_component_touch(const char *component);
614
615#ifdef USE_NEXTION_WAVEFORM
622 void add_waveform_data(uint8_t component_id, uint8_t channel_number, uint8_t value);
623
624 void open_waveform_channel(uint8_t component_id, uint8_t channel_number, uint8_t value);
625#endif // USE_NEXTION_WAVEFORM
626
640 void display_picture(uint16_t picture_id, uint16_t x_start, uint16_t y_start);
641
660 void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color);
661
679 void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, const char *color);
680
698 void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, Color color);
699
718 void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
719
737 void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char *color);
738
756 void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, Color color);
757
776 void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color);
777
795 void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, const char *color);
796
814 void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, Color color);
815
825 void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color);
826
835 void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, const char *color);
836
844 void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, Color color);
845
862 void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color);
863
879 void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, const char *color);
880
896 void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, Color color);
897
916 void qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size = 200, uint16_t background_color = 65535,
917 uint16_t foreground_color = 0, int32_t logo_pic = -1, uint8_t border_width = 8);
918
940 void qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size,
941 Color background_color = Color(255, 255, 255), Color foreground_color = Color(0, 0, 0),
942 int32_t logo_pic = -1, uint8_t border_width = 8);
943
955 void set_backlight_brightness(float brightness);
956
961 void sleep(bool sleep);
962
982
983 // ======== Nextion Intelligent Series ========
984
999 void set_component_vid(const char *component, uint8_t vid_id);
1000
1015 void set_component_drag(const char *component, bool drag);
1016
1031 void set_component_aph(const char *component, uint8_t aph);
1032
1049
1050 // ========== INTERNAL METHODS ==========
1051 // (In most use cases you won't need these)
1052 void register_touch_component(NextionComponentBase *obj) { this->touch_.push_back(obj); }
1057
1058 void setup() override;
1059 void set_brightness(float brightness) { this->brightness_ = brightness; }
1060 void update() override;
1061 void loop() override;
1062 void set_writer(const nextion_writer_t &writer);
1063
1064 // This function has been deprecated
1065 void set_wait_for_ack(bool wait_for_ack);
1066
1072 bool send_command(const char *command);
1073
1080 bool send_command_printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
1081
1082#ifdef USE_NEXTION_TFT_UPLOAD
1087 void set_tft_upload_http_timeout(uint16_t timeout_ms) { this->tft_upload_http_timeout_ = timeout_ms; }
1088
1089#ifdef USE_ESP32
1102#endif // USE_ESP32
1103
1108 void set_tft_upload_http_retries(uint8_t retries) { this->tft_upload_http_retries_ = retries; }
1109
1113 void set_tft_url(const std::string &tft_url) { this->tft_url_ = tft_url; }
1114
1135 bool upload_tft(uint32_t baud_rate = 0, bool exit_reparse = true);
1136
1137#endif // USE_NEXTION_TFT_UPLOAD
1138
1139 void dump_config() override;
1140
1144 void soft_reset();
1145
1150 template<typename F> void add_sleep_state_callback(F &&callback) {
1151 this->sleep_callback_.add(std::forward<F>(callback));
1152 }
1153
1158 template<typename F> void add_wake_state_callback(F &&callback) {
1159 this->wake_callback_.add(std::forward<F>(callback));
1160 }
1161
1166 template<typename F> void add_setup_state_callback(F &&callback) {
1167 this->setup_callback_.add(std::forward<F>(callback));
1168 }
1169
1174 template<typename F> void add_new_page_callback(F &&callback) { this->page_callback_.add(std::forward<F>(callback)); }
1175
1180 template<typename F> void add_touch_event_callback(F &&callback) {
1181 this->touch_callback_.add(std::forward<F>(callback));
1182 }
1183
1188 template<typename F> void add_buffer_overflow_event_callback(F &&callback) {
1189 this->buffer_overflow_callback_.add(std::forward<F>(callback));
1190 }
1191
1192 // Callbacks for Nextion "custom protocol" frames (0x90..0x93)
1193#ifdef USE_NEXTION_TRIGGER_CUSTOM_BINARY_SENSOR
1201 template<typename F> void add_custom_binary_sensor_callback(F &&callback) {
1202 this->custom_binary_sensor_callback_.add(std::forward<F>(callback));
1203 }
1204#endif // USE_NEXTION_TRIGGER_CUSTOM_BINARY_SENSOR
1205
1206#ifdef USE_NEXTION_TRIGGER_CUSTOM_SENSOR
1214 template<typename F> void add_custom_sensor_callback(F &&callback) {
1215 this->custom_sensor_callback_.add(std::forward<F>(callback));
1216 }
1217#endif // USE_NEXTION_TRIGGER_CUSTOM_SENSOR
1218
1219#ifdef USE_NEXTION_TRIGGER_CUSTOM_SWITCH
1227 template<typename F> void add_custom_switch_callback(F &&callback) {
1228 this->custom_switch_callback_.add(std::forward<F>(callback));
1229 }
1230#endif // USE_NEXTION_TRIGGER_CUSTOM_SWITCH
1231
1232#ifdef USE_NEXTION_TRIGGER_CUSTOM_TEXT_SENSOR
1240 template<typename F> void add_custom_text_sensor_callback(F &&callback) {
1241 this->custom_text_sensor_callback_.add(std::forward<F>(callback));
1242 }
1243#endif // USE_NEXTION_TRIGGER_CUSTOM_TEXT_SENSOR
1244
1246
1259 void set_nextion_sensor_state(int queue_type, const std::string &name, float state);
1260 void set_nextion_sensor_state(NextionQueueType queue_type, const std::string &name, float state);
1261 void set_nextion_text_state(const std::string &name, const std::string &state);
1262
1264 void add_no_result_to_queue_with_set(const std::string &variable_name, const std::string &variable_name_to_send,
1265 int32_t state_value) override;
1266
1267 void add_no_result_to_queue_with_set(NextionComponentBase *component, const std::string &state_value) override;
1268 void add_no_result_to_queue_with_set(const std::string &variable_name, const std::string &variable_name_to_send,
1269 const std::string &state_value) override;
1270
1272
1273#ifdef USE_NEXTION_WAVEFORM
1275#endif // USE_NEXTION_WAVEFORM
1276
1277 void update_components_by_prefix(const std::string &prefix);
1278
1312 void set_touch_sleep_timeout(uint16_t touch_sleep_timeout = 0);
1313
1326 void set_wake_up_page(uint8_t wake_up_page = 255);
1327
1328#ifdef USE_NEXTION_CONF_START_UP_PAGE
1341 void set_start_up_page(uint8_t start_up_page = 255) { this->start_up_page_ = start_up_page; }
1342#endif // USE_NEXTION_CONF_START_UP_PAGE
1343
1356 void set_auto_wake_on_touch(bool auto_wake_on_touch);
1357
1371 size_t queue_size() { return this->nextion_queue_.size(); }
1372
1391 bool is_updating() override;
1392
1410 bool is_connected() { return this->connection_state_.is_connected_; }
1411
1416 inline void set_max_queue_age(uint16_t age_ms) { this->max_q_age_ms_ = age_ms; }
1417
1422 inline uint16_t get_max_queue_age() const { return this->max_q_age_ms_; }
1423
1428 inline void set_startup_override_ms(uint16_t timeout_ms) { this->startup_override_ms_ = timeout_ms; }
1429
1434 inline uint16_t get_startup_override_ms() const { return this->startup_override_ms_; }
1435
1436 protected:
1437#ifdef USE_NEXTION_MAX_COMMANDS_PER_LOOP
1439#endif // USE_NEXTION_MAX_COMMANDS_PER_LOOP
1440#ifdef USE_NEXTION_MAX_QUEUE_SIZE
1442#endif // USE_NEXTION_MAX_QUEUE_SIZE
1443
1444#ifdef USE_NEXTION_COMMAND_SPACING
1446
1458#endif // USE_NEXTION_COMMAND_SPACING
1459
1460 std::list<NextionQueue *> nextion_queue_;
1461#ifdef USE_NEXTION_WAVEFORM
1465#endif // USE_NEXTION_WAVEFORM
1466 uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag);
1467 void all_components_send_state_(bool force_update = false);
1469 bool remove_from_q_(bool report_empty = true);
1470
1477 struct {
1478 uint8_t is_connected_ : 1;
1480 uint8_t ignore_is_setup_ : 1;
1482 uint8_t is_updating_ : 1;
1484 uint8_t reserved_ : 2;
1486
1490 uint8_t wake_up_page_ = 255;
1491#ifdef USE_NEXTION_CONF_START_UP_PAGE
1492 uint8_t start_up_page_ = 255;
1493#endif // USE_NEXTION_CONF_START_UP_PAGE
1495
1500 bool send_command_(const std::string &command);
1501 void add_no_result_to_queue_(const std::string &variable_name);
1502 bool add_no_result_to_queue_with_ignore_sleep_printf_(const std::string &variable_name, const char *format, ...)
1503 __attribute__((format(printf, 3, 4)));
1504 void add_no_result_to_queue_with_command_(const std::string &variable_name, const std::string &command);
1505
1506#ifdef USE_NEXTION_COMMAND_SPACING
1520 void add_no_result_to_queue_with_pending_command_(const std::string &variable_name, const std::string &command);
1521#endif // USE_NEXTION_COMMAND_SPACING
1522
1523 bool add_no_result_to_queue_with_printf_(const std::string &variable_name, const char *format, ...)
1524 __attribute__((format(printf, 3, 4)));
1525
1526 void add_no_result_to_queue_with_set_internal_(const std::string &variable_name,
1527 const std::string &variable_name_to_send, int32_t state_value,
1528 bool is_sleep_safe = false);
1529
1530 void add_no_result_to_queue_with_set_internal_(const std::string &variable_name,
1531 const std::string &variable_name_to_send,
1532 const std::string &state_value, bool is_sleep_safe = false);
1533
1534#ifdef USE_NEXTION_WAVEFORM
1536#endif // USE_NEXTION_WAVEFORM
1537
1538#ifdef USE_NEXTION_TFT_UPLOAD
1539#ifdef USE_ESP8266
1540 WiFiClient *wifi_client_{nullptr};
1541 BearSSL::WiFiClientSecure *wifi_client_secure_{nullptr};
1542 WiFiClient *get_wifi_client_();
1543#endif // USE_ESP8266
1544 std::string tft_url_;
1546 int tft_size_ = 0;
1551
1552#ifdef USE_ESP32
1554
1562 int upload_by_chunks_(esp_http_client_handle_t http_client, uint32_t &range_start);
1563#elif defined(USE_ARDUINO)
1571 int upload_by_chunks_(HTTPClient &http_client, uint32_t &range_start);
1572#endif // USE_ESP32 vs USE_ARDUINO
1573
1580 bool upload_end_(bool successful);
1581
1582#endif // USE_NEXTION_TFT_UPLOAD
1583
1585
1586 std::vector<NextionComponentBase *> touch_;
1587 std::vector<NextionComponentBase *> switchtype_;
1588 std::vector<NextionComponentBase *> sensortype_;
1589 std::vector<NextionComponentBase *> textsensortype_;
1590 std::vector<NextionComponentBase *> binarysensortype_;
1595 CallbackManager<void(uint8_t, uint8_t, bool)> touch_callback_{};
1597#ifdef USE_NEXTION_TRIGGER_CUSTOM_BINARY_SENSOR
1599#endif // USE_NEXTION_TRIGGER_CUSTOM_BINARY_SENSOR
1600#ifdef USE_NEXTION_TRIGGER_CUSTOM_SENSOR
1602#endif // USE_NEXTION_TRIGGER_CUSTOM_SENSOR
1603#ifdef USE_NEXTION_TRIGGER_CUSTOM_SWITCH
1605#endif // USE_NEXTION_TRIGGER_CUSTOM_SWITCH
1606#ifdef USE_NEXTION_TRIGGER_CUSTOM_TEXT_SENSOR
1608#endif // USE_NEXTION_TRIGGER_CUSTOM_TEXT_SENSOR
1609
1611 optional<float> brightness_;
1612
1613#ifdef USE_NEXTION_CONFIG_DUMP_DEVICE_INFO
1614 std::string device_model_;
1616 std::string serial_number_;
1617 std::string flash_size_;
1618#endif // USE_NEXTION_CONFIG_DUMP_DEVICE_INFO
1619
1621
1622#ifdef NEXTION_PROTOCOL_LOG
1624#endif // NEXTION_PROTOCOL_LOG
1625 void reset_(bool reset_nextion = true);
1626
1627 std::string command_data_;
1629
1630 uint16_t startup_override_ms_ = 8000;
1631 uint16_t max_q_age_ms_ = 8000;
1632};
1633
1634} // namespace esphome::nextion
This class simplifies creating components that periodically check a state.
Definition component.h:602
Fixed-size circular buffer with FIFO semantics and iteration support.
Definition helpers.h:304
StringRef is a reference to a string owned by something else.
Definition string_ref.h:26
void set_spacing(uint8_t spacing_ms)
Set the minimum time between commands.
Definition nextion.h:49
uint8_t get_spacing() const
Get current command spacing.
Definition nextion.h:55
bool can_send(uint32_t now) const
Check if enough time has passed to send the next command.
Definition nextion.h:63
NextionCommandPacer(uint8_t initial_spacing=0)
Creates command pacer with initial spacing.
Definition nextion.h:43
void mark_sent(uint32_t now)
Record the transmit timestamp for the most recently sent command.
Definition nextion.h:71
void add_sleep_state_callback(F &&callback)
Add a callback to be notified of sleep state changes.
Definition nextion.h:1150
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:1586
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:1587
void set_component_drag(const char *component, bool drag)
Set the drag availability of a component.
std::vector< NextionComponentBase * > binarysensortype_
Definition nextion.h:1590
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.
StaticRingBuffer< NextionQueue *, 4 > waveform_queue_
Fixed-size ring buffer for waveform queue.
Definition nextion.h:1464
uint16_t max_q_age_ms_
Maximum age for queue items in ms.
Definition nextion.h:1631
bool send_command_(const std::string &command)
Manually send a raw command to the display and don't wait for an acknowledgement packet.
size_t get_max_queue_size() const
Get the maximum allowed queue size.
Definition nextion.h:108
uint8_t tft_upload_http_retries_
HTTP retry count (default: 5)
Definition nextion.h:1550
void set_max_queue_size(size_t size)
Set the maximum allowed queue size.
Definition nextion.h:102
std::vector< NextionComponentBase * > textsensortype_
Definition nextion.h:1589
void set_max_commands_per_loop(uint16_t value)
Set the maximum number of commands to process in each loop iteration.
Definition nextion.h:89
uint8_t auto_wake_on_touch_
Display should wake automatically on touch (default: true)
Definition nextion.h:1483
CallbackManager< void(uint8_t)> page_callback_
Definition nextion.h:1594
void add_custom_text_sensor_callback(F &&callback)
Add a callback to be notified when Nextion sends a custom text sensor protocol frame (0x92).
Definition nextion.h:1240
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:1059
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:1108
struct esphome::nextion::Nextion::@144 connection_state_
Status flags for Nextion display state management.
CallbackManager< void(StringRef, int32_t)> custom_sensor_callback_
Definition nextion.h:1601
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:1614
void set_nextion_rtc_time(ESPTime time)
Send the current time to the nextion display.
void all_components_send_state_(bool force_update=false)
void set_start_up_page(uint8_t start_up_page=255)
Sets which page Nextion loads when connecting to ESPHome.
Definition nextion.h:1341
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:1615
void set_nextion_sensor_state(int queue_type, const std::string &name, float state)
Set the nextion sensor state object.
void add_addt_command_to_queue(NextionComponentBase *component) override
uint16_t get_startup_override_ms() const
Get the startup override timeout.
Definition nextion.h:1434
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:1056
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:1438
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.
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
nextion_writer_t writer_
Definition nextion.h:1610
uint16_t startup_override_ms_
Timeout before forcing setup complete.
Definition nextion.h:1630
void add_to_get_queue(NextionComponentBase *component) override
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:1482
bool send_command_printf(const char *format,...) __attribute__((format(printf
Manually send a raw formatted command to the display.
void set_max_queue_age(uint16_t age_ms)
Set the maximum age for queue items.
Definition nextion.h:1416
WiFiClient * wifi_client_
Definition nextion.h:1540
std::list< NextionQueue * > nextion_queue_
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:176
bool void set_tft_upload_http_timeout(uint16_t timeout_ms)
Set the HTTP timeout for TFT upload requests.
Definition nextion.h:1087
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 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)
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:1549
void add_setup_state_callback(F &&callback)
Add a callback to be notified when the nextion completes its initialize setup.
Definition nextion.h:1166
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:1588
bool upload_end_(bool successful)
Ends the upload process, restart Nextion and, if successful, restarts ESP.
BearSSL::WiFiClientSecure * wifi_client_secure_
Definition nextion.h:1541
void set_component_coordinates(const char *component, uint16_t x, uint16_t y)
Set the coordinates of a component on screen.
void add_new_page_callback(F &&callback)
Add a callback to be notified when the nextion changes pages.
Definition nextion.h:1174
uint8_t sent_setup_commands_
Initial setup commands have been sent.
Definition nextion.h:1479
void add_no_result_to_queue_with_set(NextionComponentBase *component, const std::string &state_value) override
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
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:1591
void hide_component(const char *component) override
Hide a component.
std::string command_data_
Definition nextion.h:1627
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:1422
optional< float > brightness_
Definition nextion.h:1611
CallbackManager< void()> wake_callback_
Definition nextion.h:1593
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.
uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag)
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:1052
void set_startup_override_ms(uint16_t timeout_ms)
Set the startup override timeout.
Definition nextion.h:1428
void goto_page(const char *page)
Show the page with a given name.
void add_buffer_overflow_event_callback(F &&callback)
Add a callback to be notified when the nextion reports a buffer overflow.
Definition nextion.h:1188
void add_custom_binary_sensor_callback(F &&callback)
Add a callback to be notified when Nextion sends a custom binary sensor protocol frame (0x93).
Definition nextion.h:1201
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)
uint8_t reserved_
Reserved bits for future flag additions.
Definition nextion.h:1484
bool void add_no_result_to_queue_with_command_(const std::string &variable_name, const std::string &command)
void add_touch_event_callback(F &&callback)
Add a callback to be notified when Nextion has a touch event.
Definition nextion.h:1180
CallbackManager< void(StringRef, bool)> custom_binary_sensor_callback_
Definition nextion.h:1598
void set_wait_for_ack(bool wait_for_ack)
void set_nextion_sensor_state(NextionQueueType queue_type, const std::string &name, float state)
void register_switch_component(NextionComponentBase *obj)
Definition nextion.h:1053
void set_tft_upload_watchdog_timeout(uint32_t timeout_ms)
Set the watchdog timeout during TFT upload.
Definition nextion.h:1101
size_t queue_size()
Retrieves the number of commands pending in the Nextion command queue.
Definition nextion.h:1371
bool send_command(const char *command)
Manually send a raw command to the display.
std::string serial_number_
Definition nextion.h:1616
CallbackManager< void()> sleep_callback_
Definition nextion.h:1592
void add_custom_sensor_callback(F &&callback)
Add a callback to be notified when Nextion sends a custom sensor protocol frame (0x91).
Definition nextion.h:1214
void set_tft_url(const std::string &tft_url)
Set the tft file URL.
Definition nextion.h:1113
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:1480
void set_component_vid(const char *component, uint8_t vid_id)
Set the video id of a component.
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:1410
void reset_(bool reset_nextion=true)
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.
void add_no_result_to_queue_(const std::string &variable_name)
void add_wake_state_callback(F &&callback)
Add a callback to be notified of wake state changes.
Definition nextion.h:1158
CallbackManager< void(uint8_t, uint8_t, bool)> touch_callback_
Definition nextion.h:1595
void register_binarysensor_component(NextionComponentBase *obj)
Definition nextion.h:1054
uint16_t get_max_commands_per_loop() const
Get the current maximum number of commands allowed per loop iteration.
Definition nextion.h:95
void dump_config() override
void set_command_spacing(uint32_t spacing_ms)
Set the command spacing for the display.
Definition nextion.h:116
NextionCommandPacer command_pacer_
Definition nextion.h:1445
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)
void add_custom_switch_callback(F &&callback)
Add a callback to be notified when Nextion sends a custom switch protocol frame (0x90).
Definition nextion.h:1227
bool add_no_result_to_queue_with_ignore_sleep_printf_(const std::string &variable_name, const char *format,...) __attribute__((format(printf
void update() override
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:1478
CallbackManager< void()> buffer_overflow_callback_
Definition nextion.h:1596
void show_component(const char *component) override
Show a component.
void set_writer(const nextion_writer_t &writer)
CallbackManager< void(StringRef, StringRef)> custom_text_sensor_callback_
Definition nextion.h:1607
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.
void register_sensor_component(NextionComponentBase *obj)
Definition nextion.h:1055
void add_no_result_to_queue_with_set(NextionComponentBase *component, int32_t state_value) override
CallbackManager< void(StringRef, bool)> custom_switch_callback_
Definition nextion.h:1604
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)
uint32_t tft_upload_watchdog_timeout_
WDT timeout in ms (0 = no adjustment)
Definition nextion.h:1553
uint8_t nextion_reports_is_setup_
Nextion has reported successful initialization.
Definition nextion.h:1481
void set_backlight_brightness(float brightness)
Set the brightness of the backlight.
struct @65::@66 __attribute__
Wake the main loop task from an ISR. ISR-safe.
Definition main_task.h:32
const Component * component
Definition component.cpp:34
bool state
Definition fan.h:2
bool active_mode
const char int line
Definition log.h:74
const char int const __FlashStringHelper * format
Definition log.h:74
uint16_t size
Definition helpers.cpp:25
static void uint32_t
A more user-friendly version of struct tm from time.h.
Definition time.h:23
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6