Pages: [1]   Go Down
Author Topic: Can a TFT LCD use GIF files to animate?  (Read 1564 times)
0 Members and 1 Guest are viewing this topic.
Philippines
Offline Offline
Newbie
*
Karma: 1
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to get my 3.2 TFT to animate with GIF files, but the images remain static. My TFT is attached to an Arduino ADK, with a Micro SD card in the TFT. All of the images are .raw files, which display with no problem, but I want one .gif image to animate when it's displayed (my "Katrina" file). When the image I want to move is a .raw file, it shows up on the TFT just fine as a static image, but when I change it to a .gif image, the program no longer runs and a quarter of the screen gets staticy (see image below).
I've tried switching "Katrina" from portrait to landscape, but it did no good. Any help getting my TFT to accept animated files? Thank you.

Code:
// Demo_Landscape (C)2012 Henning Karlsen

// web: http://www.henningkarlsen.com/electronics
// This program is a demo of the loadBitmap()-function.
// This program requires UTFT_tinyFAT, UTFT v1.2 or higher,
// as well as the tinyFAT v3.0 or higher.
// The image files must be present in the root folder
// of a FAT16 formatted SDcard in the module cardslot.

#include <tinyFAT.h>
#include <UTFT.h>
#include <UTFT_tinyFAT.h>

// Declare which fonts we will be using

extern uint8_t SmallFont[];
UTFTtf myGLCD(ITDB32S, 38, 39, 40, 41);   // Remember to change the model parameter to suit your display module!
 
// List of filenames for pictures to display.

//char* files320[]={"PIC301.RAW", "PIC302.RAW", "PIC303.RAW", "PIC304.RAW", "PIC305.RAW", "PIC306.RAW", "PIC307.RAW", "PIC308.RAW", "PIC309.RAW", "PIC310.RAW"}; // 320x240
 
char* files320[]={"KATRINA.GIF"};

char* files400[]={"PIC401.RAW", "PIC402.RAW", "PIC403.RAW", "PIC404.RAW", "PIC405.RAW", "PIC406.RAW", "PIC407.RAW", "PIC408.RAW", "PIC409.RAW", "PIC410.RAW"}; // 400x240
 
char* files220[]={"PIC601.RAW", "PIC602.RAW", "PIC603.RAW", "PIC604.RAW", "PIC605.RAW", "PIC606.RAW", "PIC607.RAW", "PIC608.RAW", "PIC609.RAW", "PIC610.RAW"}; // 220x176
 
char* files480[]={"PIC701.RAW", "PIC702.RAW", "PIC703.RAW", "PIC704.RAW", "PIC705.RAW", "", "", "", "", ""}; // 480x272
 
char* files800[]={"PIC801.RAW", "PIC802.RAW", "PIC803.RAW", "PIC804.RAW", "PIC805.RAW", "", "", "", "", ""}; // 800x480
 
char* files[1];

int picsize_x, picsize_y;

boolean display_rendertime=false;  // Set this to true if you want the rendertime to be displayed after a picture is loaded

boolean display_filename=true;  // Set this to false to disable showing of filename
 
word res;

long sm, em;

void setup()

{

  myGLCD.InitLCD();

  myGLCD.clrScr();

  file.initFAT();

  myGLCD.setColor(255,255,255);
 
  myGLCD.setFont(SmallFont);

  picsize_x=myGLCD.getDisplayXSize();

  picsize_y=myGLCD.getDisplayYSize();

  switch (picsize_x)

  {

    case 220:

      for (int z=0; z<sizeof(files220)/sizeof(*files220);z++)
 
        files[z] = files220[z];

      break;

    case 320:

      for (int z=0; z<sizeof(files320)/sizeof(*files320);z++)

        files[z] = files320[z];

      break;
 
    case 400:

      for (int z=0; z<sizeof(files400)/sizeof(*files400);z++)

        files[z] = files400[z];

      break;

    case 480:

      for (int z=0; z<sizeof(files480)/sizeof(*files480);z++)
 
        files[z] = files480[z];

      break;

    case 800:

      for (int z=0; z<sizeof(files800)/sizeof(*files800);z++)

        files[z] = files800[z];

      break;
 
  }

}

void loop()

{
  for (int i=0; i<(sizeof(files)/sizeof(*files)); i++)

  {

    if (files[i]!="")

    {
 
      sm=millis();

      res=myGLCD.loadBitmap(0, 0, picsize_x, picsize_y, files[i]);

      em=millis();

      if (res!=0)

      {

        if (res==0x10)

        {
 
          myGLCD.print("File not found...", 0, 0);

          myGLCD.print(files[i], 0, 14);

        }

        else

        {

          myGLCD.print("ERROR: ", 0, 0);
 
          myGLCD.printNumI(res, 56, 0);

        }

        delay(3000);

        myGLCD.clrScr();

      }

      else

      {

        if (display_rendertime==true)
 
        {

          myGLCD.print("Rendertime (secs):", 0, 0);

          myGLCD.printNumF(float((em-sm)/1000.0), 2, 160,0);

        }

        if (display_filename==true)
 
        {

          myGLCD.print(files[i], CENTER, myGLCD.getDisplayYSize()-12);

        }

        delay(3000);

      }

    }

  }

}


* Katrina.JPG (269.71 KB, 720x960 - viewed 77 times.)
Logged

Offline Offline
Full Member
***
Karma: 5
Posts: 219
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Animated GIFs are not self-animated.  They are made up of several (many) frames that the host display program switches between at whatever speed the GIF says they should.

Given the processing limitations of the Arduino I would think the most practical way to produce the animated effect would be to store the individual frames as separate RAW files and load them.  Even then it would likely be unsatisfactory as the time to load each frame may be too long.
Logged

Philippines
Offline Offline
Newbie
*
Karma: 1
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for your reply. I appreciate the help.
Logged

Philippines
Offline Offline
Newbie
*
Karma: 1
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does anyone know how if there is a way to speed up the rendering time? Or is there another TFT available that could possibly handle multiple .raw files in a manner so quickly that it appears to be animating?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does anyone know how if there is a way to speed up the rendering time? Or is there another TFT available that could possibly handle multiple .raw files in a manner so quickly that it appears to be animating?

I think, having used TFT screens with a Mega 2560 and also Due, it may be possible to get simple animation using Due, even using UTFT. Not slick perhaps, but reasonable?
There are folks working on optimised 16 bit drivers for Arduino to serve specific display chipsets. These look pretty promising but may take a while until they are fully proven. The main purpose appears to be to generate 15+FPS for data displays... rather than bitmapped graphics. Have a search on the forum.

Graeme
Logged

Pages: [1]   Go Up
Jump to: