Extras!

Tactile switch as power button

Its a good idea to safely turn off your Pi with a good sudo shutdown -h now but that often means pulling out a keyboard or connecting to the console. With our kernel we added a cool module that will let you turn any GPIO into a power button. Since there's a couple of tactile switches right there on the front, lets turn one into a power button. Press once to properly turn off the pi, press again to start it up. Isn't that nice?

We'll be using GPIO #23, the third button. You can use any of them or other GPIO but #23's our favorite number anyways.

Add rpi_power_switch to /etc/modules and save

Now create a new conf file or edit our existing one with

sudo nano /etc/modprobe.d/adafruit.conf

and enter in the line

options rpi_power_switch gpio_pin=23 mode=0

Of course, change the gpio_pin setting to some other # if you wish. mode=0 means its a pushbutton not a switch. If you happen to install an on/off switch, use mode=1

To make it active immediately run sudo modprobe rpi_power_switch

Boot to X Windows on PiTFT

To enable booting straight to X windows on the PiTFT follow the steps below.  First make sure a display configuration which would conflict is not present by executing in a terminal on the Pi:

sudo mv /usr/share/X11/xorg.conf.d/99-fbturbo.conf ~

Don't worry if the command fails with an error that the file doesn't exist.  This failure is normal and should happen on a good PiTFT install.  You can ignore it and move on.

Next run the command below to open the nano text editor as root and create the file /usr/share/X11/xorg.conf.d/99-pitft.conf:

sudo nano /usr/share/X11/xorg.conf.d/99-pitft.conf

When the editor loads to a blank file, copy in the text below:

Section "Device"
  Identifier "Adafruit PiTFT"
  Driver "fbdev"
  Option "fbdev" "/dev/fb1"
EndSection

Then save the file by pressing Ctrl-O and then enter, and finally exit by pressing Ctrl-X.

The step above will create a configuration file which tells X windows that it should use the PiTFT framebuffer (located at /dev/fb1) by default when it runs.

At this point you can use the raspi-config tool to enable booting to desktop just like normal on the Pi.  Run the following command:

sudo raspi-config

Then pick the Enable Boot to Desktop/Scratch option and choose if you want to boot to the console, desktop, or scratch environment.  After exiting the tool and rebooting you should see the Pi load X windows on the PiTFT after (be patient it can take around 30 seconds to load).

If you want to disable booting to X, just use the raspi-config command again to choose the console boot option

Last updated on 2015-05-04 at 04.27.56 PM Published on 2014-12-19 at 04.05.04 PM