On this page

Add a 4 inch Waveshare display spi touch

mini11 21 June 2022 pCP 7.0.0 Projects  •  •
Waveshare 4 inch resistive display, spi Touch, 480×800, HDMI, with piCorePlayer.

4 inch display

4 inch display

Steps

Step 1 - Connect the display to your Raspberry PI
  • Plug the display directly on the GPIO pins of your RPi and connect the HDMI plug with an HDMI-adaptor.

4 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
Step 2 - Prepare SD card
  • Put a fresh pCP image on to the SD card—see Burn piCorePlayer onto a SD card.
  • While the SD card is still in the laptop/pc:
    • Enter wifi credentials in wpa_supplicant.conf.sample at the end of the file 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)-----
disable_splash=1
avoid_warnings=2
gpu_mem=128 
hdmi_group=2
hdmi_mode=87
hdmi_cvt 480 800 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
display_rotate=3
#---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.
Info

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

Step 3 - 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.
    • On [Main Page] scroll down to “Additional functions” and click on “Extensions”. Wait for green ticks, then click on the [Available] tab.

devices

  • In the ‘Available extensions in the piCorePlayer repository’ section.

devices

  • Load nano.tcz extension.
  • 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 4 - Make a custom jivelite.sh startup script
  • Login to your RPi via ssh (software=putty – user: tc, password: piCore) and look, if your changes of step 2 work:
  • Insert the following command:

$ cat /proc/bus/input/devices

  • You see your connected input-devices (ie. touchscreen, mouse or IR-receiver)

devices

  • Take note of “Waveshare” and “event1” (If you do not use additional input devices (ie. IR-receiver), the input device may be event0).
Step 5 - Creating the jivelite.sh
  • 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
# Disable mouse pointer
export JIVE_NOCURSOR=1
# Set touch calibration file
TSLIB_CALIBFILE=/usr/local/etc/pointercal
# Jivelite interface framerate
export JIVE_FRAMERATE=22
# Set Touch input device 
export TSLIB_TSDEVICE=/dev/input/event1 # This might be event0 in some cases
export SDL_MOUSEDRV=TSLIB
# Define custom Skin size
# scale to 800x480. This could be any size to scale interface.
export JL_SCREEN_WIDTH=800
export JL_SCREEN_HEIGHT=480
# Set custom screen resolution
/usr/sbin/fbset -xres 800 -yres 480
# Run Jivelite
while true; do
    /opt/jivelite/bin/jivelite >> /var/log/jivelite.log 2>&1
    sleep 3
done
  • Usually we do not need a script for that resolution in Jivelite. It is standard and many skins work with that resolution. For this purpose, we need the script to define the touchscreen as input-device and to hide the cursor.
  • Save your changes and exit nano (Ctrl+X and confirm by pressing y).
Info

  • Make the new custom jivelite.sh script executable with:

$ sudo chmod +x /mnt/mmcblk0p2/tce/jivelite.sh

  • Go to Web-Gui of piCorePlayer, section [Tweaks] and set “Jivelite Autostart” to “no”.
  • Reboot your RPi.
Step 6 - Calibrate Touchscreen

$ sudo TSLIB_FBDEVICE=/dev/fb0 TSLIB_TSDEVICE=/dev/input/event1 /usr/local/bin/ts_calibrate

  • 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 7 - Configure Jivelite
  • Connect a mouse or an IR-remote to the device to configure jivelite.
  • Choose your language and in the next menu select GridSkin 800x480 or jogglerskin. Both work fine with that resolution.
  • Configure the additional settings (time, 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.