smartpi 0.1.38__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 +8 -0
- smartpi/_gui.py +66 -0
- smartpi/base_driver.py +566 -0
- smartpi/camera.py +84 -0
- smartpi/color_sensor.py +18 -0
- smartpi/cw2015.py +179 -0
- smartpi/flash.py +130 -0
- smartpi/humidity.py +20 -0
- smartpi/led.py +19 -0
- smartpi/light_sensor.py +72 -0
- smartpi/motor.py +177 -0
- smartpi/move.py +218 -0
- smartpi/onnx_hand_workflow.py +201 -0
- smartpi/onnx_image_workflow.py +176 -0
- smartpi/onnx_pose_workflow.py +482 -0
- smartpi/onnx_text_workflow.py +173 -0
- smartpi/onnx_voice_workflow.py +437 -0
- smartpi/posemodel/__init__.py +0 -0
- smartpi/posemodel/posenet.tflite +0 -0
- smartpi/posenet_utils.py +222 -0
- smartpi/rknn_hand_workflow.py +245 -0
- smartpi/rknn_image_workflow.py +405 -0
- smartpi/rknn_pose_workflow.py +592 -0
- smartpi/rknn_text_workflow.py +240 -0
- smartpi/rknn_voice_workflow.py +394 -0
- smartpi/servo.py +178 -0
- smartpi/temperature.py +18 -0
- smartpi/text_gte_model/__init__.py +0 -0
- smartpi/text_gte_model/config/__init__.py +0 -0
- smartpi/text_gte_model/config/config.json +30 -0
- smartpi/text_gte_model/config/quantize_config.json +30 -0
- smartpi/text_gte_model/config/special_tokens_map.json +7 -0
- smartpi/text_gte_model/config/tokenizer.json +14924 -0
- smartpi/text_gte_model/config/tokenizer_config.json +23 -0
- smartpi/text_gte_model/config/vocab.txt +14760 -0
- smartpi/text_gte_model/gte/__init__.py +0 -0
- smartpi/text_gte_model/gte/gte_model.onnx +0 -0
- smartpi/touch_sensor.py +16 -0
- smartpi/trace.py +120 -0
- smartpi/ultrasonic.py +20 -0
- smartpi-0.1.38.dist-info/METADATA +17 -0
- smartpi-0.1.38.dist-info/RECORD +44 -0
- smartpi-0.1.38.dist-info/WHEEL +5 -0
- smartpi-0.1.38.dist-info/top_level.txt +1 -0
|
File without changes
|
|
Binary file
|
smartpi/touch_sensor.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
import time
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
from smartpi import base_driver
|
|
5
|
+
|
|
6
|
+
#���������� port:����P�˿� �������أ�1��0; ��ȡ����-1
|
|
7
|
+
def get_value(port:bytes) -> Optional[bytes]:
|
|
8
|
+
read_sw_str=[0xA0, 0x03, 0x01, 0xBE]
|
|
9
|
+
read_sw_str[0]=0XA0+port
|
|
10
|
+
time.sleep(0.005)
|
|
11
|
+
response = base_driver.single_operate_sensor(read_sw_str,0)
|
|
12
|
+
if response == None:
|
|
13
|
+
return None
|
|
14
|
+
else:
|
|
15
|
+
return response[4]
|
|
16
|
+
|
smartpi/trace.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
import time,fcntl,serial,threading
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
from smartpi import base_driver
|
|
5
|
+
|
|
6
|
+
# 串口配置参数
|
|
7
|
+
SERIAL_PORT = "/dev/ttyS3" # 串口设备路径
|
|
8
|
+
BAUD_RATE = 921600 # 波特率
|
|
9
|
+
TIMEOUT = 0.1 # 读取超时时间(秒)
|
|
10
|
+
|
|
11
|
+
ser = serial.Serial(
|
|
12
|
+
port=SERIAL_PORT,
|
|
13
|
+
baudrate=BAUD_RATE,
|
|
14
|
+
bytesize=serial.EIGHTBITS, # 8位数据位
|
|
15
|
+
parity=serial.PARITY_NONE, # 无校验位
|
|
16
|
+
stopbits=serial.STOPBITS_ONE, # 1位停止位
|
|
17
|
+
timeout=TIMEOUT,
|
|
18
|
+
xonxoff=False, # 关闭软件流控
|
|
19
|
+
rtscts=False, # 关闭硬件流控
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# 创建全局线程锁
|
|
23
|
+
serial_lock = threading.RLock()
|
|
24
|
+
|
|
25
|
+
#循迹卡单通道阈值比较后的布尔值读取 port:连接P端口;chn:检测通道1~7;正常返回:通道布尔值; 读取错误:None
|
|
26
|
+
def get_chn_data(port:bytes, chn:bytes) -> Optional[bytes]:
|
|
27
|
+
trace_str=[0xA0, 0x18, 0x01, 0x71, 0x00, 0xBE]
|
|
28
|
+
trace_str[0]=0XA0+port
|
|
29
|
+
trace_str[4]=chn
|
|
30
|
+
time.sleep(0.005)
|
|
31
|
+
response = base_driver.single_operate_sensor(trace_str,0)
|
|
32
|
+
if response == None:
|
|
33
|
+
return None
|
|
34
|
+
else:
|
|
35
|
+
return response[4]
|
|
36
|
+
|
|
37
|
+
#循迹卡设置各通道颜色 port:连接P端口;color1~color7:7个通道彩灯的颜色1~7(红、绿、蓝、黄、紫、青、白)
|
|
38
|
+
def set_chn_color(port:bytes, color1:bytes, color2:bytes, color3:bytes, color4:bytes, color5:bytes, color6:bytes, color7:bytes) -> Optional[bytes]:
|
|
39
|
+
trace_str=[0xA0, 0x19, 0x01, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0xBE]
|
|
40
|
+
trace_str[0]=0XA0+port
|
|
41
|
+
trace_str[4]=color1
|
|
42
|
+
trace_str[6]=color2
|
|
43
|
+
trace_str[8]=color3
|
|
44
|
+
trace_str[10]=color4
|
|
45
|
+
trace_str[12]=color5
|
|
46
|
+
trace_str[14]=color6
|
|
47
|
+
trace_str[16]=color7
|
|
48
|
+
time.sleep(0.005)
|
|
49
|
+
base_driver.write_data(0X01, 0X02, trace_str)
|
|
50
|
+
# response = base_driver.single_operate_sensor(trace_str,0)
|
|
51
|
+
# if response == None:
|
|
52
|
+
# return None
|
|
53
|
+
# else:
|
|
54
|
+
return 0
|
|
55
|
+
|
|
56
|
+
#循迹卡设置全部颜色 port:连接P端口;color:全部彩灯的颜色1~7(红、绿、蓝、黄、紫、青、白)
|
|
57
|
+
def set_color(port:bytes, color:bytes) -> Optional[bytes]:
|
|
58
|
+
trace_str=[0xA0, 0x20, 0x01, 0x71, 0x00, 0xBE]
|
|
59
|
+
trace_str[0]=0XA0+port
|
|
60
|
+
trace_str[4]=color
|
|
61
|
+
time.sleep(0.005)
|
|
62
|
+
base_driver.write_data(0X01, 0X02, trace_str)
|
|
63
|
+
# response = base_driver.single_operate_sensor(trace_str,0)
|
|
64
|
+
# if response == None:
|
|
65
|
+
# return None
|
|
66
|
+
# else:
|
|
67
|
+
return 0
|
|
68
|
+
|
|
69
|
+
#循迹卡单通道光值读取 port:连接P端口;chn:检测通道;正常返回:通道光值数据; 读取错误:None
|
|
70
|
+
def get_analog(port:bytes, chn:bytes) -> Optional[bytes]:
|
|
71
|
+
trace_str=[0xA0, 0x21, 0x01, 0x71, 0x00, 0xBE]
|
|
72
|
+
trace_str[0]=0XA0+port
|
|
73
|
+
trace_str[4]=20+chn
|
|
74
|
+
time.sleep(0.005)
|
|
75
|
+
response = base_driver.single_operate_sensor(trace_str,0)
|
|
76
|
+
if response == None:
|
|
77
|
+
return None
|
|
78
|
+
else:
|
|
79
|
+
return response[4]
|
|
80
|
+
|
|
81
|
+
#循迹卡判断是否组合图形 port:连接P端口;state:判断图形组合 1:TT 2:TL 3:TR 4:TM 5:L2 6:L1 7:L 8:M 9:R 10:R1 11:R2
|
|
82
|
+
#正常返回:True/False; 读取错误:None
|
|
83
|
+
def get_line_state(port:bytes, state:bytes) -> Optional[bytes]:
|
|
84
|
+
trace_str=[0xA0, 0x22, 0x01, 0x71, 0x00, 0xBE]
|
|
85
|
+
trace_str[0]=0XA0+port
|
|
86
|
+
trace_str[4]=state
|
|
87
|
+
time.sleep(0.005)
|
|
88
|
+
response = base_driver.single_operate_sensor(trace_str,0)
|
|
89
|
+
if response == None:
|
|
90
|
+
return None
|
|
91
|
+
else:
|
|
92
|
+
return response[4]
|
|
93
|
+
|
|
94
|
+
#循迹卡自动设置灰度阈值 port:连接P端口;second:秒数
|
|
95
|
+
def set_threshold(port:bytes, second:int) -> Optional[bytes]:
|
|
96
|
+
trace_str=[0xA0, 0x23, 0x01, 0x81, 0x00, 0x00, 0xBE]
|
|
97
|
+
trace_str[0]=0XA0+port
|
|
98
|
+
trace_str[4]=second//256
|
|
99
|
+
trace_str[5]=second%256
|
|
100
|
+
time.sleep(0.005)
|
|
101
|
+
serial_lock.acquire() #获取线程锁
|
|
102
|
+
fcntl.flock(ser.fileno(), fcntl.LOCK_EX) # 进程锁,阻塞其他进程
|
|
103
|
+
base_driver.write_data(0X01, 0X02, trace_str)
|
|
104
|
+
start_time = time.time()
|
|
105
|
+
|
|
106
|
+
while True:
|
|
107
|
+
response =base_driver.process_received_data()
|
|
108
|
+
if response:
|
|
109
|
+
serial_lock.release() #释放线程锁
|
|
110
|
+
fcntl.flock(ser.fileno(), fcntl.LOCK_UN) # 释放进程锁
|
|
111
|
+
display_data = response[6:-3]
|
|
112
|
+
return display_data
|
|
113
|
+
else:
|
|
114
|
+
if time.time() - start_time > second+2:
|
|
115
|
+
print("读取超时")
|
|
116
|
+
base_driver.buf_clear()
|
|
117
|
+
serial_lock.release() #释放线程锁
|
|
118
|
+
fcntl.flock(ser.fileno(), fcntl.LOCK_UN) # 释放进程锁
|
|
119
|
+
return None
|
|
120
|
+
|
smartpi/ultrasonic.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
import time
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
from smartpi import base_driver
|
|
5
|
+
|
|
6
|
+
#��������ഫ���� port:����P�˿� �������أ��������; ��ȡ����-1
|
|
7
|
+
def get_value(port:bytes) -> Optional[bytes]:
|
|
8
|
+
ultrasonic_str=[0xA0, 0x06, 0x00, 0xBE]
|
|
9
|
+
ultrasonic_str[0]=0XA0+port
|
|
10
|
+
ultrasonic_str[2]=1
|
|
11
|
+
time.sleep(0.005)
|
|
12
|
+
response = base_driver.single_operate_sensor(ultrasonic_str,0)
|
|
13
|
+
|
|
14
|
+
if response == None:
|
|
15
|
+
return None
|
|
16
|
+
else:
|
|
17
|
+
distance_data=response[4:-1]
|
|
18
|
+
distance_num=int.from_bytes(distance_data, byteorder='big', signed=True)
|
|
19
|
+
return distance_num
|
|
20
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: smartpi
|
|
3
|
+
Version: 0.1.38
|
|
4
|
+
Summary: A library use for H2-RCU
|
|
5
|
+
Author: ZMROBO
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.7
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
灵芯派函数库
|
|
13
|
+
SmartPi library
|
|
14
|
+
|
|
15
|
+
V0.1.31
|
|
16
|
+
1、更新了设备硬件ID读取函数;
|
|
17
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
smartpi/__init__.py,sha256=96n_lgMdc9_8wLmtm7zvh6G-ybPWegp0CkZsW025nr4,356
|
|
2
|
+
smartpi/_gui.py,sha256=ij-6HZAEIwdy_hvU7f0NkyQjx_-eephijlKbGUhf8Uo,2177
|
|
3
|
+
smartpi/base_driver.py,sha256=difi-MhGoxvodSsQt1hYg-nx5fk4b-qU7D-5-A61LaY,20632
|
|
4
|
+
smartpi/camera.py,sha256=AVpZsMpW-24CP3BOfarjmRawMJdTOZY7Crq7FeLOqb4,3292
|
|
5
|
+
smartpi/color_sensor.py,sha256=ckIXD81YnqPo6nENAnipNp3gY12FJ235QKj0e8Cul9E,521
|
|
6
|
+
smartpi/cw2015.py,sha256=1lAF-pi_ye_ya1AZQS1sjbgsDf7MThO5IAskKsNGBzA,5695
|
|
7
|
+
smartpi/flash.py,sha256=-pUqg6FSVoBiLFKqrG9B4dFqn8lICnQsSPJr_MtZLIU,4132
|
|
8
|
+
smartpi/humidity.py,sha256=uoSFt5mAKr-dHz125uznHXAPeTN61ZR92_2nQmytQ5M,522
|
|
9
|
+
smartpi/led.py,sha256=6-y5MFGk0tN5N_WHclXbSRyP-anhCHhgXI3MdAQCKWM,617
|
|
10
|
+
smartpi/light_sensor.py,sha256=-ICMwQcWIZ6LGOz_A2WL5h5CL1v4opmlfacN35veMSE,2398
|
|
11
|
+
smartpi/motor.py,sha256=DvFzREEzyRafGmSCagU6ASeoE8fnAsKYI4oYMrkXXJc,5351
|
|
12
|
+
smartpi/move.py,sha256=s1ZnkFtp6SCBnxhBxp6qQjGbifdsY5hjVCwlarTsZto,6688
|
|
13
|
+
smartpi/onnx_hand_workflow.py,sha256=ZCoaWC6GygZSrhM6jhsuB6qmQ6GiAFFrso6rKAGmue8,8157
|
|
14
|
+
smartpi/onnx_image_workflow.py,sha256=-saM_NxR6yDz06xlWZOvHf6cq3zmtOCFhCyZTGqvuOk,6188
|
|
15
|
+
smartpi/onnx_pose_workflow.py,sha256=7hoZ31XfZRAbgmdQbgfK-xePniMa5mDEggV12F-Uq5c,20970
|
|
16
|
+
smartpi/onnx_text_workflow.py,sha256=6l9MTT2T1-rNye3_dSHLI2U749Z94aoRdkSe6CNXfHw,7191
|
|
17
|
+
smartpi/onnx_voice_workflow.py,sha256=jkMFzy3RUnLo8LZAuCUfsS3YCJWSZzZuiE4RFoQ2HZw,17440
|
|
18
|
+
smartpi/posenet_utils.py,sha256=o3scK41Eqvftav4y4vp6_6HinQWNCLeLpArXAzqQ-7s,8983
|
|
19
|
+
smartpi/rknn_hand_workflow.py,sha256=wsVN_PYP9M-1AFaN4yqrGksUBoamYfujW0nQq4nv3kU,10160
|
|
20
|
+
smartpi/rknn_image_workflow.py,sha256=4lTtcdmQ9KN5WiEnHayvqAd-dA0tiap5YXIqAMn5SoI,18444
|
|
21
|
+
smartpi/rknn_pose_workflow.py,sha256=LA6tXOI81R1IQhQvgBWLGV_I8Qa-ROUgXqj3kTEMfmc,27840
|
|
22
|
+
smartpi/rknn_text_workflow.py,sha256=KNBSetj3tmlLxdZOm0yzbiDnjH8S5191fuxh5Mi-uCY,9632
|
|
23
|
+
smartpi/rknn_voice_workflow.py,sha256=T8iRQWPtJYXqoHIZH2FiT1WLxwN3HQg4D-mg-5KvYdA,16326
|
|
24
|
+
smartpi/servo.py,sha256=0p09Jk-IVk5nLXz2AqFvytiYSSe4sMxdy1FaNMQijoY,5770
|
|
25
|
+
smartpi/temperature.py,sha256=xfM9V5dvJ9M-3rqnE2AjaYXEH9jP5s1_Myo4GEwH3NY,485
|
|
26
|
+
smartpi/touch_sensor.py,sha256=Zp7z0qnaZ99cuamakqDwI2tFd2a3CnjQ1rngdn_mZlM,463
|
|
27
|
+
smartpi/trace.py,sha256=HkoTleJnwseAue2J9wTFSXPgXaLx2Y-LE7Ip8UdoreE,4791
|
|
28
|
+
smartpi/ultrasonic.py,sha256=qrGge3G9_1s3ZdKYZRJ_FP8l_VhbpYEe-anlShooMwA,647
|
|
29
|
+
smartpi/posemodel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
|
+
smartpi/posemodel/posenet.tflite,sha256=KFcCnk1X5KvJrVC_c_PhL76pdvwL0hZvBdNqhzZ7J2I,1303152
|
|
31
|
+
smartpi/text_gte_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
+
smartpi/text_gte_model/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
|
+
smartpi/text_gte_model/config/config.json,sha256=dkFw_GRLSEkp6VT2U92alaGUfCRRJBQysJYSbJYznLc,818
|
|
34
|
+
smartpi/text_gte_model/config/quantize_config.json,sha256=snZbw5kBj_FupAbcYazm_11wNRCbX2m468VBjl6svd4,703
|
|
35
|
+
smartpi/text_gte_model/config/special_tokens_map.json,sha256=PDUH823_V7zkNyI9s7MIHR4rUuw-Vu5VQ4GT7LLJTdY,132
|
|
36
|
+
smartpi/text_gte_model/config/tokenizer.json,sha256=BC58aSuzfzE-tNG0UDwcFfNT_mJOYFaLoVoOs_JBEjQ,312882
|
|
37
|
+
smartpi/text_gte_model/config/tokenizer_config.json,sha256=w5RiDifbeIYy6vyGX5v94vFmcko1TMItqnY0RfcBO1Q,639
|
|
38
|
+
smartpi/text_gte_model/config/vocab.txt,sha256=oi9hP3uz_8h8XoHNh6rgLnVdJbIEm75zKoSKM8HzsC8,84758
|
|
39
|
+
smartpi/text_gte_model/gte/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
|
+
smartpi/text_gte_model/gte/gte_model.onnx,sha256=XXYg6TUhzOx1SqAhp6ePDU0QgeK6DQEqHATMuQQJCNE,30468366
|
|
41
|
+
smartpi-0.1.38.dist-info/METADATA,sha256=xBKdlQb5thD353YPofezbAyQtSEKGT-aHrbhLUD9qd4,399
|
|
42
|
+
smartpi-0.1.38.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
43
|
+
smartpi-0.1.38.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
|
|
44
|
+
smartpi-0.1.38.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
smartpi
|