Intermediate

RoboPeak USB TFT Display Setup

The latest version of Raspbian makes getting the RoboPeak TFT up and running a breeze. Here's how to do it!

6 September 2015 · Tutorial · about 15 minutes

Rejoice! The latest version of Raspbian includes some changes for Sense HAT which just so happen to be exactly what's needed to get the RoboPeak USB TFT Display up and running.

We've prepared a precompiled kernel module for both the Pi 1 and Pi 2 which you can install right into your existing Raspbian setup, all you need to do is make sure you're up-to-date and run the installer script.

Making Sure Your Pi Is Up-To-Date

First, you should make absolutely sure you're running the latest kernel. If you're not familiar with the terminology, this little fellow is the beating heart of Raspbian. The latest kernel has some tweaks and settings changes that are essential to making the RoboPeak USB display work. Without them you have to compile the kernel yourself - and that's no easy task - or download a complete compiled kernel, which will tie you to that kernel and make updates a little tricky.

To check whether your Pi needs updating, you should get the kernel version like so:

uname -a 

You're looking for version 4.1.6 and up, if you have this you're good to go!

If not you'll need to update yor Pi. Make sure you're connected to a network via Wi-Fi or Ethernet and run:

sudo apt-get update
sudo apt-get upgrade

Installing the RoboPeak USB TFT Display Driver

First you'll need to grab the GitHub repository. On your Pi, find a comfortable working directory ( cd ~ is always a good start ) and bash in the following:

git clone https://github.com/pimoroni/rp_usbdisplay

Once you've grabbed the repository, see your way into the right folder and run the installer:

cd rp_usbdisplay
./install.sh

If everything goes well you should see some static appear on your LCD. This is the installer copying random data right into its framebuffer and serves to let you know it's working.

Using The Display

The easiest way to use the display is alongside your existing HDMI display. This will let you get familiar with it, and write software to test on it without being confined to the tiny display itself.

To use split screen mode you should copy the extra/10-dualdisplay.conf file into the X config dir, like so:

sudo cp extra/10-dualdisplay.conf /usr/share/X11/xorg.conf.d/

Alongside The Raspberry Pi Touchscreen

If you've got the Official 7" Raspberry Pi Touchscreen you can run this little LCD right alongside it, with all the touch inputs working as you would expect.

Use the above file to get both screens up and running, and then run rpi-dfrobot-touch.sh to calibrate the touch screens once you're in your X desktop.

./extra/rpi-dfrobot-touch.sh

If you want to make the touchscreen calibration permanent you'll need to make sure it starts up every time X does.

First, copy xinitrc to your home directory:

cp /etc/X11/xinit/xinitrc ~/.xinitrc

Then edit it and add the touchscreen calibration script:

nano ~/.xinitrc

Add the line:

bash /home/pi/rp_usbdisplay/extra/rpi-dfrobot-touch.sh

Right before the line # invoke global X session script

Target The DFRobot Display With PyGame

You can force PyGame to start up on your second display as a handy little way to test your small-screen apps while developing on the big screen. Here's a basic example that shows a blank screen, displays events in Terminal and quits when you hit F10:

# !/usr/bin/env python

import pygame
import os

os.environ['DISPLAY'] = ':0.1'

pygame.init()
screen = pygame.display.set_mode((320,240),pygame.FULLSCREEN)
pygame.display.update()

while 1:
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN and event.key == pygame.K_F10: exit()
        if event.type == pygame.QUIT: exit()

    print(event)

    pygame.display.flip()

You should save this as a file, such as mygame.py, make it executable with chmod +x mygame.py and run with ./mygame.py.

The second display will go blank, and you should see touch events as you touch the screen.

Note: At the moment this focusses your second display, so you'll have to click/tap back on your main display to resume tweaking!