ESPHome  2024.12.2
nextion.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <deque>
4 #include <vector>
5 
6 #include "esphome/core/defines.h"
7 #include "esphome/core/time.h"
8 
10 #include "nextion_base.h"
11 #include "nextion_component.h"
13 
14 #ifdef USE_NEXTION_TFT_UPLOAD
15 #ifdef USE_ARDUINO
16 #ifdef USE_ESP32
17 #include <HTTPClient.h>
18 #endif // USE_ESP32
19 #ifdef USE_ESP8266
20 #include <ESP8266HTTPClient.h>
21 #include <WiFiClientSecure.h>
22 #endif // USE_ESP8266
23 #elif defined(USE_ESP_IDF)
24 #include <esp_http_client.h>
25 #endif // ARDUINO vs USE_ESP_IDF
26 #endif // USE_NEXTION_TFT_UPLOAD
27 
28 namespace esphome {
29 namespace nextion {
30 
31 class Nextion;
32 class NextionComponentBase;
33 
34 using nextion_writer_t = std::function<void(Nextion &)>;
35 
36 static const std::string COMMAND_DELIMITER{static_cast<char>(255), static_cast<char>(255), static_cast<char>(255)};
37 
38 class Nextion : public NextionBase, public PollingComponent, public uart::UARTDevice {
39  public:
52  void set_component_text(const char *component, const char *text);
53 
69  void set_component_text_printf(const char *component, const char *format, ...) __attribute__((format(printf, 3, 4)));
70 
83  void set_component_value(const char *component, int32_t value);
84 
97  void set_component_picture(const char *component, uint8_t picture_id);
98 
113  void set_component_background_color(const char *component, uint16_t color);
114 
128  void set_component_background_color(const char *component, const char *color);
129 
143  void set_component_background_color(const char *component, Color color) override;
144 
160  void set_component_pressed_background_color(const char *component, uint16_t color);
161 
176  void set_component_pressed_background_color(const char *component, const char *color);
177 
192  void set_component_pressed_background_color(const char *component, Color color) override;
193 
208  void set_component_foreground_color(const char *component, uint16_t color);
209 
223  void set_component_foreground_color(const char *component, const char *color);
224 
237  void set_component_foreground_color(const char *component, Color color) override;
238 
254  void set_component_pressed_foreground_color(const char *component, uint16_t color);
255 
270  void set_component_pressed_foreground_color(const char *component, const char *color);
271 
286  void set_component_pressed_foreground_color(const char *component, Color color) override;
287 
300  void set_component_pic(const char *component, uint8_t pic_id);
301 
314  void set_component_picc(const char *component, uint8_t pic_id);
315 
330  void set_component_font_color(const char *component, uint16_t color);
331 
345  void set_component_font_color(const char *component, const char *color);
346 
359  void set_component_font_color(const char *component, Color color) override;
360 
375  void set_component_pressed_font_color(const char *component, uint16_t color);
376 
390  void set_component_pressed_font_color(const char *component, const char *color);
391 
404  void set_component_pressed_font_color(const char *component, Color color) override;
405 
419  void set_component_coordinates(const char *component, uint16_t x, uint16_t y);
420 
433  void set_component_font(const char *component, uint8_t font_id) override;
434 
439  void set_nextion_rtc_time(ESPTime time);
440 
452  void goto_page(const char *page);
453 
465  void goto_page(uint8_t page);
466 
478  void hide_component(const char *component) override;
479 
491  void show_component(const char *component) override;
492 
504  void enable_component_touch(const char *component);
505 
517  void disable_component_touch(const char *component);
518 
525  void add_waveform_data(uint8_t component_id, uint8_t channel_number, uint8_t value);
526 
527  void open_waveform_channel(uint8_t component_id, uint8_t channel_number, uint8_t value);
528 
542  void display_picture(uint16_t picture_id, uint16_t x_start, uint16_t y_start);
543 
562  void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color);
563 
581  void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, const char *color);
582 
600  void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, Color color);
601 
620  void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
621 
639  void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char *color);
640 
658  void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, Color color);
659 
678  void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color);
679 
697  void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, const char *color);
698 
716  void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, Color color);
717 
727  void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color);
728 
737  void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, const char *color);
738 
746  void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, Color color);
747 
764  void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color);
765 
781  void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, const char *color);
782 
798  void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, Color color);
799 
818  void qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size = 200, uint16_t background_color = 65535,
819  uint16_t foreground_color = 0, uint8_t logo_pic = -1, uint8_t border_width = 8);
820 
842  void qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size,
843  Color background_color = Color(255, 255, 255), Color foreground_color = Color(0, 0, 0),
844  uint8_t logo_pic = -1, uint8_t border_width = 8);
845 
857  void set_backlight_brightness(float brightness);
858 
871  void set_touch_sleep_timeout(uint16_t timeout);
872 
885  void set_wake_up_page(uint8_t page_id = 255);
886 
899  void set_start_up_page(uint8_t page_id = 255);
900 
913  void set_auto_wake_on_touch(bool auto_wake);
914 
927  void set_exit_reparse_on_start(bool exit_reparse);
928 
942  void set_skip_connection_handshake(bool skip_handshake) { this->skip_connection_handshake_ = skip_handshake; }
943 
948  void sleep(bool sleep);
949 
969 
970  // ======== Nextion Intelligent Series ========
971 
986  void set_component_vid(const char *component, uint8_t vid_id);
987 
1002  void set_component_drag(const char *component, bool drag);
1003 
1018  void set_component_aph(const char *component, uint8_t aph);
1019 
1035  void set_component_position(const char *component, uint32_t x, uint32_t y);
1036 
1037  // ========== INTERNAL METHODS ==========
1038  // (In most use cases you won't need these)
1039  void register_touch_component(NextionComponentBase *obj) { this->touch_.push_back(obj); }
1040  void register_switch_component(NextionComponentBase *obj) { this->switchtype_.push_back(obj); }
1042  void register_sensor_component(NextionComponentBase *obj) { this->sensortype_.push_back(obj); }
1044 
1045  void setup() override;
1046  void set_brightness(float brightness) { this->brightness_ = brightness; }
1047  float get_setup_priority() const override;
1048  void update() override;
1049  void loop() override;
1050  void set_writer(const nextion_writer_t &writer);
1051 
1052  // This function has been deprecated
1053  void set_wait_for_ack(bool wait_for_ack);
1054 
1060  bool send_command(const char *command);
1061 
1068  bool send_command_printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
1069 
1070 #ifdef USE_NEXTION_TFT_UPLOAD
1071 
1074  void set_tft_url(const std::string &tft_url) { this->tft_url_ = tft_url; }
1075 
1096  bool upload_tft(uint32_t baud_rate = 0, bool exit_reparse = true);
1097 
1098 #endif // USE_NEXTION_TFT_UPLOAD
1099 
1100  void dump_config() override;
1101 
1105  void soft_reset();
1106 
1111  void add_sleep_state_callback(std::function<void()> &&callback);
1112 
1117  void add_wake_state_callback(std::function<void()> &&callback);
1118 
1123  void add_setup_state_callback(std::function<void()> &&callback);
1124 
1129  void add_new_page_callback(std::function<void(uint8_t)> &&callback);
1130 
1135  void add_touch_event_callback(std::function<void(uint8_t, uint8_t, bool)> &&callback);
1136 
1141  void add_buffer_overflow_event_callback(std::function<void()> &&callback);
1142 
1143  void update_all_components();
1144 
1157  void set_nextion_sensor_state(int queue_type, const std::string &name, float state);
1158  void set_nextion_sensor_state(NextionQueueType queue_type, const std::string &name, float state);
1159  void set_nextion_text_state(const std::string &name, const std::string &state);
1160 
1161  void add_no_result_to_queue_with_set(NextionComponentBase *component, int32_t state_value) override;
1162  void add_no_result_to_queue_with_set(const std::string &variable_name, const std::string &variable_name_to_send,
1163  int32_t state_value) override;
1164 
1165  void add_no_result_to_queue_with_set(NextionComponentBase *component, const std::string &state_value) override;
1166  void add_no_result_to_queue_with_set(const std::string &variable_name, const std::string &variable_name_to_send,
1167  const std::string &state_value) override;
1168 
1169  void add_to_get_queue(NextionComponentBase *component) override;
1170 
1171  void add_addt_command_to_queue(NextionComponentBase *component) override;
1172 
1173  void update_components_by_prefix(const std::string &prefix);
1174 
1175  void set_touch_sleep_timeout_internal(uint32_t touch_sleep_timeout) {
1176  this->touch_sleep_timeout_ = touch_sleep_timeout;
1177  }
1178  void set_wake_up_page_internal(uint8_t wake_up_page) { this->wake_up_page_ = wake_up_page; }
1179  void set_start_up_page_internal(uint8_t start_up_page) { this->start_up_page_ = start_up_page; }
1180  void set_auto_wake_on_touch_internal(bool auto_wake_on_touch) { this->auto_wake_on_touch_ = auto_wake_on_touch; }
1181  void set_exit_reparse_on_start_internal(bool exit_reparse_on_start) {
1182  this->exit_reparse_on_start_ = exit_reparse_on_start;
1183  }
1184 
1198  size_t queue_size() { return this->nextion_queue_.size(); }
1199 
1218  bool is_updating() override;
1219 
1220  protected:
1221  std::deque<NextionQueue *> nextion_queue_;
1222  std::deque<NextionQueue *> waveform_queue_;
1223  uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag);
1224  void all_components_send_state_(bool force_update = false);
1225  uint64_t comok_sent_ = 0;
1226  bool remove_from_q_(bool report_empty = true);
1227 
1232  bool ignore_is_setup_ = false;
1233 
1236 
1238  void process_serial_();
1239  bool is_updating_ = false;
1240  uint32_t touch_sleep_timeout_ = 0;
1241  int16_t wake_up_page_ = -1;
1242  int16_t start_up_page_ = -1;
1243  bool auto_wake_on_touch_ = true;
1246 
1251  bool send_command_(const std::string &command);
1252  void add_no_result_to_queue_(const std::string &variable_name);
1253  bool add_no_result_to_queue_with_ignore_sleep_printf_(const std::string &variable_name, const char *format, ...)
1254  __attribute__((format(printf, 3, 4)));
1255  void add_no_result_to_queue_with_command_(const std::string &variable_name, const std::string &command);
1256 
1257  bool add_no_result_to_queue_with_printf_(const std::string &variable_name, const char *format, ...)
1258  __attribute__((format(printf, 3, 4)));
1259 
1260  void add_no_result_to_queue_with_set_internal_(const std::string &variable_name,
1261  const std::string &variable_name_to_send, int32_t state_value,
1262  bool is_sleep_safe = false);
1263 
1264  void add_no_result_to_queue_with_set_internal_(const std::string &variable_name,
1265  const std::string &variable_name_to_send,
1266  const std::string &state_value, bool is_sleep_safe = false);
1267 
1268  void check_pending_waveform_();
1269 
1270 #ifdef USE_NEXTION_TFT_UPLOAD
1271 #ifdef USE_ESP8266
1272  WiFiClient *wifi_client_{nullptr};
1273  BearSSL::WiFiClientSecure *wifi_client_secure_{nullptr};
1274  WiFiClient *get_wifi_client_();
1275 #endif // USE_ESP8266
1276  std::string tft_url_;
1277  uint32_t content_length_ = 0;
1278  int tft_size_ = 0;
1279  uint32_t original_baud_rate_ = 0;
1281 
1282 #ifdef USE_ARDUINO
1283 
1290  int upload_by_chunks_(HTTPClient &http_client, uint32_t &range_start);
1291 #elif defined(USE_ESP_IDF)
1292 
1299  int upload_by_chunks_(esp_http_client_handle_t http_client, uint32_t &range_start);
1300 #endif // USE_ARDUINO vs USE_ESP_IDF
1301 
1308  bool upload_end_(bool successful);
1309 
1314  uint32_t get_free_heap_();
1315 
1316 #endif // USE_NEXTION_TFT_UPLOAD
1317 
1318  bool get_is_connected_() { return this->is_connected_; }
1319 
1320  bool check_connect_();
1321 
1322  std::vector<NextionComponentBase *> touch_;
1323  std::vector<NextionComponentBase *> switchtype_;
1324  std::vector<NextionComponentBase *> sensortype_;
1325  std::vector<NextionComponentBase *> textsensortype_;
1326  std::vector<NextionComponentBase *> binarysensortype_;
1333 
1335  float brightness_{1.0};
1336 
1337  std::string device_model_;
1338  std::string firmware_version_;
1339  std::string serial_number_;
1340  std::string flash_size_;
1341 
1342  void remove_front_no_sensors_();
1343 
1344 #ifdef NEXTION_PROTOCOL_LOG
1345  void print_queue_members_();
1346 #endif // NEXTION_PROTOCOL_LOG
1347  void reset_(bool reset_nextion = true);
1348 
1349  std::string command_data_;
1350  bool is_connected_ = false;
1351  const uint16_t startup_override_ms_ = 8000;
1352  const uint16_t max_q_age_ms_ = 8000;
1353  uint32_t started_ms_ = 0;
1354  bool sent_setup_commands_ = false;
1355 };
1356 } // namespace nextion
1357 } // namespace esphome
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.
Definition: nextion.h:1232
const uint16_t startup_override_ms_
Definition: nextion.h:1351
void all_components_send_state_(bool force_update=false)
Definition: nextion.cpp:880
CallbackManager< void(uint8_t)> page_callback_
Definition: nextion.h:1330
CallbackManager< void()> sleep_callback_
Definition: nextion.h:1328
const char * name
Definition: stm32flash.h:78
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.
Definition: nextion.cpp:185
void add_waveform_data(uint8_t component_id, uint8_t channel_number, uint8_t value)
Add waveform data to a waveform component.
void set_start_up_page_internal(uint8_t start_up_page)
Definition: nextion.h:1179
void add_wake_state_callback(std::function< void()> &&callback)
Add a callback to be notified of wake state changes.
Definition: nextion.cpp:177
bool send_command(const char *command)
Manually send a raw command to the display.
Definition: nextion.cpp:215
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.
Definition: nextion.cpp:226
bool upload_tft(uint32_t baud_rate=0, bool exit_reparse=true)
Uploads the TFT file to the Nextion display.
void add_addt_command_to_queue(NextionComponentBase *component) override
Add addt command to the queue.
Definition: nextion.cpp:1132
bool is_updating() override
Check if the TFT update process is currently running.
Definition: nextion.cpp:1169
void circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color)
Draw a circle outline.
void add_to_get_queue(NextionComponentBase *component) override
Definition: nextion.cpp:1104
std::vector< NextionComponentBase * > touch_
Definition: nextion.h:1322
optional< nextion_writer_t > writer_
Definition: nextion.h:1334
uint16_t x
Definition: tt21100.cpp:17
bool void set_tft_url(const std::string &tft_url)
Set the tft file URL.
Definition: nextion.h:1074
void set_component_position(const char *component, uint32_t x, uint32_t y)
Set the position of a component.
uint32_t get_free_heap_()
Returns the ESP Free Heap memory.
A more user-friendly version of struct tm from time.h.
Definition: time.h:15
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:181
void set_skip_connection_handshake(bool skip_handshake)
Sets whether the Nextion display should skip the connection handshake process.
Definition: nextion.h:942
CallbackManager< void()> buffer_overflow_callback_
Definition: nextion.h:1332
const uint16_t max_q_age_ms_
Definition: nextion.h:1352
bool send_command_(const std::string &command)
Manually send a raw command to the display and don&#39;t wait for an acknowledgement packet.
Definition: nextion.cpp:29
STL namespace.
void set_component_vid(const char *component, uint8_t vid_id)
Set the video id of a component.
float get_setup_priority() const override
Definition: nextion.cpp:163
void set_wake_up_page_internal(uint8_t wake_up_page)
Definition: nextion.h:1178
void setup() override
Definition: nextion.cpp:12
std::string serial_number_
Definition: nextion.h:1339
void set_brightness(float brightness)
Definition: nextion.h:1046
void register_binarysensor_component(NextionComponentBase *obj)
Definition: nextion.h:1041
void register_touch_component(NextionComponentBase *obj)
Definition: nextion.h:1039
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.
Definition: component.h:283
BearSSL::WiFiClientSecure * wifi_client_secure_
Definition: nextion.h:1273
void disable_component_touch(const char *component)
Disable touch for a component.
CallbackManager< void(uint8_t, uint8_t, bool)> touch_callback_
Definition: nextion.h:1331
bool upload_end_(bool successful)
Ends the upload process, restart Nextion and, if successful, restarts ESP.
void rectangle(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color)
Draw a rectangle outline.
void add_buffer_overflow_event_callback(std::function< void()> &&callback)
Add a callback to be notified when the nextion reports a buffer overflow.
Definition: nextion.cpp:193
void set_exit_reparse_on_start(bool exit_reparse)
Sets if Nextion should exit the active reparse mode before the "connect" command is sent...
bool active_mode
void show_component(const char *component) override
Show a component.
uint16_t y
Definition: tt21100.cpp:18
void register_sensor_component(NextionComponentBase *obj)
Definition: nextion.h:1042
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:1029
void add_sleep_state_callback(std::function< void()> &&callback)
Add a callback to be notified of sleep state changes.
Definition: nextion.cpp:173
void register_switch_component(NextionComponentBase *obj)
Definition: nextion.h:1040
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.
std::string flash_size_
Definition: nextion.h:1340
void set_component_background_color(const char *component, uint16_t color)
Set the background color of a component.
void set_component_text_printf(const char *component, const char *format,...) __attribute__((format(printf
Set the text of a component to a formatted string.
int upload_by_chunks_(HTTPClient &http_client, uint32_t &range_start)
will request chunk_size chunks from the web server and send each to the nextion
void set_nextion_sensor_state(int queue_type, const std::string &name, float state)
Set the nextion sensor state object.
Definition: nextion.cpp:823
CallbackManager< void()> setup_callback_
Definition: nextion.h:1327
bool set_protocol_reparse_mode(bool active_mode)
Sets the Nextion display&#39;s protocol reparse mode.
void set_nextion_text_state(const std::string &name, const std::string &state)
Definition: nextion.cpp:867
void set_wait_for_ack(bool wait_for_ack)
void line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Draw a line on the screen.
void loop() override
Definition: nextion.cpp:267
void set_touch_sleep_timeout_internal(uint32_t touch_sleep_timeout)
Definition: nextion.h:1175
std::deque< NextionQueue * > nextion_queue_
Definition: nextion.h:1221
CallbackManager< void()> wake_callback_
Definition: nextion.h:1329
void set_auto_wake_on_touch_internal(bool auto_wake_on_touch)
Definition: nextion.h:1180
void set_component_text(const char *component, const char *text)
Set the text of a component to a static string.
uint32_t original_baud_rate_
Definition: nextion.h:1279
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)
Definition: nextion.cpp:973
std::deque< NextionQueue * > waveform_queue_
Definition: nextion.h:1222
void set_component_font(const char *component, uint8_t font_id) override
Set the font id for a component.
std::string command_data_
Definition: nextion.h:1349
enum esphome::EntityCategory __attribute__
void enable_component_touch(const char *component)
Enable touch for a component.
bool remove_from_q_(bool report_empty=true)
Definition: nextion.cpp:312
void fill_area(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t color)
Fill a rectangle with a color.
void set_backlight_brightness(float brightness)
Set the brightness of the backlight.
std::string device_model_
Definition: nextion.h:1337
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:1066
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
Definition: nextion.cpp:1003
void register_textsensor_component(NextionComponentBase *obj)
Definition: nextion.h:1043
void set_touch_sleep_timeout(uint16_t timeout)
Set the touch sleep timeout of the display.
std::vector< NextionComponentBase * > textsensortype_
Definition: nextion.h:1325
void display_picture(uint16_t picture_id, uint16_t x_start, uint16_t y_start)
Display a picture at coordinates.
void add_touch_event_callback(std::function< void(uint8_t, uint8_t, bool)> &&callback)
Add a callback to be notified when Nextion has a touch event.
Definition: nextion.cpp:189
void set_wake_up_page(uint8_t page_id=255)
Sets which page Nextion loads when exiting sleep mode.
std::vector< NextionComponentBase * > sensortype_
Definition: nextion.h:1324
void dump_config() override
Definition: nextion.cpp:137
void filled_circle(uint16_t center_x, uint16_t center_y, uint16_t radius, uint16_t color)
Draw a filled circled.
std::vector< NextionComponentBase * > switchtype_
Definition: nextion.h:1323
WiFiClient * wifi_client_
Definition: nextion.h:1272
void set_auto_wake_on_touch(bool auto_wake)
Sets if Nextion should auto-wake from sleep when touch press occurs.
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void void set_component_value(const char *component, int32_t value)
Set the integer value of a component.
void set_start_up_page(uint8_t page_id=255)
Sets which page Nextion loads when connecting to ESPHome.
bool void add_no_result_to_queue_with_command_(const std::string &variable_name, const std::string &command)
Definition: nextion.cpp:994
void reset_(bool reset_nextion=true)
Definition: nextion.cpp:127
void set_exit_reparse_on_start_internal(bool exit_reparse_on_start)
Definition: nextion.h:1181
void qrcode(uint16_t x1, uint16_t y1, const char *content, uint16_t size=200, uint16_t background_color=65535, uint16_t foreground_color=0, uint8_t logo_pic=-1, uint8_t border_width=8)
Draws a QR code in the screen.
void update_components_by_prefix(const std::string &prefix)
Definition: nextion.cpp:900
void update() override
Definition: nextion.cpp:164
std::string firmware_version_
Definition: nextion.h:1338
void set_component_foreground_color(const char *component, uint16_t color)
Set the foreground color of a component.
void set_component_coordinates(const char *component, uint16_t x, uint16_t y)
Set the coordinates of a component on screen.
void set_component_aph(const char *component, uint8_t aph)
Set the opaqueness (fading) of a component.
void set_component_pressed_font_color(const char *component, uint16_t color)
Set the pressed font color of a component.
size_t queue_size()
Retrieves the number of commands pending in the Nextion command queue.
Definition: nextion.h:1198
void set_component_drag(const char *component, bool drag)
Set the drag availability of a component.
uint32_t touch_sleep_timeout_
Definition: nextion.h:1240
uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag)
Definition: nextion.cpp:919
void add_no_result_to_queue_with_set(NextionComponentBase *component, int32_t state_value) override
Definition: nextion.cpp:1056
void open_waveform_channel(uint8_t component_id, uint8_t channel_number, uint8_t value)
std::function< void(Nextion &)> nextion_writer_t
Definition: nextion.h:34
std::vector< NextionComponentBase * > binarysensortype_
Definition: nextion.h:1326
bool state
Definition: fan.h:34
void set_writer(const nextion_writer_t &writer)
Definition: nextion.cpp:1164