Advertisement
pleasedontcode

**GIF Display** rev_01

Nov 23rd, 2024
167
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:30:15
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* play a gif file on a 128x160 display */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /* START CODE */
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <TFT_eSPI.h>   //https://github.com/Bodmer/TFT_eSPI
  27. #include <SPI.h> // Included SPI library for TFT communication
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32.  
  33. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  34. TFT_eSPI tft = TFT_eSPI(); // Create TFT instance
  35.  
  36. // GIF animation variables
  37. const int frames = 10; // Total number of frames in the GIF
  38. const int animation_width = 128; // Width of the GIF
  39. const int animation_height = 160; // Height of the GIF
  40. uint16_t frame[frames][animation_width * animation_height]; // Array to hold the frames
  41.  
  42. void setup(void)
  43. {
  44.     // put your setup code here, to run once:
  45.     tft.init(); // Initialize the TFT
  46.     tft.setRotation(1); // Set the rotation of the display
  47.     tft.setSwapBytes(true); // Set byte order for color
  48.     tft.fillScreen(TFT_WHITE); // Fill the screen with white color
  49.  
  50.     // Load GIF frames into the frame array (this is a placeholder, actual loading code will depend on your GIF source)
  51.     for (int i = 0; i < frames; i++) {
  52.         // Load each frame into the frame array (this is just a placeholder)
  53.         // You need to implement the actual loading logic based on your GIF format
  54.         // e.g., frame[i] = loadGifFrame(i);
  55.     }
  56. }
  57.  
  58. void loop(void)
  59. {
  60.     // put your main code here, to run repeatedly:
  61.     for (int i = 0; i < frames; i++) {
  62.         delay(40);  
  63.         tft.pushImage(0, 0, animation_width, animation_height, frame[i]);
  64.     }
  65. }
  66.  
  67. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement