Add a 5 inch Waveshare display spi touch

mini11 29 July 2022 pCP 8.2.0 Projects  •  •
Waveshare 5 inch HDMI Display, 800x480, resistive spi touch with piCorePlayer.

5 inch display

5 inch display

What we need

  • Raspberry Pi 2, 3, 4 or piZero WH
  • 8GB Micro SD card
  • Waveshare 5 inch display, resistive spi-touch with HDMI-adaptor
  • Optional: Some jumper wires, female to female
  • Powersupply, 5V, >= 2,5 A
  • PC or Laptop, Putty installed

Preparation

  • Plug the display directly on the GPIO pins of your PI and connect the HDMI plug with an HDMI-adaptor

5 inch display

  • If you need additional pins for other purpose, wire the pins 1, 2, 6, 19, 21, 22, 23, 26) and connect the HDMI plug with a HDMI cable.
Pin Symbol Discription
1 3,3 V Power positive (3.3V power input)
2 5 V Power positive (5V power input)
6 GND Ground
19 TP_SI SPI data input of Touch Panel
21 TP_SO SPI data output of Touch Panel
22 TP_IRQ Touch Panel interrupt
23 TP_SCK SPI clock of Touch Panel
26 TP_CS Touch Panel chip selection

Steps

Step 1 - Prepare SD card
Info

You find these files in your Windows Explorer in root-section of the pcp_boot drive.

files

  • Enter wifi access data in wpa_supplicant.conf.sample and “Save as” wpa_supplicant.conf.
# This is the details about your Wireless network. Configure as needed.
# Most will just need to change the ssid and psk.

network={
        ssid="your ssid"
        psk="your password"
        key_mgmt=WPA-PSK
        auth_alg=OPEN
}
  • Add the following lines to config.txt, in the Custom Configuration area at the end of the file (between the Begin-Custom and End-Custom lines).
#---Begin-Custom-(Do not alter Begin or End Tags)-----
gpu_mem=128
disable_splash=1
avoid_warnings=2
hdmi_group=2
hdmi_mode=87
hdmi_drive=1
hdmi_cvt 800 480 60 6 0 0 0
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
#---End-Custom------------------------
  • Comment out the gpu_mem=16 and lcd_rotate=2 default settings by putting an # at the beginning of the line.
  • Save your changes.
Step 2 - Boot Raspberry Pi
  • Put the SD card in your RPi and boot.
  • Find the IP address of the RPi, and enter this in a browser—see Determine your piCorePlayer IP address.
  • Once the RPi has booted up, this should bring up the pCP web interface.
    • Install Jivelite from the [Tweaks page] (this step includes an automatic backup, so accept the reboot prompt.)
    • After the reboot do not configure jivelite – we’ll do this later!
Step 3 - Make a custom jivelite.sh startup script
  • Login to your RPi via ssh (software=putty – user: tc, password: piCore) and insert the following command:
    • $ tce-load -wi nano.tcz
  • This installs the nano.tcz editor extension.
    • $ cat /proc/bus/input/devices
  • You see your connectet input-devices (ie. touchscreen, mouse or ir-reciever)

devices

  • Take note of “event0” (If you use additional input devices (ie. IR-Receiver), the input device may be event1).
Info

If you add additional input devices later, the event of your touchscreen may change and the touch won’t work. This affords adjusting your jivelite.sh script.

  • Still connected by ssh, insert the following command:
    • $ sudo nano /mnt/mmcblk0p2/tce/jivelite.sh
  • Put into the empty file (copy and paste) the following script:

#!/bin/sh

EVENTNO=$(cat /proc/bus/input/devices | awk '/ADS7846 Touchscreen/{for(a=0;a>=0;a++){getline;{if(/mouse/==1){ print $NF;exit 0;}}}}')

export JIVE_NOCURSOR=1
export TSLIB_TSDEVICE=/dev/input/event0
export SDL_MOUSEDRV=TSLIB

while true; do
    /opt/jivelite/bin/jivelite
	sleep 3
done
Info

If your event was 1, change event0 to event1

  • For this purpose, we need the script to define the touchscreen as input-device and hide the cursor.
  • Save your changes and exit nano (Ctrl+X and confirm by pressing y).
  • Make the new custom jivelite.sh script executable with:
    • $ sudo chmod +x /mnt/mmcblk0p2/tce/jivelite.sh
  • Save your changes by pcp bu
Step 5 - Calibrate Touchscreen
  • Bring up Web-Gui of piCorePlayer, section [Tweaks] and set “Jivelite Autostart” to “no”.
  • Reboot your RPi.
  • Login to your RPi via ssh (putty – user: tc, password: piCore)—see Access piCorePlayer via ssh.
  • Insert the following command:
    • $ sudo TSLIB_FBDEVICE=/dev/fb0 TSLIB_TSDEVICE=/dev/input/event0 /usr/local/bin/ts_calibrate
Info

If your event was 1, change event0 to event1.

  • Click the 5 calibration points properly.
  • Make your calibration persistent:
    • $ pcp bu
  • Go to the WebGui of piCorePlayer, section [Tweaks] and set “Jivelite Autostart” to “yes”.
  • Reboot your RPi.
    • After the reboot, the touch of the display should work fine.
Step 6 - Configure Jivelite
Info

If you use a RPi Zero without audio card, go to WebGui of piCorePlayer, section [Sqeezelite Settings] and change the default audio output to “none”. RPi Zero does not provide headphone output, squeezelite will not start with default settings.

  • Configure jivelite with your touchscreen. You can do that with a keyboard or an IR remote too.
  • Choose your language and in the next menu select GridSkin 800x480 or jogglerskin. Both work fine with that resolution.
  • Configure the additional settings (time, screensaver, background and so on).
  • Save your changes in Jivelite Settings (Settings > piCorePlayer > Save Settings to SD Card)

More information

The Software and Information is provided "as is" without warranty of any kind, either express or implied, including without limitation any implied warranties of condition, uninterrupted use, merchantability, fitness for a particular purpose, or non-infringement.
Raspberry Pi is a trademark of the Raspberry Pi Foundation.