Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: **GIF Display**
- - Source Code NOT compiled for: ESP32 DevKit V1
- - Source Code created on: 2024-11-23 15:34:45
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* play a gif file on a 128x160 display, gpio pin */
- /* out must be TFT_MISO=23, TFT_SCK=18, TFT_CS=5, */
- /* TFT_DC=27, TFT_RESET=33. And has variable speed */
- /* or framerate */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <TFT_eSPI.h> // https://github.com/Bodmer/TFT_eSPI
- #include <SPI.h> // Included for SPI functionality
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- TFT_eSPI tft = TFT_eSPI(); // Create TFT_eSPI object
- // Variables for GIF playback
- const int frames = 10; // Number of frames in the GIF
- const int animation_width = 128; // Width of the GIF
- const int animation_height = 160; // Height of the GIF
- uint16_t frame[frames][animation_width * animation_height]; // Array to hold the frames
- // Variable to control frame rate
- int frameDelay = 40; // Delay in milliseconds between frames
- void setup(void)
- {
- // Initialize the TFT
- tft.init();
- tft.setRotation(1);
- tft.setSwapBytes(true);
- tft.fillScreen(TFT_WHITE); // Fill the screen with white color
- // Load frames into the array (this part needs to be implemented based on your GIF source)
- // For example:
- // loadGifFrames(frame); // You need to implement this function to load your GIF frames
- }
- void loop(void)
- {
- // Play the GIF by iterating through the frames
- for (int i = 0; i < frames; i++) {
- tft.pushImage(0, 0, animation_width, animation_height, frame[i]); // Display the current frame
- delay(frameDelay); // Wait for the specified delay before showing the next frame
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement