From bffeec16152f72ba8e1f3bceb06b9ace87ce32ba Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sun, 21 May 2023 18:37:18 +0200 Subject: [PATCH] Remove PSRAM use from global LED buffer. --- wled00/FX_fcn.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 557cdd2d..d3363cb9 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -199,14 +199,13 @@ void Segment::setUpLeds() { #else leds = &Segment::_globalLeds[start]; #endif - else if (leds == nullptr) { + else if (leds == nullptr && length() > 0) { //softhack007 quickfix - avoid malloc(0) which is undefined behaviour (should not happen, but i've seen it) //#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM) //if (psramFound()) // leds = (CRGB*)ps_malloc(sizeof(CRGB)*length()); // softhack007 disabled; putting leds into psram leads to horrible slowdown on WROVER boards //else //#endif - if (length() > 0) //softhack007 quickfix - avoid malloc(0) which is undefined behaviour (should not happen, but i've seen it) - leds = (CRGB*)malloc(sizeof(CRGB)*length()); + leds = (CRGB*)malloc(sizeof(CRGB)*length()); } } @@ -1070,11 +1069,12 @@ void WS2812FX::finalizeInit(void) } if (useLedsArray) { size_t arrSize = sizeof(CRGB) * getLengthTotal(); - #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM) - if (psramFound()) - Segment::_globalLeds = (CRGB*) ps_malloc(arrSize); - else - #endif + // softhack007 disabled; putting leds into psram leads to horrible slowdown on WROVER boards (see setUpLeds()) + //#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM) + //if (psramFound()) + // Segment::_globalLeds = (CRGB*) ps_malloc(arrSize); + //else + //#endif Segment::_globalLeds = (CRGB*) malloc(arrSize); memset(Segment::_globalLeds, 0, arrSize); }