Raspberry pi 1.3" spi display, waveshare, stretch, quake 3, ST7789VM, spi
So i recently picked up this little module for a cheap price,
However some of the instructions were hacky and out of date.
Seems this was tested on jessie.
So i made updated instructions.
But firstly
Thank you to the assist form FactoryFactory on the adafruit discord.
Ur great buddy.
first grab a fresh copy of stretch.
Do not grab the retropie edition as it has given my nightmares we can load retropie later.
after loading up a fresh copy of Stretch make sure to update
sudo apt-get update
-Configure the modules
after that well need to tell it what modules to load by editing ect/modules
sudo nano ect/modules
and add these lines to enable spi, run flexfb and start fbtft
flexfb
fbtft_device
spi-bcm2835
Press ctrl + X to exit and it will ask to save
Press Y and hit enter again to confirm the file and directory.
-Create FBTFT config
sudo nano nano /etc/modprobe.d/fbtft.con
and add the following 2 lines to configure fbcp to the display.
The first line of options sets up the pins used on the 1.3"hat, the spi speed, fps, height and width.
The second sets up the address and initialization data.
options fbtft_device name=flexfb gpios=reset:27,dc:25,cs:8,led:24 speed=40000000 bgr=1 fps=60 custom=1 height=240 width=240
options flexfb gsetaddrwin=0 width=240 height=240 init=-1,0x11,-2,120,-1,0x36,0x70,-1,0x3A,0x05,-1,0xB2,0x0C,0x0C,0x00,0x33,0x33,-1,0xB7,0x35,-1,0xBB,0x1A,-1,0xC0,0x2C,-1,0xC2,0x01,-1,0xC3,0x0B,-1,0xC4,0x20,-1,0xC6,0x0F,-1,0xD0,0xA4,0xA1,-1,0x21,-1,0xE0,0x00,0x19,0x1E,0x0A,0x09,0x15,0x3D,0x44,0x51,0x12,0x03,0x00,0x3F,0x3F,-1,0xE1,0x00,0x18,0x1E,0x0A,0x09,0x25,0x3F,0x43,0x52,0x33,0x03,0x00,0x3F,0x3F,-1,0x29,-3
options fbtft_device name=flexfb gpios=reset:27,dc:25,cs:8,led:24 speed=40000000 bgr=1 fps=60 custom=1 height=240 width=240
options flexfb setaddrwin=0 width=240 height=240 init=-1,0x11,-2,120,-1,0x36,0x70,-1,0x3A,0x05,-1,0xB2,0x0C,0x0C,0x00,0x33,0x33,-1,0xB7,0x35,-1,0xBB,0x1A,-1,0xC0,0x2C,-1,0xC2,0x01,-1,0xC3,0x0B,-1,0xC4,0x20,-1,0xC6,0x0F,-1,0xD0,0xA4,0xA1,-1,0x21,-1,0xE0,0x00,0x19,0x1E,0x0A,0x09,0x15,0x3D,0x44,0x51,0x12,0x03,0x00,0x3F,0x3F,-1,0xE1,0x00,0x18,0x1E,0x0A,0x09,0x25,0x3F,0x43,0x52,0x33,0x03,0x00,0x3F,0x3F,-1,0x29,-3
Should be 2 lines like bellow
After rebooting you should start to see some activity.
-Displaying the desktop
sudo apt-get install cmake git
cd ~
git clone https://github.com/tasanakorn/rpi-fbcp
cd rpi-fbcp/
mkdir build
cd build/
cmake ..
make
sudo install fbcp /usr/local/bin/fbcp
sudo nano /etc/rc.local
In the next file default the frame buffer
Add fbcp& in front of exit 0
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
fbcp&
exit 0
Make sure everything matches as above.
-Enable light.dm
sudo vi /etc/lightdm/lightdm.conf
Modify lightdm.conf
find the 'xserver-command' which is under the option [SetDefaults].
Uncomment the statement: #xserver-command=X and change it to xserver-command=X -s 0 -dpms
-s: Disables the display protection.
dpms: closes the power efficiency manager.
Next setup a custom resolution.
Edit /boot/config.txt and add the following lines.
hdmi_force_hotplug = 1
hdmi_cvt = 240 240 60 1 0 0 0
hdmi_group = 2
hdmi_mode = 1
hdmi_mode = 87
display_rotate = 1
Finally, reboot your Pi.
-Troubleshooting
I sometimes find spi does not properly enable... idk why.
Run sudo raspi-config .
Use the down arrow to select 5 Interfacing Options.
Arrow down to P4 SPI .
Select yes when it asks you to enable SPI,
Also select yes if it asks about automatically loading the kernel module.
Use the right arrow to select the <Finish> button.
Select yes when it asks to reboot.
-Setting up controls.
As we can see from the data sheet this is not too complex.
https://www.waveshare.com/w/upload/a/a6/1.3inch-LCD-HAT-Schematic.pdf
Install retrogame
https://learn.adafruit.com/retro-gaming-with-raspberry-pi/adding-controls-software
https://learn.adafruit.com/pigrrl-2/software#installing-keypress-retrogame-support-4-9
The buttons are pre mapped to work with NES and SNES emulators. If you'd like to remap the controls, you'll need to modify the retrogame.cfg file in /boot.
# Sample configuration file for retrogame.
# Really minimal syntax, typically two elements per line w/space delimiter:
# 1) a key name (from keyTable.h; shortened from /usr/include/linux/input.h).
# 2) a GPIO pin number; when grounded, will simulate corresponding keypress.
# Uses Broadcom pin numbers for GPIO.
# If first element is GND, the corresponding pin (or pins, multiple can be
# given) is a LOW-level output; an extra ground pin for connecting buttons.
# A '#' character indicates a comment to end-of-line.
# File can be edited "live," no need to restart retrogame!
# Here's a pin configuration for the PiGRRL Zero project:
LEFT 5 # Joypad left
RIGHT 26 # Joypad right
DOWN 19 # Joypad down
UP 6 # Joypad up
Q 21 # Top button
W 20 # Middle button
ESC 16 # Bottom button
ENTER 13 # Mid of directional
# For configurations with few buttons (e.g. Cupcade), a key can be followed
# by multiple pin numbers. When those pins are all held for a few seconds,
# this will generate the corresponding keypress (e.g. ESC to exit ROM).
# Only ONE such combo is supported within the file though; later entries
# will override earlier.