Adafruit PiTFT 2.8″ on Ubuntu

If your trying to get the Adafruit 2.8″ display running on a Raspbian distro get yourself along to the Adafruit pages as they have done all the hardwork for you and there is little more your going to need to know to get things up and running. If however your wanting to get things running with the Ubuntu distro I spoke of briefly on the Ubuntu on the Pi 2 page then read on….

I am by no means an expert at this sort of thing but I have managed to hack it together to give me the desired result, I would happily accept any pointers and hints on how to do this properly!

The only way the nice people at Adafruit are distributing the PiTFT kernel packages right now is thru apt.adafruit.com so you’ll still need to run:

curl -SLs https://apt.adafruit.com/add | sudo bash

To add apt.adafruit.com to your list of software sources, once that is complete we need to install the kernal with the following command:

sudo apt-get install -y adafruit-pitft-helper

That’s the kernel installed, all you have to do is run the helper which will configure the kernel device tree overlays and add the few configurations to make the console show up

sudo adafruit-pitft-helper -t 28r -u /home/linaro

Screen rotation is controlled via the boot config, so edit /boot/config.txt with the following command:

sudo nano /boot/config.txt

and at the end of the file add the following lines

[pi1]
device_tree=bcm2708-rpi-b-plus.dtb
[pi2]
device_tree=bcm2709-rpi-2-b.dtb
[all]
dtparam=spi=on
dtparam=i2c1=on
dtparam=i2c_arm=on
dtoverlay=pitft28r,rotate=90,speed=32000000,fps=20

There are a few bits in there that deserve extra explanation…

The rotate= variable tells the driver to rotate the screen 0 90 180 or 270 degrees.
0 is portrait, with the bottom near the USB jacks
90 is landscape, with the bottom of the screen near the headphone jack
180 is portrait, with the top near the USB jacks
270 is landscape, with the top of the screen near the headphone jack.

The speed= variable tells the driver how to fast to drive the display. 32MHz (32000000) is a good place to start but if your screen is acting funny, try taking it down to 16MHz (16000000) especially if you’re doing something like using a GPIO extender to put the screen away from the Pi.

All the way through testing I had the screen attached to an additional riser as I need the additional space to gain access to the extra GPIO pins on the Pi 2 without any issues on the speed side of things.

You will require a reboot before any of these changes will take effect

If you have changed the screen rotation you will need to re-calibrate the touch screen

sudo adafruit-pitft-touch-cal

If everything is working up to this point then as the Pi 2 started up the PiTFT should have been white, and then turned black, and a bunch of the console during boot will be displayed, before it just seams to freeze… don’t panic all this has happened is the display has now been directed over to the HDMI port as per the pre-config of the Ubuntu build, this is easily fixed with a quick edit of the xorg.conf file

sudo nano /etc/X11/xorg.conf

Have a look for the line

Option "fbdev" "/dev/fb0"

and change it to read

Option "fbdev" "/dev/fb1"

This will direct screen output to the PiTFT all of the time

If you want to stop LXDE starting by default when we power the Pi 2 up, run the following to rename the lxdm config file:

sudo mv /etc/init/lxdm.conf /etc/init/lxdm.conf.nostart

If you ever want to put it back you can by running the following command

sudo mv /etc/init/lxdm.conf.nostart /etc/init/lxdm.conf

Have fun and play safe

UM

You may also like...

3 Responses

  1. Wesley says:

    Hi,

    I was wondering if this would work on Ubuntu MATE 16.04 on the Raspberry Pi 3.

    Thanks

    • uncle-muddy says:

      Hi,
      I can’t see any reason as to why it wouldn’t work in that configuration. Ubuntu also uses reboot as a command so providing that the Pi behaves the same during the reboot cycle and initializes the GPIO pins during the reboot you will still have the pull to GND that we need to signal to the 500C

  2. Larry Litton says:

    Using Pi3, pitft 2.8, Ubuntu 16.04.1 , and after entering your code I get
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:

    The following packages have unmet dependencies:
    adafruit-pitft-helper : Depends: tslib but it is not installable
    Depends: libts-bin but it is not installable
    E: Unable to correct problems, you have held broken packages.

    Not sure where to go from here, I’m rather new to Ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *