#!/bin/bash if ! grep "#Waveshare" /boot/config.txt >/dev/null then cp /boot/config.txt . cat <<'EOF'>> add.txt #Waveshare 5inch hdmi_group=2 hdmi_mode=87 hdmi_cvt 800 480 60 6 0 0 0 hdmi_drive=1 dtoverlay=ads7846,cs=1,penirq=25,penirq_pull=2,speed=50000,keep_vref_on=0,swapxy=0,pmax=255,xohms=150,xmin=200,xmax=3900,ymin=200,ymax=3900 EOF cat add.txt >> config.txt rm add.txt sudo cp config.txt /boot/ rm config.txt fi sudo apt-get update sudo apt-get install xserver-xorg-input-evdev xinput-calibrator -y sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf if [ -f /usr/share/X11/xorg.conf.d/99-calibration.conf ] then sudo rm /usr/share/X11/xorg.conf.d/99-calibration.conf fi sudo cat <<'EOF'>> 99-calibration.conf Section "InputClass" Identifier "calibration" MatchProduct "ADS7846 Touchscreen" Option "Calibration" "208 3905 288 3910" Option "SwapAxes" "0" Option "EmulateThirdButton" "1" Option "EmulateThirdButtonTimeout" "1000" Option "EmulateThirdButtonMoveThreshold" "300" EndSection EOF sudo cp 99-calibration.conf /usr/share/X11/xorg.conf.d/99-calibration.conf rm 99-calibration.conf