Clean up RAMAllocators in light related code (#9142)

This commit is contained in:
Jesse Hills 2025-06-21 19:32:24 +12:00 committed by GitHub
parent 169db9cc0a
commit 4ef0264ed3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 6 deletions

View File

@ -7,11 +7,13 @@
extern "C" { extern "C" {
#include "rtos_pub.h" #include "rtos_pub.h"
#include "spi.h" // rtos_pub.h must be included before the rest of the includes
#include "arm_arch.h" #include "arm_arch.h"
#include "general_dma_pub.h" #include "general_dma_pub.h"
#include "gpio_pub.h" #include "gpio_pub.h"
#include "icu_pub.h" #include "icu_pub.h"
#include "spi.h"
#undef SPI_DAT #undef SPI_DAT
#undef SPI_BASE #undef SPI_BASE
}; };
@ -124,7 +126,7 @@ void BekenSPILEDStripLightOutput::setup() {
size_t buffer_size = this->get_buffer_size_(); size_t buffer_size = this->get_buffer_size_();
size_t dma_buffer_size = (buffer_size * 8) + (2 * 64); size_t dma_buffer_size = (buffer_size * 8) + (2 * 64);
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE); RAMAllocator<uint8_t> allocator;
this->buf_ = allocator.allocate(buffer_size); this->buf_ = allocator.allocate(buffer_size);
if (this->buf_ == nullptr) { if (this->buf_ == nullptr) {
ESP_LOGE(TAG, "Cannot allocate LED buffer!"); ESP_LOGE(TAG, "Cannot allocate LED buffer!");

View File

@ -8,7 +8,7 @@ namespace m5stack_8angle {
static const char *const TAG = "m5stack_8angle.light"; static const char *const TAG = "m5stack_8angle.light";
void M5Stack8AngleLightOutput::setup() { void M5Stack8AngleLightOutput::setup() {
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE); RAMAllocator<uint8_t> allocator;
this->buf_ = allocator.allocate(M5STACK_8ANGLE_NUM_LEDS * M5STACK_8ANGLE_BYTES_PER_LED); this->buf_ = allocator.allocate(M5STACK_8ANGLE_NUM_LEDS * M5STACK_8ANGLE_BYTES_PER_LED);
if (this->buf_ == nullptr) { if (this->buf_ == nullptr) {
ESP_LOGE(TAG, "Failed to allocate buffer of size %u", M5STACK_8ANGLE_NUM_LEDS * M5STACK_8ANGLE_BYTES_PER_LED); ESP_LOGE(TAG, "Failed to allocate buffer of size %u", M5STACK_8ANGLE_NUM_LEDS * M5STACK_8ANGLE_BYTES_PER_LED);

View File

@ -9,8 +9,8 @@
#include <hardware/dma.h> #include <hardware/dma.h>
#include <hardware/irq.h> #include <hardware/irq.h>
#include <hardware/pio.h> #include <hardware/pio.h>
#include <pico/stdlib.h>
#include <pico/sem.h> #include <pico/sem.h>
#include <pico/stdlib.h>
namespace esphome { namespace esphome {
namespace rp2040_pio_led_strip { namespace rp2040_pio_led_strip {
@ -44,7 +44,7 @@ void RP2040PIOLEDStripLightOutput::setup() {
size_t buffer_size = this->get_buffer_size_(); size_t buffer_size = this->get_buffer_size_();
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE); RAMAllocator<uint8_t> allocator;
this->buf_ = allocator.allocate(buffer_size); this->buf_ = allocator.allocate(buffer_size);
if (this->buf_ == nullptr) { if (this->buf_ == nullptr) {
ESP_LOGE(TAG, "Failed to allocate buffer of size %u", buffer_size); ESP_LOGE(TAG, "Failed to allocate buffer of size %u", buffer_size);

View File

@ -5,7 +5,7 @@ namespace spi_led_strip {
SpiLedStrip::SpiLedStrip(uint16_t num_leds) { SpiLedStrip::SpiLedStrip(uint16_t num_leds) {
this->num_leds_ = num_leds; this->num_leds_ = num_leds;
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE); RAMAllocator<uint8_t> allocator;
this->buffer_size_ = num_leds * 4 + 8; this->buffer_size_ = num_leds * 4 + 8;
this->buf_ = allocator.allocate(this->buffer_size_); this->buf_ = allocator.allocate(this->buffer_size_);
if (this->buf_ == nullptr) { if (this->buf_ == nullptr) {