mirror of
https://github.com/wled/WLED.git
synced 2025-07-25 03:36:45 +00:00
Added PSRAM support for effect data.
This commit is contained in:
parent
94c0324e8a
commit
9a5917a331
10
wled00/FX.h
10
wled00/FX.h
@ -330,7 +330,13 @@ class WS2812FX {
|
|||||||
if (data && _dataLen == len) return true; //already allocated
|
if (data && _dataLen == len) return true; //already allocated
|
||||||
deallocateData();
|
deallocateData();
|
||||||
if (WS2812FX::instance->_usedSegmentData + len > MAX_SEGMENT_DATA) return false; //not enough memory
|
if (WS2812FX::instance->_usedSegmentData + len > MAX_SEGMENT_DATA) return false; //not enough memory
|
||||||
data = new (std::nothrow) byte[len];
|
// if possible use SPI RAM on ESP32
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
if (psramFound())
|
||||||
|
data = (byte*) ps_malloc(len);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
data = (byte*) malloc(len);
|
||||||
if (!data) return false; //allocation failed
|
if (!data) return false; //allocation failed
|
||||||
WS2812FX::instance->_usedSegmentData += len;
|
WS2812FX::instance->_usedSegmentData += len;
|
||||||
_dataLen = len;
|
_dataLen = len;
|
||||||
@ -338,7 +344,7 @@ class WS2812FX {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void deallocateData(){
|
void deallocateData(){
|
||||||
delete[] data;
|
free(data);
|
||||||
data = nullptr;
|
data = nullptr;
|
||||||
WS2812FX::instance->_usedSegmentData -= _dataLen;
|
WS2812FX::instance->_usedSegmentData -= _dataLen;
|
||||||
_dataLen = 0;
|
_dataLen = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user