Skip to content

Instantly share code, notes, and snippets.

@bchanudet
Last active Aug 19, 2021
Embed
What would you like to do?
Framebuffer on ST7735s (1.44inch LCD HAT)

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_green gpios=reset:27,dc:25,cs:8,led:24 speed=40000000 bgr=1 fps=60 custom=1 height=128 width=128 rotate=180

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

@badjano
Copy link

badjano commented Feb 28, 2021

I just noticed your cmake command is missing some arguments:

#1.3inch LCD HAT
cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_ST7789VW_HAT=ON -DDMA_TX_CHANNEL=5 -DDMA_RX_CHANNEL=6 -DBACKLIGHT_CONTROL=ON -DSTATISTICS=0 ..
#1.44inch LCD HAT
cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_ST7735S_HAT=ON -DDMA_TX_CHANNEL=5 -DDMA_RX_CHANNEL=6 -DBACKLIGHT_CONTROL=ON -DSTATISTICS=0 ..

mine had a channel error, which made me change 5 to 7 and 6 to 1

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