Raspberry Pi drive 1.44inch LCD HAT with fbtft

The hardware:

The software:

  Some users feedback that this LCD less of instruction and some of them like to use it as a monitor of Pi. So, this article Let's learn how to port fbtft for displaying with Raspberry Pi.
  Framebuffer uses an buffer to store the data for displaying, if you want to change the display you just need to change the data on buffer.
  There is an open source project on github: https://github.com/notro/fbtft. Thanks to its contributors. With this project, Raspberry Pi could supports TFT LCD perfectly. Let's do it.


1. Open and edit module file to enable modules
   sudo nano /etc/modules
   Append two statement below to the file . The first one is to enable the SPI of Pi and the second is used to start the fbtft device.
2. Creating a new file for fbtft configuration
  sudo nano /etc/modprobe.d/fbtft.conf
   Add the statements to this new file:
   # /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
   Note: You need to edit the name to the exact type of controller of your LCD. The controller of 1.44inch LCD HAT is ST7735s which is same as adafruit18_green and the fbtft support it as well, so we use adafruit18_green here.
  gpios=reset:27,dc:25,cs:8,led:24 This statement set the PIN of LCD according to the schematic.
  height=128 width=128 rotate=180 Set the resolution of LCD and the orinetatin of display .
3. Restart your Pi. If you find that the screen is became black display then it is working. (Don't forget inset your LCD to Pi at first)
4. list the device and you can find that there is a device fb1. Otherwise the device failed to boot.
5. Use fbset command to get the infromation of fbtft device
  sudo fbset -i
6. If you failed to execute the fbset command you can install it and try again
   sudo apt-get install fbset
   As the image above, the resolution 128x128 is correct. However, others are wrong like the size is 32768 in fact but not 65536.
7. Read the memory with command:
   sudo cat /dev/fb1 > fb.fb
   Use the command ls -l it show that the size of fb.fb file is 32768
8. Edit it:
   vi -b fb.fb
 Type at the bottom to change its format to HEX: :%!xxd
9. You can see that there are all 0 on the memory, it is why the screen display black.  We change the first line to FF, convert to BIN file again and save.
:%!xxd -r
10. Display it
sudo cat fb.fb > /dev/fb1
   Then you can see that several white dots are display at left-bottom of screen. This is what Framebuffer work. If we change the data on buffer, the display will change as well,

Display a picture

Lets display a picture, first we need to install the PIL library of python
sudo apt-get install python-imaging
The code are:
#!/usr/bin/env python2
import os
import struct
from PIL import Image

im = Image.open('time.bmp')
im = im.rotate(270)

w, h = im.size
print( "w:", w ,"h:", h)

with open('/dev/fb1', 'wb') as f:
    for j in range(0,h):
        for i in range(0,w):
            r,g,b =im.getpixel((i,j))
            rgb=struct.pack('H',((r >> 3) << 11)|((j >> 2) << 5)|(b >> 3))
  The code will read one image,  convert it to data and write to device /dev/fb1. Note that the display uses two bytes for one pixel which is based on RGB565.
  If you run the code above, you will find that the screen displays line by line, it looks uncomfortable. 
  We can modify the code, first store data to fb file and then display it by command cat
#!/usr/bin/env python2
import os
import struct
from PIL import Image

im = Image.open('time.bmp')
im = im.rotate(270)

w, h = im.size
print( "w:", w ,"h:", h)

with open('time.fb', 'wb') as f:
    for j in range(0,h):
        for i in range(0,w):
            r,g,b =im.getpixel((i,j))
            rgb=struct.pack('H',((r >> 3) << 11)|((j >> 2) << 5)|(b >> 3))
os.system('cat time.fb > /dev/fb1')
Here we share these projects for you. You can click to download.

Display Desktop

  To display the desktop, we need to copy the content of fb0 to fb1 to make them keep synchronous.
1.  Install cmake tool
sudo apt-get install cmake git
2. Use the open source project we mention before
cd ~
git clone https://github.com/tasanakorn/rpi-fbcp
cd rpi-fbcp/
mkdir build
cd build/
cmake ..
sudo install fbcp /usr/local/bin/fbcp
3. Modify the fie:
sudo nano /etc/rc.local
 Add fbcp& in front of exit 0
Note: the character & is necessary, Otherwise the pi may failed to boot

4. Set the config.txt file
sudo vi /boot/config.txt
 Add statements:
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
5. Reboot your Pi and the LCD will display the desktop

Keeping lighting

 1. Open the lightdm.conf file:
sudo vi /etc/lightdm/lightdm.conf
2. Modify lightdm.conf
   find the 'xserver-command' which is under the option [SeatDefaults]. Uncomment     the statement: #xserver-command=X and change it to xserver-command=X -s 0 -dpms
  • -s: Disable the display protection
  • dpms: close the power efficiency manage
3. Finally, reboot your Pi.

Some users may like to use it for games, you could refer to these links, and we will not explain anymore.
-By Waveshare


  1. the image resolution is not coming correct in my case , any suggestions

  2. im getting fb1 but not correct image resolution

  3. ok, thank you very much
    it can help me


  4. Open Frame LCD Monitor, 32" Plug and Play Open Frame LCD Advertising Screen

    Commercial Display Manufacturer Co Ltd offers 32 Inch" Open frame LCD monitor, Frameless Advertising Player, Lcd Video Screen, Lcd Advertising Monitor.

    Visit here:- Open frame lcd monitor




Make a new larger font for Waveshare SPI e-Paper

Re-Compile Raspbian Kernel for Touch Rotation of Waveshare HDMI LCD