43 Commits

Author SHA1 Message Date
星光-k
a8059bac56 Update README.md 2025-01-12 17:06:41 +08:00
星光-k
a80e3a2722 Update README.md 2025-01-12 17:06:05 +08:00
星光-k
c60fccb210 Update README.md 2025-01-12 17:05:24 +08:00
星光-k
53e1845ce4 Update README.md 2025-01-12 17:04:29 +08:00
星光-k
3844f71943 Add files via upload 2025-01-12 09:03:30 +00:00
星光-k
b2336dcbfb Update clean.sh 2025-01-12 16:52:01 +08:00
星光-k
5a976157c2 Rename clean-info.log to info-clean.log 2025-01-12 16:42:51 +08:00
星光-k
b6866ee2b9 Update clean.sh 2025-01-12 16:39:55 +08:00
星光-k
32565ef2f5 Update clean.sh 2025-01-12 16:36:58 +08:00
星光-k
0c4282ebc9 Update start.sh 2025-01-12 16:33:04 +08:00
星光-k
f8b2c1b332 Update install.sh 2025-01-12 16:25:59 +08:00
星光-k
5b5dace7d3 Update install.sh 2025-01-12 16:22:08 +08:00
星光-k
04ab97f5b6 Update clean.sh 2025-01-12 16:21:45 +08:00
星光-k
0565fd6cf5 Update start.sh 2025-01-12 16:18:33 +08:00
星光-k
173d7eba78 Update main.py 2025-01-12 15:51:00 +08:00
星光-k
28895e7188 Update clean.sh 2025-01-12 14:55:53 +08:00
星光-k
8a4ba07f5b Update e-Paper_clean.service 2025-01-12 14:55:35 +08:00
星光-k
ecaa4006ce Update e-Paper_clean.service 2025-01-12 14:55:24 +08:00
星光-k
c5a3ef0dcf Update main.py 2025-01-12 14:52:18 +08:00
星光-k
99c2bb3152 Update main.py 2025-01-12 14:45:24 +08:00
星光-k
533e76d536 Update main.py 2025-01-12 14:08:23 +08:00
星光-k
26ee5bf6e7 Update main.py 2025-01-12 14:07:17 +08:00
星光-k
a710b293b6 Update main.py 2025-01-12 13:53:03 +08:00
星光-k
3a90a36ffa 更新 main.py 2025-01-12 05:34:51 +00:00
星光-k
fdd3e6008a 更新 main.py 2025-01-12 05:31:35 +00:00
星光-k
e3fd070e3c 更新 install.sh 2025-01-12 04:51:02 +00:00
星光-k
5e353f68f6 更新 install.sh 2025-01-12 04:48:42 +00:00
星光-k
6e0646612b 更新 install.sh 2025-01-12 04:46:09 +00:00
星光-k
d2b4073c98 更新 install.sh 2025-01-12 04:42:44 +00:00
星光-k
9fb1ef0c6b 更新 install.sh 2025-01-12 04:42:03 +00:00
星光-k
7c39658cdf 更新 install.sh 2025-01-12 04:35:34 +00:00
星光-k
6628fc01e2 更新 install.sh 2025-01-12 04:31:59 +00:00
星光-k
b505f9a61d 更新 install.sh 2025-01-12 04:26:12 +00:00
星光-k
7db25e5136 更新 install.sh 2025-01-12 04:22:31 +00:00
星光-k
9e28156c65 更新 install.sh 2025-01-12 04:13:48 +00:00
星光-k
1be7856992 更新 install.sh 2025-01-12 04:06:31 +00:00
星光-k
368ed919dd 更新 install.sh 2025-01-12 03:59:40 +00:00
星光-k
7a9108134a 更新 install.sh 2025-01-12 03:50:32 +00:00
星光-k
1aa62fb894 更新 install.sh 2025-01-12 03:46:47 +00:00
星光-k
d5ff700884 更新 install.sh 2025-01-12 03:21:28 +00:00
星光-k
c56bd3784e 更新 install.sh 2025-01-12 03:19:48 +00:00
星光-k
597790d4ad 更新 install.sh 2025-01-12 03:17:07 +00:00
星光-k
e8011c7282 更新 install.sh 2025-01-12 03:14:12 +00:00
8 changed files with 363 additions and 340 deletions

View File

@@ -112,4 +112,5 @@ sudo apt-get update && sudo apt install -y git && sudo apt-get install -y python
特别注意: 特别注意:
在代码文件第三十三行,此次代码需要更改,否则将展示默认城市天气数据 在代码文件第三十三行,此次代码需要更改,否则将展示默认城市天气数据
![image](https://raw.githubusercontent.com/huanglinsd/2.13-Ink-screen-clock/main/pic/IMG_1245.JPG) # 效果展示
![image](https://github.com/kxgx/2.13-Ink-screen-clock/raw/main/pic/1736672578025.jpg)

View File

@@ -1,27 +1,27 @@
#!/bin/bash #!/bin/bash
f_name=clean.py f_name="clean.py"
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
logdir=${dir%/*} logdir="${dir}/log"
screen_name="clean_screen"
service_name="raspi_e-Paper.service" service_name="raspi_e-Paper.service"
hold_time_seconds=5 # 设置维持时间例如300秒5分钟 hold_time_seconds=3 # 设置维持时间例如300秒5分钟
# 创建一个新的screen会话并运行Python脚本 # 停止raspi_e-Paper服务
screen -dmS $screen_name /usr/bin/python3 -u $dir/$f_name > $logdir/log/clean-info.log 2>&1 echo "正在停止$service_name服务..."
sudo systemctl stop "$service_name"
# 确保日志目录存在
mkdir -p "${logdir}"
# 获取并终止所有与脚本相关的进程
pids=$(pgrep -f "$dir/$f_name")
if [ -n "$pids" ]; then
kill -9 $pids
fi
# 使用nohup在后台运行Python脚本并将输出重定向到日志文件
nohup /usr/bin/python3 -u "$dir/$f_name" > "${logdir}/info-clean.log" 2>&1 &
# 等待维持时间 # 等待维持时间
echo "正在运行脚本,将在 ${hold_time_seconds} 秒后停止服务..." echo "正在运行脚本,将在 ${hold_time_seconds} 秒后停止服务..."
sleep $hold_time_seconds sleep $hold_time_seconds
# 停止raspi_e-Paper服务
echo "正在停止$service_name服务..."
sudo systemctl stop $service_name
# 查找并结束所有与指定screen_name相关的screen会话
pids=$(screen -ls | grep $screen_name | awk -F '.' '{print $1}' | awk '{print $1}')
for pid in $pids; do
screen -S $pid -X quit
done
echo "脚本运行完成服务已停止screen会话已结束。"

View File

@@ -8,7 +8,6 @@ Before=reboot.target
Type=oneshot Type=oneshot
ExecStart=/bin/bash /root/2.13-Ink-screen-clock/bin/clean.sh ExecStart=/bin/bash /root/2.13-Ink-screen-clock/bin/clean.sh
RemainAfterExit=yes RemainAfterExit=yes
TimeoutSec=5
[Install] [Install]
WantedBy=shutdown.target WantedBy=shutdown.target

View File

@@ -33,25 +33,57 @@ while [ "$#" -gt 0 ]; do
shift shift
done done
# 获取当前语言环境变量
CURRENT_LANG=$(locale | grep LANG | sed 's/.*=//')
# 打印当前语言环境变量
echo "当前语言环境: $CURRENT_LANG"
# 设置语言环境 # 设置语言环境
export LANG=$DEFAULT_LANG if [ "$CURRENT_LANG" != "$DEFAULT_LANG" ]; then
export LC_ALL=$DEFAULT_LANG echo "当前语言环境不是 $DEFAULT_LANG,将进行设置"
# 如果 locale.gen 中不存在,则添加到 locale.gen # 设置新的语言环境变量
if ! grep -q "^$DEFAULT_LANG UTF-8" /etc/locale.gen; then export LANG=$DEFAULT_LANG
echo "$DEFAULT_LANG UTF-8" | sudo tee -a /etc/locale.gen export LC_ALL=$DEFAULT_LANG
fi
# 生成 locale # 检查 locale.gen 中是否已存在 DEFAULT_LANG
if ! sudo locale-gen; then found=0
echo "生成 locale 失败" >&2 while read -r line; do
exit 1 if [[ "$line" == "$DEFAULT_LANG UTF-8" ]]; then
fi found=1
break
fi
done < /etc/locale.gen
# 重新配置 locales if [ $found -eq 0 ]; then
if ! sudo dpkg-reconfigure --frontend=noninteractive locales; then # 如果不存在,则添加到 locale.gen
echo "重新配置 locales 失败" >&2 echo "$DEFAULT_LANG UTF-8" | sudo tee -a /etc/locale.gen
exit 1 # 确保 locale.gen 被正确更新
if [ $? -ne 0 ]; then
echo "无法更新 locale.gen 文件" >&2
exit 1
fi
else
echo "语言环境 $DEFAULT_LANG 已在 locale.gen 中设置,跳过添加"
fi
# 生成 locale
if ! sudo locale-gen; then
# 如果生成失败,打印错误消息并退出
echo "生成 locale 失败" >&2
exit 1
fi
# 更新 locale 配置
if ! sudo update-locale LANG=$DEFAULT_LANG; then
echo "更新 locale 配置失败" >&2
exit 1
fi
echo "语言环境设置完成"
else
echo "当前语言环境已经是 $DEFAULT_LANG,跳过设置"
fi fi
# Debian版本相关命令 # Debian版本相关命令
@@ -147,7 +179,7 @@ install_packages() {
echo "系统更新失败" >&2 echo "系统更新失败" >&2
exit 1 exit 1
fi fi
if ! sudo apt-get install -y git pigpio raspi-config netcat* gawk python3-dev python3-pip python3-pil python3-numpy python3-gpiozero python3-pigpio build-essential screen; then if ! sudo apt-get install -y git pigpio raspi-config netcat* gawk python3-dev python3-pip python3-pil python3-numpy python3-gpiozero python3-pigpio build-essential; then
echo "软件包安装失败" >&2 echo "软件包安装失败" >&2
exit 1 exit 1
fi fi
@@ -210,7 +242,7 @@ setup_service() {
# 主逻辑 # 主逻辑
# 检测是否是Debian系统 # 检测是否是Debian系统
if [ -f /etc/debian_version ]; then if [ -f /etc/debian_version ]; then
echo "检测到Debian系统" echo "检测到Debian$DEBIAN_VERSION系统"
# 提取版本号的小数点前的部分 # 提取版本号的小数点前的部分
if ! MAJOR_VERSION=$(echo $DEBIAN_VERSION | cut -d '.' -f 1); then if ! MAJOR_VERSION=$(echo $DEBIAN_VERSION | cut -d '.' -f 1); then

View File

@@ -32,7 +32,7 @@ def Local_strong_brush(): #局部强制刷新显示
i = i + 1 i = i + 1
def getWeath(city='101060111'): #天气函数,下载json天气至本地 def getWeath(city='101060111'): #天气函数,下载json天气至本地
headers = { headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36 Edg/94.0.992.50', 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
'Referer':'http://www.weather.com.cn/' 'Referer':'http://www.weather.com.cn/'
} }
response = requests.get('http://d1.weather.com.cn/sk_2d/'+city+'.html',headers=headers) response = requests.get('http://d1.weather.com.cn/sk_2d/'+city+'.html',headers=headers)
@@ -141,10 +141,6 @@ def Weather(): #在图片中添加天气内容
def Basic_refresh(): #全刷函数 def Basic_refresh(): #全刷函数
logging.info("Refresh and prepare the basic content before starting the canvas")#开始画布前刷新准备基础内容 logging.info("Refresh and prepare the basic content before starting the canvas")#开始画布前刷新准备基础内容
epd.init()
epd.Clear(0xFF)
epd.init()
epd.Clear(0xFF)
global get_date_var global get_date_var
get_date_var=get_date() #记录开始数据 get_date_var=get_date() #记录开始数据
draw.text((2,2),get_date_var,font = font02,fill =0)#将日期及星期几显示到屏幕 draw.text((2,2),get_date_var,font = font02,fill =0)#将日期及星期几显示到屏幕

View File

@@ -1,15 +1,10 @@
#!/bin/bash #!/bin/bash
f_name=main.py f_name=main.py
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
logdir=${dir%/*} logdir=${dir%/*}
screen_name="main_screen" pid=`ps -ef |grep $dir/$f_name | grep -v grep |awk '{print $2}'`
for id in $pid
# 查找并结束所有与指定screen_name相关的screen会话 do
pids=$(screen -ls | grep $screen_name | awk -F '.' '{print $1}' | awk '{print $1}') kill -9 $id
for pid in $pids; do
screen -S $pid -X quit
done done
nohup /usr/bin/python3 -u $dir/$f_name > $logdir/log/info.log 2>&1 &
# 创建一个新的screen会话并运行Python脚本
screen -dmS $screen_name /usr/bin/python3 -u $dir/$f_name > $logdir/log/info.log 2>&1

BIN
pic/1736672578025.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 MiB