smartpi 0.1.27__py3-none-any.whl → 0.1.29__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,6 @@
1
- __all__ = ["base_driver"]
1
+ from ._gui import gui
2
2
 
3
- __version__ = "0.1.27"
3
+ __all__ = ["base_driver","gui","ultrasonic","touch_sensor","temperature","humidity","light_sensor","color_sensor","motor","servo","led","flash"]
4
+
5
+ __version__ = "0.1.29"
4
6
 
@@ -2,7 +2,7 @@ import socket
2
2
  import json
3
3
  import time
4
4
 
5
- class _gui_client:
5
+ class gui_client:
6
6
  def __init__(self, host="127.0.0.1", port=65167):
7
7
  self.sock = socket.create_connection((host, port))
8
8
  self.clear()
@@ -44,44 +44,6 @@ class _gui_client:
44
44
  def finish(self):
45
45
  self.sock.close()
46
46
 
47
- # 创建全局实例
48
- _client_instance = _gui_client()
47
+ # 外部调用
48
+ gui = gui_client()
49
49
 
50
- # 将类方法提升为模块级别的函数
51
- def show_text(x, y, text, color="black", size=16):
52
- _client_instance.show_text(x, y, text, color, size)
53
-
54
- def print(text):
55
- _client_instance.print(text)
56
-
57
- def println(text):
58
- _client_instance.println(text)
59
-
60
- def show_image(x, y, path, width, height):
61
- _client_instance.show_image(x, y, path, width, height)
62
-
63
- def draw_line(x1, y1, x2, y2, color="black", width=1):
64
- _client_instance.draw_line(x1, y1, x2, y2, color, width)
65
-
66
- def fill_rect(x, y, w, h, color="black"):
67
- _client_instance.fill_rect(x, y, w, h, color)
68
-
69
- def draw_rect(x, y, w, h, width, color="black"):
70
- _client_instance.draw_rect(x, y, w, h, width, color)
71
-
72
- def fill_circle(cx, cy, r, color="black"):
73
- _client_instance.fill_circle(cx, cy, r, color)
74
-
75
- def draw_circle(cx, cy, r, width, color="black"):
76
- _client_instance.draw_circle(cx, cy, r, width, color)
77
-
78
- def clear():
79
- _client_instance.clear()
80
-
81
- def finish():
82
- _client_instance.finish()
83
-
84
- # 可选:如果希望仍然可以使用类创建新实例
85
- def create_client(host="127.0.0.1", port=65167):
86
- return _gui_client(host, port)
87
-
smartpi/base_driver.py CHANGED
@@ -2,7 +2,7 @@
2
2
  import serial,time,struct,threading,fcntl
3
3
  from typing import List, Optional
4
4
  from collections import deque
5
- from . import servo,motor,cw2015,gui
5
+ from . import servo,motor,cw2015
6
6
 
7
7
  # 创建全局线程锁
8
8
  serial_lock = threading.RLock()
@@ -575,28 +575,8 @@ def shut_down():
575
575
  serial_lock.release() #释放线程锁
576
576
  fcntl.flock(ser.fileno(), fcntl.LOCK_UN) # 释放进程锁
577
577
  time.sleep(0.5)
578
-
579
- def shut_down_state() -> bool:
580
- serial_lock.acquire() #获取线程锁
581
- fcntl.flock(ser.fileno(), fcntl.LOCK_EX) # 进程锁,阻塞其他进程
582
- response =process_received_data()
583
- if response:
584
- receive_data = response[4:-3]
585
- if receive_data[0]==0XFF and receive_data[1]==0XFE:
586
- serial_lock.release() #释放线程锁
587
- fcntl.flock(ser.fileno(), fcntl.LOCK_UN) # 释放进程锁
588
- return True
589
- else:
590
- buffer.clear()
591
- serial_lock.release() #释放线程锁
592
- fcntl.flock(ser.fileno(), fcntl.LOCK_UN) # 释放进程锁
593
- return False
594
- else:
595
- serial_lock.release() #释放线程锁
596
- fcntl.flock(ser.fileno(), fcntl.LOCK_UN) # 释放进程锁
597
- return False
598
578
 
599
- def exit_program() -> bool:
579
+ def power_button_detec() -> bytes:
600
580
  serial_lock.acquire() #获取线程锁
601
581
  fcntl.flock(ser.fileno(), fcntl.LOCK_EX) # 进程锁,阻塞其他进程
602
582
  response =process_received_data()
@@ -605,16 +585,20 @@ def exit_program() -> bool:
605
585
  if receive_data[0]==0XFF and receive_data[1]==0XFD:
606
586
  serial_lock.release() #释放线程锁
607
587
  fcntl.flock(ser.fileno(), fcntl.LOCK_UN) # 释放进程锁
608
- return True
588
+ return 1
589
+ elif receive_data[0]==0XFF and receive_data[1]==0XFE:
590
+ serial_lock.release() #释放线程锁
591
+ fcntl.flock(ser.fileno(), fcntl.LOCK_UN) # 释放进程锁
592
+ return 2
609
593
  else:
610
594
  buffer.clear()
611
595
  serial_lock.release() #释放线程锁
612
596
  fcntl.flock(ser.fileno(), fcntl.LOCK_UN) # 释放进程锁
613
- return False
597
+ return 0
614
598
  else:
615
599
  serial_lock.release() #释放线程锁
616
600
  fcntl.flock(ser.fileno(), fcntl.LOCK_UN) # 释放进程锁
617
- return False
601
+ return 0
618
602
 
619
603
  def buf_clear():
620
604
  buffer.clear()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smartpi
3
- Version: 0.1.27
3
+ Version: 0.1.29
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=BzLHJz_p4B14Wqd4Ns_Zpte5C5k34J6GRQlwjT6Qx0E,55
2
- smartpi/base_driver.py,sha256=2mlWUIsgFHg_IUltMN8KDcAdKadTHMd9n_aB4YQiro0,25006
1
+ smartpi/__init__.py,sha256=DD3m7tPhima564oB5wb8kPTu1puPptby_1t8IlPB5d0,199
2
+ smartpi/_gui.py,sha256=QObbzAx3m9m7E6A0uQ0Ek_Ofb3stSl7ef96FdVpMVn4,1779
3
+ smartpi/base_driver.py,sha256=hJ5_Rph1BT-riYiW1pgw685WAgEMjpqDF264BLSP6hk,24392
3
4
  smartpi/color_sensor.py,sha256=YXJjknYjp7teTZsHYZRAWgi73CH0MhBp1go9y0Inxyo,498
4
5
  smartpi/cw2015.py,sha256=1lAF-pi_ye_ya1AZQS1sjbgsDf7MThO5IAskKsNGBzA,5695
5
6
  smartpi/flash.py,sha256=-pUqg6FSVoBiLFKqrG9B4dFqn8lICnQsSPJr_MtZLIU,4132
6
- smartpi/gui.py,sha256=HaupXWg5cWw_n86ge8IxARrvL3gpcDCNRwATK9irwH8,2960
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.27.dist-info/METADATA,sha256=sdrqXFW-34__a1ICBrHYjMJAqjbzDad0DiYM0aY0FpE,311
18
- smartpi-0.1.27.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
19
- smartpi-0.1.27.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
20
- smartpi-0.1.27.dist-info/RECORD,,
17
+ smartpi-0.1.29.dist-info/METADATA,sha256=EX2b2m3MfzrJHoX2hRGSQJhlBYMWpFuRcwPttrctwhA,311
18
+ smartpi-0.1.29.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
19
+ smartpi-0.1.29.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
20
+ smartpi-0.1.29.dist-info/RECORD,,