smartpi 0.1.0__py3-none-any.whl → 0.1.2__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/GUI.py +0 -0
- smartpi/__init__.py +2 -2
- smartpi/base_driver.py +501 -0
- smartpi/color_sensor.py +6 -0
- smartpi/humidity.py +20 -0
- smartpi/led.py +17 -0
- smartpi/light_sensor.py +27 -0
- smartpi/motor.py +60 -0
- smartpi/move.py +0 -0
- smartpi/photosensitive.py +0 -0
- smartpi/servo.py +25 -0
- smartpi/temperature.py +18 -0
- smartpi/touch_sensor.py +15 -0
- smartpi/trace.py +0 -0
- smartpi/ultrasonic.py +27 -0
- {smartpi-0.1.0.dist-info → smartpi-0.1.2.dist-info}/METADATA +1 -3
- smartpi-0.1.2.dist-info/RECORD +19 -0
- smartpi/app_module.py +0 -119
- smartpi/module.py +0 -503
- smartpi/mpu6500.py +0 -130
- smartpi-0.1.0.dist-info/RECORD +0 -8
- {smartpi-0.1.0.dist-info → smartpi-0.1.2.dist-info}/WHEEL +0 -0
- {smartpi-0.1.0.dist-info → smartpi-0.1.2.dist-info}/top_level.txt +0 -0
smartpi/touch_sensor.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
import time
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
from smartpi import base_driver
|
|
5
|
+
|
|
6
|
+
#���������� port:����P�˿�
|
|
7
|
+
def get_value(port:bytes) -> Optional[bytes]:
|
|
8
|
+
read_sw_str=[0xA0, 0x03, 0x01, 0xBE]
|
|
9
|
+
read_sw_str[0]=0XA0+port
|
|
10
|
+
response = base_driver.single_operate_sensor(read_sw_str)
|
|
11
|
+
if response:
|
|
12
|
+
return 0
|
|
13
|
+
else:
|
|
14
|
+
return -1
|
|
15
|
+
|
smartpi/trace.py
ADDED
|
File without changes
|
smartpi/ultrasonic.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
import time
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
from smartpi import base_driver
|
|
5
|
+
|
|
6
|
+
#��������ȡ port:����P�˿ڣ�command:1:��ȡ��
|
|
7
|
+
#def get_value(port:bytes,command:bytes) -> Optional[bytes]:
|
|
8
|
+
# ultrasonic_str=[0xA0, 0x06, 0x00, 0xBE]
|
|
9
|
+
# ultrasonic_str[0]=0XA0+port
|
|
10
|
+
# ultrasonic_str[2]=command
|
|
11
|
+
# response = base_driver.single_operate_sensor(ultrasonic_str)
|
|
12
|
+
# if response:
|
|
13
|
+
# return 0
|
|
14
|
+
# else:
|
|
15
|
+
# return -1
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_value(port:bytes) -> Optional[bytes]:
|
|
19
|
+
ultrasonic_str=[0xA0, 0x06, 0x00, 0xBE]
|
|
20
|
+
ultrasonic_str[0]=0XA0+port
|
|
21
|
+
ultrasonic_str[2]=1
|
|
22
|
+
response = base_driver.single_operate_sensor(ultrasonic_str)
|
|
23
|
+
if response:
|
|
24
|
+
return 0
|
|
25
|
+
else:
|
|
26
|
+
return -1
|
|
27
|
+
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: smartpi
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: A library use for H2-RCU
|
|
5
5
|
Author-email: Driver_cai <1547363120@qq.com>
|
|
6
|
-
Project-URL: Homepage, https://github.com/Drvier_cai/smartpi
|
|
7
|
-
Project-URL: Bug Tracker, https://github.com/Driver/smartpi/issues
|
|
8
6
|
Classifier: Programming Language :: Python :: 3
|
|
9
7
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
8
|
Classifier: Operating System :: OS Independent
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
smartpi/GUI.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
smartpi/__init__.py,sha256=xdzDVGW4Uw7PG44QR4hHh12hTBDzyxg6RujH2fQAjnM,54
|
|
3
|
+
smartpi/base_driver.py,sha256=EIJp-H02io5S09u7oQTxV8plIfCcf9yvFUxhwVPF0zc,17197
|
|
4
|
+
smartpi/color_sensor.py,sha256=COa4bh_yrcBMJbb-iFCf4k5fNwfEdpYvPdTbIwFis4M,101
|
|
5
|
+
smartpi/humidity.py,sha256=CJVjulD4Gk_c9iwy4zmaGLv-Ta6M00koDmR2qfahkZ4,446
|
|
6
|
+
smartpi/led.py,sha256=f8K7ebHFy9kIlCLWKEyQbmPQv4z2TMTNGs1vaKOtMAs,495
|
|
7
|
+
smartpi/light_sensor.py,sha256=PHonOg7d3POjZnB6uETHeOQk8dWszxNoMfn6u9Tl1ow,726
|
|
8
|
+
smartpi/motor.py,sha256=NPzDZ1kVpBu30JOntjcIqr8XslFu6nRehj31MROLCOY,1942
|
|
9
|
+
smartpi/move.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
smartpi/photosensitive.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
smartpi/servo.py,sha256=uoitiCWzh4dnfztpXXo5ABkGF-a3qdvXMxjlIBZZQaU,783
|
|
12
|
+
smartpi/temperature.py,sha256=p89_AYIeEQsF7UKKnTexOCIRNXipYKKZWrULqjKeMLM,426
|
|
13
|
+
smartpi/touch_sensor.py,sha256=MyzghSoTkwAGp2_uNemYKRu9zeR3A2PeW3f0S8su3SI,386
|
|
14
|
+
smartpi/trace.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
+
smartpi/ultrasonic.py,sha256=xdSZe6uyihbfaBLiGmFahKYXTsOgVailMyq5ZYHrlFU,768
|
|
16
|
+
smartpi-0.1.2.dist-info/METADATA,sha256=mTtF5nXDibfCDSOUZuDgkzFOGrWneydBRDMIk0-4XnI,340
|
|
17
|
+
smartpi-0.1.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
18
|
+
smartpi-0.1.2.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
|
|
19
|
+
smartpi-0.1.2.dist-info/RECORD,,
|
smartpi/app_module.py
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
# coding=utf-8
|
|
2
|
-
import time
|
|
3
|
-
from typing import List, Optional
|
|
4
|
-
from smartpi.module import Uart3_funtions,base_driver
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class app_funtion:
|
|
8
|
-
#马达编码读取 port:连接M端口;
|
|
9
|
-
def read_motor_code(port:bytes) -> Optional[bytes]:
|
|
10
|
-
motor_str=[0xA0, 0x01, 0x01, 0xBE]
|
|
11
|
-
motor_str[0]=0XA0+port
|
|
12
|
-
response = Uart3_funtions.single_operate_sensor(motor_str)
|
|
13
|
-
if response:
|
|
14
|
-
return 0
|
|
15
|
-
else:
|
|
16
|
-
return -1
|
|
17
|
-
|
|
18
|
-
#马达速度控制 port:连接M端口;speed:0~100
|
|
19
|
-
def write_motor_speed(port:bytes,speed:bytes) -> Optional[bytes]:
|
|
20
|
-
motor_str=[0xA0, 0x01, 0x02, 0x71, 0x00, 0xBE]
|
|
21
|
-
motor_str[0]=0XA0+port
|
|
22
|
-
motor_str[4]=speed
|
|
23
|
-
response = Uart3_funtions.single_operate_sensor(motor_str)
|
|
24
|
-
if response:
|
|
25
|
-
return 0
|
|
26
|
-
else:
|
|
27
|
-
return -1
|
|
28
|
-
|
|
29
|
-
#马达速度编码控制 port:连接M端口;speed:0~100;code:0~65535
|
|
30
|
-
def motor_servoctl(port:bytes,speed:bytes,code:int) -> Optional[bytes]:
|
|
31
|
-
motor_str=[0xA0, 0x01, 0x04, 0x81, 0x00, 0x81, 0x00, 0x00, 0xBE]
|
|
32
|
-
motor_str[0]=0XA0+port
|
|
33
|
-
motor_str[4]=speed
|
|
34
|
-
motor_str[6]=code//256
|
|
35
|
-
motor_str[7]=code%256
|
|
36
|
-
response = Uart3_funtions.single_operate_sensor(motor_str)
|
|
37
|
-
if response:
|
|
38
|
-
return 0
|
|
39
|
-
else:
|
|
40
|
-
return -1
|
|
41
|
-
|
|
42
|
-
#马达方向控制 port:连接M端口;dir:
|
|
43
|
-
def write_motor_dir(port:bytes,direc:bytes) -> Optional[bytes]:
|
|
44
|
-
motor_str=[0xA0, 0x01, 0x06, 0x71, 0x00, 0xBE]
|
|
45
|
-
motor_str[0]=0XA0+port
|
|
46
|
-
motor_str[4]=direc
|
|
47
|
-
response = Uart3_funtions.single_operate_sensor(motor_str)
|
|
48
|
-
if response:
|
|
49
|
-
return 0
|
|
50
|
-
else:
|
|
51
|
-
return -1
|
|
52
|
-
|
|
53
|
-
#彩灯控制 port:连接P端口;command:0:关灯;1:红;2:绿;3:蓝;4:黄;5:紫;6:青;7:白
|
|
54
|
-
def color_lamp_operate(port:bytes,command:bytes) -> Optional[bytes]:
|
|
55
|
-
color_lamp_str=[0xA0, 0x05, 0x00, 0xBE]
|
|
56
|
-
color_lamp_str[0]=0XA0+port
|
|
57
|
-
color_lamp_str[2]=command
|
|
58
|
-
response = Uart3_funtions.single_operate_sensor(color_lamp_str)
|
|
59
|
-
if response:
|
|
60
|
-
return 0
|
|
61
|
-
else:
|
|
62
|
-
return -1
|
|
63
|
-
|
|
64
|
-
#触碰传感器 port:连接P端口
|
|
65
|
-
def read_switch(port:bytes) -> Optional[bytes]:
|
|
66
|
-
read_sw_str=[0xA0, 0x03, 0x01, 0xBE]
|
|
67
|
-
read_sw_str[0]=0XA0+port
|
|
68
|
-
response = Uart3_funtions.single_operate_sensor(read_sw_str)
|
|
69
|
-
if response:
|
|
70
|
-
return 0
|
|
71
|
-
else:
|
|
72
|
-
return -1
|
|
73
|
-
|
|
74
|
-
#光电读取 port:连接P端口;command:1:读取;2:开灯;3:关灯;
|
|
75
|
-
def light_operate(port:bytes,command:bytes) -> Optional[bytes]:
|
|
76
|
-
light_str=[0xA0, 0x02, 0x00, 0xBE]
|
|
77
|
-
light_str[0]=0XA0+port
|
|
78
|
-
light_str[2]=command
|
|
79
|
-
response = Uart3_funtions.single_operate_sensor(light_str)
|
|
80
|
-
if response:
|
|
81
|
-
return 0
|
|
82
|
-
else:
|
|
83
|
-
return -1
|
|
84
|
-
|
|
85
|
-
#温湿度读取 port:连接P端口;command:0:读取湿度;1:读取温度;
|
|
86
|
-
def humiture_operate(port:bytes,command:bytes) -> Optional[bytes]:
|
|
87
|
-
humiture_str=[0xA0, 0x0C, 0x01, 0x71, 0x00, 0xBE]
|
|
88
|
-
humiture_str[0]=0XA0+port
|
|
89
|
-
humiture_str[2]=command
|
|
90
|
-
response = Uart3_funtions.single_operate_sensor(humiture_str)
|
|
91
|
-
if response:
|
|
92
|
-
return 0
|
|
93
|
-
else:
|
|
94
|
-
return -1
|
|
95
|
-
|
|
96
|
-
#超声波读取 port:连接P端口;command:1:读取;
|
|
97
|
-
def ultrasonic_operate(port:bytes,command:bytes) -> Optional[bytes]:
|
|
98
|
-
ultrasonic_str=[0xA0, 0x06, 0x00, 0xBE]
|
|
99
|
-
ultrasonic_str[0]=0XA0+port
|
|
100
|
-
ultrasonic_str[2]=command
|
|
101
|
-
response = Uart3_funtions.single_operate_sensor(ultrasonic_str)
|
|
102
|
-
if response:
|
|
103
|
-
return 0
|
|
104
|
-
else:
|
|
105
|
-
return -1
|
|
106
|
-
|
|
107
|
-
#舵机控制 port:连接P端口;command:
|
|
108
|
-
def servo_operate(port:bytes,command:bytes,angle:bytes) -> Optional[bytes]:
|
|
109
|
-
servo_str=[0xA0, 0x0E, 0x01, 0x71, 0x00, 0xBE]
|
|
110
|
-
servo_str[0]=0XA0+port
|
|
111
|
-
servo_str[2]=command
|
|
112
|
-
servo_str[4]=angle
|
|
113
|
-
response = Uart3_funtions.single_operate_sensor(servo_str)
|
|
114
|
-
if response:
|
|
115
|
-
return 0
|
|
116
|
-
else:
|
|
117
|
-
return -1
|
|
118
|
-
|
|
119
|
-
|