4inch DPI LCD (C)

From Waveshare Wiki
Jump to: navigation, search
4inch DPI LCD (C)
4inch-DPI-LCD-C-1.jpg

4inch Square Capacitive Touch Screen LCD (C) for Raspberry Pi, 720 × 720, DPI, IPS
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Introduction

4inch Square Capacitive Touch Screen LCD (C) for Raspberry Pi, 720 × 720, DPI, IPS, toughened glass cover, low power solution.

Features

  • 4inch IPS Display, 720 x 720 hardware resolution.
  • Designed for Raspberry Pi, based on Raspberry Pi 40pin GPIO interface.
  • Using DPI666 interface of Raspberry Pi to drive LCD, refresh rate up to 60Hz.
  • Drive capacitive touch through I2C interface of Raspberry Pi, 5-point touch, toughened glass panel, hardness up to 6H.
  • Supports Raspberry Pi OS / Ubuntu / Kali systems.

Using with Raspberry Pi

Hardware connection

Please install the display slowly on the 40PIN GPIO interface of the Raspberry Pi as shown below.
4DPIC-Pi-4B.jpg

Software setting

If you don't know the difference between the two branches of Raspberry Pi OS, you can check the following introduction #Introducing the Raspberry Pi OS fork

For Raspberry Pi OS Bookworm and Bullseye branch

Please download the latest version of the image from the Raspberry Pi official website.
1. Download the compressed file to the PC, and extract the img file.
2. Connect the TF card to the PC and use SDFormatter to format the TF card.
3. Open the Win32DiskImager software, select the system image prepared in step 1, and click write to flash the system image.
4. After the programming is completed, open the config.txt file in the root directory of the TF card, add the following code at the end of config.txt, and save it.

dtoverlay=vc4-kms-v3d
dtoverlay=vc4-kms-DPI-4inch
dtoverlay=waveshare-4dpic-3b-4b
dtoverlay=waveshare-4dpic-3b
dtoverlay=waveshare-4dpic-4b
dtoverlay=waveshare-4dpi
dtoverlay=waveshare-touch-4dpi

5. Download the 4inch DPI LCD (C)-KMS display file and put it in the /boot/overlays directory of the TF card, and eject the TF card safely.
6. Insert the TF card into the Raspberry Pi, power on the Raspberry Pi, and wait for about thirty seconds to display normally.

For Raspberry Pi OS Buster branch and Ubuntu system

1. Open the config.txt file in the root directory of the TF card, add the following code at the end of config.txt, save and safely eject the TF card.

gpio=0-9=a2
gpio=12-17=a2
gpio=20-25=a2
dtoverlay=dpi24
enable_dpi_lcd=1
display_default_lcd=1
extra_transpose_buffer=2
dpi_group=2
dpi_mode=87
dpi_output_format=0x7f216
dpi_timings=720 0 46 2 42 720 0 16 2 18 0 0 0 60 0 60000000 6
dtoverlay=waveshare-4dpic-3b-4b
dtoverlay=waveshare-4dpic-3b
dtoverlay=waveshare-4dpic-4b

2. Download the 4inch DPI LCD (C)-KMS display file and put it in the /boot/overlays directory of the TF card, and eject the TF card safely.
3. Insert the TF card into the Raspberry Pi, power on the Raspberry Pi, and wait for about thirty seconds to display normally.

Display Rotation

Bookworm Display Rotation

GUI interface rotation

  • 1. Open the "Screen Configuration" application;

DSI-LCD-Bookworm-Rotate-01.png

  • 2. Go to "Screen" -> "DPI-1" -> "Touchscreen" and check "13-005 Goodix Capacitive TouchScreen";

400px-2.8 DPI LCD rotate 1.png

  • 3. Go to "Screen" -> "DPI-1" -> "Orientation", check the direction you need to rotate, and finally click "Apply" to complete the screen and touch synchronous rotation.

400px-2.8 DPI LCD rotate 2.png -->
Note: Only the Bookworm system supports the above synchronization rotation method. Note: Only the Bookworm system supports the above synchronous rotation methods. For Bullseye and Buster systems, after displaying rotation, touch rotation needs to be manually set separately.

lite version display rotation

sudo nano /boot/firmware/cmdline.txt
#Add a command to display the rotation angle at the beginning of the cmdline.txt file, and save it to take effect after restarting
#Display rotation 90 degrees
video=DPI-1:720x720M@60,rotate=90
#Display rotation 180 degrees
video=DPI-1:720x720M@60,rotate=180
#Display rotation 270 degrees
video=DPI-1:720x720M@60,rotate=270

Note: Unable to rotate DPI display and HDMI display separately using cmdline.txt. When you use both DPI and HDMI simultaneously, they share the same rotation value.

Bullseye/Buster Display Rotation

GUI interface rotation

  • 1. Open the "Screen Configuration" application;

DSI-LCD-Bullseye-Rotate-02.png

  • 2. Go to "Screen" -> "DPI-1" -> "Orientation", check the direction you need to rotate, and finally click "Apply" to complete the display rotation.

DSI-LCD-Bullseye-Rotate-03.png


lite version display rotation

  • 1. Need to modify the /boot/cmdline.txt file:
sudo nano /boot/cmdline.txt
  • 2. At the beginning of the cmdline.txt file, add the command for displaying the rotation angle: (Please note, this command needs to be on the same line, with each command separated by a space.)
video=DPI-1:720x720M@60,rotate=90

Change the display rotation angle by modifying the rotate value to 90, 180, or 270.

  • 3. Save and restart
sudo reboot

Stretch/Jessie Display Rotation

For some older systems, they do not use the vc4-kms-v3d or vc4-fkms-v3d driver modes, and the display rotation method is as follows:

  • 1. Add a statement to the config.txt file (the config file is located in the root directory of the TF card, i.e., in the /boot folder):
display_rotate=1 #1: 90; 2: 180; 3: 270
  • 2. Save the changes and then reboot the Raspberry Pi
sudo reboot

Touch Rotation

Bookworm Touch Rotation

If you use the graphical interface for rotation, you can tick "Touchscreen" in the screen layout editor window to synchronize the touch rotation. Please refer to the previous introduction for how to rotate the screen. For the command line rotation method, please refer to the following text:
1. Create a new file named 99-waveshare-touch.rules

sudo nano /etc/udev/rules.d/99-waveshare-touch.rules

2. Add the following lines as needed:

#90°:
ENV{ID_INPUT_TOUCHSCREEN}=="1", ENV{LIBINPUT_CALIBRATION_MATRIX}="0 -1 1 1 0 0"

#180°:
#ENV{ID_INPUT_TOUCHSCREEN}=="1", ENV{LIBINPUT_CALIBRATION_MATRIX}="-1 0 1 0 -1 1"

#270°:
#ENV{ID_INPUT_TOUCHSCREEN}=="1", ENV{LIBINPUT_CALIBRATION_MATRIX}="0 1 0 -1 0 1"

3. Save and reboot

sudo reboot

Bullseye/Buster Touch Rotation

After some systems display rotation, the touch direction is inconsistent, and you need to perform the following operations to perform touch rotation:
1. Install libinput

sudo apt-get install xserver-xorg-input-libinput
  • If you have Ubuntu or Jetson Nano installed. The installation code is:
sudo apt install xserver-xorg-input-synaptics

2. Create the xorg.conf.d directory under /etc/X11 (if the directory already exists, proceed directly to step 3).

sudo mkdir /etc/X11/xorg.conf.d

3. Copy the 40-libinput-conf file to the directory you created just now.

sudo cp /usr/share/X11/xorg.conf.d/40-libinput.conf /etc/X11/xorg.conf.d/

4. Edit this file.

sudo nano /etc/X11/xorg.conf.d/40-libinput.conf
#Find the touchscreen section, add the corresponding rotation angle command in it, and save it
#"90° Right touch rotation:
Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1"
#180° Inverted touch rotation: 
#Option "CalibrationMatrix" "-1 0 1 0 -1 1 0 0 1"
#270° Left touch rotation: 
#Option "CalibrationMatrix" "0 -1 1 1 0 0 0 0 1"
Similar to the position in the following image:

Touch roate.jpg
5. Reboot Raspberry Pi

sudo reboot

After completing the above steps, touch will cause a rotation.

Touch Mode Selection

The Bookworm system supports two touch modes, which can be switched in the Screen Configuration > Touchscreen menu:
600px-DSI-Touch-Bookworm-Keyboard-03.png

  • 1. Mouse Emulation (default)
Click = Left mouse button function
Long press = Right mouse button function
Supports double-click
Does not support swipe page and multi-touch functions

Note: This mode is suitable for scenarios that require mouse operation, such as double clicking to open the file manager and long pressing to achieve right-click functionality.

  • 2.Multitouch
Supports multi-touch functionality
Supports swiping pages
Does not support double-click and right-click long press functions

Note: This mode is suitable for touch-optimized scenarios, such as web browsing and scrolling lists.

Use Touchscreen Virtual Keyboard

Raspberry Pi OS Bookworm and later versions include Squeekboard on-screen keyboard by default.
When connecting to the touch display, the on-screen keyboard will automatically appear if text input is possible, and it will automatically hide if text input is not possible.
For applications that do not support automatic text input detection, you can manually display or hide the on-screen keyboard by clicking the keyboard icon at the far right of the task bar.
600px-DSI-Touch-Bookworm-Keyboard-01.png
You can also permanently set the display or hide the screen keyboard through the "Display" option under "Raspberry Pi Configuration" or through the "Display" section in raspi-config.
600px-DSI-Touch-Bookworm-Keyboard-02.png

  • Note:

For versions of Raspberry Pi OS before Bookworm, use matchbox-keyboard. If you are using the wayfire desktop compositor, use wvkbd.

Disable Power Saving

If you want to keep the display turning on all the time, you can disable the power-saving function. You can disable the function by setting it up as follows.
Open lightdm.conf

sudo nano /etc/lightdm/lightdm.conf

Modify lightdm.conf Find the [SeatDefaults] option and uncomment the line "xserver-command", modify it as below:

#xserver-command=X

Modify it into:

xserver-command=X -s 0 -dpms
  • -s # –Disable the screen protection.
  • dpms Disable power saving.

Reboot.

sudo reboot

Adjust Backlight

PWM Backlight Adjustment

  • Install WiringPi
cd ~
git clone https://github.com/WiringPi/WiringPi.git
cd WiringPi
./build
gpio -v

The successful installation will output the gpio version as follows:
3.5F pwm1.png

  • Manually adjust the screen PWM backlight
gpio -g mode 18 pwm       	#Configure the PIN as PWM mode
gpio pwmc 100   		#Set PWM clock divider
gpio -g pwm 18 0         	#Darkest
gpio -g pwm 18 1023      	#Brightest
gpio -g mode 18 out             #Clear the PIN to output mode
  • Set the screen off and on

You can use the following commands to set the screen off and on.

Note: The PWM pin must be set to output to achieve this control.

sudo echo 1 | sudo tee /sys/class/backlight/rpi_backlight/bl_power
sudo echo 0 | sudo tee /sys/class/backlight/rpi_backlight/bl_power

pinctrl Backlight Adjustment

  • Set the screen on
sudo pinctrl set 18 op dh
  • Set the screen off
sudo pinctrl set 18 op dl

Interface

The pins labeled "NC" below mean that those pins of Raspberry Pi are not occupied by the LCD, and the user can use them for other applications.

PIN NO. SYMBOL DESCRIPTION
1 NC Power positive (3.3V power input)
2 5V Power positive (5V power input)
3 VSYNC Vertical sync
4 5V Power positive (5V power input)
5 HSYNC Horizontal sync
6 GND Ground
7 B0 RGB signal cable
8 G2 RGB signal cable
9 GND Ground
10 G3 RGB signal cable
11 G5 RGB signal cable
12 PWM GPIO header
13 TP_INT Touch Panel interrupt
14 GND Ground
15 R2 RGB signal cable
16 R3 RGB signal cable
17 NC Power positive (3.3V power input)
18 R4 RGB signal cable
19 TP_SDA I2C SDA for touch panel
20 GND Ground
21 B5 RGB signal cable
22 R5 RGB signal cable
23 TP_SCL I2C SCL for touch panel
24 B4 RGB signal cable
25 GND Ground
26 B3 RGB signal cable
27 LCD_CLK LCD clock
28 DE LCD data enable
29 B1 RGB signal cable
30 GND Ground
31 B2 RGB signal cable
32 G0 RGB signal cable
33 G1 RGB signal cable
34 GND Ground
35 NC GPIO interface
36 G4 RGB signal cable
37 NC GPIO interface
38 R0 RGB signal cable
39 GND Ground
40 R1 RGB signal cable

Resource

3D Drawing

Software

Project Resources

This section features third - party project resources. We merely provide links and bear no responsibility for content updates or maintenance. Thank you for your understanding.


printminion - Desktop case for Waveshare 4" Square Touch and raspberry pi


FAQ

 Answer:

You can comment out the following statements in the config.txt file

dtoverlay=waveshare-touch-4dpi


 Answer:

It is not recommended to extend the DPI screen cable by more than 10 cm.

Since DPI uses parallel signals and contains a large number of high-speed data cables, transmission over longer distances is prone to signal interference, picture jitter, screen flickering, or inability to display.
If you need a connection over longer distances, it is recommended to use interface types that support differential signals, such as HDMI, MIPI DSI, or LVDS, which are better suited for long-distance transmission in terms of interference resistance and signal integrity.



Anti-Piracy

Since the first-generation Raspberry Pi released, Waveshare has been working on designing, developing, and producing various fantastic touch LCDs for the Pi. Unfortunately, there are quite a few pirated/knock-off products in the market. They're usually some poor copies of our early hardware revisions, and comes with none support service.

To avoid becoming a victim of pirated products, please pay attention to the following features when purchasing:

RPi-LCD-Anti-Piracy.jpg

(Click to enlarge)

Beware of knock-offs

Please note that we've found some poor copies of this item in the market. They are usually made of inferior materials and shipped without any testing.

You might be wondering if the one you're watching or you've purchased in other non-official stores is original, feel free to contact us.

Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)