I went to the webpage of my screen (waveshare) and followed their instructions.
having a 99-calibration.conf in /etc/X11/xorg.conf.d/
Section "InputClass"
Identifier "calibration"
MatchProduct "stmpe-ts"
Option "Calibration" "3807 174 244 3872"
Option "SwapAxes" "1"
EndSection
In config.txt
hdmi_drive=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 800 480 60 6 0 0 0
display_rotate=2
in /etc/X11/xorg.conf.d/40-libinput.conf
besides other sections:
Section "InputClass" Identifier "libinput touchscreen catchall" MatchIsTouchscreen "on" Option "CalibrationMatrix" "-1 0 1 0 -1 1 0 0 1" MatchDevicePath "/dev/input/event*" Driver "libinput" EndSection