From 6259ca9ded5b5c05cf0e47e45a588511053cb875 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Tue, 15 Apr 2025 11:10:44 +1000 Subject: [PATCH] [lvgl] Small buffers in internal RAM (#8523) --- esphome/components/lvgl/lvgl_esphome.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/esphome/components/lvgl/lvgl_esphome.cpp b/esphome/components/lvgl/lvgl_esphome.cpp index 2560cd2168..8d8380d429 100644 --- a/esphome/components/lvgl/lvgl_esphome.cpp +++ b/esphome/components/lvgl/lvgl_esphome.cpp @@ -433,7 +433,11 @@ void LvglComponent::setup() { auto height = display->get_height(); size_t buffer_pixels = width * height / this->buffer_frac_; auto buf_bytes = buffer_pixels * LV_COLOR_DEPTH / 8; - auto *buffer = lv_custom_mem_alloc(buf_bytes); // NOLINT + void *buffer = nullptr; + if (this->buffer_frac_ >= 4) + buffer = malloc(buf_bytes); // NOLINT + if (buffer == nullptr) + buffer = lv_custom_mem_alloc(buf_bytes); // NOLINT if (buffer == nullptr) { this->mark_failed(); this->status_set_error("Memory allocation failure");