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");