diff --git a/Extensions/Sprite.cpp b/Extensions/Sprite.cpp index acfc315..73285da 100644 --- a/Extensions/Sprite.cpp +++ b/Extensions/Sprite.cpp @@ -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) { diff --git a/README.md b/README.md index bb2dfd5..b61fc76 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ Drawing graphics into a sprite is very fast, for those familiar with the Adafrui Sprites can be plotted to the TFT with one colour being specified as "transparent", see Transparent_Sprite_Demo example. +IF an ESP32 board with SPIRAM (i.e. PSRAM) fitted then Sprites will use the PSRAM memory and large full screen buffer Sprites can be created. Full screen Sprites take longer to render (~45ms for a 320 x 240 16 bit Sprite), so bear that in mind. + The XPT2046 touch screen controller is supported. The SPI bus for the touch controller is shared with the TFT and only an additional chip select line is needed. The Button class from Adafruit_GFX is incorporated, with the enhancement that the button labels can be in any font. diff --git a/library.json b/library.json index ceaa20f..81f4046 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "1.1.0", + "version": "1.1.1", "keywords": "tft, ePaper, display, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789", "description": "A TFT and ePaper SPI graphics library for ESP8266 and ESP32", "repository": diff --git a/library.properties b/library.properties index 8e9b396..6b18d6b 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=1.1.0 +version=1.1.1 author=Bodmer maintainer=Bodmer sentence=A fast TFT graphics library for ESP8266 and ESP32 processors for the Arduino IDE