From 887c60d57a13d71a4a49574eb27c3a5812ef98e7 Mon Sep 17 00:00:00 2001 From: mrfaptastic <12006953+mrfaptastic@users.noreply.github.com> Date: Wed, 22 Dec 2021 16:50:09 +0000 Subject: [PATCH] Updated AnimatedGIF Panel --- .../AnimatedGIFPanel/AnimatedGIFPanel.ino | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/examples/AnimatedGIFPanel/AnimatedGIFPanel.ino b/examples/AnimatedGIFPanel/AnimatedGIFPanel.ino index bd5c107..4e79ff1 100644 --- a/examples/AnimatedGIFPanel/AnimatedGIFPanel.ino +++ b/examples/AnimatedGIFPanel/AnimatedGIFPanel.ino @@ -143,6 +143,8 @@ void GIFDraw(GIFDRAW *pDraw) void * GIFOpenFile(const char *fname, int32_t *pSize) { + Serial.print("Playing gif: "); + Serial.println(fname); f = FILESYSTEM.open(fname); if (f) { @@ -254,33 +256,39 @@ void setup() { } -void loop() { -char *szDir = "/gifs"; // play all GIFs in this directory on the SD card -char fname[256]; -File root, temp; +String gifDir = "/gifs"; // play all GIFs in this directory on the SD card +char filePath[256] = { 0 }; +File root, gifFile; +void loop() +{ while (1) // run forever { - root = FILESYSTEM.open(szDir); + + root = FILESYSTEM.open(gifDir); if (root) { - temp = root.openNextFile(); - while (temp) + gifFile = root.openNextFile(); + while (gifFile) { - if (!temp.isDirectory()) // play it + if (!gifFile.isDirectory()) // play it { - strcpy(fname, temp.name()); - - Serial.printf("Playing %s\n", temp.name()); - Serial.flush(); - ShowGIF((char *)temp.name()); - + + // C-strings... urghh... + memset(filePath, 0x0, sizeof(filePath)); + strcpy(filePath, gifFile.path()); + + // Show it. + ShowGIF(filePath); + } - temp.close(); - temp = root.openNextFile(); + gifFile.close(); + gifFile = root.openNextFile(); } root.close(); } // root - delay(4000); // pause before restarting + + delay(1000); // pause before restarting + } // while -} +} \ No newline at end of file