3.2inch RPi LCD (B)

来自Waveshare Wiki
跳转至: 导航搜索

说明

3.2inch-RPi-LCD-B
{{{name2}}}
{{{name3}}}
功能简介
特性 3.2寸树莓派电阻屏 提供驱动
分辨率 320×240
适用范围 兼容任何版本的树莓派
' 无特性,不解释
' 无特性,不解释
接口 RPi I/Os

产品特点

  • 硬件分辨率为320x240
  • 电阻式触摸控制
  • 兼容并可直接插入任何版本树莓派
  • 提供驱动(支持Raspbian\Ubuntu\Kali和Retropie系统)
  • 支持FBCP软件驱动,可设置软件分辨率和双屏显示
  • 和你的树莓派一样大
  • 沉金工艺,精雕细琢

硬件连接

连接GPIO接口,Raspberry Pi引出了40个GPIO管脚,而屏幕引出了26个管脚,连接时注意对应屏幕管脚和树莓派管脚。

接口定义

以下标识为“NC”的引脚表示LCD没有占用该引脚,用户可用于其它应用。

引脚号 标识 描述
1 3.3V 电源正(3.3V电源输入)
2 5V 电源正(5V电源输入)
3 NC NC
4 5V 电源正(5V电源输入)
5 NC NC
6 GND 电源地
7 NC NC
8 NC NC
9 GND 电源地
10 NC NC
11 TP_IRQ 触摸面板中断,检测到触摸面板有按下则为低电平
12 KEY1 按键
13 RST 复位信号,低电平复位
14 GND 电源地
15 LCD_RS 指令/数据 寄存器选择,低电平为指令,高电平为数据
16 KEY2 按键
17 3.3V 电源正(3.3V电源输入)
18 KEY3 按键
19 LCD_SI / TP_SI LCD显示 / 触摸面板的SPI数据输入
20 GND 电源地
21 TP_SO 触摸面板的SPI数据输出
22 NC NC
23 LCD_SCK / TP_SCK LCD显示 / 触摸面板的SPI时钟信号
24 LCD_CS LCD片选信号,低电平选择LCD
25 GND 电源地
26 TP_CS 触摸面板片选信号,低电平选择触摸面板


软件设置

在Trixie和Bookworm系统上使用

适用于Raspberry pi4 & pi5

1、配置驱动
打开树莓派终端,执行:

sudo apt-get install unzip -y
sudo apt-get install cmake -y
sudo wget https://www.waveshare.net/w/upload/c/c3/Waveshare32b.zip
sudo unzip ./Waveshare32b.zip
sudo cp waveshare32b.dtbo /boot/overlays/

编辑config.txt文件

sudo nano /boot/firmware/config.txt

屏蔽下图对应的语句
FBCP CLOSE.jpg
在config.txt最后加入以下代码

dtparam=spi=on
dtoverlay=waveshare32b
hdmi_force_hotplug=1
max_usb_current=1
hdmi_group=2
hdmi_mode=87
hdmi_cvt 640 480 60 6 0 0 0
hdmi_drive=2
display_rotate=0

2、设置开机自启动

  • 打开.bash_profile文件,如果没有.bash_profile文件则自己创建一个
sudo nano ~/.bash_profile

把以下代码加到.bash_profile文件最下面

export FRAMEBUFFER=/dev/fb1
startx  2> /tmp/xorg_errors
  • 打开99-fbturbo.~文件,若已经存在此文件需要确认fb为fb0
sudo nano /usr/share/X11/xorg.conf.d/99-fbturbo.~

把以下内容加到99-fbturbo.~配置文件中

Section "Device"
        Identifier      "Allwinner A10/A13 FBDEV"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb0"

        Option          "SwapbuffersWait" "true"
EndSection

3、设置CLI自动登录

sudo raspi-config nonint do_boot_behaviour B2
sudo raspi-config nonint do_wayland W1
sudo reboot

Note1:确保树莓派的用户名为pi否则无法正常自动登录
Note2:设置上述所有配置后,系统每次重启期间都会变久一点,SSH也需要等待一会儿才能进入;

4、配置触摸

  • 安装calibrator软件
sudo apt-get install xserver-xorg-input-evdev 
sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf
sudo apt-get install xinput-calibrator
  • 编辑99-calibration.conf配置文件
sudo nano /usr/share/X11/xorg.conf.d/99-calibration.conf

把以下内容加到99-calibration.conf配置文件中

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "Calibration"   "3795 171 168 3913"
        Option  "SwapAxes"      "1"
EndSection

重启后生效

sudo reboot

5、配置摄像头

  • 编辑config.txt文件
sudo nano /boot/firmware/config.txt

在config.txt最后加入以下代码

dtoverlay=vc4-kms-v3d
max_framebuffers=2
  • 编辑98-spi-screen.conf配置文件
sudo nano /etc/X11/xorg.conf.d/98-spi-screen.conf

把以下内容加到98-spi-screen.conf配置文件中 并添加:

Section "Device"
Identifier "SPI Screen" 
Driver "fbdev"
Option "fbdev" "/dev/fb0"
EndSection

重启后生效

sudo reboot

打开摄像头:

libcamera-hello --qt-preview

适用于所有树莓派版本

注意:以下操作必须基于Raspberry Pi OS Lite版本

可使用任意下列 Lite 系统镜像(根据需要选择 64 位或 32 位):

1、下载必要的软件

  • 更新系统
sudo apt update && sudo apt upgrade && sudo apt full-upgrade -y
  • 安装xorg服务
sudo apt-get install --no-install-recommends xserver-xorg -y
sudo apt-get install --no-install-recommends xinit -y
  • 安装桌面管理器
sudo apt install lightdm -y
  • 安装树莓派官方GUI
sudo apt install raspberrypi-ui-mods -y  
  • 安装浏览器(可选)
sudo apt install chromium-browser -y

2、配置驱动
打开树莓派终端,执行:

sudo apt-get install unzip -y
sudo apt-get install cmake -y
sudo wget https://www.waveshare.net/w/upload/c/c3/Waveshare32b.zip
sudo unzip ./Waveshare32b.zip
sudo cp waveshare32b.dtbo /boot/overlays/

编辑config.txt文件

sudo nano /boot/firmware/config.txt

屏蔽下图对应的语句
FBCP CLOSE.jpg
在config.txt最后加入以下代码

dtparam=spi=on
dtoverlay=waveshare32b
hdmi_force_hotplug=1
max_usb_current=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 480 320 60 6 0 0 0
hdmi_drive=2
display_rotate=0

3、设置自启动startx

  • 打开.bash_profile文件,如果没有.bash_profile文件则自己创建一个
sudo nano ~/.bash_profile

把以下代码加到.bash_profile文件最下面

export FRAMEBUFFER=/dev/fb1
startx  2> /tmp/xorg_errors
  • 打开99-fbturbo.~文件,若已经存在此文件需要确认fb为fb0
sudo nano /usr/share/X11/xorg.conf.d/99-fbturbo.~

把以下代码加到99-fbturbo.~文件里面

Section "Device"
        Identifier      "Allwinner A10/A13 FBDEV"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb0"

        Option          "SwapbuffersWait" "true"
EndSection

4、设置CLI自动登录

sudo raspi-config nonint do_boot_behaviour B2
sudo raspi-config nonint do_wayland W1
sudo reboot

Note1:确保树莓派的用户名为pi否则无法正常自动登录
Note2:设置上述所有配置后,系统每次重启期间都会变久一点,SSH也需要等待一会儿才能进入;

5、配置触摸

  • 安装calibrator软件
sudo apt-get install xserver-xorg-input-evdev 
sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf
sudo apt-get install xinput-calibrator
  • 编辑99-calibration.conf配置文件
sudo nano /usr/share/X11/xorg.conf.d/99-calibration.conf

把以下内容加到99-calibration.conf配置文件中

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "Calibration"   "3795 171 168 3913"
        Option  "SwapAxes"      "1"
EndSection

重启后生效

sudo reboot

在Bullseye 64位系统上使用

请在树莓派官网下载bullseye版本的镜像64bit。
1、配置驱动
打开boot目录下的config.txt文件,注释掉dtoverlay=vc4-kms-v3d,并在[all]末尾添加

dtparam=spi=on
dtoverlay=waveshare32b

hdmi_force_hotplug=1
max_usb_current=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 480 320 60 6 0 0 0
hdmi_drive=2
display_rotate=0

2、配置触摸
在终端运行以下语句:

sudo apt-get install xserver-xorg-input-evdev 
sudo cp -rf /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf
sudo apt-get install xinput-calibrator
sudo nano /usr/share/X11/xorg.conf.d/99-calibration.conf

在99-calibration.conf文件中增加以下语句:

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "Calibration"   "3932 300 294 3801"
        Option  "SwapAxes"      "1"
        Option "EmulateThirdButton" "1"
        Option "EmulateThirdButtonTimeout" "1000"
        Option "EmulateThirdButtonMoveThreshold" "300"
EndSection

3、运行FBCP移植
此过程需要联网

sudo apt-get install cmake
wget https://www.waveshare.net/w/upload/6/66/Rpi-fbcp.zip
unzip Rpi-fbcp.zip
cd rpi-fbcp/
mkdir build
cd build/
cmake ..
make
sudo install fbcp /usr/local/bin/fbcp

4、设置开机自启动

sudo nano /etc/rc.local

在末尾exit 0前添加以下语句:

sleep 7
fbcp &

3.5A 1.png

重启后屏幕即可正常显示

sudo reboot


在Bullseye 32位系统和Buster系统上使用

方法一,安装驱动

请在树莓派官网下载最新版本的镜像(Raspbian/Ubuntu Mate/Kali或Retropie)。为了方便使用,这里提供Raspbian镜像

1) 将镜像文件下载到电脑上,并解压得到.img文件。

2) 将TF卡连接到电脑,打开Win32DiskImager.exe软件,选择第1步准备的.img文件,点击write烧写镜像。烧写完成后,安全弹出TF卡。

3) 将TF卡接入到树莓派上,启动树莓派,登录树莓派的终端(可以将树莓派接到HDMI显示器或用ssh远程登录)。

4) 先通过网络下载相关驱动代码,在执行相应的安装命令,在整个过程中确保可以正常联网

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

重启后即可使用(为了方便使用,可以调整屏幕显示方向,参见#设置显示方向)。

注意1:执行apt-get upgrade会导致LCD无法正常工作。此时需要编辑SD卡中的 config.txt 文件,并删除这一句:dtoverlay=ads7846。

注意2:在Raspbian-lite下,需要执行sudo ./LCD32-show lite命令,以安装驱动。

方法二,使用预装驱动的镜像

这里提供预装驱动的镜像,解压并把镜像写入到TF卡中(打开Win32DiskImager.exe软件,选择.img文件,点击「write」烧写镜像)。然后把卡插入树莓派就可以使用了。

设置显示方向

安装完触摸驱动后,可以通过运行以下命令修改屏幕旋转方向。

cd LCD-show/
#X可选0、90、180和270。分别表示LCD旋转0度、90度、180度和270度。
sudo ./LCD32-show X

在Raspbian-lite下的旋转命令如下:

cd LCD-show/
#X可选0、90、180和270。分别表示LCD旋转0度、90度、180度和270度。
sudo ./LCD32-show lite X

安装校准软件进行校准

  • 本LCD可以通过xinput-calibrator程序进行校准。
  • 运行以下命令,进行安装:
sudo apt-get install xinput-calibrator
  • 点击任务栏的Menu键,选择Preferences -> Calibrate Touchscreen。
  • 按显示提示进行触摸校准。
  • 如果要保存这些触摸值,需要在以下路径新建一个99-calibration.conf文件(如果已存在则不需要新建)
   /etc/X11/xorg.conf.d/99-calibration.conf
  • 将触摸参数(不同LCD,下图数据可能不同)保存至99-calibration.conf,即可

5inch HDMI LCD FAQ1.jpg

安装虚拟键盘

1. 执行以下命令安装相应软件

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

2. 复制以下内容到toggle-matchbox-keyboard.sh,保存退出

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

3. 执行以下命令

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. 复制以下内容到toggle-matchbox-keyboard.desktop,保存退出

[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. 执行以下命令,注意该步骤必须使用"pi"用户权限,如果使用管理员权限,将找不到该文件

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

6. 找到类似以下命令(不同版本的图标可能有一定差异)

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

7. 加入以下代码以新增一个Button项,如下图

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

RPILCD-INSTALL-KEYBOARD01.png

8. 执行以下命令重启系统,正常可以看到左上角多了一个虚拟键盘的图标

sudo reboot

资料

视频

开发资料

树莓派镜像

软件

树莓派相关教程

树莓派入门教程(新)
树莓派入门教程
树莓派OpenCV教程
树莓派littleGL系列教程
树莓派QT教程
树莓派OpenWrt教程

LCD显示区域

3.2inch RPi LCD (B)显示区域

FAQ

  • 该LCD必须安装驱动才能正常使用。具体请查看用户手册相关介绍。


  • 由于树莓派镜像和版本经常更新,如遇到无法正常使用LCD的情况,请下载我们提供的最新版本镜像或到树莓派官网下载最新的镜像并安装我们提供的最新驱动进行使用。
  • 确定硬件连接无误且接触良好。
  • 确定TF卡烧写正常。
    树莓派正常启动时PWR灯常亮,ACT灯闪烁。如果发现两灯都常亮则可能是TF卡烧写镜像不成功或TF卡与树莓派接触不良。

推荐使用5V 2.5A电源适配器对树莓派进行供电。 如使用PC机的USB接口对树莓派供电,可能由于供电不足导致树莓派无法正常启动。




售后

联系人:梁工
电话:0755-83043099
微信:扫下方二维码添加
Ljh.png

说明:进行售后服务前,请准备好客户信息(定货单位、定货人等),以供验证