Cycle GIFS with Arduino and a TFT Display

Cycle GIF Documentation 



Goal: Use a TFT Display to display and cycle through 3 different GIFS with a button



Libraries Used: 


Arduino.h

SPI.h

FS.h

TFT_eSPI.h

AnimatedGIF.h


I am using Vscode with PIO home to control the Arduino


How to get the code to run:

Install all of the libraries above into a workspace, and set up the normal display GIF function


1. Install TFT_eSPI library into VSCODE

Under libdeps > TFT_eSPI > User_Setup.h change your settings to match the display you have



1. Define which driver you are using:

                    












             






2. Define TFT Width + Height 

            


















3. Define Required Pins


a. MISO - MISO

b. MOSI - MOSI

c. SCLK - SCK






1. Install Animated GIF Library

Copy files Github files into src: 

AdaoH3/Github/GIFCycle

        1. GIFDraw.ino

          2. TFT_eSPI_memory.ino









 








b. Change Width and Height to your tft screen size (In GIF Draw)




















c. Download the included files from GitHub and put them in the include folder in vscode

1. jetre.h 

2. out.h

3. yoru.h












d. Build and run the program

       1. If your device doesn’t have a backlight, disable the backlight in TFT_eSPI_memory.ino

   If It does, change the value to the corresponding pin

       

        

        











2. Define button the pin that corresponds


3. If the program does not build, you can use ChatGPT to help diagnose and

troubleshoot the problem


4. If you still can’t get it to work, email me (adamkhaq@gmail.com)



How to alter/change the GIF files:


1. Download a GIF of your choice

2. Use ezgif.com to alter it to not take up so much memory (optional but heavily recommended)

a. Crop your GIF to your pixel size 


b. Optimize your GIF

1. Select Color Reduction + dither and reduce colors to 15-30 to take up less space


c. Cut duration of GIF (by frame number)

1. Make sure that you don’t have to many frames (Recommend adjusting from 1-10                        frames)


d. Download GIF


3. Use image_to_c to convert the GIF to C code


Links: Image to C Converter https://github.com/bitbank2/image_to_c


    

Steps for Mac:

    1. Download X Code and its command line tools
    2. Copy filename location of the image_to_c folder
    3. Open Terminal and paste "cd (pathlocation):
    4. Run make
    5. Put your GIF file into the image_to_c folder
    6. In the terminal run ./image_to_c filename.gif > file.h
    7. Your file should appear in a C format (Drag the file into your vscode folder under include)

    For Windows:


        1. Follow these steps (Timestamp 3:18 - 4:28)

    https://www.youtube.com/watch?v=dPathl6HrCY

 

        2. Include the file into your project folder

 

        3. Change the file names in Vscode so the compiler recognizes it

    a. #include”” - File name

    b. #define GIF_IMAGE# - variable name 

 

4. Follow up by changing the file names of the GIFs in Vscode 





5. If you want to alter how many GIFS are on the device, alter this portion: 







Comments