While trying to connect my Raspberry Pi Model B (Version 1) to Adafruit 2.8 TFT capacitive screen (not the PiTFT), I'm having complication of the screen constantly showing white screen despite following the latest guide by Adafruit here on 'Running OpenGL-based Games & Emulators on Adafruit PiTFT Displays'. Perhaps that guide will work straight out of the box for PiTFT, but certainly not the 2.8' TFT that I'm having.
I've actually spent a whole night trying to source out the problems and solution and I'm glad that I did. So I've decided to write this tutorial in case you're having the same problem as I had.
Note: I'm connecting the Adafruit 2.8 TFT display to my Raspberry Pi Model B (Version 1). The steps should be similar in the second revision.
This guide is made possible thanks to various contribution authors mentioned in the Reference section at the end of this article.
<Pictures will be added in the future>
Connecting the Raspberry PiFirst of all, connect the Adafruit 2.8 TFT to your Raspberry Pi following the chart mapping below:
|Connecting pins from Raspberry Pi to 2.8' Adafruit TFT|
In order for the TFT to know that we are using the SPI instead of the 8-bits data line connection, we will have to either connect the three selectors (IM1, IM2, IM3) to 3.3V or solder the pads. I don't really want to mess up the soldering so I've decided to route it to 3.3V of the Pi instead using spare breadboard. For miniature project like PiBoy you might want to solder it to save some wiring.
Note: Only connect IM1, IM2, and IM3 to the 3.3V pin instead of the 5V to avoid damage!
Installing Adafruit PiTFTHelperBefore proceeding to update the repository, make sure your Raspberry Pi network connection is not behind any Firewall or proxy to prevent the link not found error or timeout.
In case you are seeing connection problem trying to connect to the raspian repository, change to another mirror url by adding the following to the repository source list.
deb http://archive.raspbian.org/raspbian wheezy main contrib non-free
deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free
pi@retropie ~ $ sudo nano /etc/apt/sources.list
* The deb http://apt.adafruit.com/raspbian repo link is added when you follow the steps below. So you don't have to add that yourself.
Next, update the repository by:
pi@retropie ~ $ sudo apt-get dist-upgrade
pi@retropie ~ $ sudo apt-get update
Most of the steps are taken from Adafruit Guide on Running OpenGL-based Games & Emulators on Adafruit PiTFT Displays here.
1. Fetch the PiTFT configuration helper script:
pi@retropie ~ $ curl -SLs https://apt.adafruit.com/add | sudo bash
pi@retropie ~ $ sudo apt-get install adafruit-pitft-helper
Note: In case you cannot input the '|' character, make sure you switch the keyboard layout to English (US). By default Raspberry Pi uses English (UK) layout. Entering '|' is crucial as it pipes the script into the bash terminal. Refer to the [Extra Configuration] section at the end of this article on how to do so.
2. Run the configuration script with
pi@retropie ~ $ sudo adafruit-pitft-helper -t 28r
Enter 'NO' when it ask to display console on the PiTFT.
* 28r indicates the 2.8inch resistive screen.
The script will append some lines in the /boot/config.txt files. We'll see this later.
3. Install fbcp (a live framebuffer mirroring tool developed by an awesome guy nicked Notro here. To the uninitiated, using framebuffer will speed up the display tremendously.
pi@retropie ~ $ sudo apt-get install cmake
pi@retropie ~ $ git clone https://github.com/tasanakorn/rpi-fbcp
pi@retropie ~ $ cd rpi-fbcp/
pi@retropie ~ $ mkdir build
pi@retropie ~ $ cd build/
pi@retropie ~ $ cmake ..
pi@retropie ~ $ make
pi@retropie ~ $ sudo install fbcp /usr/local/bin/fbcp
Basically this will compiled a binary executable called fbcp and put it in your local directory where you can simply execute by typing fbcp.
Here is where the steps will differ compared to Adafruit guide. In my personal experience, following the guide shows nothing but white screen upon reboot. Please follows the steps below carefully.
4. Add both spi-bcm2708 and fbtft_device module to the modules file.
pi@retropie ~ $ sudo nano /etc/modules
5. Add the following parameters for the newly created fbtft_device module
options fbtft_device custom name=fb_ili9341 rotate=90 buswidth=8 bgr=1 fps=60 speed=80000000 gpios=reset:25,dc:24,led:18
pi@retropie ~ $ sudo nano /etc/modprobe.d/fbtft_device.conf
Also add the similar parameter to /etc/modprobe.d/adafruit.conf
6. Add the following in the /boot/config.txt. We don't really need to add the dtoverlay=... statement since we're already defining it in the fbtft_device.conf module.
pi@retropie ~ $ hdmi_force_hotplug=1
pi@retropie ~ $ hdmi_cvt=320 240 60 1 0 0 0
pi@retropie ~ $ hdmi_group=2
pi@retropie ~ $ hdmi_mode=87
Doing this will force the HDMI to output in 320x240 resolution, 60 FPS. The resolution is important here as setting it too high will result in some lagginess in the PiTFT display. More on custom HDMI modes here.
7. Make the fbcp run at startup instead of manually invoking it via SSH. Add the following lines just under the do_start() function.
pi@retropie ~ $ sudo nano /etc/init.d/rc.local
8. Switch the Console back to HDMI instead of the PiTFT
By default fbtft will output the console to the PiTFT screen. We really don't want that since it will then be showing both the EmulationStation and the console overlapping together with a blinking cursor. Even worst, you will see the key press (e.g. [[23) when pressing the keys in game.
To do that, edit the /etc/rc.local file and add the following before the exit 0 line
pi@retropie ~ $ sudo nano /etc/rc.local
9. Make sure EmulationStation is not switching to HDMI resolution when launching the games.
Add the following lines to the script:
mode_new = "DMT-87"
pi@retropie ~ $ sudo nano /opt/retropie/supplementary/runcommand/runcommand.sh
10. Alright we are all set. Reboot your Pi and you should the bootup sequence followed by EmulationStation screen! Now enjoy your emulation on your 2.8' PiTFT! :-)
Feel free to leave a comment below if this is helpful!
- The backlight will turn off after 30 minutes of inactivity.