smartpi 0.1.24__py3-none-any.whl → 0.1.26__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- smartpi/__init__.py +1 -1
- smartpi/base_driver.py +20 -0
- smartpi/gui.py +26 -9
- {smartpi-0.1.24.dist-info → smartpi-0.1.26.dist-info}/METADATA +1 -1
- {smartpi-0.1.24.dist-info → smartpi-0.1.26.dist-info}/RECORD +7 -7
- {smartpi-0.1.24.dist-info → smartpi-0.1.26.dist-info}/WHEEL +0 -0
- {smartpi-0.1.24.dist-info → smartpi-0.1.26.dist-info}/top_level.txt +0 -0
smartpi/__init__.py
CHANGED
smartpi/base_driver.py
CHANGED
|
@@ -595,6 +595,26 @@ def shut_down_state() -> bool:
|
|
|
595
595
|
serial_lock.release() #释放线程锁
|
|
596
596
|
fcntl.flock(ser.fileno(), fcntl.LOCK_UN) # 释放进程锁
|
|
597
597
|
return False
|
|
598
|
+
|
|
599
|
+
def exit_program() -> bool:
|
|
600
|
+
serial_lock.acquire() #获取线程锁
|
|
601
|
+
fcntl.flock(ser.fileno(), fcntl.LOCK_EX) # 进程锁,阻塞其他进程
|
|
602
|
+
response =process_received_data()
|
|
603
|
+
if response:
|
|
604
|
+
receive_data = response[4:-3]
|
|
605
|
+
if receive_data[0]==0XFF and receive_data[1]==0XFD:
|
|
606
|
+
serial_lock.release() #释放线程锁
|
|
607
|
+
fcntl.flock(ser.fileno(), fcntl.LOCK_UN) # 释放进程锁
|
|
608
|
+
return True
|
|
609
|
+
else:
|
|
610
|
+
buffer.clear()
|
|
611
|
+
serial_lock.release() #释放线程锁
|
|
612
|
+
fcntl.flock(ser.fileno(), fcntl.LOCK_UN) # 释放进程锁
|
|
613
|
+
return False
|
|
614
|
+
else:
|
|
615
|
+
serial_lock.release() #释放线程锁
|
|
616
|
+
fcntl.flock(ser.fileno(), fcntl.LOCK_UN) # 释放进程锁
|
|
617
|
+
return False
|
|
598
618
|
|
|
599
619
|
def buf_clear():
|
|
600
620
|
buffer.clear()
|
smartpi/gui.py
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
可靠触摸屏GUI - 恢复可工作版本
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
2
|
import tkinter as tk
|
|
7
3
|
from tkinter import font as tkfont
|
|
8
4
|
import os
|
|
@@ -100,8 +96,7 @@ def _read_touch_events():
|
|
|
100
96
|
break
|
|
101
97
|
except Exception as e:
|
|
102
98
|
print(f"触摸读取异常: {e}")
|
|
103
|
-
break
|
|
104
|
-
|
|
99
|
+
break
|
|
105
100
|
# 关闭设备
|
|
106
101
|
os.close(fd)
|
|
107
102
|
|
|
@@ -142,10 +137,8 @@ def init():
|
|
|
142
137
|
touch_thread = threading.Thread(target=_read_touch_events, daemon=True)
|
|
143
138
|
touch_thread.start()
|
|
144
139
|
|
|
145
|
-
# 等待GUI初始化完成
|
|
146
140
|
time.sleep(0.2)
|
|
147
141
|
|
|
148
|
-
|
|
149
142
|
# 公共接口函数
|
|
150
143
|
def show_text(x, y, text, color="black", size=16):
|
|
151
144
|
if _canvas and _fonts:
|
|
@@ -190,6 +183,18 @@ def get_touch_y():
|
|
|
190
183
|
def get_touchscreen():
|
|
191
184
|
return _touch_pressed
|
|
192
185
|
|
|
186
|
+
#检测区域范围内是否按下 返回:1:按下;0:没按下
|
|
187
|
+
def get_xy_touch(x1,y1,x2,y2):
|
|
188
|
+
if get_touchscreen():
|
|
189
|
+
x = get_touch_x()
|
|
190
|
+
y = get_touch_y()
|
|
191
|
+
if x1 <= x <= x2 and y1 <= y <= y2:
|
|
192
|
+
return 1
|
|
193
|
+
else:
|
|
194
|
+
return 0
|
|
195
|
+
else:
|
|
196
|
+
return 0
|
|
197
|
+
|
|
193
198
|
def should_exit():
|
|
194
199
|
"""检查是否应该退出程序"""
|
|
195
200
|
return _exit_triggered
|
|
@@ -235,4 +240,16 @@ def check_exit_button(x, y):
|
|
|
235
240
|
global _exit_triggered
|
|
236
241
|
_exit_triggered = True
|
|
237
242
|
return True
|
|
238
|
-
return False
|
|
243
|
+
return False
|
|
244
|
+
|
|
245
|
+
#判断有无按下退出按键 返回:1:按下;0:没按下
|
|
246
|
+
def exit_button():
|
|
247
|
+
x = get_touch_x()
|
|
248
|
+
y = get_touch_y()
|
|
249
|
+
pressed = get_touchscreen()
|
|
250
|
+
draw_exit_button()
|
|
251
|
+
if pressed and check_exit_button(x,y):
|
|
252
|
+
return 1
|
|
253
|
+
else:
|
|
254
|
+
return 0
|
|
255
|
+
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
smartpi/__init__.py,sha256=
|
|
2
|
-
smartpi/base_driver.py,sha256=
|
|
1
|
+
smartpi/__init__.py,sha256=QSExDrXsT6YYS4iMlWm6tRK2sV5uLqOeGXQOVD70emo,55
|
|
2
|
+
smartpi/base_driver.py,sha256=kVpIRNObvhQUQDF7nXnoSvEDMhgfwYxAYQ8Ymv0cMek,24998
|
|
3
3
|
smartpi/color_sensor.py,sha256=YXJjknYjp7teTZsHYZRAWgi73CH0MhBp1go9y0Inxyo,498
|
|
4
4
|
smartpi/cw2015.py,sha256=1lAF-pi_ye_ya1AZQS1sjbgsDf7MThO5IAskKsNGBzA,5695
|
|
5
5
|
smartpi/flash.py,sha256=-pUqg6FSVoBiLFKqrG9B4dFqn8lICnQsSPJr_MtZLIU,4132
|
|
6
|
-
smartpi/gui.py,sha256=
|
|
6
|
+
smartpi/gui.py,sha256=UEi-ub1KFxIl5uYFhwZRJ2Jt-nFFgAnEhwczVzL4PnE,7755
|
|
7
7
|
smartpi/humidity.py,sha256=nZwiBtMWKNipVM83ymajZACPHxkC2vUJjDMmCOPN9lw,499
|
|
8
8
|
smartpi/led.py,sha256=flvN7EJfP6VDTSiC93w1uR8pRxcZD9w2vLXA1GbJTo8,538
|
|
9
9
|
smartpi/light_sensor.py,sha256=MayyVikWcXQfjeZrtYRnwYgHBDzu2g-mfJLpdd29EG8,1852
|
|
@@ -14,7 +14,7 @@ smartpi/temperature.py,sha256=VT79CYA41q1d_4AM-Y0eIMeIw7AtCkSXjWVws6Yx5yE,462
|
|
|
14
14
|
smartpi/touch_sensor.py,sha256=P57RRQlqY0KexpMi-ydqwF5albOKCBOGb0Rb6zeVTqk,440
|
|
15
15
|
smartpi/trace.py,sha256=tut7BMbq87ShaR5eNuv7PZtAEz9DS5_BDf0_muIZ-tQ,4577
|
|
16
16
|
smartpi/ultrasonic.py,sha256=kmVpUfvE1oHoqgv92ZU6Fi-sO6DSwm10ssKsImNeOkY,624
|
|
17
|
-
smartpi-0.1.
|
|
18
|
-
smartpi-0.1.
|
|
19
|
-
smartpi-0.1.
|
|
20
|
-
smartpi-0.1.
|
|
17
|
+
smartpi-0.1.26.dist-info/METADATA,sha256=nQZgGpvSJ9IT-ozXTDLaVj62i8pUoeE1Ug-lznHudJM,311
|
|
18
|
+
smartpi-0.1.26.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
19
|
+
smartpi-0.1.26.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
|
|
20
|
+
smartpi-0.1.26.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|