为Raspberry Pi 5B 小屏幕打造屏幕保护程序

Posted on Jul 6, 2024
为Raspberry Pi 5B 小屏幕打造屏幕保护程序

硬件

Raspberry Pi5
128GB micro sd card
3.5 inch LCD Display
sd卡读卡器

刷入系统

下载镜像烧录器 (Raspberry Pi Imager) https://www.raspberrypi.com/software/

插入sd卡和读卡器选 Raspberry Pi OS Lite(64-bit) 烧录完成将卡插入树莓派5

安装常用软件

更换源:

/etc/apt/sources.list

deb http://mirrors.ustc.edu.cn/debian bookworm main contrib non-free non-free-firmware
deb http://mirrors.ustc.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware
deb http://mirrors.ustc.edu.cn/debian bookworm-updates main contrib non-free non-free-firmware
# Uncomment deb-src lines below then 'apt-get update' to enable 'apt-get source'
#deb-src http://mirrors.ustc.edu.cn/debian bookworm main contrib non-free non-free-firmware
#deb-src http://mirrors.ustc.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware
#deb-src http://mirrors.ustc.edu.cn/debian bookworm-updates main contrib non-free non-free-firmware

/etc/apt/sources.list.d/raspi.list

deb http://mirrors.ustc.edu.cn/raspberrypi/debian/ bookworm main
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://mirrors.ustc.edu.cn/raspberrypi/debian/ bookworm main

sudo apt update && sudo apt upgrade
sudo apt install vim git tree byobu lm-sensors dnsutils

安装LCD屏驱动

git clone https://github.com/goodtft/LCD-show.git

sudo ./LCD-show/MHS35-show

安装完成后会自动重启

配置自动登录

tty1自动登录

/etc/systemd/system/[email protected]/autologin.conf

[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin <username> --noclear %I $TERM

systemctl daemon-reload
systemctl restart [email protected]

设置屏保程序

登录自动启动byobu终端程序: ~/.bashrc 添加

# tty login with byobu
if [ -z "$SSH_CONNECTION" ] && [ -z "$SSH_CLIENT" ] && [[ "$(tty)" == /dev/tty* || "$(tty)" == /dev/console* ]]; then
    if [ "$TMUX" = "" ]; then byobu; fi
fi

获取 rest 屏保程序(或使用 cmatrix 等 apt install cmatrix)

https://github.com/rb-plan/rest.git

~/.byobu/.tmux.conf

set -g lock-after-time 600
set -g lock-command "rest"

rpi-rest

使用 fbcon 调整屏幕方向

apt install fbset

fbcon=rotate:<n>
    0:不旋转
    1:旋转 90 度
    2:旋转 180 度
    3:旋转 270 度

/boot/firmware/cmdline.txt 文件末尾添加 fbcon=rotate:2

console=serial0,115200 console=tty1 root=PARTUUID=fe7ca83d-02 rootfstype=ext4 fsck.repair=yes rootwait cfg80211.ieee80211_regdom=US fbcon=rotate:2

重启以下 reboot