Advertisement
pleasedontcode

**GIF Display** rev_02

Nov 23rd, 2024
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **GIF Display**
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-11-23 15:34:45
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* play a gif file on a 128x160 display, gpio  pin */
  21.     /* out must be TFT_MISO=23, TFT_SCK=18, TFT_CS=5, */
  22.     /* TFT_DC=27, TFT_RESET=33. And  has variable speed */
  23.     /* or framerate */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /* START CODE */
  27.  
  28. /****** DEFINITION OF LIBRARIES *****/
  29. #include <TFT_eSPI.h>   // https://github.com/Bodmer/TFT_eSPI
  30. #include <SPI.h> // Included for SPI functionality
  31.  
  32. /****** FUNCTION PROTOTYPES *****/
  33. void setup(void);
  34. void loop(void);
  35.  
  36. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  37. TFT_eSPI tft = TFT_eSPI(); // Create TFT_eSPI object
  38.  
  39. // Variables for GIF playback
  40. const int frames = 10; // Number of frames in the GIF
  41. const int animation_width = 128; // Width of the GIF
  42. const int animation_height = 160; // Height of the GIF
  43. uint16_t frame[frames][animation_width * animation_height]; // Array to hold the frames
  44.  
  45. // Variable to control frame rate
  46. int frameDelay = 40; // Delay in milliseconds between frames
  47.  
  48. void setup(void)
  49. {
  50.     // Initialize the TFT
  51.     tft.init();              
  52.     tft.setRotation(1);      
  53.     tft.setSwapBytes(true);  
  54.     tft.fillScreen(TFT_WHITE); // Fill the screen with white color
  55.  
  56.     // Load frames into the array (this part needs to be implemented based on your GIF source)
  57.     // For example:
  58.     // loadGifFrames(frame); // You need to implement this function to load your GIF frames
  59. }
  60.  
  61. void loop(void)
  62. {
  63.     // Play the GIF by iterating through the frames
  64.     for (int i = 0; i < frames; i++) {
  65.         tft.pushImage(0, 0, animation_width, animation_height, frame[i]); // Display the current frame
  66.         delay(frameDelay); // Wait for the specified delay before showing the next frame
  67.     }
  68. }
  69.  
  70. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement