mirror of
https://github.com/kxgx/2.13-Ink-screen-clock.git
synced 2026-03-17 07:23:16 +08:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8059bac56 | ||
|
|
a80e3a2722 | ||
|
|
c60fccb210 | ||
|
|
53e1845ce4 | ||
|
|
3844f71943 | ||
|
|
b2336dcbfb | ||
|
|
5a976157c2 | ||
|
|
b6866ee2b9 | ||
|
|
32565ef2f5 | ||
|
|
0c4282ebc9 | ||
|
|
f8b2c1b332 | ||
|
|
5b5dace7d3 | ||
|
|
04ab97f5b6 | ||
|
|
0565fd6cf5 | ||
|
|
173d7eba78 |
@@ -112,4 +112,5 @@ sudo apt-get update && sudo apt install -y git && sudo apt-get install -y python
|
||||
|
||||
特别注意:
|
||||
在代码文件第三十三行,此次代码需要更改,否则将展示默认城市天气数据
|
||||

|
||||
# 效果展示
|
||||

|
||||
|
||||
34
bin/clean.sh
34
bin/clean.sh
@@ -1,27 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
f_name=clean.py
|
||||
f_name="clean.py"
|
||||
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
logdir=${dir%/*}
|
||||
screen_name="clean_screen"
|
||||
logdir="${dir}/log"
|
||||
service_name="raspi_e-Paper.service"
|
||||
hold_time_seconds=3 # 设置维持时间,例如300秒(5分钟)
|
||||
|
||||
# 创建一个新的screen会话并运行Python脚本
|
||||
screen -dmS $screen_name /usr/bin/python3 -u $dir/$f_name > $logdir/log/clean-info.log 2>&1
|
||||
# 停止raspi_e-Paper服务
|
||||
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} 秒后停止服务..."
|
||||
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会话已结束。"
|
||||
|
||||
@@ -179,7 +179,7 @@ install_packages() {
|
||||
echo "系统更新失败" >&2
|
||||
exit 1
|
||||
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
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -32,7 +32,7 @@ def Local_strong_brush(): #局部强制刷新显示
|
||||
i = i + 1
|
||||
def getWeath(city='101060111'): #天气函数,下载json天气至本地
|
||||
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/'
|
||||
}
|
||||
response = requests.get('http://d1.weather.com.cn/sk_2d/'+city+'.html',headers=headers)
|
||||
@@ -141,8 +141,6 @@ def Weather(): #在图片中添加天气内容
|
||||
|
||||
def Basic_refresh(): #全刷函数
|
||||
logging.info("Refresh and prepare the basic content before starting the canvas")#开始画布前刷新准备基础内容
|
||||
epd.init()
|
||||
epd.Clear(0xFF)
|
||||
global get_date_var
|
||||
get_date_var=get_date() #记录开始数据
|
||||
draw.text((2,2),get_date_var,font = font02,fill =0)#将日期及星期几显示到屏幕
|
||||
|
||||
15
bin/start.sh
15
bin/start.sh
@@ -1,15 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
f_name=main.py
|
||||
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
logdir=${dir%/*}
|
||||
screen_name="main_screen"
|
||||
|
||||
# 查找并结束所有与指定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
|
||||
pid=`ps -ef |grep $dir/$f_name | grep -v grep |awk '{print $2}'`
|
||||
for id in $pid
|
||||
do
|
||||
kill -9 $id
|
||||
done
|
||||
|
||||
# 创建一个新的screen会话并运行Python脚本
|
||||
screen -dmS $screen_name /usr/bin/python3 -u $dir/$f_name > $logdir/log/info.log 2>&1
|
||||
nohup /usr/bin/python3 -u $dir/$f_name > $logdir/log/info.log 2>&1 &
|
||||
|
||||
BIN
pic/1736672578025.jpg
Normal file
BIN
pic/1736672578025.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.0 MiB |
Reference in New Issue
Block a user