smartpi 0.1.7__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 CHANGED
@@ -1,4 +1,4 @@
1
1
  __all__ = ["base_driver"]
2
2
 
3
- __version__ = "0.1.7"
3
+ __version__ = "0.1.9"
4
4
 
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:
@@ -506,6 +506,18 @@ def smartpi_init():
506
506
  P_port_init(4)
507
507
  P_port_init(5)
508
508
  P_port_init(6)
509
+ servo.set_init(1)
510
+ servo.set_init(2)
511
+ servo.set_init(3)
512
+ servo.set_init(4)
513
+ servo.set_init(5)
514
+ servo.set_init(6)
515
+ motor.set_motor(1,0)
516
+ motor.set_motor(2,0)
517
+ motor.set_motor(3,0)
518
+ motor.set_motor(4,0)
519
+ motor.set_motor(5,0)
520
+ motor.set_motor(6,0)
509
521
  servo.reset_encode(1)
510
522
  servo.reset_encode(2)
511
523
  servo.reset_encode(3)
@@ -518,12 +530,7 @@ def smartpi_init():
518
530
  motor.reset_motor_encoder(4)
519
531
  motor.reset_motor_encoder(5)
520
532
  motor.reset_motor_encoder(6)
521
- motor.set_motor(1,0)
522
- motor.set_motor(2,0)
523
- motor.set_motor(3,0)
524
- motor.set_motor(4,0)
525
- motor.set_motor(5,0)
526
- motor.set_motor(6,0)
533
+ time.sleep(0.1)
527
534
  gui.init()
528
-
535
+ time.sleep(0.1)
529
536
 
smartpi/motor.py CHANGED
@@ -68,7 +68,7 @@ def set_motor_stop(port:bytes) -> Optional[bytes]:
68
68
  else:
69
69
  return -1
70
70
 
71
- #���������� port:����M�˿ڣ�speed:-100~100��code:0~65535
71
+ #����Ƕȿ��� port:����M�˿ڣ�speed:-100~100��degree:0~65535
72
72
  def set_motor_angle(port:bytes,speed:int,degree:int) -> Optional[bytes]:
73
73
  motor_str=[0xA0, 0x01, 0x04, 0x81, 0x00, 0x81, 0x00, 0x00, 0xBE]
74
74
  motor_str[0]=0XA0+port
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:int,second:bytes) -> Optional[bytes]:
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
- if speed>100:
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:bytes) -> Optional[bytes]:
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]=m_par
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[4]=m_par
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[6]=m_par
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, 0x14, 0x71, 0x00, 0x71, 0x00, 0xBE]
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[4]=m_par
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[6]=m_par
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
- #设置左右轮功率移动 Lspeed:0~100; Rspeed:0~100;
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]=Lpower
171
- move_str[6]=Rpower
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
- #设置最大功率 Lspeed:0~100; Rspeed:0~100;
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[8]=0x01
193
+ move_str[4]=0x01
215
194
  elif state=="all_reversal":
216
- move_str[8]=0x02
195
+ move_str[4]=0x02
217
196
  elif state=="left_reversal":
218
- move_str[8]=0x03
197
+ move_str[4]=0x03
219
198
  elif state=="right_reversal":
220
- move_str[8]=0x04
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:
smartpi/servo.py CHANGED
@@ -28,7 +28,7 @@ def steer_angle_delay(port:bytes,angle:bytes,second:bytes) -> Optional[bytes]:
28
28
  else:
29
29
  return -1
30
30
 
31
- #BE-9528������ٶ�ת���Ƕ� port:����P�˿ڣ�angle:�Ƕ�(0~360)��speed:�ٶ�(0~100)��
31
+ #BE-9528���ֶ�����ٶ�ת���Ƕ� port:����P�˿ڣ�angle:�Ƕ�(0~360)��speed:�ٶ�(0~100)��
32
32
  def set_angle_speed(port:bytes,angle:bytes,speed:bytes) -> Optional[bytes]:
33
33
  servo_str=[0xA0, 0x0D, 0x01, 0x81, 0x00, 0x00, 0x81, 0x00, 0xBE]
34
34
  servo_str[0]=0XA0+port
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smartpi
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: A library use for H2-RCU
5
5
  Author: ZMROBO
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,18 +1,18 @@
1
- smartpi/__init__.py,sha256=ZclPhHYYgwOoiYzyCuuqxUl5A8ir-wB2ebte9HfOlrg,54
2
- smartpi/base_driver.py,sha256=yysHuSxu15IXnupiNLzMFk5OLs8BhLBgMeBTKgNRxw0,17816
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
6
6
  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
- smartpi/motor.py,sha256=ePBKQu7FSrqjnM-d1kDcT1nYMLpnLeALJ0agI2dznoQ,4447
10
- smartpi/move.py,sha256=1LpNlveTJLnObyD4nzbHIC0rlkPuPUwPtnF3sgr1t6g,6599
11
- smartpi/servo.py,sha256=3cGyBattPY0nXQvJl3b462VGyyzca7S33X_9xIp2tUQ,4533
9
+ smartpi/motor.py,sha256=vdtLjHSwCodFkqhYh0y3l8RSl7IUlMwdNuktgQ3FdkQ,4449
10
+ smartpi/move.py,sha256=MUu1Hnu77gebTJLjnYq27mLYrjvBvDh9a6TWJ-GXgLk,6155
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.7.dist-info/METADATA,sha256=DJ35EI43vY45QcQAAjRCxTZr_ZLC9kiz3TutBikygbs,310
16
- smartpi-0.1.7.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
17
- smartpi-0.1.7.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
18
- smartpi-0.1.7.dist-info/RECORD,,
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,,