Skip to content

Instantly share code, notes, and snippets.

@shkbahmad
Last active October 29, 2020 17:26
Show Gist options
  • Save shkbahmad/f74c33e156d8e6a1cd68020c2ecc36a2 to your computer and use it in GitHub Desktop.
Save shkbahmad/f74c33e156d8e6a1cd68020c2ecc36a2 to your computer and use it in GitHub Desktop.
xpt2046 ads7846 3.5" GPIO Touchscreen Config For Raspbian Buster

sudo apt-get update

sudo apt-get upgrade

sudo reboot

sudo raspi-config

Go to Interface Options and Enable SPI

sudo reboot

sudo nano /boot/config.txt

Add this line at the end:

dtoverlay=piscreen,speed=16000000,cs=1,penirq=25,penirq_pull=2,keep_vref_on=0,swapxy=1,pmax=255,xohms=150,xmin=200,xmax=3900,ymin=200,ymax=3900,display_rotate=0

sudo reboot

sudo apt-get install fbi

sudo reboot

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

Change "fbdev" "/dev/fb0" to "fbdev" "/dev/fb1"

sudo reboot

sudo nano /etc/xdg/lxsession/LXDE/touchscreen.sh

Add these lines to the file:

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

Make it executable:

sudo chmod +x /etc/xdg/lxsession/LXDE/touchscreen.sh

sudo nano /etc/xdg/lxsession/LXDE/autostart

BEFORE the line @xscreensaver -no-splash add this:

@lxterminal --command "/etc/xdg/lxsession/LXDE/touchscreen.sh"

sudo reboot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment