HY28B - 2.8" Touchscreen Display for Raspberry Pi

From wiki
Jump to: navigation, search

Contents

Ready made image

A Raspbian ready-made image for you to download so that you do not need to go through the configuration procedure below, click and download it and install into a new SD card. Thanks to Notro for putting it together!

2014-01-07-wheezy-raspbian-2014-03-12-fbtft-builtin-firmware-hy28b-speed-10M-mode-3.img.7z

go to work

The fbtft_device module can be built as a loadable kernel module, and built into the kernel proper (kernel.img on the RasPi). When builtin, the parameters to fbtft_device is provided on the kernel command line (/boot/cmdline.txt on the RasPi). Like this:

 fbtft_device.name=hy28b fbtft_device.speed=10000000 fbtft_device.rotate=90 fbtft_device.mode=3

The rotate= variable tells the driver to rotate the screen 0 90 180 or 270 degrees. You can change this file with nano and reboot to make the change stick.

The speed= variable tells the driver how to fast to drive the display. 36MHz (36000000) is a pretty nice 20 FPS rate but if your screen is acting funny, try taking it down to 10MHz (10000000), in fact, Most LCD speed can be up to 36MHz.

The mode= variable tells the driver the SPI mode use for the display. mode 3 is capable for all LCD, but for some LCD, when you touch the screen, the LCD display is abnormal, you can try SPI mode=0.

Touchpanel calibration

The touchpanel needs calibration to be precise. On the first start of X-windows, a calibration window will be shown.

Use a stylus to touch the points shown.

# no need to specify FRAMEBUFFER
# sudo is only needed when doing calibration
sudo startx

if you want to recalibrate the touchpanel for X windows, Delete /etc/pointercal.xinput, and then startx.

Some applications like PyGame, uses tslib for touch support.

sudo ts_calibrate

Test tslib

sudo ts_test

Special

When you touch the screen, the LCD display is abnormal, you can try SPI mode=0.

2014-01-07-wheezy-raspbian-2014-03-12-fbtft-builtin-firmware-hy28b-speed-10M-mode-0.img.7z

FBTFT Image Download

Raspberry Pi image with FBTFT support.

Wiki: https://github.com/notro/fbtft-spindle/wiki/FBTFT-image

FBTFT drivers as loadable modules. See 'Step-by-step' for loading drivers.

2014-06-20-wheezy-raspbian-2014-07-25-fbtft-master-firmware.zip
2014-01-07-wheezy-raspbian-2014-03-12-fbtft-master-firmware.zip

FBFTF drivers are built into the kernel. More info: branch: builtin

2014-06-20-wheezy-raspbian-2014-07-25-fbtft-builtin-firmware.zip
2014-01-07-wheezy-raspbian-2014-03-12-fbtft-builtin-firmware.zip

Step-by-step using FBTFT

Run the following commands to install the screen driver. Note that the screen will go from white to black indicating the commands succeeded.

if use loadable kernel module

sudo nano /etc/modules
spi-bcm2708
fbtft dma
fbtft_device name=hy28b rotate=90 speed=10000000 mode=3
ads7846_device pressure_max=255 y_min=190 y_max=3850 gpio_pendown=17 x_max=3850 x_min=230 x_plate_ohms=100 swap_xy=1 verbose=3

if use builtin kernel

 sudo nano /boot/cmdline.txt
 fbtft_device.name=hy28b fbtft_device.speed=10000000 fbtft_device.rotate=90 fbtft_device.mode=3
 sudo nano /etc/modules
 ads7846_device pressure_max=255 y_min=190 y_max=3850 gpio_pendown=17 x_max=3850 x_min=230 x_plate_ohms=100 swap_xy=1 verbose=3

To have the console start on the framebuffer with fonts VGA8X8 – edit /boot/cmdline.txt

Other fonts: MINI4x6, VGA8x8, Acorn8x8, PEARL8x8, ProFont6x11, 7×14, VGA8x16, SUN8x16, 10×18, SUN12x22

fbcon=rotate:1 can be used to rotate the console.

sudo nano /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline 
rootwait fbcon=map:10 fbcon=font:VGA8X8

Calibrate the touch panel

sudo apt-get update
sudo apt-get install libts-bin evtest xinput python-dev python-pip -y
sudo pip install evdev
sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0 ts_calibrate

Configure touch panel for landscape use

sudo nano /etc/X11/xinit/xinitrc

Add this line before “. /etc/X11/Xsession”

DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 0 0

blog comments powered by Disqus

Personal tools