add debug mode

pull/4/head
ERR0RPR0MPT 2024-04-19 02:09:02 +08:00
parent 51359d710f
commit 4fb84e740d
2 changed files with 15 additions and 1 deletions

View File

@ -1,3 +1,5 @@
# 是否开启调试模式
DEBUG: false
# 编辑好的图片路径 # 编辑好的图片路径
IMAGE_PATH: "./image/image_monitor.png" IMAGE_PATH: "./image/image_monitor.png"
# 串口号 # 串口号

14
main.py
View File

@ -12,6 +12,8 @@ import win32gui
import threading import threading
import copy import copy
# 是否开启调试模式
DEBUG = False
# 编辑好的图片路径 # 编辑好的图片路径
IMAGE_PATH = "./image/image_monitor.png" IMAGE_PATH = "./image/image_monitor.png"
# 串口号 # 串口号
@ -256,7 +258,7 @@ def getevent():
clock = pygame.time.Clock() clock = pygame.time.Clock()
while True: while True:
# start_time = time.perf_counter() # start_time = time.perf_counter()
clock.tick(120) clock.tick(1200)
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
break break
@ -274,6 +276,14 @@ def getevent():
elif event.type == pygame.FINGERUP: elif event.type == pygame.FINGERUP:
touch_data.pop(str(touch_id)) touch_data.pop(str(touch_id))
convert(touch_data) convert(touch_data)
if not DEBUG:
continue
if event.type == pygame.FINGERDOWN:
print(f"Touch Down: ID={touch_id}, X={touch_x}, Y={touch_y}")
elif event.type == pygame.FINGERUP:
print(f"Touch Up: ID={touch_id}, X={touch_x}, Y={touch_y}")
elif event.type == pygame.FINGERMOTION:
print(f"Touch Motion: ID={touch_id}, X={touch_x}, Y={touch_y}")
# print("单次执行时间:", (time.perf_counter() - start_time) * 1e3, "毫秒") # print("单次执行时间:", (time.perf_counter() - start_time) * 1e3, "毫秒")
@ -288,6 +298,7 @@ if __name__ == "__main__":
print("使用配置文件:", yaml_file_path) print("使用配置文件:", yaml_file_path)
with open(yaml_file_path, 'r', encoding='utf-8') as file: with open(yaml_file_path, 'r', encoding='utf-8') as file:
c = yaml.safe_load(file) c = yaml.safe_load(file)
DEBUG = c["DEBUG"]
IMAGE_PATH = c["IMAGE_PATH"] IMAGE_PATH = c["IMAGE_PATH"]
COM_PORT = c["COM_PORT"] COM_PORT = c["COM_PORT"]
COM_BAUDRATE = c["COM_BAUDRATE"] COM_BAUDRATE = c["COM_BAUDRATE"]
@ -304,6 +315,7 @@ if __name__ == "__main__":
exp_image = Image.open(IMAGE_PATH) exp_image = Image.open(IMAGE_PATH)
exp_image_width, exp_image_height = exp_image.size exp_image_width, exp_image_height = exp_image.size
print(f"定位图路径: {IMAGE_PATH}") print(f"定位图路径: {IMAGE_PATH}")
print(f"触摸屏幕大小: {MONITOR_SIZE}")
print(('' if REVERSE_MONITOR else '') + "开启屏幕反转") print(('' if REVERSE_MONITOR else '') + "开启屏幕反转")
serial_manager = SerialManager() serial_manager = SerialManager()
serial_manager.start() serial_manager.start()