Skip to content

Commit

Permalink
disabled gif support on non-cardputer devices (pr3y#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
eadmaster committed Nov 30, 2024
1 parent b82a31f commit defe2fa
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/core/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,12 +816,13 @@ bool showJpeg(FS fs, String filename, int x, int y) {
#include <AnimatedGIF.h>

#define NORMAL_SPEED
#define GIF_BUFFER_SIZE 100
//#define USE_DMA

#ifdef USE_DMA
uint16_t usTemp[2][SAFE_STACK_BUFFER_SIZE]; // Global to support DMA use
uint16_t usTemp[2][GIF_BUFFER_SIZE]; // Global to support DMA use
#else
uint16_t usTemp[1][SAFE_STACK_BUFFER_SIZE]; // Global to support DMA use
uint16_t usTemp[1][GIF_BUFFER_SIZE]; // Global to support DMA use
#endif
bool dmaBuf = 0;

Expand Down Expand Up @@ -864,7 +865,7 @@ void GIFDraw(GIFDRAW *pDraw)
{
c = ucTransparent - 1;
d = &usTemp[0][0];
while (c != ucTransparent && s < pEnd && iCount < SAFE_STACK_BUFFER_SIZE )
while (c != ucTransparent && s < pEnd && iCount < GIF_BUFFER_SIZE )
{
c = *s++;
if (c == ucTransparent) // done, stop
Expand Down Expand Up @@ -904,10 +905,10 @@ void GIFDraw(GIFDRAW *pDraw)

// Unroll the first pass to boost DMA performance
// Translate the 8-bit pixels through the RGB565 palette (already byte reversed)
if (iWidth <= SAFE_STACK_BUFFER_SIZE)
if (iWidth <= GIF_BUFFER_SIZE)
for (iCount = 0; iCount < iWidth; iCount++) usTemp[dmaBuf][iCount] = usPalette[*s++];
else
for (iCount = 0; iCount < SAFE_STACK_BUFFER_SIZE; iCount++) usTemp[dmaBuf][iCount] = usPalette[*s++];
for (iCount = 0; iCount < GIF_BUFFER_SIZE; iCount++) usTemp[dmaBuf][iCount] = usPalette[*s++];

#ifdef USE_DMA // 71.6 fps (ST7796 84.5 fps)
tft.dmaWait();
Expand All @@ -924,10 +925,10 @@ void GIFDraw(GIFDRAW *pDraw)
while (iWidth > 0)
{
// Translate the 8-bit pixels through the RGB565 palette (already byte reversed)
if (iWidth <= SAFE_STACK_BUFFER_SIZE)
if (iWidth <= GIF_BUFFER_SIZE)
for (iCount = 0; iCount < iWidth; iCount++) usTemp[dmaBuf][iCount] = usPalette[*s++];
else
for (iCount = 0; iCount < SAFE_STACK_BUFFER_SIZE; iCount++) usTemp[dmaBuf][iCount] = usPalette[*s++];
for (iCount = 0; iCount < GIF_BUFFER_SIZE; iCount++) usTemp[dmaBuf][iCount] = usPalette[*s++];

#ifdef USE_DMA
tft.dmaWait();
Expand All @@ -945,7 +946,7 @@ void * GIFOpenFile(const char *fname, int32_t *pSize)
{
static File FSGifFile; // MEMO: declared static to survive return
if(SD.exists(fname)) FSGifFile = SD.open(fname);
if(LittleFS.exists(fname)) FSGifFile = LittleFS.open(fname);
else if(LittleFS.exists(fname)) FSGifFile = LittleFS.open(fname);
if (FSGifFile) {
*pSize = FSGifFile.size();
return (void *)&FSGifFile;
Expand Down Expand Up @@ -994,7 +995,8 @@ int32_t GIFSeekFile(GIFFILE *pFile, int32_t iPosition)
}

bool showGIF(FS fs, String filename, int x, int y) {
#if defined(CONFIG_IDF_TARGET_ESP32S3)
//#if defined(CONFIG_IDF_TARGET_ESP32S3)
#if defined(CARDPUTER)
if(!fs.exists(filename))
return false;
static AnimatedGIF gif; // MEMO: triggers stack canary if not static
Expand Down

0 comments on commit defe2fa

Please sign in to comment.