There are quite a few displays out there that can be used with the RPi. Apart from those having an HDMI adapter or being connected via the composite output most bare bones displays have a parallel or serial data interface. Both of these last two types have to be connected via the SPI interface on the GPIO header. This means that those displays with a parallel data connection need to be interfaced via some sort of serial to parallel converter.
Being lasy and not wanting to take the extra risk to mess something up with the serial to parallel converter, I searched for an inexpensive small display with touch screen and SPI interface. I found the perfect match for my need in the HY28B.
After having some trouble getting it to run as the primary display of my RPi, I decided to share what I have learned. There are certainly other ways to achieve what I did and many of them are already described in variouse places. But I feel that my way might be the easiest and fastest and especially suited for users inexperienced in the linux world.
Step 1: Wire up your Display
For this step you will probably need some soldering skills because the 2mm pin spacing of the display makes it difficult to use standard jumper cables. For a quick and dirty setup I decided to connect everything with some loose wires as seen in the picture. Note that I didn’t solder the wires directly to the header pins but to the pcb side of some female header blocks.
My next step will be to design an adapter pcb to fit the display neatly on-top of my RPi in such a way that it can be integrated into a cutout in the existing enclosure.
Display pin #1 right (3V3_in) <-> RPi pin #1 (+3.3V)
Display pin #2 right (GND) <-> RPi pin #6 (GND)
Display pin #4 right (LCD_SDI) and pin #7 left (TP_SDI) <-> RPi pin #19 (SPI MOSI)
Display pin #5 right (LCD_SDO) and pin #6 left (TP_SDO) <-> RPi pin #22 (SPI MISO)
Display pin #6 right (LCD_RST) <-> RPi pin #22 (GPIO25)
Display pin #8 right (LCD_SCK) and pin #8 left (TP_SCK) <-> RPi pin #23 (SPI SCLK)
Display pin #10 right (LCD_CS) <-> RPi pin #24 (SPI CS0)
Display pin #1 left (BL_CTRL) <-> RPi pin #12 (GPIO18)
Display pin #5 left (TP_IRQ) <-> RPi pin #11 (GPIO17)
Display pin #9 left (TP_CS) <-> RPi pin #26 (SPI CS1)
The pins on the display are counted bottom up. The RPi pins are counted left to right, top to bottom (Ethernet jack facing to you).
If you don’t like to do this yourself you may still be able to get a ready made display with RPi adapter (shield) here.
Step 2: (Alternative) make an adapter pcb (shield)
If you are lucky enough to have etching equipment or a CNC mill precise enough to do isolation milling or if you have the time to wait for pcb fabrication abroad you can skip the wiring and make solid adapter pcb. Here is an example of how I did it: https://github.com/jgeisler0303/RPi-HY28b-adapter. Please also read the README in the github repository.
This adapter fits very tight onto the Pi, so there have to be some cut-outs for the composite connector and the Ethernet jack. You will also have to cut some unused pins from the display board to prevent them from touching the Ethernet jack. Please not that there is a difference between the layout I posted on github and the one shown on the photos. The new layout doesn’t require any extra wires. The layout is designed in such a way that you can use it for a double sided or for a single sided pcb. The single sided version requires some wiring though.
Step 3: Prepare your SD Card with a ready made image
The source for all SPI display drivers for the RPi is the github repository of notro. There is a ton of helpful information in the wiki of this repo. But for a quick start, notro also offers a ready made image of the official Raspbian with built-in display drivers. (There is also an image prepared to be used with the drivers as loadable modules. But since I wanted to use my RPi with the display as the only output, I opted for the kernel built-in version).
You can download the image from here. But please consider also visiting this containing site to donate for notro’s incredible efforts. After the download you will have to flash your SD card by following these instructions.
Step 4: Configure the image for the HY28B display
This is the step that contains my actual learning experience. The ready made image is not tailored to any specific display. So, you will have to add this information to two files on the SD card yourself. You can either do this on the host pc you already used to flash your card, or you can do it directly on your (still headless) RPi using ssh.
Before you can edit the two files you might have to run the SD card once to let it expand the file system. Since this is what I did, I don’t know if this step is really necessary or if you can proceed directly after flashing the card.
The first change you have to make concerns the configuration of the kernel driver for the display. This is done by adding the following to the one and only line in the file boot/cmdline.txt:
fbtft_device.name=hy28b fbtft_device.rotate=90 fbtft_device.speed=48000000 fbtft_device.fps=50 fbtft_device.debug=0 fbtft_device.verbose=0 fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo
(Since this file resides in the boot partition of the SD card, I don’t know if or how you can access this file on a Windows PC.)
For more detail: HY28B Touch Display with Raspberry Pi