E-Paper Display Time and Animation Project for ESP32 and waveshare 1.54 epaper screen
This project drives an e-paper display using an ESP32 WROOM dev module. The display shows both dynamic time updates and a sequence of animations. The code is designed to work with a 1.54-inch e-paper screen using SPI communication. Below is a breakdown of the key functionality:
Key Features
- Time Display: The current time is displayed at the bottom of the screen and is incremented in real-time. Users can adjust the hours, minutes, and seconds.
- Animation Sequence: The display runs a series of 21 bitmap frames that create an animation. This loops continuously while the time is updated.
- Partial Screen Updates: To preserve energy and e-paper durability, only portions of the display are updated rather than refreshing the entire screen.
Code Overview
1. Libraries and Pin Setup
The code starts by including essential libraries like EPD.h
(for e-paper control) and GUI_Paint.h
(for drawing operations), followed by defining GPIO pins for SPI communication.
#include "DEV_Config.h" #include "EPD.h" #include "GUI_Paint.h" #include "imagedata.h"
SPI pins are mapped to specific GPIOs, ensuring proper communication between the microcontroller and the display.
2. Time Management
The code uses a PAINT_TIME
structure to track and manage time. There are functions to increment and decrement hours, minutes, and seconds.
PAINT_TIME sPaint_time = {12, 34, 56}; PAINT_TIME confirmed_time = {12, 34, 56};
These functions allow the time to be adjusted, providing flexibility in real-time control.
3. Image Buffering
An image buffer (BlackImage
) is created to hold the bitmap data before it is written to the display. This is crucial for managing partial updates, where only sections of the display are refreshed, allowing smooth animations.
UBYTE *BlackImage;
4. Setup Function
The setup()
function initializes the e-paper display and prepares it for partial updates. It also loads the first frame of the animation and sets up the time and button functionality (if needed in future development).
void setup() { EPD_1IN54_V2_Init(); // Initialize the display and start the animation sequence }
5. Animation and Time Update Loop
The loop()
function controls the main behavior of the display:
- Animation: A sequence of 21 frames is looped to create an animated effect. These frames are stored as bitmaps and displayed one by one.
- Time Update: With each frame update, the time is also incremented by seconds, and the display shows the current time in a banner at the bottom.
void loop() { // Loop through the frames while updating the time }
The time and score banners remain static while the rest of the screen updates with animations.
6. Future Development
The code includes placeholders for button controls (commented out) that can be used to adjust the time or trigger certain actions, making it highly extendable.
How It Works
- The display runs in partial update mode, meaning only sections of the screen that change (e.g., animation frames, time) are updated. This saves energy and reduces flicker.
- The time increments every second, and the display updates to show the new time while continuing to play the animation.