Display Spooky Animations and Faces with This Live Newspaper Project
Coming up with the idea
In more recent years, Leopoldo, who runs the Deep Tronix blog, developed a much deeper appreciation for art that makes use of electronic devices and clever engineering. While he was busy working on a dithering library for Arduino-compatible boards, he thought of using it for an animated picture frame that could display moving pictures on ePaper screens. It was from this initial idea that he went even further and wanted to build a real-life version of the moving newspaper from Harry Potter.
To turn this concept from merely a thought into reality, Leopoldo had to carefully consider and select which components he needed to use. Perhaps the most obvious one is the ePaper display which works by using many microscopic "microcapsules" that flip to either their dark or light side depending on the polarization of the current passing through them. For static text and images, this technology works well enough, but displaying moving objects would prove to be a significant challenge due to the refresh rate being measured in terms of seconds per frame.
Leopoldo also wanted this project to detect when a person is standing in front of the newspaper in order to reduce the amount of screen burn-in that can occur over time. Additionally, he hoped to be able to capture images from a camera and show them right back at the observer for a spooky effect. To do both of these things, he connected an ESP32 board to a camera module and an external PSRAM chip to store the resulting data. A Teensy 3.5 was added as the display controller, as it takes image data from an SD card and writes it to the ePaper screen.
Capturing someone's picture
The first of the three modes simply captures an image from the camera and shows it on the screen. Ordinarily, this would be a nearly trivial task, but due to the more specialized hardware, a bit of tinkering was required to get everything working properly. To begin, the ESP32 takes a new 640x480px monochrome picture about once every two seconds and stores it in PSRAM for later. From there, the image is scaled down to 320x240px due to MTMN model only accepting input data of that size and shape. If a face is detected, the facial detection algorithm is run a few more times just to confirm, at which point the image is rotated, offset, cropped, and dithered before sending the buffer to the Teensy 3.5.
Because the ePaper display only supports two colors, black and white, while the image is grayscale, it must first be converted. Dithering is simply a technique that is used to simulate grayscale on a monochrome display by creating patterns of dense/sparse areas of dark pixels to give the appearance of a gradient to the human eye.
Making and showing animations
Facial detection and snapping photos isn't the only thing this "magical" project is capable of doing, as it can also show animated images that are stored on an SD card. As is widely known, animations are simply a series of static images that are quickly changed to trick us into perceiving motion that does not actually exist. This is done by using an animation library that reads several bitmap files from the SD card in order and writes them to the ePaper display through the use of some clever drawing functions and pin toggling.
Constructing and using the magical newspaper frame
With the arduous task of writing the code and testing the hardware completed, Leopoldo could finally finish the last step of this project: building the newspaper itself. After choosing a suitable picture frame, he printed out a fictional article from the Daily Prophet on rice paper and removed the center to make space for the ePaper display.