mirror of
https://github.com/esphome/esphome.git
synced 2025-07-28 06:06:33 +00:00
Clean up RAMAllocators in light related code (#9142)
This commit is contained in:
parent
169db9cc0a
commit
4ef0264ed3
@ -7,11 +7,13 @@
|
||||
|
||||
extern "C" {
|
||||
#include "rtos_pub.h"
|
||||
#include "spi.h"
|
||||
// rtos_pub.h must be included before the rest of the includes
|
||||
|
||||
#include "arm_arch.h"
|
||||
#include "general_dma_pub.h"
|
||||
#include "gpio_pub.h"
|
||||
#include "icu_pub.h"
|
||||
#include "spi.h"
|
||||
#undef SPI_DAT
|
||||
#undef SPI_BASE
|
||||
};
|
||||
@ -124,7 +126,7 @@ void BekenSPILEDStripLightOutput::setup() {
|
||||
size_t buffer_size = this->get_buffer_size_();
|
||||
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);
|
||||
if (this->buf_ == nullptr) {
|
||||
ESP_LOGE(TAG, "Cannot allocate LED buffer!");
|
||||
|
@ -8,7 +8,7 @@ namespace m5stack_8angle {
|
||||
static const char *const TAG = "m5stack_8angle.light";
|
||||
|
||||
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);
|
||||
if (this->buf_ == nullptr) {
|
||||
ESP_LOGE(TAG, "Failed to allocate buffer of size %u", M5STACK_8ANGLE_NUM_LEDS * M5STACK_8ANGLE_BYTES_PER_LED);
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include <hardware/dma.h>
|
||||
#include <hardware/irq.h>
|
||||
#include <hardware/pio.h>
|
||||
#include <pico/stdlib.h>
|
||||
#include <pico/sem.h>
|
||||
#include <pico/stdlib.h>
|
||||
|
||||
namespace esphome {
|
||||
namespace rp2040_pio_led_strip {
|
||||
@ -44,7 +44,7 @@ void RP2040PIOLEDStripLightOutput::setup() {
|
||||
|
||||
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);
|
||||
if (this->buf_ == nullptr) {
|
||||
ESP_LOGE(TAG, "Failed to allocate buffer of size %u", buffer_size);
|
||||
|
@ -5,7 +5,7 @@ namespace spi_led_strip {
|
||||
|
||||
SpiLedStrip::SpiLedStrip(uint16_t 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->buf_ = allocator.allocate(this->buffer_size_);
|
||||
if (this->buf_ == nullptr) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user