currentScreenIndex

This commit is contained in:
charles 2023-08-19 06:32:28 -04:00
parent a89fe7ba3e
commit 815dd72095
2 changed files with 8 additions and 5 deletions

View File

@ -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)
{

View File

@ -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() */