Sunday, 13 July 2014

Raspberry pi + PiTFT Mini Kit - 320x240 2.8" TFT+Touchscreen

After some research and some help from notro, I'v finally gotten my raspberry pi up and running fully with the Adafruit PiTFT Mini Kit, using notro's 3.12.21+ #1 PREEMPT kernel.

This means that I have full support for the wifi chips I needed to use and really early activation of the fbtft screen (good for seeing if there are any boot time errors).

In the end i used the following process.
(note some extracts taken verbatim from notro's site)

Install rpi-update

rpi-update is used to install this kernel.
It must have REPO_URI support (auto updating doesn't work, since it overwrites the REPO_URI variable):
sudo wget -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update
Raspian: Remember to expand the filesystem if you haven't done so
sudo raspi-config
Raspian: Remember to enable SPI if needed
# remove or comment out the spi blacklist line
sudo nano /etc/modprobe.d/raspi-blacklist.conf

Install the kernel

FBTFT drivers built into the kernel proper
sudo REPO_URI= BRANCH=builtin rpi-update
sudo reboot
Enable modules to drive the screen hardware

edit /etc/modules
and  add/uncoment the following lines

stmpe_device cs=1 chip=stmpe610 blocks=gpio,ts irq-pullup irq-gpio=24 irq-base=330 sample-time=4 mod-12b=1 ref-sel=0 adc-freq=2 ave-ctrl=3 touch-det-delay=4 settling=2 fraction-z=7 i-drive=0
gpio_backlight_device gpio=252

edit /boot/cmdline.txt
and add the following fbtft_device.rotate=270 fbtft_device.speed=48000000 fbtft_device.fps=50 fbtft_device.debug=0 fbtft_device.verbose=0 fbcon=map:10 fbcon=font:8x8

Configure touchscreen
this can be done by using the Adafruit guide at their site so I won't reiterate it here.

Controlling the backlight

# Turn off backlight
echo 1 | sudo tee /sys/class/backlight/*/bl_power

# Turn on backlight
echo 0 | sudo tee /sys/class/backlight/*/bl_power
Brightness is currently not supported (need a kernel PWM driver for the Raspberry Pi).
Backlight control outside of FBTFT

Wiring Pi can be used to dim the backlight.
gpio -g mode 18 pwm 
gpio -g pwm 18 1023

and that's it.
hopefully this will give you the necessary pointers to get this up and running for yourself

Raspberry pi time on screen

Ever wanted to have the time show on the console all the time?
Well there's an easy way to do it.

just edit
and enable
at the end of the file