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
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
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