Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/esphome/esphome into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
clydebarrow committed May 2, 2024
2 parents e27d558 + bc65e6e commit 6bd6c9b
Show file tree
Hide file tree
Showing 32 changed files with 1,065 additions and 686 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ esphome/components/mpl3115a2/* @kbickar
esphome/components/mpu6886/* @fabaff
esphome/components/ms8607/* @e28eta
esphome/components/network/* @esphome/core
esphome/components/nextion/* @senexcrenshaw
esphome/components/nextion/* @edwardtfn @senexcrenshaw
esphome/components/nextion/binary_sensor/* @senexcrenshaw
esphome/components/nextion/sensor/* @senexcrenshaw
esphome/components/nextion/switch/* @senexcrenshaw
Expand Down
7 changes: 6 additions & 1 deletion esphome/components/mqtt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@

DEPENDENCIES = ["network"]

AUTO_LOAD = ["json"]

def AUTO_LOAD():
if CORE.is_esp8266 or CORE.is_libretiny:
return ["async_tcp", "json"]
return ["json"]


CONF_IDF_SEND_ASYNC = "idf_send_async"
CONF_SKIP_CERT_CN_CHECK = "skip_cert_cn_check"
Expand Down
2 changes: 1 addition & 1 deletion esphome/components/nextion/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
CONF_EXIT_REPARSE_ON_START,
)

CODEOWNERS = ["@senexcrenshaw"]
CODEOWNERS = ["@senexcrenshaw", "@edwardtfn"]

DEPENDENCIES = ["uart"]
AUTO_LOAD = ["binary_sensor", "switch", "sensor", "text_sensor"]
Expand Down
61 changes: 25 additions & 36 deletions esphome/components/nextion/nextion.h
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
* @return Whether the send was successful.
*/
bool send_command(const char *command);

/**
* Manually send a raw formatted command to the display.
* @param format The printf-style command format, like "vis %s,0"
Expand All @@ -989,7 +990,6 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
* Set the tft file URL. https seems problematic with arduino..
*/
void set_tft_url(const std::string &tft_url) { this->tft_url_ = tft_url; }
#endif

/**
* @brief Uploads the TFT file to the Nextion display.
Expand All @@ -1013,6 +1013,8 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
*/
bool upload_tft(uint32_t baud_rate = 0, bool exit_reparse = true);

#endif // USE_NEXTION_TFT_UPLOAD

void dump_config() override;

/**
Expand Down Expand Up @@ -1134,11 +1136,13 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
void all_components_send_state_(bool force_update = false);
uint64_t comok_sent_ = 0;
bool remove_from_q_(bool report_empty = true);

/**
* @brief
* Sends commands ignoring of the Nextion has been setup.
*/
bool ignore_is_setup_ = false;

bool nextion_reports_is_setup_ = false;
uint8_t nextion_event_;

Expand Down Expand Up @@ -1175,65 +1179,50 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
void check_pending_waveform_();

#ifdef USE_NEXTION_TFT_UPLOAD
uint32_t content_length_ = 0;
int tft_size_ = 0;
uint32_t original_baud_rate_ = 0;
bool upload_first_chunk_sent_ = false;

std::string tft_url_;
uint8_t *transfer_buffer_{nullptr};
size_t transfer_buffer_size_;

#ifdef USE_ESP8266
WiFiClient *wifi_client_{nullptr};
BearSSL::WiFiClientSecure *wifi_client_secure_{nullptr};
WiFiClient *get_wifi_client_();
#endif
#endif // USE_ESP8266
std::string tft_url_;
uint32_t content_length_ = 0;
int tft_size_ = 0;
uint32_t original_baud_rate_ = 0;
bool upload_first_chunk_sent_ = false;

#ifdef ARDUINO
/**
* will request chunk_size chunks from the web server
* and send each to the nextion
* @param HTTPClient http HTTP client handler.
* @param HTTPClient http_client HTTP client handler.
* @param int range_start Position of next byte to transfer.
* @return position of last byte transferred, -1 for failure.
*/
int upload_by_chunks_(HTTPClient *http, int range_start);

bool upload_with_range_(uint32_t range_start, uint32_t range_end);

/**
* start update tft file to nextion.
*
* @param const uint8_t *file_buf
* @param size_t buf_size
* @return true if success, false for failure.
*/
bool upload_from_buffer_(const uint8_t *file_buf, size_t buf_size);
/**
* Ends the upload process, restart Nextion and, if successful,
* restarts ESP
* @param bool url successful True: Transfer completed successfuly, False: Transfer failed.
* @return bool True: Transfer completed successfuly, False: Transfer failed.
*/
bool upload_end_(bool successful);
int upload_by_chunks_(HTTPClient &http_client, uint32_t &range_start);
#elif defined(USE_ESP_IDF)
/**
* will request 4096 bytes chunks from the web server
* and send each to Nextion
* @param std::string url Full url for download.
* @param esp_http_client_handle_t http_client HTTP client handler.
* @param int range_start Position of next byte to transfer.
* @return position of last byte transferred, -1 for failure.
*/
int upload_range(const std::string &url, int range_start);
int upload_by_chunks_(esp_http_client_handle_t http_client, uint32_t &range_start);
#endif // ARDUINO vs USE_ESP_IDF

/**
* Ends the upload process, restart Nextion and, if successful,
* restarts ESP
* @param bool url successful True: Transfer completed successfuly, False: Transfer failed.
* @return bool True: Transfer completed successfuly, False: Transfer failed.
*/
bool upload_end(bool successful);
#endif // ARDUINO vs ESP-IDF
bool upload_end_(bool successful);

/**
* Returns the ESP Free Heap memory. This is framework independent.
* @return Free Heap in bytes.
*/
uint32_t get_free_heap_();

#endif // USE_NEXTION_TFT_UPLOAD

Expand Down Expand Up @@ -1264,7 +1253,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe

#ifdef NEXTION_PROTOCOL_LOG
void print_queue_members_();
#endif
#endif // NEXTION_PROTOCOL_LOG
void reset_(bool reset_nextion = true);

std::string command_data_;
Expand Down
Loading

0 comments on commit 6bd6c9b

Please sign in to comment.