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:37:56
- ********* 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 */
- /****** SYSTEM REQUIREMENT 2 *****/
- /* Implement a GIF playback feature on a 128x160 TFT */
- /* display using the TFT_eSPI library, with GPIO pins */
- /* configured as TFT_MISO=23, TFT_SCK=18, TFT_CS=5, */
- /* TFT_DC=27, TFT_RESET=33, allowing adjustable frame */
- /* rates. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <SPI.h> // Required for SPI communication
- #include <TFT_eSPI.h> // https://github.com/Bodmer/TFT_eSPI
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- TFT_eSPI tft = TFT_eSPI(); // Create TFT object
- // GIF playback variables
- const int frames = 10; // Number of frames in the GIF
- int animation_width = 128; // Width of the GIF
- int animation_height = 160; // Height of the GIF
- uint16_t frame[frames][animation_width * animation_height]; // Array to hold frame data
- int frameDelay = 40; // Delay between frames in milliseconds
- void setup(void)
- {
- // Initialize the TFT display
- tft.init(); // Initialize the TFT
- tft.setRotation(1); // Set the rotation of the display
- tft.setSwapBytes(true); // Swap bytes for correct color representation
- tft.fillScreen(TFT_WHITE); // Fill the screen with white color
- // Load GIF frames into the frame array (this part is assumed to be implemented)
- // loadGifFrames(frame); // Function to load GIF frames into the array
- }
- void loop(void)
- {
- // Loop through each frame to display the GIF
- for(int i = 0; i < frames; i++) {
- tft.pushImage(0, 0, animation_width, animation_height, frame[i]); // Display the current frame
- delay(frameDelay); // Delay for the specified frame rate
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement