mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Clean up RAMAllocators in display related code (#9141)
This commit is contained in:
		| @@ -11,7 +11,7 @@ namespace display { | ||||
| static const char *const TAG = "display"; | ||||
|  | ||||
| void DisplayBuffer::init_internal_(uint32_t buffer_length) { | ||||
|   ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE); | ||||
|   RAMAllocator<uint8_t> allocator; | ||||
|   this->buffer_ = allocator.allocate(buffer_length); | ||||
|   if (this->buffer_ == nullptr) { | ||||
|     ESP_LOGE(TAG, "Could not allocate buffer for display!"); | ||||
|   | ||||
| @@ -67,10 +67,10 @@ class Font | ||||
|   inline int get_height() { return this->height_; } | ||||
|   inline int get_bpp() { return this->bpp_; } | ||||
|  | ||||
|   const std::vector<Glyph, ExternalRAMAllocator<Glyph>> &get_glyphs() const { return glyphs_; } | ||||
|   const std::vector<Glyph, RAMAllocator<Glyph>> &get_glyphs() const { return glyphs_; } | ||||
|  | ||||
|  protected: | ||||
|   std::vector<Glyph, ExternalRAMAllocator<Glyph>> glyphs_; | ||||
|   std::vector<Glyph, RAMAllocator<Glyph>> glyphs_; | ||||
|   int baseline_; | ||||
|   int height_; | ||||
|   uint8_t bpp_;  // bits per pixel | ||||
|   | ||||
| @@ -57,8 +57,8 @@ void Inkplate6::setup() { | ||||
|  * Allocate buffers. May be called after setup to re-initialise if e.g. greyscale is changed. | ||||
|  */ | ||||
| void Inkplate6::initialize_() { | ||||
|   ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE); | ||||
|   ExternalRAMAllocator<uint32_t> allocator32(ExternalRAMAllocator<uint32_t>::ALLOW_FAILURE); | ||||
|   RAMAllocator<uint8_t> allocator; | ||||
|   RAMAllocator<uint32_t> allocator32; | ||||
|   uint32_t buffer_size = this->get_buffer_length_(); | ||||
|   if (buffer_size == 0) | ||||
|     return; | ||||
|   | ||||
| @@ -1,8 +1,8 @@ | ||||
| #include "nextion.h" | ||||
| #include "esphome/core/util.h" | ||||
| #include "esphome/core/log.h" | ||||
| #include "esphome/core/application.h" | ||||
| #include <cinttypes> | ||||
| #include "esphome/core/application.h" | ||||
| #include "esphome/core/log.h" | ||||
| #include "esphome/core/util.h" | ||||
|  | ||||
| namespace esphome { | ||||
| namespace nextion { | ||||
| @@ -1003,7 +1003,7 @@ void Nextion::add_no_result_to_queue_(const std::string &variable_name) { | ||||
|   } | ||||
| #endif | ||||
|  | ||||
|   ExternalRAMAllocator<nextion::NextionQueue> allocator(ExternalRAMAllocator<nextion::NextionQueue>::ALLOW_FAILURE); | ||||
|   RAMAllocator<nextion::NextionQueue> allocator; | ||||
|   nextion::NextionQueue *nextion_queue = allocator.allocate(1); | ||||
|   if (nextion_queue == nullptr) { | ||||
|     ESP_LOGW(TAG, "Queue alloc failed"); | ||||
| @@ -1159,7 +1159,7 @@ void Nextion::add_to_get_queue(NextionComponentBase *component) { | ||||
|   } | ||||
| #endif | ||||
|  | ||||
|   ExternalRAMAllocator<nextion::NextionQueue> allocator(ExternalRAMAllocator<nextion::NextionQueue>::ALLOW_FAILURE); | ||||
|   RAMAllocator<nextion::NextionQueue> allocator; | ||||
|   nextion::NextionQueue *nextion_queue = allocator.allocate(1); | ||||
|   if (nextion_queue == nullptr) { | ||||
|     ESP_LOGW(TAG, "Queue alloc failed"); | ||||
| @@ -1191,7 +1191,7 @@ void Nextion::add_addt_command_to_queue(NextionComponentBase *component) { | ||||
|   if ((!this->is_setup() && !this->ignore_is_setup_) || this->is_sleeping()) | ||||
|     return; | ||||
|  | ||||
|   ExternalRAMAllocator<nextion::NextionQueue> allocator(ExternalRAMAllocator<nextion::NextionQueue>::ALLOW_FAILURE); | ||||
|   RAMAllocator<nextion::NextionQueue> allocator; | ||||
|   nextion::NextionQueue *nextion_queue = allocator.allocate(1); | ||||
|   if (nextion_queue == nullptr) { | ||||
|     ESP_LOGW(TAG, "Queue alloc failed"); | ||||
|   | ||||
| @@ -3,12 +3,12 @@ | ||||
| #ifdef USE_NEXTION_TFT_UPLOAD | ||||
| #ifdef USE_ARDUINO | ||||
|  | ||||
| #include <cinttypes> | ||||
| #include "esphome/components/network/util.h" | ||||
| #include "esphome/core/application.h" | ||||
| #include "esphome/core/defines.h" | ||||
| #include "esphome/core/util.h" | ||||
| #include "esphome/core/log.h" | ||||
| #include "esphome/components/network/util.h" | ||||
| #include <cinttypes> | ||||
| #include "esphome/core/util.h" | ||||
|  | ||||
| #ifdef USE_ESP32 | ||||
| #include <esp_heap_caps.h> | ||||
| @@ -52,7 +52,7 @@ int Nextion::upload_by_chunks_(HTTPClient &http_client, uint32_t &range_start) { | ||||
|   } | ||||
|  | ||||
|   // Allocate the buffer dynamically | ||||
|   ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE); | ||||
|   RAMAllocator<uint8_t> allocator; | ||||
|   uint8_t *buffer = allocator.allocate(4096); | ||||
|   if (!buffer) { | ||||
|     ESP_LOGE(TAG, "Buffer alloc failed"); | ||||
|   | ||||
| @@ -3,14 +3,14 @@ | ||||
| #ifdef USE_NEXTION_TFT_UPLOAD | ||||
| #ifdef USE_ESP_IDF | ||||
|  | ||||
| #include "esphome/core/application.h" | ||||
| #include "esphome/core/defines.h" | ||||
| #include "esphome/core/util.h" | ||||
| #include "esphome/core/log.h" | ||||
| #include "esphome/components/network/util.h" | ||||
| #include <cinttypes> | ||||
| #include <esp_heap_caps.h> | ||||
| #include <esp_http_client.h> | ||||
| #include <cinttypes> | ||||
| #include "esphome/components/network/util.h" | ||||
| #include "esphome/core/application.h" | ||||
| #include "esphome/core/defines.h" | ||||
| #include "esphome/core/log.h" | ||||
| #include "esphome/core/util.h" | ||||
|  | ||||
| namespace esphome { | ||||
| namespace nextion { | ||||
| @@ -51,7 +51,7 @@ int Nextion::upload_by_chunks_(esp_http_client_handle_t http_client, uint32_t &r | ||||
|   } | ||||
|  | ||||
|   // Allocate the buffer dynamically | ||||
|   ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE); | ||||
|   RAMAllocator<uint8_t> allocator; | ||||
|   uint8_t *buffer = allocator.allocate(4096); | ||||
|   if (!buffer) { | ||||
|     ESP_LOGE(TAG, "Buffer alloc failed"); | ||||
|   | ||||
| @@ -1,9 +1,9 @@ | ||||
| #include "waveshare_epaper.h" | ||||
| #include <bitset> | ||||
| #include <cinttypes> | ||||
| #include "esphome/core/application.h" | ||||
| #include "esphome/core/helpers.h" | ||||
| #include "esphome/core/log.h" | ||||
| #include <cinttypes> | ||||
| #include <bitset> | ||||
|  | ||||
| namespace esphome { | ||||
| namespace waveshare_epaper { | ||||
| @@ -185,7 +185,7 @@ void WaveshareEPaper7C::setup() { | ||||
|   this->initialize(); | ||||
| } | ||||
| void WaveshareEPaper7C::init_internal_7c_(uint32_t buffer_length) { | ||||
|   ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE); | ||||
|   RAMAllocator<uint8_t> allocator; | ||||
|   uint32_t small_buffer_length = buffer_length / NUM_BUFFERS; | ||||
|  | ||||
|   for (int i = 0; i < NUM_BUFFERS; i++) { | ||||
| @@ -2054,7 +2054,7 @@ void GDEW029T5::initialize() { | ||||
|     this->deep_sleep_between_updates_ = true; | ||||
|  | ||||
|   // old buffer for partial update | ||||
|   ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE); | ||||
|   RAMAllocator<uint8_t> allocator; | ||||
|   this->old_buffer_ = allocator.allocate(this->get_buffer_length_()); | ||||
|   if (this->old_buffer_ == nullptr) { | ||||
|     ESP_LOGE(TAG, "Could not allocate old buffer for display!"); | ||||
| @@ -2199,7 +2199,7 @@ void GDEW029T5::dump_config() { | ||||
|  | ||||
| void GDEW0154M09::initialize() { | ||||
|   this->init_internal_(); | ||||
|   ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE); | ||||
|   RAMAllocator<uint8_t> allocator; | ||||
|   this->lastbuff_ = allocator.allocate(this->get_buffer_length_()); | ||||
|   if (this->lastbuff_ != nullptr) { | ||||
|     memset(this->lastbuff_, 0xff, sizeof(uint8_t) * this->get_buffer_length_()); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user