smartpi 0.1.4__py3-none-any.whl → 0.1.5__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 +3 -3
- smartpi/color_sensor.py +4 -4
- smartpi/humidity.py +7 -8
- smartpi/light_sensor.py +2 -26
- smartpi/motor.py +10 -10
- smartpi/servo.py +8 -8
- smartpi/temperature.py +4 -4
- smartpi/touch_sensor.py +3 -3
- smartpi/ultrasonic.py +4 -3
- {smartpi-0.1.4.dist-info → smartpi-0.1.5.dist-info}/METADATA +1 -1
- smartpi-0.1.5.dist-info/RECORD +15 -0
- smartpi-0.1.4.dist-info/RECORD +0 -15
- {smartpi-0.1.4.dist-info → smartpi-0.1.5.dist-info}/WHEEL +0 -0
- {smartpi-0.1.4.dist-info → smartpi-0.1.5.dist-info}/top_level.txt +0 -0
smartpi/__init__.py
CHANGED
smartpi/base_driver.py
CHANGED
|
@@ -450,9 +450,9 @@ def single_operate_sensor(op_struct: bytes) -> Optional[bytes]:
|
|
|
450
450
|
response =process_received_data()
|
|
451
451
|
if response:
|
|
452
452
|
display_data = response[6:-3]
|
|
453
|
-
for x in display_data:
|
|
454
|
-
print(f"{x:02X}", end=' ')
|
|
455
|
-
print("\n")
|
|
453
|
+
# for x in display_data:
|
|
454
|
+
# print(f"{x:02X}", end=' ')
|
|
455
|
+
# print("\n")
|
|
456
456
|
return display_data
|
|
457
457
|
else:
|
|
458
458
|
if time.time() - start_time > 3:
|
smartpi/color_sensor.py
CHANGED
|
@@ -8,10 +8,10 @@ def get_value(port:bytes) -> Optional[bytes]:
|
|
|
8
8
|
color_str=[0xA0, 0x04, 0x00, 0xBE]
|
|
9
9
|
color_str[0]=0XA0+port
|
|
10
10
|
color_str[2]=1
|
|
11
|
-
response = base_driver.single_operate_sensor(color_str)
|
|
12
|
-
if response:
|
|
13
|
-
return response[4]
|
|
14
|
-
else:
|
|
11
|
+
response = base_driver.single_operate_sensor(color_str)
|
|
12
|
+
if response == -1:
|
|
15
13
|
return -1
|
|
14
|
+
else:
|
|
15
|
+
return response[4]
|
|
16
16
|
|
|
17
17
|
|
smartpi/humidity.py
CHANGED
|
@@ -6,15 +6,14 @@ from smartpi import base_driver
|
|
|
6
6
|
|
|
7
7
|
#湿度读取 port:连接P端口;
|
|
8
8
|
def get_value(port:bytes) -> Optional[bytes]:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
response = base_driver.single_operate_sensor(
|
|
13
|
-
if response:
|
|
14
|
-
return response[4]
|
|
15
|
-
else:
|
|
9
|
+
humi_str=[0XA0, 0X0C, 0X01, 0X71, 0X00, 0XBE]
|
|
10
|
+
humi_str[0]=0XA0+port
|
|
11
|
+
humi_str[4]=0X01
|
|
12
|
+
response = base_driver.single_operate_sensor(humi_str)
|
|
13
|
+
if response == -1:
|
|
16
14
|
return -1
|
|
17
|
-
|
|
15
|
+
else:
|
|
16
|
+
return response[4]
|
|
18
17
|
|
|
19
18
|
|
|
20
19
|
|
smartpi/light_sensor.py
CHANGED
|
@@ -8,35 +8,11 @@ def get_value(port:bytes) -> Optional[bytes]:
|
|
|
8
8
|
light_str=[0xA0, 0x02, 0x00, 0xBE]
|
|
9
9
|
light_str[0]=0XA0+port
|
|
10
10
|
light_str[2]=1
|
|
11
|
-
response = base_driver.single_operate_sensor(light_str)
|
|
12
|
-
if response:
|
|
13
|
-
light_data=response[4:-1]
|
|
14
|
-
light_num=int.from_bytes(light_data, byteorder='big', signed=True)
|
|
15
|
-
return light_num
|
|
16
|
-
else:
|
|
11
|
+
response = base_driver.single_operate_sensor(light_str)
|
|
12
|
+
if response == -1:
|
|
17
13
|
return -1
|
|
18
|
-
|
|
19
|
-
def light_on(port:bytes) -> Optional[bytes]:
|
|
20
|
-
light_str=[0xA0, 0x02, 0x00, 0xBE]
|
|
21
|
-
light_str[0]=0XA0+port
|
|
22
|
-
light_str[2]=2
|
|
23
|
-
response = base_driver.single_operate_sensor(light_str)
|
|
24
|
-
if response:
|
|
25
|
-
light_data=response[4:-1]
|
|
26
|
-
light_num=int.from_bytes(light_data, byteorder='big', signed=True)
|
|
27
|
-
return light_num
|
|
28
14
|
else:
|
|
29
|
-
return -1
|
|
30
|
-
|
|
31
|
-
def light_off(port:bytes) -> Optional[bytes]:
|
|
32
|
-
light_str=[0xA0, 0x02, 0x00, 0xBE]
|
|
33
|
-
light_str[0]=0XA0+port
|
|
34
|
-
light_str[2]=3
|
|
35
|
-
response = base_driver.single_operate_sensor(light_str)
|
|
36
|
-
if response:
|
|
37
15
|
light_data=response[4:-1]
|
|
38
16
|
light_num=int.from_bytes(light_data, byteorder='big', signed=True)
|
|
39
17
|
return light_num
|
|
40
|
-
else:
|
|
41
|
-
return -1
|
|
42
18
|
|
smartpi/motor.py
CHANGED
|
@@ -8,13 +8,13 @@ from smartpi import base_driver
|
|
|
8
8
|
def get_motor_encoder(port:bytes) -> Optional[bytes]:
|
|
9
9
|
motor_str=[0xA0, 0x01, 0x01, 0xBE]
|
|
10
10
|
motor_str[0]=0XA0+port
|
|
11
|
-
response = base_driver.single_operate_sensor(motor_str)
|
|
12
|
-
if response:
|
|
11
|
+
response = base_driver.single_operate_sensor(motor_str)
|
|
12
|
+
if response == -1:
|
|
13
|
+
return -1
|
|
14
|
+
else:
|
|
13
15
|
code_data=response[4:-1]
|
|
14
16
|
code_num=int.from_bytes(code_data, byteorder='big', signed=True)
|
|
15
17
|
return code_num
|
|
16
|
-
else:
|
|
17
|
-
return -1
|
|
18
18
|
|
|
19
19
|
#����������� port:����M�˿ڣ�
|
|
20
20
|
def reset_motor_encoder(port:bytes) -> Optional[bytes]:
|
|
@@ -135,17 +135,17 @@ def set_motor_constspeed(port:bytes,speed:int) -> Optional[bytes]:
|
|
|
135
135
|
else:
|
|
136
136
|
return -1
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
#�����ٶȶ�ȡ port:����M�˿ڣ�
|
|
139
139
|
def get_motor_speed(port:bytes) -> Optional[bytes]:
|
|
140
140
|
motor_str=[0xA0, 0x01, 0x10, 0xBE]
|
|
141
141
|
motor_str[0]=0XA0+port
|
|
142
|
-
response = base_driver.single_operate_sensor(motor_str)
|
|
143
|
-
if response:
|
|
142
|
+
response = base_driver.single_operate_sensor(motor_str)
|
|
143
|
+
if response == -1:
|
|
144
|
+
return -1
|
|
145
|
+
else:
|
|
144
146
|
code_data=response[4:-1]
|
|
145
147
|
code_num=int.from_bytes(code_data, byteorder='big', signed=True)
|
|
146
|
-
return code_num
|
|
147
|
-
else:
|
|
148
|
-
return -1
|
|
148
|
+
return code_num
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
|
smartpi/servo.py
CHANGED
|
@@ -69,13 +69,13 @@ def set_init(port:bytes) -> Optional[bytes]:
|
|
|
69
69
|
def get_angle(port:bytes) -> Optional[bytes]:
|
|
70
70
|
servo_str=[0xA0, 0x13, 0x01, 0xBE]
|
|
71
71
|
servo_str[0]=0XA0+port
|
|
72
|
-
response = base_driver.single_operate_sensor(servo_str)
|
|
73
|
-
if response:
|
|
72
|
+
response = base_driver.single_operate_sensor(servo_str)
|
|
73
|
+
if response == -1:
|
|
74
|
+
return -1
|
|
75
|
+
else:
|
|
74
76
|
angle_data=response[4:-1]
|
|
75
77
|
angle_num=int.from_bytes(angle_data, byteorder='big', signed=True)
|
|
76
78
|
return angle_num
|
|
77
|
-
else:
|
|
78
|
-
return -1
|
|
79
79
|
|
|
80
80
|
#���ֶ���ٶ�ת�� port:����P�˿ڣ�
|
|
81
81
|
def set_speed(port:bytes,speed:int) -> Optional[bytes]:
|
|
@@ -135,13 +135,13 @@ def reset_encode(port:bytes) -> Optional[bytes]:
|
|
|
135
135
|
def get_encoder(port:bytes) -> Optional[bytes]:
|
|
136
136
|
servo_str=[0xA0, 0x17, 0x01, 0xBE]
|
|
137
137
|
servo_str[0]=0XA0+port
|
|
138
|
-
response = base_driver.single_operate_sensor(servo_str)
|
|
139
|
-
if response:
|
|
138
|
+
response = base_driver.single_operate_sensor(servo_str)
|
|
139
|
+
if response == -1:
|
|
140
|
+
return -1
|
|
141
|
+
else:
|
|
140
142
|
code_data=response[4:-1]
|
|
141
143
|
code_num=int.from_bytes(code_data, byteorder='big', signed=True)
|
|
142
144
|
return code_num
|
|
143
|
-
else:
|
|
144
|
-
return -1
|
|
145
145
|
|
|
146
146
|
|
|
147
147
|
|
smartpi/temperature.py
CHANGED
|
@@ -6,12 +6,12 @@ from smartpi import base_driver
|
|
|
6
6
|
|
|
7
7
|
#�¶ȶ�ȡ port:����P�˿ڣ�
|
|
8
8
|
def get_value(port:bytes) -> Optional[bytes]:
|
|
9
|
-
temp_str=[
|
|
9
|
+
temp_str=[0XA0, 0X0C, 0X01, 0X71, 0X00, 0XBE]
|
|
10
10
|
temp_str[0]=0XA0+port
|
|
11
11
|
temp_str[4]=0
|
|
12
12
|
response = base_driver.single_operate_sensor(temp_str)
|
|
13
|
-
if response:
|
|
14
|
-
return response[4]
|
|
15
|
-
else:
|
|
13
|
+
if response == -1:
|
|
16
14
|
return -1
|
|
15
|
+
else:
|
|
16
|
+
return response[4]
|
|
17
17
|
|
smartpi/touch_sensor.py
CHANGED
|
@@ -8,8 +8,8 @@ def get_value(port:bytes) -> Optional[bytes]:
|
|
|
8
8
|
read_sw_str=[0xA0, 0x03, 0x01, 0xBE]
|
|
9
9
|
read_sw_str[0]=0XA0+port
|
|
10
10
|
response = base_driver.single_operate_sensor(read_sw_str)
|
|
11
|
-
if response:
|
|
12
|
-
return response[4]
|
|
13
|
-
else:
|
|
11
|
+
if response == -1:
|
|
14
12
|
return -1
|
|
13
|
+
else:
|
|
14
|
+
return response[4]
|
|
15
15
|
|
smartpi/ultrasonic.py
CHANGED
|
@@ -9,10 +9,11 @@ def get_value(port:bytes) -> Optional[bytes]:
|
|
|
9
9
|
ultrasonic_str[0]=0XA0+port
|
|
10
10
|
ultrasonic_str[2]=1
|
|
11
11
|
response = base_driver.single_operate_sensor(ultrasonic_str)
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
if response == -1:
|
|
14
|
+
return -1
|
|
15
|
+
else:
|
|
13
16
|
distance_data=response[4:-1]
|
|
14
17
|
distance_num=int.from_bytes(distance_data, byteorder='big', signed=True)
|
|
15
18
|
return distance_num
|
|
16
|
-
else:
|
|
17
|
-
return -1
|
|
18
19
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
smartpi/__init__.py,sha256=YiOQYNSL9JyXp6tMC2Qk7gNu5e8xpCGFFzmLdnoVEG4,54
|
|
2
|
+
smartpi/base_driver.py,sha256=LNdUw4LyMuUTZyw8PGj0fw6sPc6qYDX_yT23KfqyoDA,17444
|
|
3
|
+
smartpi/color_sensor.py,sha256=q6NcaE8lXbU4BXEeiWYVoJH-X3ot4Sb_u_0vpiJy6Ho,460
|
|
4
|
+
smartpi/humidity.py,sha256=06NEK1KyH1ZC5QOuWoXxBkVAp39wRmt-27ntOIjw1jc,447
|
|
5
|
+
smartpi/led.py,sha256=f8K7ebHFy9kIlCLWKEyQbmPQv4z2TMTNGs1vaKOtMAs,495
|
|
6
|
+
smartpi/light_sensor.py,sha256=KjIXoEQKmvTk7qQ8GIl0ZUXaPw_vVsB8qCXk5Fiw-4g,511
|
|
7
|
+
smartpi/motor.py,sha256=ePBKQu7FSrqjnM-d1kDcT1nYMLpnLeALJ0agI2dznoQ,4447
|
|
8
|
+
smartpi/servo.py,sha256=n6T_3F9WsZYatogg8hnhvSlXvJaSg2zc5wjuTD_qyqI,4519
|
|
9
|
+
smartpi/temperature.py,sha256=5-T8LYZXhqwdtYFZLvuDcMtA89PyEzSZkK-RghFZLgQ,424
|
|
10
|
+
smartpi/touch_sensor.py,sha256=R7LRPvhEeLGzXkujp2_Jb3D4Hb0y0HVRbcfIZ3ptMak,402
|
|
11
|
+
smartpi/ultrasonic.py,sha256=Xu4EqeFWadsepyRCOdJIXl3Uu-Y8_9pkw3EWsRXWyAs,555
|
|
12
|
+
smartpi-0.1.5.dist-info/METADATA,sha256=5B1ruRb_8L9s_Pq7s-zJrhye8PgYn2gN-uU68DgZi3k,310
|
|
13
|
+
smartpi-0.1.5.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
14
|
+
smartpi-0.1.5.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
|
|
15
|
+
smartpi-0.1.5.dist-info/RECORD,,
|
smartpi-0.1.4.dist-info/RECORD
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
smartpi/__init__.py,sha256=Pavr-N-hqEpqeTD1ck9SZw9vGtn_Ju7cbQF81qkkDxg,54
|
|
2
|
-
smartpi/base_driver.py,sha256=xnAfn8PjaJUhlFLxKRXDbtKY5nmp_yiDGtx4lyHEp9U,17441
|
|
3
|
-
smartpi/color_sensor.py,sha256=HJAUGO8CPaoodgLwgzx_LVdvf0MoG63fg91-Y5Qp3fk,446
|
|
4
|
-
smartpi/humidity.py,sha256=Y8vLrK8FD5hdR_KshQxka2ygfJcCbuWs48gGr7zBqu4,456
|
|
5
|
-
smartpi/led.py,sha256=f8K7ebHFy9kIlCLWKEyQbmPQv4z2TMTNGs1vaKOtMAs,495
|
|
6
|
-
smartpi/light_sensor.py,sha256=QdY5jB_yg0mh3r7eUBsULqAEmQgaQgaUQHnKR0z3FAs,1279
|
|
7
|
-
smartpi/motor.py,sha256=igk9OFJjsS4nq16Sfl8s1ok8qolALreTFWXUeuDmHi4,4424
|
|
8
|
-
smartpi/servo.py,sha256=NFaoiDPdgs6wUklNWhL175CHIF0dJSRNDyOYRfum1xM,4492
|
|
9
|
-
smartpi/temperature.py,sha256=FUSoR7FeLZ4a_xj7ej60jXqXbX1frUTz3wDXzSTkob8,418
|
|
10
|
-
smartpi/touch_sensor.py,sha256=Y491KYiQBljX3IAvldld3Z8nXkBOAqqx7cTXda3Y-tA,396
|
|
11
|
-
smartpi/ultrasonic.py,sha256=lGPJRxDZN_uIIxqFMUa715miuN7ZXoKJ9npD03dyuXU,539
|
|
12
|
-
smartpi-0.1.4.dist-info/METADATA,sha256=fevHCCy6ZRYLCt1tl8cHMi-eIC8WHRIMc768xVPaIzo,310
|
|
13
|
-
smartpi-0.1.4.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
14
|
-
smartpi-0.1.4.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
|
|
15
|
-
smartpi-0.1.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|