-
1Step 1
Setting up the display
First you need to wire up the display as following:
RPi Header TFT Display GPIO 11 (SCLK) SCK GPIO 10 (MOSI) MOSI GPIO 8 (CE0) CS GPIO 24 D/C GPIO 25 RESET 5v VCC, BL GND GND -
2Step 2
When you have wired the display you have to boot your Raspberry pi and run:
sudo raspi-config
In this menu you have to expand the file system and enable SPI under the Advanced Options menu. -
3Step 3
To make the module load on boot-up run this
sudo REPO_URI=https://github.com/notro/rpi-firmware rpi-update sudo nano /etc/modules fbtft_device name=sainsmart18 rotate=90
Source: http://www.raspberrypirobot.com/1-8-tft-lcd-display-raspberry-pi-expansion-board/
-
4Step 4
sudo reboot
Now you have to reboot and the display should work. In the beginning the display would be blank but after a while you should see the terminal. Now you could login with the default credentials.
To start the desktop environment you have to run
sudo FRAMEBUFFER=/dev/fb1 startx -- -dpi 60
And it would look a bit like this: -
5Step 5
Installing RetroPie
Installing RetroPie is very simple. You just have to follow the steps on the github page and make it boot automatically.
https://github.com/retropie/RetroPie-Setup
Before we install the program to run RetroPie on the display it would be easier to configure it on a monitor because the text is very small on the display. But if you want to configure it on the TFT you could do step 6 first.
I configured the controls as following:
A 7 on the numpad B 8 on the numpad START z key SELECT x key LEFT Left arrow RIGHT Right arrow UP Up arrow DOWN Down arrow L Number 5 R Number 6 -
6Step 6
Routing EmulationStation to the TFT
The emulators won't route to the TFT by default. That's why we have to install fbcp.
Fbcp is used to mirror /dev/fb0 to /dev/fb1. To install it you have to do the following:
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
Then you need to edit /boot/config.txt and add or change the existing lines to:
hdmi_force_hotplug=1 hdmi_cvt=160 128 60 1 0 0 0 hdmi_group=2 hdmi_mode=87 dtoverlay=pitft28r,rotate=90,speed=80000000,fps=60
-
7Step 7
Setting up Adafruit-Retrogame:
Clone Adafruit-Retrogame from the github repo
git clone https://github.com/adafruit/Adafruit-Retrogame.git
Whenthis is done cd into Adafruit-Retrogame and open retrogame.c inside the
Adafruit-Retrogame folder. In retrogame.c you should search for the
line "ioStandard[] = {" and change it to the following:
ioStandard[] = { // This pin/key table is used when the PiTFT isn't found // (using HDMI or composite instead), as with our original // retro gaming guide. // Input Output (from /usr/include/linux/input.h) { 5, KEY_LEFT }, { 6, KEY_RIGHT }, { 13, KEY_UP }, { 19, KEY_DOWN }, { 20, KEY_Z }, { 16, KEY_X }, { 26, KEY_KP7 }, { 21, KEY_KP8 }, { 12, KEY_5 }, { 23, KEY_6 }, { -1, -1 } }; // END OF LIST, DO NOT CHANGE
When you are finished you need to make the file by running:make retrogame
Because RetroPie is build on SDL2 it won't recognize the input by default that's why we need to add a rule. To add the rule you have to open /etc/udev/rules.d/10-retrogame.rules and add the following line:
SUBSYSTEM=="input", ATTRS{name}=="retrogame", ENV{ID_INPUT_KEYBOARD}="1"
After you have added the rule we can make retrogame run on boot by editing rc.local. The location of this file is /etc/rc.local in these file you have to append
/home/pi/Adafruit-Retrogame/retrogame &
before the "exit 0" line.
Now you could reboot and retrogame will run.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.