Sunday, October 16, 2016

A while back my local MicroCenter got some Pi Zeros in stock. I bought several, along with a couple microSD cards. I ordered a micro-HDMI adapter and an OTG USB hub, and I was in business.

I was poking around on Amazon and found that a number of vendors are selling low cost TFT LCDs that work over the hardware SPI port. A number of developers have written kernel drivers for them, including the very popular Notro FBTFT drivers and SWKim01's Waveshare drivers. Prices range from $11 on up, with plenty being available for around $20.

I didn't have a project in mind, but it seemed like a neat thing to be able to do with a $5 computer, so I selected this one, a 3.5" LCD that uses the Waveshare driver. This unit is designed to plug right on top of the headers on the Pi Zero. This is convenient, but blocks a lot of the IO pins. The vendor provides a customized distribution of Rasbian for download, but I preferred to work on the standard one. Luckily, one of the reviewers left an outstanding review with all the details needed to get it going on a standard Raspian machine.

The Zero doesn't have any IO pin headers installed, so I added enough to plug in the LCD.

The LCD plugs in and stands off a good distance from the Pi. If I wanted a thinner setup, I'd probably buy an LCD that does not plug into the headers and hand wire the connections.

When you next start up the Pi, don't expect video yet. You need to do some configuration to have it use the correct driver for the framebuffer and direct the console there. All of this information came from the terrific writeup in an Amazon review here. I'm not breaking any new ground at all, but wanted to duplicate it in case the review goes away.

1) Edit /boot/cmdline.txt to have the following arguments:

dwc_otg.lpm_enable=0 console=tty1 console=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo
2) Add the following to the end of /boot/config.txt:

If, like me, you have a minimal installation without X Windows installed, you can reboot now - you're done. The framebuffer console should scroll on the LCD. I have not tested the section below yet, but the Amazon comment goes into the detail for configuring X Windows:

(update: I have tested X, and it works great. Notes on preventing screen blanking are below)

add the following to /etc/lightdm/lightdm.conf in the section [SeatDefaults]

xserver-command=X -s 0 -dpms

Framebuffer Console Tools

With the framebuffer working, you can use programs like fbi to display images, or other utilities to play video. I found that video did work, but was limited by the SPI throughput to a couple of frames per second, so I'm not convinced that's very useful. For displaying images in a slide show, this command works well:

sudo fbi -T 2 -d /dev/fb1 -a -t 5 -noverbose /home/pi/images/*

It will display all the images in the passed directory in an infinite loop with delay of 5 seconds.

About Me

One guy's wanderings through science and technology, just for the fun of it. Currently focused on astronomy and hobby robotics, but likely to wander into photography, DIY drones, CNC and 3D printing, or whatever seems interesting at the time.