nano /boot/config.txt
after the last entry:
dtoverlay=ads7846,speed=500000,penirq=17,swapxy=1
Press Ctrl-X then Y to exit nano and save the changes.
nano /usr/share/X11/xorg.conf.d/10-evdev.conf
Section “InputClass”
Identifier “evdev touchscreen catchall”
MatchIsTouchscreen “on”
MatchDevicePath “/dev/input/event*”
Driver “evdev”
Option “InvertY” “true”
EndSection
Press Ctrl-X then Y to exit nano and save the changes.