Noam Zeise's Clever Raspberry Pi Software Hack Turns a 2" SPI Display Into an HDMI-Like Monitor

By faking a connected HDMI display and mirroring the framebuffer, this clever hack turns an SPI TFT panel into a fully-working main monitor.

Gareth Halfacree
11 days ago β€’ Displays / HW101

Computer science student Noam Zeise has put a compact 2" SPI display to an unusual task: acting as the main monitor for a Raspberry Pi single-board computer, by mirroring the images that would normally be sent over HDMI.

"My overall goal is to have a sort of handheld 'console' that I can connect a keyboard to and use as a normal computer," Ziese explains of the project, brought to our attention by Adafruit. "This [project] implements the display functionality needed to fulfill part of the goal. The end result is a system service that runs on startup, consuming 2.5MB of RAM and ~2% of the CPU. It also respects the X display power management system (DPMS) to save on battery life by going to sleep and turning the backlight off."

If regular monitors are a little big for your Raspberry Pi projects, why not mirror the image to a tiny SPI display instead? (πŸ“Ή: Noam Zeise)

Using compact LCD panels with single-board computers, connected over the SPI or I2C bus, is nothing new β€” except, typically, these displays act independently to the host operating system, showing a custom user interface developed specifically for the task at hand. To deliver on the project's goals, Ziese needed something different: a display identical to the one you'd see if you connected a normal monitor over HDMI.

The display in quest, an Adafruit implementation of a Sitronix ST7789-based 2" 320Γ—240 IPS panel and controller, can't take an HDMI or composite signal, and the Raspberry Pi Zero 2 W at the heart of Ziese's project only offers HDMI and composite. SPI is available over the board's general-purpose input/output (GPIO) headers, though, and with some clever software trickery that's enough to get things running.

"We essentially force the [Raspberry] Pi to think it is outputting to a monitor with the same resolution as the TFT display," Zeise explains, "then copy the framebuffer data over via SPI. This allows us to use the GPU to render programs as normal without extra effort. I wrote a program that runs as a system service and show the currently active display. It monitors whether the user is in a TTY terminal, or in a desktop environment and switches rendering modes accordingly."

Zeise has published the source code for the mirroring program to GitHub under an unspecified license; instructions on using it with a Raspberry Pi and ST7789-based display are available in a companion blog post.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles