Using 2.8” Touchscreen Display on Raspberry PI

Updated on 2014.09.13: this tutorial is for Raspberry Pi model A/B only. If you follow this tutorial on model B+, it will not work. At the time being we could not say it is impossible to use this screen on the model B+, but at least some work on software has to be done before that happens.


 

This is a cute, tiny 2.8″ touchscreen for Raspberry Pi. It is designed to work as an SPI device, and use the hardware SPI pins (SCK, MOSI, MISO, CE0, CE1). It also has 4 reserved buttons on board, which use 4 GPIO pins (#23, #22, #21, and #18). You can define some special tasks for this buttons, such as “shutdown”, “reset”, “brightness up/down” etc.


Here are the steps to setup everything.

Step 1: Mount the Touchscreen Over the Pi

First off you need to mount this tiny touchscreen over the Raspberry Pi, like this:

PiTFT - 2.8" Touchscreen Display for Raspberry Pi

Step 2: Driver Installation

To install the driver for this touchscreen, you need to login to Raspberry Pi via SSH or you have another display connected to the Pi.

You need to download these driver packages:

If your Raspbian is released after January 2014, you may need to download this patch as well:

Let’s install them:

Again if your Raspbian version is after January 2014, please move the configuration file, as shown below:

Then you need to reboot your Pi:

 Step 3: Testing Driver

Now you input the commands below, and enter X window. If everything goes fine, you should see the X window in the mini display:

IMG_0102

Step 4: Auto Loading the Driver at Boot

If you wish the driver to be loaded at boot, you can modify the /etc/modueles file:

and append two lines as below:

and then modify the adafruit.conf file:

add the following line

Here we set the driver to rotate the screen 90 degrees (it could be 0, 90, 180 or 270 degrees). You can always change this file with and reboot to let the change take effect.

We also set the refresh frequency of the display to 32MHz, which is good for 20 FPS. If your display doesn’t behave correctly with this frequency, try 16MHz instead.

We need to create the calibration file and the directory to store it:

Put the following content into the file and save it.

If you don’t wish to specify the output device every time, you can modify the .profile file:

and add the line below into the file:

 Step 5: Calibration

First we modify the 95-stmpe.rules file:

and add the command below:

Execute this command to remove and re-install the touchscreen:

Now we install the calibration application:

Input the command below to start calibration, you can always quit with Ctrl+C:

IMG_0100

Type this command to verify the result of calibration, again you can quit with Ctrl+C:

IMG_0101

Step 6: Display a Picture

Use the commands below can download a picture and display it on your mini touchscreen display:

IMG_0105

Step 7: As Terminal Display

Well, if you wish to use this display to replace the HDMI/TV output, you are just one step away:

Append this after the “rootwait”

By doing so, next time when you boot your Pi, this tiny touchscreen will work as the terminal display.

IMG_0098 IMG_0099

Because of the low resolution, using 6×12 font will get better result:

Just follow these configure steps and then reboot your Pi:

UTF-8 -> Guess optimal character set -> Terminus -> 6×12(framebuffer only)

config

Step 8: Button to Shutdown Your Pi

Do you still remember the 4 reserved buttons? We can define the task we need and associate with them. For example: shutdown the Pi.

Add this to the file:

Again we modify the adafruit.conf file:

Append these to the file, the first button on the left is the one that connect to GPIO #23:

Done! Now you can enjoy it :-)

See also