Advertisement
pleasedontcode

**GIF Display** rev_03

Nov 23rd, 2024
180
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:37:56
  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. /****** SYSTEM REQUIREMENT 2 *****/
  25.     /* Implement a GIF playback feature on a 128x160 TFT */
  26.     /* display using the TFT_eSPI library, with GPIO pins */
  27.     /* configured as TFT_MISO=23, TFT_SCK=18, TFT_CS=5, */
  28.     /* TFT_DC=27, TFT_RESET=33, allowing adjustable frame */
  29.     /* rates. */
  30. /****** END SYSTEM REQUIREMENTS *****/
  31.  
  32. /* START CODE */
  33.  
  34. /****** DEFINITION OF LIBRARIES *****/
  35. #include <SPI.h>           // Required for SPI communication
  36. #include <TFT_eSPI.h>      // https://github.com/Bodmer/TFT_eSPI
  37.  
  38. /****** FUNCTION PROTOTYPES *****/
  39. void setup(void);
  40. void loop(void);
  41.  
  42. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  43. TFT_eSPI tft = TFT_eSPI(); // Create TFT object
  44.  
  45. // GIF playback variables
  46. const int frames = 10; // Number of frames in the GIF
  47. int animation_width = 128; // Width of the GIF
  48. int animation_height = 160; // Height of the GIF
  49. uint16_t frame[frames][animation_width * animation_height]; // Array to hold frame data
  50. int frameDelay = 40; // Delay between frames in milliseconds
  51.  
  52. void setup(void)
  53. {
  54.     // Initialize the TFT display
  55.     tft.init();                // Initialize the TFT
  56.     tft.setRotation(1);       // Set the rotation of the display
  57.     tft.setSwapBytes(true);   // Swap bytes for correct color representation
  58.     tft.fillScreen(TFT_WHITE); // Fill the screen with white color
  59.  
  60.     // Load GIF frames into the frame array (this part is assumed to be implemented)
  61.     // loadGifFrames(frame); // Function to load GIF frames into the array
  62. }
  63.  
  64. void loop(void)
  65. {
  66.     // Loop through each frame to display the GIF
  67.     for(int i = 0; i < frames; i++) {
  68.         tft.pushImage(0, 0, animation_width, animation_height, frame[i]); // Display the current frame
  69.         delay(frameDelay); // Delay for the specified frame rate
  70.     }
  71. }
  72.  
  73. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement