30 FPS Video on SSD1106 OLED Display
This project aims to test the maximum limits of the SSD1106 OLED display, which is typically limited to basic text display or simple animated graphics in general Embedded projects. However, my goal this time is to push past those limits by streaming Real-time video onto this tiny screen. Achieving this, of course, presented several technical challenges, particularly concerning "Bandwidth" and "Color Depth".
Hardware Limitations and Interface Optimization (Overclocking SPI)
The first and most significant challenge was the Bandwidth limitation of the interface between the microcontroller and the SSD1106 display. This display supports a resolution of 128x64 pixels. To send one frame of image data to the screen (Frame Buffer), we need to transmit a total of 1,024 bytes (128 * 64 / 8 bits). If we want a smooth frame rate, standard SPI communication might not be sufficient.
To solve this problem, I decided to overclock the SPI connection to 2MHz. I chose to use a Library with optimized Code (Optimized Library) that directly accesses the Registers, to reduce system Overhead and maximize data transmission efficiency. Furthermore, for receiving video data from the computer via serial communication (UART), I set the Baud rate to a high 1MHz, to ensure that the video data from the source would not encounter a Bottleneck before reaching the processor.
Simulating Grayscale Images with Dithering Technique
Another physical limitation of OLED displays is that each pixel can only display two states: "On" or "Off", also known as 1-bit color. This prevents the display of Grayscale in normal video.
To make the output image appear more realistic and dimensional, I applied the Dithering technique. The principle of Dithering is to arrange patterns of black and white pixels with varying densities, to trick the human eye into perceiving different shades of gray, even though only black and white pixels are truly present. The results exceeded my expectations, providing surprisingly good image quality and enhancing video detail.
Software Logic (Logic Overview)
The operational process is divided into two main parts:
- Computer Side (Source Node): processes the original video by downsampling the image to 128x64 pixels and calculating Dithering for each frame. It then packs the data into a Byte Stream and sends it out via the Serial Port at 1Mbps.
- Microcontroller Side (Display Node): waits to receive data from the UART Buffer. Once a complete frame of data (1,024 bytes) is received, the microcontroller immediately commands the high-speed SPI to update the data to the SSD1106 display driver. This rapid, cyclical (Loop) operation allows us to watch Real-time video on this small screen.
This project demonstrates that even with seemingly impossible hardware limitations, through algorithm optimization and squeezing out performance from communication protocols, we can push inexpensive devices to perform complex tasks efficiently. What are your thoughts on this type of performance optimization technique? Feel free to share your perspectives!