Support for ESP32 PSRAM added

If PSRAM is fitted and enabled the Sprites are now created in PSRAM.
This makes multiple full screen buffers possible!
This commit is contained in:
Bodmer
2018-10-21 21:22:20 +01:00
parent 1a0b37097a
commit 9666314eb6
4 changed files with 19 additions and 3 deletions
+15 -1
View File
@@ -67,7 +67,13 @@ void* TFT_eSprite::createSprite(int16_t w, int16_t h, uint8_t frames)
// hence will run faster in normal circumstances.
if (_bpp == 16)
{
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
if ( psramFound() ) _img8_1 = ( uint8_t*) ps_calloc(w * h + 1, sizeof(uint16_t));
else
#endif
_img8_1 = ( uint8_t*) calloc(w * h + 1, sizeof(uint16_t));
_img8_2 = _img8_1;
_img = (uint16_t*) _img8_1;
@@ -80,6 +86,10 @@ void* TFT_eSprite::createSprite(int16_t w, int16_t h, uint8_t frames)
else if (_bpp == 8)
{
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
if ( psramFound() ) _img8_1 = ( uint8_t*) ps_calloc(w * h + 1, sizeof(uint8_t));
else
#endif
_img8_1 = ( uint8_t*) calloc(w * h + 1, sizeof(uint8_t));
if (_img8_1)
@@ -103,7 +113,11 @@ void* TFT_eSprite::createSprite(int16_t w, int16_t h, uint8_t frames)
if (frames > 2) frames = 2; // Currently restricted to 2 frame buffers
if (frames < 1) frames = 1;
_img8 = ( uint8_t*) calloc(frames * (w>>3) * h + frames, sizeof(uint8_t)); // extra pixel added
#if defined (ESP32) && defined (CONFIG_SPIRAM_SUPPORT)
if ( psramFound() ) _img8 = ( uint8_t*) ps_calloc(frames * (w>>3) * h + frames, sizeof(uint8_t));
else
#endif
_img8 = ( uint8_t*) calloc(frames * (w>>3) * h + frames, sizeof(uint8_t));
if (_img8)
{