Difference between revisions of "Template:RPi LCD User Manual"

From Waveshare Wiki
Jump to: navigation, search
 
(95 intermediate revisions by 6 users not shown)
Line 1: Line 1:
== Getting Started ==
+
== '''Getting Started''' ==
<!-- [[File:RPi-LCD-User-Manual-1.jpg|thumb|150px|Enabling the virtual keyboard]] -->
+
=== Hardware Connection ===
The RPi LCD can be driven in two ways: Method 1. install driver to your Raspbian OS. Method 2. use the Ready-to-use image file of which LCD driver was pre-installed.
+
* There are 40 pins on Raspberry Pi, but there are 26 pins on the LCD, so you should pay attention to connecting the pins to your Pi accordingly.
  
=== Method 1. Driver installation ===
+
===Touch Driver Installation===
1. Configure your Pi:
+
The RPi LCD can be driven in two ways:<br/>
sudo raspi-config
+
Method 1. Install the driver to your Raspbian OS. <br/>
Set as:
+
Method 2. Use the Ready-to-use image file of which the LCD driver was pre-installed.
* Select Expand Filesystem.
+
 
* Boot Option -> Desktop Autologin (may differ depending on Raspbian revision)
+
''' Method 1. Driver installation'''
 +
 
 +
Please download the bullseye 32bit version of the image on the [https://www.raspberrypi.org/downloads/ Raspberry Pi official website.] (Raspbian/Ubuntu Mate/Kali or Retropie)
 +
 
 +
1) Download the compressed image file to the PC, and unzip it to get the .img file.
 +
 
 +
2) Connect the TF card to the PC, open the [https://files.waveshare.com/upload/7/76/Win32DiskImager.zip Win32DiskImager] software, select the system image downloaded in step 1, and click 'Write' to write the system image. ( How to write an image to a micro SD card for your Pi? See [[RPi-Image-Installation-Guides|RPi Image Installation Guides]] for more details)
 +
 
 +
3) Connect the TF card to the Raspberry Pi, and start the Raspberry Pi. The LCD will display after booting up, and then log in to the Raspberry Pi terminal,(You may need to connect a keyboard and HDMI LCD to Pi for driver installation, or log in remotely with SSH.)
 +
 
 +
4) Then open the terminal of Raspberry Pi to install the touch driver.
 +
<pre>
 +
git clone https://github.com/waveshare/LCD-show.git
 +
cd LCD-show/
 +
</pre>
 +
'''Note: The Raspberry Pi must be connected to the network, or else the touch driver won't be successfully installed.'''
  
2. Copy the driver [[#Driver|(choose the driver according to your OS)]] into your OS then Run the following commands:
 
tar xvf LCD-show-*.tar.gz
 
cd LCD-show/
 
Install the driver and it toggles the mode to LCD display:
 
'''Note: Net work connection is required while installing driver to your Pi, or else the touch won't work properly.'''
 
 
{{#switch: {{FULLPAGENAME}}
 
{{#switch: {{FULLPAGENAME}}
 
| 2.8inch RPi LCD (A) =
 
| 2.8inch RPi LCD (A) =
 
<pre>
 
<pre>
 
chmod +x LCD28-show
 
chmod +x LCD28-show
./LCD28-show
+
If it is an old version, execute the following code:
 +
sudo ./LCD28-show
 +
If it is a new version, execute the following code:
 +
sudo ./LCD28-show-V2
 
</pre>
 
</pre>
 
| 3.2inch RPi LCD (B) =
 
| 3.2inch RPi LCD (B) =
 
<pre>
 
<pre>
 
chmod +x LCD32-show
 
chmod +x LCD32-show
./LCD32-show
+
./LCD32-show
 +
</pre>
 +
| 3.2inch RPi LCD (C) =
 +
<pre>
 +
chmod +x LCD32C-show
 +
./LCD32C-show
 
</pre>
 
</pre>
 
| 3.5inch RPi LCD (A) =
 
| 3.5inch RPi LCD (A) =
 
<pre>
 
<pre>
 
chmod +x LCD35-show
 
chmod +x LCD35-show
./LCD35-show
+
./LCD35-show
 
</pre>
 
</pre>
 
| 3.5inch RPi LCD (B) =
 
| 3.5inch RPi LCD (B) =
 +
<pre>
 +
#if old version, use this command:
 +
chmod +x LCD35B-show
 +
./LCD35B-show
 +
</pre>
  
chmod +x LCD35B-show
+
<pre>
 
+
#if new version, use this command:
<font color=#777777>#if old version, use this command: </font>
+
chmod +x LCD35B-show-V2
 
+
  ./LCD35B-show-V2
  ./LCD35B-show
+
</pre>
 
+
| 3.5inch RPi LCD (C) =
<font color=#777777>#if new version, use this command:</font>
+
<pre>
 
+
chmod +x LCD35C-show
  ./LCD35B-show-V2
+
  ./LCD35C-show
 
+
</pre>
| 4inch RPi LCD (A) =
+
| 4inch RPi LCD (A) =  
 
<pre>
 
<pre>
 
chmod +x LCD4-show
 
chmod +x LCD4-show
./LCD4-show
+
./LCD4-show  
 
</pre>
 
</pre>
| #default =  
+
| 4inch RPi LCD (C) =
 
<pre>
 
<pre>
chmod +x LCD*show
+
chmod +x LCD4C-show
 +
./LCD4C-show  
 
</pre>
 
</pre>
 +
| #default =
 
* For 2.8inch RPi LCD (A):
 
* For 2.8inch RPi LCD (A):
  ./LCD28-show
+
  ./LCD28-show  
 
* For 3.2inch RPi LCD (B):
 
* For 3.2inch RPi LCD (B):
  ./LCD32-show
+
  ./LCD32-show
 +
* For 3.2inch RPi LCD (C):
 +
./LCD32C-show
 
* For 3.5inch RPi LCD (A):
 
* For 3.5inch RPi LCD (A):
  ./LCD35-show
+
  ./LCD35-show  
 
* For 3.5inch RPi LCD (B):
 
* For 3.5inch RPi LCD (B):
<font color=#777777>#if old version, use this command: </font>
+
  ./LCD35B-show  
  ./LCD35B-show
+
* For 3.5inch RPi LCD (C):
<font color=#777777>#if new version, use this command:</font>
+
  ./LCD35C-show  
  ./LCD35B-show-V2
 
 
* For 4inch RPi LCD (A):
 
* For 4inch RPi LCD (A):
  ./LCD4-show
+
  ./LCD4-show
 +
* For 4inch RPi LCD (C):
 +
./LCD4C-show  
 
}}
 
}}
  
''Note: this LCD won't work after apt-get upgrade, in such cases, please edit the config.txt file in the SD card and remove this statement: <code>dtoverlay=ads7846</code>''
+
The touch function will work after restart. For ease of use, you can set the screen orientation, see: [[#Screen orientation settings]].
 
 
3. After system rebooting, the RPi LCD is ready to use.
 
 
 
=== Method 2. Using Ready-to-use image ===
 
The image file with pre-installed driver is located in the IMAGE directory of the CD, or you can download it from [[#Image]]. Extract the .7z file and you will get an .img file. Write the image to your micro SD card (How to write an image to a micro SD card for your Pi? See [[RPi-Image-Installation-Guides|RPi Image Installation Guides]] for more details). Then insert the card to your Pi, power up and enjoy it.
 
  
== Toggle between LCD and HDMI display ==
+
'''Notes:'''
Once this LCD is enabled, meanwhile the default settings for HDMI are changed. If you want to use another HDMI monitor, please run the following command:
+
*1. Executing apt-get upgrade will cause the LCD to fail to work properly. In this case, you need to edit the config.txt file in the SD card and delete this sentence: dtoverlay=ads7846.
cd LCD-show/
+
*2. Using Raspbian-lite, the command of the touch driver installation should be:
./LCD-hdmi
 
This toggles the mode to LCD display:
 
 
{{#switch: {{FULLPAGENAME}}
 
{{#switch: {{FULLPAGENAME}}
 
| 2.8inch RPi LCD (A) =
 
| 2.8inch RPi LCD (A) =
<pre>./LCD28-show</pre>
+
<pre>
 +
./LCD28-show lite
 +
</pre>
 
| 3.2inch RPi LCD (B) =
 
| 3.2inch RPi LCD (B) =
<pre>./LCD32-show</pre>
+
<pre>
 +
./LCD32-show lite
 +
</pre>
 +
| 3.2inch RPi LCD (C) =
 +
<pre>
 +
./LCD32C-show lite
 +
</pre>
 
| 3.5inch RPi LCD (A) =
 
| 3.5inch RPi LCD (A) =
<pre>./LCD35-show</pre>
+
<pre>
 +
./LCD35-show lite
 +
</pre>
 
| 3.5inch RPi LCD (B) =
 
| 3.5inch RPi LCD (B) =
<pre>./LCD35B-show</pre>
+
<pre>
| 4inch RPi LCD (A) =
+
#if old version, use this command:
<pre>./LCD4-show</pre>
+
./LCD35B-show lite
| 5inch HDMI LCD =
+
</pre>
<pre>./LCD5-show</pre>
+
 
 +
<pre>
 +
#if new version, use this command:
 +
./LCD35B-show-V2 lite
 +
</pre>
 +
| 3.5inch RPi LCD (C) =
 +
<pre>
 +
./LCD35C-show lite
 +
</pre>
 +
| 4inch RPi LCD (A) =  
 +
<pre>
 +
./LCD4-show lite
 +
</pre>
 +
| 4inch RPi LCD (C) =
 +
<pre>
 +
./LCD4C-show lite
 +
</pre>
 
| #default =  
 
| #default =  
 
* For 2.8inch RPi LCD (A):
 
* For 2.8inch RPi LCD (A):
  ./LCD28-show
+
  ./LCD28-show lite
 
* For 3.2inch RPi LCD (B):
 
* For 3.2inch RPi LCD (B):
  ./LCD32-show
+
  ./LCD32-show lite
 +
* For 3.2inch RPi LCD (C):
 +
./LCD32C-show lite
 
* For 3.5inch RPi LCD (A):
 
* For 3.5inch RPi LCD (A):
  ./LCD35-show
+
  ./LCD35-show lite
 
* For 3.5inch RPi LCD (B):
 
* For 3.5inch RPi LCD (B):
  ./LCD35B-show
+
  ./LCD35B-show lite
 +
* For 3.5inch RPi LCD (C):
 +
./LCD35C-show lite
 
* For 4inch RPi LCD (A):
 
* For 4inch RPi LCD (A):
  ./LCD4-show
+
  ./LCD4-show lite
* For 5inch HDMI LCD:
+
* For 4inch RPi LCD (C):
  ./LCD5-show
+
  ./LCD4C-show lite
 
}}
 
}}
 +
For bullseye 64bit systems, manual configuration is required as follows: [[3.5inch RPi LCD (B) Manual Configuration]].
 +
 +
'''Method 2. Using Ready-to-use image'''
 +
 +
The image file with the pre-installed driver is located in the IMAGE directory of the CD, or you can download it from [[#Image]]. Extract the .7z file and you will get an .img file. Write the image to your micro SD card (How to write an image to a micro SD card for your Pi? See [[RPi-Image-Installation-Guides|RPi Image Installation Guides]] for more details). Then insert the card into your Pi, power up, and enjoy it.
  
== Screen orientation settings ==
+
<!-- 
After touch driver installed, the screen orientation can be set by these commands:
+
== '''Toggle between LCD and HDMI display''' ==
 +
Once this LCD is enabled, meanwhile the default settings for HDMI are changed. If you want to use another HDMI monitor, please run the following command:
 +
cd LCD-show/
 +
  ./LCD-hdmi
 +
This toggles the mode to LCD display:
 
{{#switch: {{FULLPAGENAME}}
 
{{#switch: {{FULLPAGENAME}}
 
| 2.8inch RPi LCD (A) =
 
| 2.8inch RPi LCD (A) =
* 0 degree rotation
+
<pre>
cd LCD-show/
+
  ./LCD28-show
./LCD28-show 0
+
</pre>
* 90 degree rotation
 
cd LCD-show/
 
./LCD28-show 90
 
* 180 degree rotation
 
cd LCD-show/
 
  ./LCD28-show 180
 
* 270 degree rotation
 
cd LCD-show/
 
./LCD28-show 270
 
 
| 3.2inch RPi LCD (B) =
 
| 3.2inch RPi LCD (B) =
* 0 degree rotation
+
<pre>
cd LCD-show/
+
  ./LCD32-show
  ./LCD32-show 0
+
</pre>
* 90 degree rotation
+
| 3.2inch RPi LCD (C) =
cd LCD-show/
+
<pre>
./LCD32-show 90
+
  ./LCD32C-show
* 180 degree rotation
+
</pre>
cd LCD-show/
 
  ./LCD32-show 180
 
* 270 degree rotation
 
cd LCD-show/
 
./LCD32-show 270
 
 
| 3.5inch RPi LCD (A) =
 
| 3.5inch RPi LCD (A) =
* 0 degree rotation
+
<pre>
cd LCD-show/
+
  ./LCD35-show
./LCD35-show 0
+
</pre>
* 90 degree rotation
 
cd LCD-show/
 
./LCD35-show 90
 
* 180 degree rotation
 
cd LCD-show/
 
  ./LCD35-show 180
 
* 270 degree rotation
 
cd LCD-show/
 
./LCD35-show 270
 
 
| 3.5inch RPi LCD (B) =
 
| 3.5inch RPi LCD (B) =
* 0 degree rotation
+
<pre>
cd LCD-show/
+
#if old version, use this command:
  ./LCD35B-show 0
+
  ./LCD35B-show  
* 90 degree rotation
+
</pre>
cd LCD-show/
+
<!--   
  ./LCD35B-show 90
+
<pre>
* 180 degree rotation
+
#if new version, use this command:
cd LCD-show/
+
  ./LCD35B-show-V2
  ./LCD35B-show 180
+
</pre>
* 270 degree rotation
+
| 3.5inch RPi LCD (C) =
cd LCD-show/
+
<pre>
  ./LCD35B-show 270
+
  ./LCD35C-show
| 4inch RPi LCD (A) =
+
</pre>
* 0 degree rotation
+
| 4inch RPi LCD (A) =  
cd LCD-show/
+
<pre>
  ./LCD4-show 0
+
  ./LCD4-show  
* 90 degree rotation
+
</pre>
cd LCD-show/
+
| 4inch RPi LCD (C) =
./LCD4-show 90
+
<pre>
* 180 degree rotation
+
  ./LCD4C-show  
cd LCD-show/
+
</pre>
  ./LCD4-show 180
 
* 270 degree rotation
 
cd LCD-show/
 
./LCD4-show 270
 
 
| #default =  
 
| #default =  
 
* For 2.8inch RPi LCD (A):
 
* For 2.8inch RPi LCD (A):
  ./LCD28-show degree
+
  ./LCD28-show  
 
* For 3.2inch RPi LCD (B):
 
* For 3.2inch RPi LCD (B):
  ./LCD32-show degree
+
  ./LCD32-show  
 +
* For 3.2inch RPi LCD (C):
 +
./LCD32C-show
 
* For 3.5inch RPi LCD (A):
 
* For 3.5inch RPi LCD (A):
  ./LCD35-show degree
+
  ./LCD35-show  
 
* For 3.5inch RPi LCD (B):
 
* For 3.5inch RPi LCD (B):
  ./LCD35B-show degree
+
  ./LCD35B-show  
 +
* For 3.5inch RPi LCD (C):
 +
./LCD35C-show
 
* For 4inch RPi LCD (A):
 
* For 4inch RPi LCD (A):
  ./LCD4-show degree
+
  ./LCD4-show  
The degree can be specified as 0, 90, 180, 270.
+
* For 4inch RPi LCD (C):
 +
./LCD4C-show
 
}}
 
}}
 +
-->
 +
 +
== '''Screen Orientation Settings''' ==
 +
 +
After installing the touch driver, you can modify the screen rotation direction by running the following commands.
 +
 +
<syntaxhighlight lang="c">
 +
cd LCD-show/
 +
#X can be 0, 90, 180, and 270. Indicates that the LCD rotates 0 degrees, 90 degrees, 180 degrees, and 270 degrees, respectively.
 +
#If it is an old version, execute the following code:
 +
sudo ./LCD28-show X
 +
#If it is a new version, execute the following code:
 +
sudo ./LCD28-show-V2 X
 +
</syntaxhighlight>
  
== Touch screen calibration ==
+
The rotation command under Raspbian-lite is as follows:
This LCD can be calibrated using a program called xinput_calibrator which is pre-installed on the CD image. However, it was not pre-installed on original Raspbian OS. So in this case, you should get and install the program manually with
+
<syntaxhighlight lang="c">
sudo apt-get install -y xinput-calibrator
+
cd LCD-show/
Enter the following commands for touch screen calibration:  
+
#X can be 0, 90, 180, and 270. Indicates that the LCD rotates 0 degrees, 90 degrees, 180 degrees, and 270 degrees, respectively.
sudo DISPLAY=:0.0 xinput_calibrator
+
#If it is an old version, execute the following code:
or select Menu -> Preferences -> Calibrate Touchscreen.
+
sudo ./LCD28-show lite X
 +
#If it is a new version, execute the following code:
 +
sudo ./LCD28-show-V2 lite X
 +
</syntaxhighlight>
  
After running these commands, there will be a prompt for four-point calibration shown in the LCD screen. Click the points one by one to finish the touch calibration. Then, the new calibration data will be displayed in the terminal, as shows below. Please get these data for future use.
+
== '''Touch screen calibration''' ==
Doing dynamic recalibration:
+
This LCD can be calibrated through the xinput-calibrator demo. '''Note: The Raspberry Pi must be connected to the network, or else the program won't be successfully installed.'''
Setting new calibration data: 3919, 208, 236, 3913
 
  
Enter the following command to edit 99-calibration.conf:
+
*Run the following command to install:
 +
sudo apt-get install xinput-calibrator
 +
* Click the "Menu" button on the taskbar, and choose "Preference" -> "Calibrate Touchscreen".
 +
* Finish the touch calibration following the prompts. Maybe rebooting is required to make calibration active.
 +
* You can create a 99-calibration.conf file to save the touch parameters (not necessary if the file exists).
 
  sudo nano /etc/X11/xorg.conf.d/99-calibration.conf
 
  sudo nano /etc/X11/xorg.conf.d/99-calibration.conf
 +
* Save the touch parameters (may differ depending on LCD) to 99-calibration.conf, as shown in the picture:
 +
[[File:5inch_HDMI_LCD_FAQ1.jpg]]
 +
 +
==Control Backlight Brightness with GPIO==
 +
Use a 0R resistor or solder to connect this pad.<br/>
 +
[[File:Virtual Keyboard Install01.png]]<br/>
 +
Execute the following command on the Raspberry Pi terminal to control the backlight brightness:<br/>
 +
<syntaxhighlight lang="c">
 +
gpio -g pwm 18 1024
 +
gpio -g mode 18 pwm (the occupied pins are PWM pins)
 +
gpio pwmc 1000
 +
gpio -g pwm 18 X (control brightness, the X value is between 0~1024)
 +
</syntaxhighlight>
  
Then, the old calibration data will be displayed in the terminal:
+
<!--
Section "InputClass"
+
== '''2.8inch RPi LCD (A) - Rev2.1 PWM backlight adjustment function''' ==
Identifier "calibration"
+
For Pi4, you need to update the wiringPi version first. The operation method is as follows (for 3B+ and earlier versions, there is no need to update):
MatchProduct "ADS7846 Touchscreen"
+
<pre>
Option "Calibration" "160 3723 3896 181"
+
wget https://project-downloads.drogon.net/wiringpi-latest.deb
Option "SwapAxes" "1"
+
sudo dpkg -i wiringpi-latest.deb
EndSection
+
gpio -v
 +
# Run gpio -v and version 2.52 will appear. If it does not appear, the installation is wrong
 +
</pre>
 +
After the wiringPi is updated successfully, the backlight brightness can be controlled by the following commands.
 +
<pre>
 +
gpio -g mode 18 pwm #Occupied pins are PWM pins
 +
gpio pwmc 100
 +
gpio -g pwm 18 0 #the darkest
 +
gpio -g pwm 18 1023 #brightest
 +
gpio -g mode 18 out #Release as output
 +
</pre>
 +
-->
  
Modify the calibration data to the new calibration data displayed above):
+
== '''Install Virtual Keyboard''' ==
  Section "InputClass"
+
1. Install matchbox-keyboard. <br />
Identifier "calibration"
+
<pre>
MatchProduct "ADS7846 Touchscreen"
+
sudo apt-get install update
Option "Calibration" "3919 208 236 3913"
+
sudo apt-get install matchbox-keyboard
Option "SwapAxes" "1"
+
sudo nano /usr/bin/toggle-matchbox-keyboard.sh
EndSection
+
</pre>
  
Press the keys Ctrl+X, and select the option Y to save the modification.
+
2. Copy the statements below to toggle-matchbox-keyboard.sh and save.
 +
<pre>
 +
#!/bin/bash
 +
#This script toggle the virtual keyboard
 +
PID=`pidof matchbox-keyboard`
 +
if [ ! -e $PID ]; then
 +
killall matchbox-keyboard
 +
else
 +
matchbox-keyboard -s 50 extended&
 +
fi
 +
</pre>
 +
3. Execute the commands:
 +
<pre>
 +
sudo chmod +x /usr/bin/toggle-matchbox-keyboard.sh
 +
sudo mkdir /usr/local/share/applications
 +
sudo nano /usr/local/share/applications/toggle-matchbox-keyboard.desktop
 +
</pre>
 +
4. Copy the statements to toggle-matchbox-keyboard.desktop and save.
 +
<pre>
 +
[Desktop Entry]
 +
Name=Toggle Matchbox Keyboard
 +
Comment=Toggle Matchbox Keyboard`
 +
Exec=toggle-matchbox-keyboard.sh
 +
Type=Application
 +
Icon=matchbox-keyboard.png
 +
Categories=Panel;Utility;MB
 +
X-MB-INPUT-MECHANSIM=True
 +
</pre>
 +
5. Execute commands as below. '''Note that you need to use "Pi " user permission instead of root to execute this command.'''
 +
<pre>
 +
sudo nano /etc/xdg/lxpanel/LXDE-pi/panels/panel
 +
</pre>
 +
6. Find the statement that is similar to below: (It may be different in different versions.)
 +
<pre>
 +
Plugin {
 +
type = launchbar
 +
Config {
 +
Button {
 +
id=lxde-screenlock.desktop
 +
}
 +
Button {
 +
id=lxde-logout.desktop
 +
}
 +
}
 +
</pre>
 +
7. Append these statements to add a button option:
 +
<pre>
 +
Button {
 +
id=/usr/local/share/applications/toggle-matchbox-keyboard.desktop
 +
}
 +
</pre>
 +
[[File:RPILCD-INSTALL-KEYBOARD01.png|400px]] <br />
  
The modification will be valid after rebooting the system. Enter the following command for system reboot:
+
8. Reboot your Raspberry Pi. If the virtual keyboard is installed correctly, you can find that there is a keyboard icon on the left of the bar.
 
  sudo reboot
 
  sudo reboot
'''Notices: In case of inaccurate touch, please perform screen calibration again and reboot the system.'''
+
<br />
{{Virtual Keyboard Installation}}
+
 
 +
<!-- 
 +
== '''How to work with a camera''' ==
  
== How to work with a camera ==
 
 
<!--  
 
<!--  
 
RPi LCD can also work with an external camera to take photos. In this operation, a Raspberry Pi camera is required, which should be purchased separately.  
 
RPi LCD can also work with an external camera to take photos. In this operation, a Raspberry Pi camera is required, which should be purchased separately.  
  
If you use the image provided from us, after camera attached, you can open the camera by command lines.  
+
If you use the image provided by us, after the camera is attached, you can open the camera by command lines.  
 
  cd /home/pi/camera/
 
  cd /home/pi/camera/
 
  Camera
 
  Camera
  
Then, waiting several seconds, the camera application will be started automatically. Now, you can capture pictures by double clicking the screen.
+
Then, waiting several seconds, the camera application will be started automatically. Now, you can capture pictures by double-clicking the screen.
  
If you use the image with clean installation, you can setup the camera driver with:
+
If you use the image with a clean installation, you can set up the camera driver with:
 
-->
 
-->
 +
<!-- 
 
1. Select "Enable Camera" -> "<YES>"
 
1. Select "Enable Camera" -> "<YES>"
 
  sudo raspi-config
 
  sudo raspi-config
Line 280: Line 415:
 
  sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_calibrate
 
  sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_calibrate
 
Camera will be enabled by the steps above.
 
Camera will be enabled by the steps above.
 +
-->

Latest revision as of 09:31, 6 February 2024

Getting Started

Hardware Connection

  • There are 40 pins on Raspberry Pi, but there are 26 pins on the LCD, so you should pay attention to connecting the pins to your Pi accordingly.

Touch Driver Installation

The RPi LCD can be driven in two ways:
Method 1. Install the driver to your Raspbian OS.
Method 2. Use the Ready-to-use image file of which the LCD driver was pre-installed.

Method 1. Driver installation

Please download the bullseye 32bit version of the image on the Raspberry Pi official website. (Raspbian/Ubuntu Mate/Kali or Retropie)

1) Download the compressed image file to the PC, and unzip it to get the .img file.

2) Connect the TF card to the PC, open the Win32DiskImager software, select the system image downloaded in step 1, and click 'Write' to write the system image. ( How to write an image to a micro SD card for your Pi? See RPi Image Installation Guides for more details)

3) Connect the TF card to the Raspberry Pi, and start the Raspberry Pi. The LCD will display after booting up, and then log in to the Raspberry Pi terminal,(You may need to connect a keyboard and HDMI LCD to Pi for driver installation, or log in remotely with SSH.)

4) Then open the terminal of Raspberry Pi to install the touch driver.

git clone https://github.com/waveshare/LCD-show.git
cd LCD-show/

Note: The Raspberry Pi must be connected to the network, or else the touch driver won't be successfully installed.

  • For 2.8inch RPi LCD (A):
./LCD28-show 
  • For 3.2inch RPi LCD (B):
./LCD32-show 
  • For 3.2inch RPi LCD (C):
./LCD32C-show
  • For 3.5inch RPi LCD (A):
./LCD35-show 
  • For 3.5inch RPi LCD (B):
./LCD35B-show 
  • For 3.5inch RPi LCD (C):
./LCD35C-show 
  • For 4inch RPi LCD (A):
./LCD4-show 
  • For 4inch RPi LCD (C):
./LCD4C-show

The touch function will work after restart. For ease of use, you can set the screen orientation, see: #Screen orientation settings.

Notes:

  • 1. Executing apt-get upgrade will cause the LCD to fail to work properly. In this case, you need to edit the config.txt file in the SD card and delete this sentence: dtoverlay=ads7846.
  • 2. Using Raspbian-lite, the command of the touch driver installation should be:
  • For 2.8inch RPi LCD (A):
./LCD28-show lite
  • For 3.2inch RPi LCD (B):
./LCD32-show lite
  • For 3.2inch RPi LCD (C):
./LCD32C-show lite
  • For 3.5inch RPi LCD (A):
./LCD35-show lite
  • For 3.5inch RPi LCD (B):
./LCD35B-show lite
  • For 3.5inch RPi LCD (C):
./LCD35C-show lite
  • For 4inch RPi LCD (A):
./LCD4-show lite
  • For 4inch RPi LCD (C):
./LCD4C-show lite

For bullseye 64bit systems, manual configuration is required as follows: 3.5inch RPi LCD (B) Manual Configuration.

Method 2. Using Ready-to-use image

The image file with the pre-installed driver is located in the IMAGE directory of the CD, or you can download it from #Image. Extract the .7z file and you will get an .img file. Write the image to your micro SD card (How to write an image to a micro SD card for your Pi? See RPi Image Installation Guides for more details). Then insert the card into your Pi, power up, and enjoy it.


Screen Orientation Settings

After installing the touch driver, you can modify the screen rotation direction by running the following commands.

cd LCD-show/
#X can be 0, 90, 180, and 270. Indicates that the LCD rotates 0 degrees, 90 degrees, 180 degrees, and 270 degrees, respectively.
#If it is an old version, execute the following code:
sudo ./LCD28-show X
#If it is a new version, execute the following code:
sudo ./LCD28-show-V2 X

The rotation command under Raspbian-lite is as follows:

cd LCD-show/
#X can be 0, 90, 180, and 270. Indicates that the LCD rotates 0 degrees, 90 degrees, 180 degrees, and 270 degrees, respectively.
#If it is an old version, execute the following code:
sudo ./LCD28-show lite X
#If it is a new version, execute the following code:
sudo ./LCD28-show-V2 lite X

Touch screen calibration

This LCD can be calibrated through the xinput-calibrator demo. Note: The Raspberry Pi must be connected to the network, or else the program won't be successfully installed.

  • Run the following command to install:
sudo apt-get install xinput-calibrator 
  • Click the "Menu" button on the taskbar, and choose "Preference" -> "Calibrate Touchscreen".
  • Finish the touch calibration following the prompts. Maybe rebooting is required to make calibration active.
  • You can create a 99-calibration.conf file to save the touch parameters (not necessary if the file exists).
sudo nano /etc/X11/xorg.conf.d/99-calibration.conf
  • Save the touch parameters (may differ depending on LCD) to 99-calibration.conf, as shown in the picture:

5inch HDMI LCD FAQ1.jpg

Control Backlight Brightness with GPIO

Use a 0R resistor or solder to connect this pad.
Virtual Keyboard Install01.png
Execute the following command on the Raspberry Pi terminal to control the backlight brightness:

gpio -g pwm 18 1024
gpio -g mode 18 pwm (the occupied pins are PWM pins)
gpio pwmc 1000
gpio -g pwm 18 X (control brightness, the X value is between 0~1024)


Install Virtual Keyboard

1. Install matchbox-keyboard.

sudo apt-get install update
sudo apt-get install matchbox-keyboard
sudo nano /usr/bin/toggle-matchbox-keyboard.sh

2. Copy the statements below to toggle-matchbox-keyboard.sh and save.

#!/bin/bash
#This script toggle the virtual keyboard
PID=`pidof matchbox-keyboard`
if [ ! -e $PID ]; then
killall matchbox-keyboard
else
matchbox-keyboard -s 50 extended&
fi

3. Execute the commands:

sudo chmod +x /usr/bin/toggle-matchbox-keyboard.sh
sudo mkdir /usr/local/share/applications
sudo nano /usr/local/share/applications/toggle-matchbox-keyboard.desktop

4. Copy the statements to toggle-matchbox-keyboard.desktop and save.

[Desktop Entry]
Name=Toggle Matchbox Keyboard
Comment=Toggle Matchbox Keyboard`
Exec=toggle-matchbox-keyboard.sh
Type=Application
Icon=matchbox-keyboard.png
Categories=Panel;Utility;MB
X-MB-INPUT-MECHANSIM=True

5. Execute commands as below. Note that you need to use "Pi " user permission instead of root to execute this command.

sudo nano /etc/xdg/lxpanel/LXDE-pi/panels/panel

6. Find the statement that is similar to below: (It may be different in different versions.)

Plugin {
type = launchbar
Config {
Button {
id=lxde-screenlock.desktop
}
Button {
id=lxde-logout.desktop
}
}

7. Append these statements to add a button option:

Button {
id=/usr/local/share/applications/toggle-matchbox-keyboard.desktop
}

RPILCD-INSTALL-KEYBOARD01.png

8. Reboot your Raspberry Pi. If the virtual keyboard is installed correctly, you can find that there is a keyboard icon on the left of the bar.

sudo reboot