From b09fcf9fac962d7fb859af296bc4f583b5b6a2e3 Mon Sep 17 00:00:00 2001 From: cnphpbb Date: Wed, 2 Sep 2026 16:40:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(i2c.py):=20=E4=BF=AE=E5=A4=8D=20status.py?= =?UTF-8?q?=20=E6=97=B6=E9=97=B4=E5=92=8C=E9=80=80=E5=87=BA=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i2c.py/status.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/i2c.py/status.py b/i2c.py/status.py index b892c1b..ff670f4 100644 --- a/i2c.py/status.py +++ b/i2c.py/status.py @@ -10,7 +10,7 @@ from PIL import Image, ImageDraw, ImageFont DISPLAY_WIDTH = 128 DISPLAY_HEIGHT = 64 SYSTEM_INFO_INTERVAL = 2.0 -DISPLAY_REFRESH_INTERVAL = 0.1 +DISPLAY_REFRESH_INTERVAL = 1.0 FONT_PATH = '/usr/share/fonts/truetype/wqy/wqy-microhei.ttc' FONT_SIZE_SMALL = 11 FONT_SIZE_DATE = 16 @@ -84,11 +84,21 @@ while running: draw_text(1, f"CPU: {cpu}") draw_text(2, mem) draw_text(3, disk) - draw_text(4, time.strftime("%Y-%m-%d, %H:%M:%S"), font_date) + draw_text(4, time.strftime("%Y-%m-%d %H:%M:%S"), font_date) disp.image(image) - disp.show() + try: + disp.show() + except Exception: + try: + i2c.unlock() + except Exception: + pass + time.sleep(1) time.sleep(DISPLAY_REFRESH_INTERVAL) -disp.fill(0) -disp.show() +try: + disp.fill(0) + disp.show() +except Exception: + pass