smartpi 0.1.8__py3-none-any.whl → 0.1.9__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 +6 -6
- smartpi/move.py +24 -42
- {smartpi-0.1.8.dist-info → smartpi-0.1.9.dist-info}/METADATA +1 -1
- {smartpi-0.1.8.dist-info → smartpi-0.1.9.dist-info}/RECORD +7 -7
- {smartpi-0.1.8.dist-info → smartpi-0.1.9.dist-info}/WHEEL +0 -0
- {smartpi-0.1.8.dist-info → smartpi-0.1.9.dist-info}/top_level.txt +0 -0
smartpi/__init__.py
CHANGED
smartpi/base_driver.py
CHANGED
|
@@ -423,9 +423,9 @@ def read_peripheral() -> Optional[bytes]:
|
|
|
423
423
|
response =process_received_data()
|
|
424
424
|
if response:
|
|
425
425
|
display_data = response[6:-3]
|
|
426
|
-
for x in display_data:
|
|
427
|
-
print(f"{x:02X}", end=' ')
|
|
428
|
-
print("\n")
|
|
426
|
+
# for x in display_data:
|
|
427
|
+
# print(f"{x:02X}", end=' ')
|
|
428
|
+
# print("\n")
|
|
429
429
|
return display_data
|
|
430
430
|
else:
|
|
431
431
|
if time.time() - start_time > 3:
|
|
@@ -441,9 +441,9 @@ def single_operate_sensor(op_struct: bytes) -> Optional[bytes]:
|
|
|
441
441
|
response =process_received_data()
|
|
442
442
|
if response:
|
|
443
443
|
display_data = response[6:-3]
|
|
444
|
-
for x in display_data:
|
|
445
|
-
print(f"{x:02X}", end=' ')
|
|
446
|
-
print("\n")
|
|
444
|
+
# for x in display_data:
|
|
445
|
+
# print(f"{x:02X}", end=' ')
|
|
446
|
+
# print("\n")
|
|
447
447
|
return display_data
|
|
448
448
|
else:
|
|
449
449
|
if time.time() - start_time > 3:
|
smartpi/move.py
CHANGED
|
@@ -5,28 +5,19 @@ from smartpi import base_driver
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
#以速度移动x秒 dir:方向forward、backward、turnright、turnleft ; speed:0~100; second:x秒
|
|
8
|
-
def run_second(dir:bytes,speed:
|
|
8
|
+
def run_second(dir:bytes,speed:bytes,second:bytes) -> Optional[bytes]:
|
|
9
9
|
move_str=[0xA0, 0x01, 0x11, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0xBE]
|
|
10
10
|
|
|
11
11
|
if dir=="forward":
|
|
12
12
|
move_str[4]=0x01
|
|
13
13
|
elif dir=="backward":
|
|
14
14
|
move_str[4]=0x02
|
|
15
|
-
elif dir=="turnleft":
|
|
16
|
-
move_str[4]=0x03
|
|
17
15
|
elif dir=="turnright":
|
|
16
|
+
move_str[4]=0x03
|
|
17
|
+
elif dir=="turnleft":
|
|
18
18
|
move_str[4]=0x04
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
m_par=100
|
|
22
|
-
elif speed>=0 and speed<=100:
|
|
23
|
-
m_par=speed
|
|
24
|
-
elif speed<-100:
|
|
25
|
-
m_par=156
|
|
26
|
-
elif speed<=0 and speed>=-100:
|
|
27
|
-
m_par=256+speed
|
|
28
|
-
|
|
29
|
-
move_str[6]=m_par
|
|
19
|
+
|
|
20
|
+
move_str[6]=speed
|
|
30
21
|
move_str[8]=second
|
|
31
22
|
|
|
32
23
|
response = base_driver.single_operate_sensor(move_str)
|
|
@@ -36,7 +27,7 @@ def run_second(dir:bytes,speed:int,second:bytes) -> Optional[bytes]:
|
|
|
36
27
|
return 0
|
|
37
28
|
|
|
38
29
|
#以速度移动x度(编码) dir:方向forward、backward、turnright、turnleft; speed:0~100; angle:x角度
|
|
39
|
-
def run_angle(dir:bytes,speed:bytes,angle:
|
|
30
|
+
def run_angle(dir:bytes,speed:bytes,angle:int) -> Optional[bytes]:
|
|
40
31
|
move_str=[0xA0, 0x01, 0x12, 0x71, 0x00, 0x71, 0x00, 0x81, 0x00, 0x00, 0xBE]
|
|
41
32
|
|
|
42
33
|
if dir=="forward":
|
|
@@ -47,17 +38,8 @@ def run_angle(dir:bytes,speed:bytes,angle:bytes) -> Optional[bytes]:
|
|
|
47
38
|
move_str[4]=0x03
|
|
48
39
|
elif dir=="turnleft":
|
|
49
40
|
move_str[4]=0x04
|
|
50
|
-
|
|
51
|
-
if speed>100:
|
|
52
|
-
m_par=100
|
|
53
|
-
elif speed>=0 and speed<=100:
|
|
54
|
-
m_par=speed
|
|
55
|
-
elif speed<-100:
|
|
56
|
-
m_par=156
|
|
57
|
-
elif speed<=0 and speed>=-100:
|
|
58
|
-
m_par=256+speed
|
|
59
41
|
|
|
60
|
-
move_str[6]=
|
|
42
|
+
move_str[6]=speed
|
|
61
43
|
move_str[8]=angle//256
|
|
62
44
|
move_str[9]=angle%256
|
|
63
45
|
|
|
@@ -110,7 +92,7 @@ def run_speed_second(Lspeed:int,Rspeed:int,second:bytes) -> Optional[bytes]:
|
|
|
110
92
|
elif Lspeed<=0 and Lspeed>=-100:
|
|
111
93
|
m_par=256+Lspeed
|
|
112
94
|
|
|
113
|
-
move_str[
|
|
95
|
+
move_str[6]=m_par
|
|
114
96
|
|
|
115
97
|
if Rspeed>100:
|
|
116
98
|
m_par=100
|
|
@@ -121,7 +103,7 @@ def run_speed_second(Lspeed:int,Rspeed:int,second:bytes) -> Optional[bytes]:
|
|
|
121
103
|
elif Rspeed<=0 and Rspeed>=-100:
|
|
122
104
|
m_par=256+Rspeed
|
|
123
105
|
|
|
124
|
-
move_str[
|
|
106
|
+
move_str[4]=m_par
|
|
125
107
|
|
|
126
108
|
move_str[8]=second
|
|
127
109
|
|
|
@@ -133,7 +115,7 @@ def run_speed_second(Lspeed:int,Rspeed:int,second:bytes) -> Optional[bytes]:
|
|
|
133
115
|
|
|
134
116
|
#设置左右轮速度移动 Lspeed:-100~100; Rspeed:-100~100;
|
|
135
117
|
def run_speed(Lspeed:int,Rspeed:int) -> Optional[bytes]:
|
|
136
|
-
move_str=[0xA0, 0x01,
|
|
118
|
+
move_str=[0xA0, 0x01, 0x15, 0x71, 0x00, 0x71, 0x00, 0xBE]
|
|
137
119
|
|
|
138
120
|
if Lspeed>100:
|
|
139
121
|
m_par=100
|
|
@@ -144,7 +126,7 @@ def run_speed(Lspeed:int,Rspeed:int) -> Optional[bytes]:
|
|
|
144
126
|
elif Lspeed<=0 and Lspeed>=-100:
|
|
145
127
|
m_par=256+Lspeed
|
|
146
128
|
|
|
147
|
-
move_str[
|
|
129
|
+
move_str[6]=m_par
|
|
148
130
|
|
|
149
131
|
if Rspeed>100:
|
|
150
132
|
m_par=100
|
|
@@ -155,7 +137,7 @@ def run_speed(Lspeed:int,Rspeed:int) -> Optional[bytes]:
|
|
|
155
137
|
elif Rspeed<=0 and Rspeed>=-100:
|
|
156
138
|
m_par=256+Rspeed
|
|
157
139
|
|
|
158
|
-
move_str[
|
|
140
|
+
move_str[4]=m_par
|
|
159
141
|
|
|
160
142
|
response = base_driver.single_operate_sensor(move_str)
|
|
161
143
|
if response == -1:
|
|
@@ -163,12 +145,12 @@ def run_speed(Lspeed:int,Rspeed:int) -> Optional[bytes]:
|
|
|
163
145
|
else:
|
|
164
146
|
return 0
|
|
165
147
|
|
|
166
|
-
#设置左右轮功率移动
|
|
148
|
+
#设置左右轮功率移动 Lpower:0~100; Rpower:0~100;
|
|
167
149
|
def run_power(Lpower:bytes,Rpower:bytes) -> Optional[bytes]:
|
|
168
150
|
move_str=[0xA0, 0x01, 0x17, 0x71, 0x00, 0x71, 0x00, 0xBE]
|
|
169
151
|
|
|
170
|
-
move_str[4]=
|
|
171
|
-
move_str[6]=
|
|
152
|
+
move_str[4]=Rpower
|
|
153
|
+
move_str[6]=Lpower
|
|
172
154
|
|
|
173
155
|
response = base_driver.single_operate_sensor(move_str)
|
|
174
156
|
if response == -1:
|
|
@@ -176,7 +158,7 @@ def run_power(Lpower:bytes,Rpower:bytes) -> Optional[bytes]:
|
|
|
176
158
|
else:
|
|
177
159
|
return 0
|
|
178
160
|
|
|
179
|
-
#设置最大功率
|
|
161
|
+
#设置最大功率
|
|
180
162
|
def set_maxpower(M1:bytes,M2:bytes,M3:bytes,M4:bytes,M5:bytes,M6:bytes) -> Optional[bytes]:
|
|
181
163
|
move_str=[0xA0, 0x01, 0x18, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0xBE]
|
|
182
164
|
|
|
@@ -206,18 +188,18 @@ def stop() -> Optional[bytes]:
|
|
|
206
188
|
#设置左右轮方向 Lmotor:1~6; Rmotor:1~6; state: no_reversal、all_reversal、left_reversal、right_reversal
|
|
207
189
|
def set_move_init(Lmotor:bytes,Rmotor:bytes,state:bytes) -> Optional[bytes]:
|
|
208
190
|
move_str=[0xA0, 0x01, 0x19, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0xBE]
|
|
209
|
-
|
|
210
|
-
move_str[4]=Lmotor
|
|
211
|
-
move_str[6]=Rmotor
|
|
212
|
-
|
|
191
|
+
|
|
213
192
|
if state=="no_reversal":
|
|
214
|
-
move_str[
|
|
193
|
+
move_str[4]=0x01
|
|
215
194
|
elif state=="all_reversal":
|
|
216
|
-
move_str[
|
|
195
|
+
move_str[4]=0x02
|
|
217
196
|
elif state=="left_reversal":
|
|
218
|
-
move_str[
|
|
197
|
+
move_str[4]=0x03
|
|
219
198
|
elif state=="right_reversal":
|
|
220
|
-
move_str[
|
|
199
|
+
move_str[4]=0x04
|
|
200
|
+
|
|
201
|
+
move_str[6]=Rmotor
|
|
202
|
+
move_str[8]=Lmotor
|
|
221
203
|
|
|
222
204
|
response = base_driver.single_operate_sensor(move_str)
|
|
223
205
|
if response == -1:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
smartpi/__init__.py,sha256=
|
|
2
|
-
smartpi/base_driver.py,sha256=
|
|
1
|
+
smartpi/__init__.py,sha256=1GIYn_KvjJ8KECZ8TW56CcZUERF5WVdQ-QM6gyofxlw,54
|
|
2
|
+
smartpi/base_driver.py,sha256=nfvzjcVZGrRldtAeAtL4MDlEMh4qbF28gbrf1-71N0c,17994
|
|
3
3
|
smartpi/color_sensor.py,sha256=IubJb8zd87oWf3qTn07wTHM2vjUADwgSdXUChGgovHw,492
|
|
4
4
|
smartpi/cw2015.py,sha256=1lAF-pi_ye_ya1AZQS1sjbgsDf7MThO5IAskKsNGBzA,5695
|
|
5
5
|
smartpi/gui.py,sha256=E98_soyWbEf_dwYhXZgMSXrgY5QuYoDTuFCPK63flIQ,2102
|
|
@@ -7,12 +7,12 @@ smartpi/humidity.py,sha256=-awlSiy7ea6iwtirUMdDAMmmdIgVQZ3D7cDzgXmy314,493
|
|
|
7
7
|
smartpi/led.py,sha256=92SBKjQbg1HN6rtKRH1NNWvAFRBP2-5OUGM9muOvhyQ,526
|
|
8
8
|
smartpi/light_sensor.py,sha256=wsW0_ZnKeHN6IWRH3CIybKLdHPVK2I8jSTCqXlUECVk,565
|
|
9
9
|
smartpi/motor.py,sha256=vdtLjHSwCodFkqhYh0y3l8RSl7IUlMwdNuktgQ3FdkQ,4449
|
|
10
|
-
smartpi/move.py,sha256=
|
|
10
|
+
smartpi/move.py,sha256=MUu1Hnu77gebTJLjnYq27mLYrjvBvDh9a6TWJ-GXgLk,6155
|
|
11
11
|
smartpi/servo.py,sha256=_eM3ZAcBA543iVyFi8agOAXt0K3LEauxwyq7SFCpygM,4537
|
|
12
12
|
smartpi/temperature.py,sha256=JeuiwsV6AUjnFQsQxgvjM3AuBrVvK5DuSE-BbX1Di2s,456
|
|
13
13
|
smartpi/touch_sensor.py,sha256=jlKqvcoSmfZzH9zJeafBeVEQhxIYkkzXe4_fifX0COI,434
|
|
14
14
|
smartpi/ultrasonic.py,sha256=5MS0EdQNirAl8iZbdwZ63fnjp6axHRZHw6dJwcwuXnQ,618
|
|
15
|
-
smartpi-0.1.
|
|
16
|
-
smartpi-0.1.
|
|
17
|
-
smartpi-0.1.
|
|
18
|
-
smartpi-0.1.
|
|
15
|
+
smartpi-0.1.9.dist-info/METADATA,sha256=7JJLk0Uol-2FcoiVBjYyqYhCIuKfilRYAxSuwEv4fKc,310
|
|
16
|
+
smartpi-0.1.9.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
17
|
+
smartpi-0.1.9.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
|
|
18
|
+
smartpi-0.1.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|