Adafruit piTFT install
I bought one of these neat modules and am writing up a small digest of the install procedure:
Easy install
wget http://adafru.it/pitftsh mv pitftsh pitft.sh chmod +x pitft.sh sudo ./pitft.sh -t 28r -r
Customisation
This script carries out a lot of adaptations on the system. Details on the install in case you want to roll back a certain part of the install:
Installing screen driver:
sudo modprobe spi-bcm2708
sudo modprobe fbtft_device name=adafruitts rotate=90
export FRAMEBUFFER=/dev/fb1
this happens automatic on load:
sudo nano /etc/modules
added two lines:
spi-bcm2708 fbtft_device
screen configuration saved in modprobe, sets rotation and framerate:
sudo nano /etc/modprobe.d/adafruit.conf
options fbtft_device name=adafruitrt28 rotate=90 frequency=32000000
Calbration configuration is stored like this:
sudo mkdir /etc/X11/xorg.conf.d sudo nano /etc/X11/xorg.conf.d/99-calibration.conf
file contents:
Section "InputClass" Identifier "calibration" MatchProduct "stmpe-ts" Option "Calibration" "3800 200 200 3800" Option "SwapAxes" "1" EndSection
start graphc modes in piTFT (FB1), edit this file:
sudo nano ~/.profile
add/change:
export FRAMEBUFFER=/dev/fb1
Screen calibration
This is defined lke this:
sudo nano /etc/udev/rules.d/95-stmpe.rules
added:
SUBSYSTEM=="input", ATTRS{name}=="stmpe-ts", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
Remove and re-install the touchscreen with
sudo rmmod stmpe_ts; sudo modprobe stmpe_ts
Then type
ls -l /dev/input/touchscreen
It should point to eventX where X is some number, that number will be different on different setups since other keyboards/mice/USB devices will take up an event slot
There are some tools we can use to calibrate & debug the touchscreen. Install the “event test” and “touchscreen library” packages with
sudo apt-get install evtest tslib libts-bin
sudo evtest /dev/input/touchscreen
Auto calibration script here:
wget https://github.com/adafruit/PiTFT_Extras/raw/master/pitft_touch_cal.py sudo mkdir /etc/X11/xorg.conf.d/ chmod +x pitft_touch_cal.py sudo ./pitft_touch_cal.py
manual calibration:
sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_calibrate
and test:
sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_test
X-calibration system:
wget http://adafruit-download.s3.amazonaws.com/xinput-calibrator_0.7.5-1_armhf.deb sudo dpkg -i -B xinput-calibrator_0.7.5-1_armhf.deb
delete old calibration:
sudo rm /etc/X11/xorg.conf.d/99-calibration.conf
Now you’ll have to run the xcalibrator while also running X. You can do this by startx and then opening up the terminal program and running the xinput_calibrator command (which is challenging to do on such a small screen) OR you can do what we do which is run startx in a SSH/Terminal shell and then run the xinput_calibrator from the same shell, which requires the following command order:
FRAMEBUFFER=/dev/fb1 startx & DISPLAY=:0.0 xinput_calibrator
Run sudo nano /etc/X11/xorg.conf.d/99-calibration.conf and copy the
Section "InputClass" Identifier "calibration" MatchProduct "stmpe-ts" Option "Calibration" "119 3736 3850 174" # Option "SwapAxes" "1" EndSection
or whatever you got, into there. You can quit X if you want by typing fg to bring that command into the foreground, and then Control-C to quit.
Depending on the ‘rotation’ of the screen, when you do this calibration, you may need to comment out the SwapAxes part with a # and/or swap the numbers around so looks like:
Option "Calibration" "119 3736 3850 174"
to
Option "Calibration" "3736 119 174 3850"
Change Console look
sudo nano /boot/cmdline.txt
fbcon=map:10 fbcon=font:VGA8x8
sudo dpkg-reconfigure console-setup
and go thru to select Terminus 6×12
You may notice the console goes black after 30 minutes, this is a sort of ‘power saving’ or ‘screensaver’ feature. You can disable this by editing
/etc/kbd/config
and setting the blank time to 0 (which turns it off)
BLANK_TIME=30