I know SPI screens get a bad write up, they are not as fast, they suffer with 'tearing' and they use up your gpio pins, but they have lots of benefits too!
You can get a screen that is ready to roll with no modifying for somewhere in the region of $6, they come in a range of sizes (2.2",2.4",2.8") and you can chop away excess PCB and get it rather small. They have a few more wires, and some slight software tweaks are needed to get them to work. So first off, lets get the wires connected.
Display--------Raspberry Pi
BL--------------pin 12 (GPIO 18)
SCK------------pin 23 (GPIO 11)
MISO----------pin 21 (GPIO 9)
MOSI----------pin 19 (GPIO 10)
CS--------------pin 24 (GPIO 8)
RST------------pin 22 (GPIO 25)
D/C-------------pin 18 (GPIO 24)
VIN-------------pin 17 (3.3v)
GND-----------pin 20 (GND)
So now your pi is wired up, get your pi up and running with a keyboard and a screen, we need to start to get things working. I am assuming we are working on a fresh install of RetroPie
First off we need to change a few "system" settings on the pi. If you exit emulationstation and in the terminal type
Code: Select all
sudo raspi-config
once you are back up and running again, exit emulationstation once more and get yourself back to a terminal and type
Code: Select all
sudo modprobe fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24,led:18 speed=16000000 bgr=1
now try typing
Code: Select all
con2fbmap 1 1

hurrahh
you can always type
Code: Select all
con2fbmap 1 0
OK, so we have proven the screen works, we need to make things more interesting. Firstly, you might have noticed that if you were to restart the pi, you will need to type your modprobe line in again to restart the screen. now this is no fun for a tiny handheld, so lets make the screen work every time.
First off we need to tell the pi to load the screen module at startup. We can do this by editing a file. type this,
Code: Select all
sudo nano /etc/modules
Code: Select all
spi-bcm2835
fbtft_device
You need to add the spi line, so that we are sure the connection port is ready for use, and then the tft device starts the screen. but we need to add in all of those extra settings that we had to type before. there is a place for this and it is another file. type this
Code: Select all
sudo nano /etc/modprobe.d/fbtft.conf
Code: Select all
options fbtft_device name=fb_ili9341 gpios=reset:25,dc:24,led:18 speed=16000000 bgr=1 rotate=90 custom=1
now try restarting the pi (I normally type sudo init 6) and let the pi restart. Fingers crossed your screen will light during the reboot process. If not, check your files for typo's, and check dmesg for any errors.
If your screen is illuminated, you can check it is ready to roll with the good old
Code: Select all
con2fbmap 1 1
So the screen works, and it loads every time, we now just need to make it do something fun. The main sticking point with these screens is that there is no real 'graphics acceleration' we can use with them. The only way it will work is to install some software to basically copy the current screen over to the ili9341 screen. now this is quite a simple task, we just need to type the following in a fresh terminal
Code: Select all
sudo apt-get install cmake
git clone https://github.com/tasanakorn/rpi-fbcp
cd rpi-fbcp/
mkdir build
cd build/
cmake ..
make
sudo install fbcp /usr/local/bin/fbcp
Code: Select all
fbcp

we just need to make this happen every time we boot. This is actually simple to do. We just need to add our newly installed program into the pi's autostart config file. To do this, we need to fire up the terminal again
Code: Select all
sudo nano /etc/rc.local
within this file you will see there is already some text in there. You need to make an addition between the ip address code and the exit line. You need to add in the line
Code: Select all
fbcp&
Code: Select all
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
fbcp&
exit 0
