2.2" Display for Raspberry Pi

Jun 13, 2015

These cheap 2.2" LCDs are pretty handy for a Raspberry Pi.

Connect them like this:

Use Notoro's fbtft modules to get them working with Linux. They are included in the Raspberry Pi Raspbian image.

Edit /etc/modules and add (for landscape orientation):

fbtft_device name=adafruit22a rotate=90

Edit /boot/cmdline.txt to put login console on the LCD, add the following to the end:


Edit /boot/config.txt and add or uncomment the following to enable SPI:


User mode access using PyGame and DirectFB took a bit of sleuthing, bit I finally nailed it down.

  • Append the modes for the LCD to /etc/fb.modes
fbset --info -fb /dev/fb1|sed -n '/mode/,/endmode/p'|sudo tee -a /etc/fb.modes
  • Create ~/.directfbrc with:
  • Check permissions and ownership of /dev/fb1
[email protected] ~ $ ls -l /dev/fb1
crw-rw---T 1 root video 29, 1 Jun 14 16:50 /dev/fb1
  • Make your user is in the video group:
[email protected] ~ $ groups
pi adm dialout cdrom sudo audio video plugdev games users netdev gpio i2c spi input
  • Use the following code to initialise your PyGame application
        """Ininitializes a new pygame screen using the framebuffer"""
        # Based on "Python GUI in Linux frame buffer"
        # http://www.karoltomala.com/blog/?p=679
        disp_no = os.getenv("DISPLAY")
        if disp_no:
            print "I'm running under X display = {0}".format(disp_no)
        # Check which frame buffer drivers are available
        # Start with fbcon since directfb hangs with composite output
        drivers = ['fbcon', 'directfb', 'svgalib']
        found = False
        for driver in drivers:
            # Make sure that SDL_VIDEODRIVER is set
            if not os.getenv('SDL_VIDEODRIVER'):
                os.putenv('SDL_VIDEODRIVER', driver)
            except pygame.error:
                print 'Driver: {0} failed.'.format(driver)
            found = True
        if not found:
            raise Exception('No suitable video driver found!')
        size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
        print "%s: framebuffer size: %d x %d" % (driver, size[0], size[1])
        screen = pygame.display.set_mode(size, pygame.FULLSCREEN)
Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.