From 6846819dc1c695006cbdad89d8872d043de4b3f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=85=89-k?= <36470587+kxgx@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:59:03 +0800 Subject: [PATCH] Create clean.py --- bin/clean.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 bin/clean.py diff --git a/bin/clean.py b/bin/clean.py new file mode 100644 index 0000000..d60b5dc --- /dev/null +++ b/bin/clean.py @@ -0,0 +1,51 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +import sys +import os +from waveshare_epd import epd2in13_V4 +import logging + +# 设置 picdir 和 libdir 路径 +picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') +libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') +if os.path.exists(libdir): + sys.path.append(libdir) + +# 配置日志 +logging.basicConfig(level=logging.DEBUG) + +def clear_screen(): + try: + logging.info("Starting e-Paper clear screen script") + + # 初始化并创建一个 epd2in13_V4 对象 + epd = epd2in13_V4.EPD() + + # 初始化屏幕 + logging.info("Initializing e-Paper display") + epd.init() + + # 清除屏幕 + logging.info("Clearing e-Paper display") + epd.Clear(0xFF) + + # 等待一段时间,确保清除操作完成 + time.sleep(1) + + # 将屏幕置于睡眠模式 + logging.info("Putting e-Paper display to sleep") + epd.sleep() + + logging.info("e-Paper display cleared successfully") + + except IOError as e: + logging.info(e) + + except KeyboardInterrupt: + logging.info("Ctrl+C pressed, exiting") + epd2in13_V4.epdconfig.module_exit(cleanup=True) + exit() + +if __name__ == '__main__': + clear_screen()