From 815dd7209562d3a8daa8dc9c6604fcf28e61bf4a Mon Sep 17 00:00:00 2001 From: charles Date: Sat, 19 Aug 2023 06:32:28 -0400 Subject: [PATCH] currentScreenIndex --- ESP32ManyRoundScreenTest.ino | 8 +++----- GIFDraw.ino | 5 +++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ESP32ManyRoundScreenTest.ino b/ESP32ManyRoundScreenTest.ino index 1052246..eea4cf3 100644 --- a/ESP32ManyRoundScreenTest.ino +++ b/ESP32ManyRoundScreenTest.ino @@ -27,6 +27,7 @@ const int NUM_DISPLAYS = 6; // Add more CS pins if you have more displays, each display must have a dedicated pin const int CS_PINS[NUM_DISPLAYS] = {19, 22, 21, 32, 33, 26}; +int currentScreenIndex = 0; AnimatedGIF gif_1; AnimatedGIF gif_2; @@ -81,9 +82,7 @@ void openGif(AnimatedGIF *gif, const uint8_t *gifImage, int gifSize) void playGif(AnimatedGIF *gif, int screenIndex) { - - digitalWrite(CS_PINS[screenIndex], LOW); // Select the display - tft.startWrite(); + currentScreenIndex = screenIndex; int res = gif->playFrame(false, NULL); if (res == 0) { @@ -95,8 +94,7 @@ void playGif(AnimatedGIF *gif, int screenIndex) { Serial.printf("Gif Error = %d on screen %d\n", gif->getLastError(), screenIndex); } - tft.endWrite(); - digitalWrite(CS_PINS[screenIndex], HIGH); // Deselect the display + if (screenIndex == 0) { diff --git a/GIFDraw.ino b/GIFDraw.ino index de6cb7f..a149609 100644 --- a/GIFDraw.ino +++ b/GIFDraw.ino @@ -14,6 +14,9 @@ bool dmaBuf = 0; // Draw a line of image directly on the LCD void GIFDraw(GIFDRAW *pDraw) { + digitalWrite(CS_PINS[currentScreenIndex], LOW); // Select the display + tft.startWrite(); + uint8_t *s; uint16_t *d, *usPalette; int x, y, iWidth, iCount; @@ -128,4 +131,6 @@ void GIFDraw(GIFDRAW *pDraw) iWidth -= iCount; } } + tft.endWrite(); + digitalWrite(CS_PINS[currentScreenIndex], HIGH); // Deselect the display } /* GIFDraw() */