PSRAM: you can have it, and eat it or not eat it

*This patch allows to compile with BOARD_HAS_PSRAM, but not set WLED_USE_PSRAM - reserved pins will be protected, and PSRAM usage will be shown in info.
* if you add `-D WLED_USE_PSRAM_JSON` then PSRAM will be used for some JSON buffers, but not for LEDs and Segments.
This commit is contained in:
Frank
2023-04-19 17:58:50 +02:00
parent e2d3800fc3
commit d90ee766f6
7 changed files with 12 additions and 11 deletions

View File

@@ -157,7 +157,7 @@ bool Segment::allocateData(size_t len) {
deallocateData();
if (Segment::getUsedSegmentData() + len > MAX_SEGMENT_DATA) return false; //not enough memory
// if possible use SPI RAM on ESP32
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
#if defined(ARDUINO_ARCH_ESP32) && defined(BOARD_HAS_PSRAM) && defined(WLED_USE_PSRAM)
if (psramFound())
data = (byte*) ps_malloc(len);
else
@@ -204,7 +204,7 @@ void Segment::setUpLeds() {
leds = &Segment::_globalLeds[start];
#endif
else if (!leds) {
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
#if defined(ARDUINO_ARCH_ESP32) && defined(BOARD_HAS_PSRAM) && defined(WLED_USE_PSRAM)
if (psramFound())
leds = (CRGB*)ps_malloc(sizeof(CRGB)*length());
else
@@ -1443,7 +1443,7 @@ void WS2812FX::finalizeInit(void)
}
if (useLedsArray) {
size_t arrSize = sizeof(CRGB) * getLengthTotal();
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
#if defined(ARDUINO_ARCH_ESP32) && defined(BOARD_HAS_PSRAM) && defined(WLED_USE_PSRAM)
if (psramFound())
Segment::_globalLeds = (CRGB*) ps_malloc(arrSize);
else