Skip to content

Instantly share code, notes, and snippets.

@GautamBose
Forked from bchanudet/readme.md
Last active May 1, 2022 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GautamBose/f65bced3701afff223b2264619d4a1ad to your computer and use it in GitHub Desktop.
Save GautamBose/f65bced3701afff223b2264619d4a1ad to your computer and use it in GitHub Desktop.
Framebuffer on ST7735r (1.8inch TFT LCD SPI Display)

Enable modules in Kernel

In raspi-config

Enable SPI under "Interfacing options"

Add modules

$ sudo nano /etc/modules

Append two modules (in two lines) :

spi-bcm2835
fbtft_device

Create FBTFT configuration

# /etc/modprobe.d/fbtft.conf
options fbtft_device name=adafruit18 speed=24000000 gpios=reset:24,dc:25,cs:8,led:22 fps=60

Check /dev/fb1 is present

  1. Reboot you Raspberry Pi

    $ sudo reboot
    
  2. Once rebooted, check if new fb device is present

    $ sudo ls /dev # /dev/fb1 must appear
    $ sudo apt-get install fbset # framebuffer utility
    $ sudo fbset -i -fb /dev/fb1 # should return information of screen.
    

Change options in /boot/config.txt

Add or modify the following options in the file:

dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4
hdmi_force_hotplug=1
hdmi_cvt=128 128 60 1 0 0 0
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
display_rotate=1

#disable uart to boost boot speed
enable_uart=0
start_x=0

Then reboot:

$ sudo reboot

Synchroneous copy between fb0 and fb1

In order to display console and other things on the screen.

Compile fbcp

$ 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

Test it

$ fbcp

Right now you should see the content of the screen on the pHAT screen.

Launch automatically at startup

Edit the file /etc/rc.local. Add before the exit 0 line:

fbcp&

References

@steamkbg0506
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment