smartpi 0.1.24__py3-none-any.whl → 0.1.25__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 CHANGED
@@ -1,4 +1,4 @@
1
1
  __all__ = ["base_driver"]
2
2
 
3
- __version__ = "0.1.24"
3
+ __version__ = "0.1.25"
4
4
 
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smartpi
3
- Version: 0.1.24
3
+ Version: 0.1.25
4
4
  Summary: A library use for H2-RCU
5
5
  Author: ZMROBO
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,9 +1,9 @@
1
- smartpi/__init__.py,sha256=mtkDm-FlobRiZdbqGbS77ZzAwe5A9DRGKwIoWdhN2U4,55
1
+ smartpi/__init__.py,sha256=Ym1EDHFMEQ6UHRHJvC060fvy-ByNd89489gwDffa1Yg,55
2
2
  smartpi/base_driver.py,sha256=jP8cuQ0LRfjMuVQ2I6tY7fxp3JsjcUH8fdWKooIogME,24188
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=nUFfU-jbDMOHIqZOyiy-7bwO0gMTJllscjnTLyoPYsk,7228
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.24.dist-info/METADATA,sha256=EQIoqPSL55ic97bXSlKHbMhQYTH37iI-k9tCJHCJPXc,311
18
- smartpi-0.1.24.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
19
- smartpi-0.1.24.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
20
- smartpi-0.1.24.dist-info/RECORD,,
17
+ smartpi-0.1.25.dist-info/METADATA,sha256=ouofp2CDp_w2C6ohXACM7UyBEuWWXRvwv94T_H57kjo,311
18
+ smartpi-0.1.25.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
19
+ smartpi-0.1.25.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
20
+ smartpi-0.1.25.dist-info/RECORD,,