1.3″ screen with Raspberry pi

tl;dr

Just thought I would write a quick guide if like me your struggling to get your 1.3″ screen with ST7789 driver to work on a Rapsberry pi. Follow along below to get it up and running in no time. I need to point out that you will NOT be able to get this screen working on the breakout board is comes on. You can ether make your own breakout board or use the one I made HERE and can be ordered from oshpark HERE

Guide

The pinout for the screen I’m using is the same as waveshare use on there raspberry pi HAT board found HERE

  • SCLK – PIN 23 BCM 11
  • MOSI – PIN 19 BCM 10
  • DC – PIN 22 BCM 25
  • CS – PIN 24 BCM 8
  • RST PIN 13 BCM 27
  • LEDK – PIN 6 GND resistor 10 ohm
  • LEDA – PIN 1 VCC

Here is the pin numbers for the ribbon on the bare screen

Once that’s all wired up we move on to the software. I have copied all that is below from a PDF waveshare gave me. I copied it because it’s really hard to highlight and copy the text off of the PDF

Before we get started we need to go into raspi-config and turn on SPI. To do this run

sudo raspi-config

Then go down to option 5 “Interfacing Options”.

Then select P4 “SPI” and enable it.

After that just exit by selecting finished at the bottom.

Next we need to edit the file below


/etc/modules

Added the text below to the file then save and exit

spi-bcm2835
flexfb
fbtft_device

Next up we need to make a new file as shown below

/etc/modprobe.d/fbtft.conf

Add the text below to the file then save and exit

options fbtft_device name=flexfb speed=32000000 gpios=reset:27,dc:25
options flexfb setaddrwin=0 width=240 height=240 init=-1,0x11,-2,120,-1,0x36,0x00,-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

We need to install some software. Use the commands below to do so.

sudo apt-get install cmake git
git clone https://github.com/tasanakorn/rpi-fbcp
cd rpi-fbcp/
mkdir build
cd build
cmake ..
make
sudo install fbcp /usr/local/bin/fbcp

To make it run at boot time we need to open the file below

/etc/rc.local

Then here is the important part you need to add the following text to the file be it has to be above the word “exit” at the end of the file. Save and exit

fbcp &

You can reboot now to see if the screen is working. If you want to change the screen res you will need to exit the file below

/boot/config.txt

Just add this to the end. Uncomment/comment out the rotate lines as you see fit

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 # Upside down
display_rotate=2 #Right way up
#display_rotate=3 # Left

Github board files – https://github.com/facelessloser/ST7789_1.3_screen

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s