fix delay bug

pull/4/head
ERR0RPR0MPT 2024-04-21 05:33:08 +08:00
parent ac022f13e9
commit 18ab4e6934
2 changed files with 45 additions and 44 deletions

View File

@ -1,57 +1,57 @@
# 是否开启调试模式 # 是否开启调试模式
DEBUG: false DEBUG: false
# 编辑好的图片路径 # 编辑好的图片路径
IMAGE_PATH: "./image/image_monitor.png" IMAGE_PATH: "./image/image_monitor_3840x2160_square.png"
# 串口号 # 串口号
COM_PORT: "COM33" COM_PORT: "COM33"
# 比特率 # 比特率
COM_BAUDRATE: 9600 COM_BAUDRATE: 9600
# 检测区域的像素值范围 # 检测区域的像素值范围
AREA_SCOPE: 50 AREA_SCOPE: 120
# 检测区域圆上点的数量 # 检测区域圆上点的数量
AREA_POINT_NUM: 8 AREA_POINT_NUM: 8
# 触摸屏幕大小 (单位:像素) # 触摸屏幕大小 (单位:像素)
MONITOR_SIZE: [ 1600, 2560 ] MONITOR_SIZE: [2160, 3840]
# 是否开启屏幕反转 # 是否开启屏幕反转
REVERSE_MONITOR: false REVERSE_MONITOR: false
# touch_thread 是否启用sleep, 默认开启, 如果程序 CPU 占用较高则开启, 如果滑动时延迟极大请关闭 # touch_thread 是否启用sleep, 默认开启, 如果程序 CPU 占用较高则开启, 如果滑动时延迟极大请关闭
TOUCH_THREAD_SLEEP_MODE: true TOUCH_THREAD_SLEEP_MODE: false
# 每次 sleep 的延迟, 单位: 微秒, 默认 10 微秒 # 每次 sleep 的延迟, 单位: 微秒, 默认 10 微秒
TOUCH_THREAD_SLEEP_DELAY: 10 TOUCH_THREAD_SLEEP_DELAY: 10
# RGB 颜色值对应区块配置 # RGB 颜色值对应区块配置
exp_image_dict: exp_image_dict:
'41-65-93': A1 "41-65-93": A1
'87-152-13': A2 "87-152-13": A2
'213-109-81': A3 "213-109-81": A3
'23-222-55': A4 "23-222-55": A4
'69-203-71': A5 "69-203-71": A5
'147-253-55': A6 "147-253-55": A6
'77-19-35': A7 "77-19-35": A7
'159-109-79': A8 "159-109-79": A8
'87-217-111': B1 "87-217-111": B1
'149-95-154': B2 "149-95-154": B2
'97-233-9': B3 "97-233-9": B3
'159-27-222': B4 "159-27-222": B4
'152-173-186': B5 "152-173-186": B5
'192-185-149': B6 "192-185-149": B6
'158-45-23': B7 "158-45-23": B7
'197-158-219': B8 "197-158-219": B8
'127-144-79': C1 "127-144-79": C1
'242-41-155': C2 "242-41-155": C2
'69-67-213': D1 "69-67-213": D1
'105-25-130': D2 "105-25-130": D2
'17-39-170': D3 "17-39-170": D3
'97-103-203': D4 "97-103-203": D4
'113-25-77': D5 "113-25-77": D5
'21-21-140': D6 "21-21-140": D6
'155-179-166': D7 "155-179-166": D7
'55-181-134': D8 "55-181-134": D8
'61-33-27': E1 "61-33-27": E1
'51-91-95': E2 "51-91-95": E2
'143-227-63': E3 "143-227-63": E3
'216-67-226': E4 "216-67-226": E4
'202-181-245': E5 "202-181-245": E5
'99-11-183': E6 "99-11-183": E6
'75-119-224': E7 "75-119-224": E7
'182-19-85': E8 "182-19-85": E8

13
main.py
View File

@ -21,11 +21,11 @@ COM_PORT = "COM33"
# 比特率 # 比特率
COM_BAUDRATE = 9600 COM_BAUDRATE = 9600
# 检测区域的像素值范围 # 检测区域的像素值范围
AREA_SCOPE = 50 AREA_SCOPE = 120
# 检测区域圆上点的数量 # 检测区域圆上点的数量
AREA_POINT_NUM = 8 AREA_POINT_NUM = 8
# 触摸屏幕大小 (单位:像素) # 触摸屏幕大小 (单位:像素)
MONITOR_SIZE = [1600, 2560] MONITOR_SIZE = [2160, 3840]
# 是否开启屏幕反转 # 是否开启屏幕反转
REVERSE_MONITOR = False REVERSE_MONITOR = False
# touch_thread 是否启用sleep, 默认开启, 如果程序 CPU 占用较高则开启, 如果滑动时延迟极大请关闭 # touch_thread 是否启用sleep, 默认开启, 如果程序 CPU 占用较高则开启, 如果滑动时延迟极大请关闭
@ -92,9 +92,10 @@ class SerialManager:
def write_thread(self): def write_thread(self):
while True: while True:
# 延迟匹配波特率 # # 延迟匹配波特率
time.sleep(0.0075) # 9600 # time.sleep(0.0075) # 9600
# time.sleep(0.002) # 115200 # # time.sleep(0.002) # 115200
time.sleep(0.000001) # 避免延迟过大
if not self.startUp: if not self.startUp:
# print("当前没有启动") # print("当前没有启动")
continue continue
@ -258,7 +259,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(1200) clock.tick(6000)
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
break break