This code is to get the Waveshare 3.5″ LCD running on a Raspberry Pi. A huge thanks to Awooga on the raspberrypi.org forum for posting this code. I have copied it verbatim, so I never lose it!
First step is to update everything
sudo apt-get update && sudo apt-get upgrade
Then we download the drivers from the manufacturer’s website
wget http://www.waveshare.com/w/upload/9/9d/LCD-show-151020.tar.gz
Not sure what this next bit does, I think it unpacks the download…
tar xvf LCD-show-151020.tar.gz
Now change the current directory
cd LCD-show
Finally, run the driver
sudo ./LCD35-show
This will boot you out the ssh and reboot the Pi, hopefully with the screen working. If you have issues, you may need to go into the raspi-config, go into A5 Device Tree, enable. A6 SPI enable and reboot automatically.
Calibration
You will need to install some software to calibrate the screen
sudo apt-get install -y xinput-calibrator
Use a mouse on the Pi to start the calibration via the main Preferences menu. It will ask you to touch for crosshairs and will then present you with some new calibration data in a Terminal window. Copy or memorise those numbers and then insert them into the areas denoted by: (here)
sudo nano /etc/X11/xorg.conf.d/99-calibration.conf
Section “InputClass”
Identifier “calibration”
MatchProduct “ADS7846 Touchscreen”
Option “Calibration” “(here) (here) (here) (here)”
Option “SwapAxes” “1”
EndSection