Blog Home Dudermang

pi touch screen

by Corey Faulkerson

Posted on 2016-12-29 23:59:11


Following instructions will save tons of time for Raspberry Pi3 users who had purchased
display like 5 Inch Touch Display from Waveshare which uses XPT2046 driver chip.

0) In OS Jessie NO DRIVER REQUIRED! for XPT2046 or ADS7846 Touchscreen. Do not install original driver from Waveshare or any other driver announced as compatible. You will kill your Jessie for sure. At least Waveshare driver totally disables WiFi module functionality!!!

1 ) sudo nano /boot/config.txt
Code: Select all

2) sudo nano /etc/modules
Code: Select all
ads7846_device model=7846 cs=1 gpio_pendown=25 speed=1000000 keep_vref_on=1 swap_xy=1 pressure_max=255 x_plate_ohms=150 x_min=184 x_max=3869 y_min=141 y_max=3959

NOTE: This will start the internal touch driver with calibration parameters same as xinput calibrate utility gives. However, X axis will be inverted.
Values In config string x_min=184 x_max=3869 y_min=141 y_max=3959
are the same that xinput config string
Code: Select all
Option  "Calibration"   "3869 184 141 3959"

3) Now fixing inverted X axis. Get evtest for screen touch axis management
sudo apt-get install -y libts-bin evtest xinput python-dev python-pip
sudo pip install evdev

4) Create axis inversion script in your /home and add this script into autostart
Edit Autostart for Wheesy sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
Edit Autostart for Jessie sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart
Add string
Code: Select all
@sh /home/pi/

Run command
sudo nano /home/pi/
Add following into to newly created file
Code: Select all
#Copyright for this script belongs to Raspberry Pi community
#script to set correct touchscreen orientation after x start
#this won't rotate the displayed image, only the touchscreen input
#to rotate the displayed image add the following to /boot/config.txt
#"display_rotate=1" to rotate display 90 degrees
#"display_rotate=3" to rotate display 270 degrees
#DISPLAY=:0 xinput set-prop 'ADS7846 Touchscreen' 'Evdev Axes Swap' 1
#Uncomment this for 90 rotation
#xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 0 1
#Uncomment this for 270 rotation
DISPLAY=:0  xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 0

5) REBOOT aaaaand have fun!!!!!!


pi, raspberry, touch, screen,