mirror of
https://github.com/esphome/esphome.git
synced 2025-10-10 05:43:48 +01:00
Run clang-tidy against Arduino 3 (#2146)
* Add macros header with more usable Arduino version defines * Change Arduino version checking to use our version defines * Add missing ESP8266 check * Rename Arduino version macro to ARDUINO_VERSION_CODE * Upgrade clang-tidy to use Arduino 3 * Fix clang-tidy warnings * Upgrade NeoPixelBus to upstream 2.6.7 * Use Arduino-version-appropriate API to set redirect flags * Remove now unnecessary CLANG_TIDY ifdefs * Add preprocessor hackery to avoid including pgmspace.h * Bump base image to 4.1.1 and update lint * Fix nfctag * Fix make_unique ambiguous * Fix ignore name * Fix ambiguous v2 * Remove unused begin * Cast time_t to prevent issues on platforms where time_t is 32bit Co-authored-by: Otto winter <otto@otto-winter.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
#include "nextion.h"
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/macros.h"
|
||||
#include "esphome/core/util.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
@@ -26,8 +27,12 @@ int Nextion::upload_by_chunks_(HTTPClient *http, int range_start) {
|
||||
range_end = this->tft_size_;
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
#ifndef CLANG_TIDY
|
||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 7, 0)
|
||||
http->setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||
#elif ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||
http->setFollowRedirects(true);
|
||||
#endif
|
||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||
http->setRedirectLimit(3);
|
||||
#endif
|
||||
#endif
|
||||
@@ -44,10 +49,8 @@ int Nextion::upload_by_chunks_(HTTPClient *http, int range_start) {
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
begin_status = http->begin(this->tft_url_.c_str());
|
||||
#endif
|
||||
#ifndef CLANG_TIDY
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
begin_status = http->begin(*this->get_wifi_client_(), this->tft_url_.c_str());
|
||||
#endif
|
||||
#endif
|
||||
|
||||
++tries;
|
||||
@@ -140,11 +143,15 @@ void Nextion::upload_tft() {
|
||||
begin_status = http.begin(this->tft_url_.c_str());
|
||||
#endif
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
#ifndef CLANG_TIDY
|
||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 7, 0)
|
||||
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||
http.setRedirectLimit(3);
|
||||
begin_status = http.begin(*this->get_wifi_client_(), this->tft_url_.c_str());
|
||||
#elif ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||
http.setFollowRedirects(true);
|
||||
#endif
|
||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||
http.setRedirectLimit(3);
|
||||
#endif
|
||||
begin_status = http.begin(*this->get_wifi_client_(), this->tft_url_.c_str());
|
||||
#endif
|
||||
|
||||
if (!begin_status) {
|
||||
@@ -256,6 +263,7 @@ void Nextion::upload_tft() {
|
||||
}
|
||||
}
|
||||
#else
|
||||
// NOLINTNEXTLINE(readability-static-accessed-through-instance)
|
||||
uint32_t chunk_size = ESP.getFreeHeap() < 10240 ? 4096 : 8192;
|
||||
#endif
|
||||
|
||||
@@ -270,6 +278,7 @@ void Nextion::upload_tft() {
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
// NOLINTNEXTLINE(readability-static-accessed-through-instance)
|
||||
ESP_LOGD(TAG, "Allocating buffer size %d, Heap size is %u", chunk_size, ESP.getFreeHeap());
|
||||
this->transfer_buffer_ = new (std::nothrow) uint8_t[chunk_size]; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
if (this->transfer_buffer_ == nullptr) { // Try a smaller size
|
||||
@@ -288,6 +297,7 @@ void Nextion::upload_tft() {
|
||||
this->transfer_buffer_size_ = chunk_size;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(readability-static-accessed-through-instance)
|
||||
ESP_LOGD(TAG, "Updating tft from \"%s\" with a file size of %d using %zu chunksize, Heap Size %d",
|
||||
this->tft_url_.c_str(), this->content_length_, this->transfer_buffer_size_, ESP.getFreeHeap());
|
||||
|
||||
@@ -299,6 +309,7 @@ void Nextion::upload_tft() {
|
||||
this->upload_end_();
|
||||
}
|
||||
App.feed_wdt();
|
||||
// NOLINTNEXTLINE(readability-static-accessed-through-instance)
|
||||
ESP_LOGD(TAG, "Heap Size %d, Bytes left %d", ESP.getFreeHeap(), this->content_length_);
|
||||
}
|
||||
ESP_LOGD(TAG, "Successfully updated Nextion!");
|
||||
@@ -311,7 +322,7 @@ void Nextion::upload_end_() {
|
||||
this->soft_reset();
|
||||
delay(1500); // NOLINT
|
||||
ESP_LOGD(TAG, "Restarting esphome");
|
||||
ESP.restart();
|
||||
ESP.restart(); // NOLINT(readability-static-accessed-through-instance)
|
||||
}
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
|
Reference in New Issue
Block a user