smartpi 0.1.8__py3-none-any.whl → 0.1.10__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.8"
3
+ __version__ = "0.1.10"
4
4
 
smartpi/base_driver.py CHANGED
@@ -55,7 +55,7 @@ MIN_FRAME_LEN = 9 # 最小帧长度
55
55
 
56
56
  # 串口配置参数
57
57
  SERIAL_PORT = "/dev/ttyS3" # 串口设备路径
58
- BAUD_RATE = 115200 # 波特率
58
+ BAUD_RATE = 921600 # 波特率
59
59
  TIMEOUT = 0.1 # 读取超时时间(秒)
60
60
 
61
61
  ser = serial.Serial(
@@ -75,7 +75,7 @@ def uart3_init() -> Optional[serial.Serial]:
75
75
  """初始化串口"""
76
76
  try:
77
77
  if ser.is_open:
78
- print("UART3初始化成功")
78
+ # print("UART3初始化成功")
79
79
  return ser
80
80
  else:
81
81
  print("Error opening UART3")
@@ -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
@@ -4,29 +4,20 @@ from typing import List, Optional
4
4
  from smartpi import base_driver
5
5
 
6
6
 
7
- #以速度移动xdir:方向forward、backward、turnright、turnleft ; speed:0~100; second:x秒
8
- def run_second(dir:bytes,speed:int,second:bytes) -> Optional[bytes]:
7
+ #以速度移动x秒:dir:方向forward、backward、turnright、turnleftspeed:0~100;second:x秒
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)
@@ -35,8 +26,8 @@ def run_second(dir:bytes,speed:int,second:bytes) -> Optional[bytes]:
35
26
  else:
36
27
  return 0
37
28
 
38
- #以速度移动x度(编码) dir:方向forward、backward、turnright、turnleftspeed:0~100angle:x角度
39
- def run_angle(dir:bytes,speed:bytes,angle:bytes) -> Optional[bytes]:
29
+ #以速度移动x度:dir:方向forward、backward、turnright、turnleftspeed:0~100angle:65535
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
 
@@ -67,8 +49,8 @@ def run_angle(dir:bytes,speed:bytes,angle:bytes) -> Optional[bytes]:
67
49
  else:
68
50
  return 0
69
51
 
70
- #以速度移动 dir:方向forward、backward、turnright、turnleft ; speed:0~100;
71
- def run(dir:bytes,speed:int) -> Optional[bytes]:
52
+ #以速度移动:dir:方向forward、backward、turnright、turnleftspeed:0~100;
53
+ def run(dir:bytes,speed:bytes) -> Optional[bytes]:
72
54
  move_str=[0xA0, 0x01, 0x13, 0x71, 0x00, 0x71, 0x00, 0xBE]
73
55
 
74
56
  if dir=="forward":
@@ -79,17 +61,8 @@ def run(dir:bytes,speed:int) -> Optional[bytes]:
79
61
  move_str[4]=0x03
80
62
  elif dir=="turnleft":
81
63
  move_str[4]=0x04
82
-
83
- if speed>100:
84
- m_par=100
85
- elif speed>=0 and speed<=100:
86
- m_par=speed
87
- elif speed<-100:
88
- m_par=156
89
- elif speed<=0 and speed>=-100:
90
- m_par=256+speed
91
64
 
92
- move_str[6]=m_par
65
+ move_str[6]=speed
93
66
 
94
67
  response = base_driver.single_operate_sensor(move_str)
95
68
  if response == -1:
@@ -97,7 +70,7 @@ def run(dir:bytes,speed:int) -> Optional[bytes]:
97
70
  else:
98
71
  return 0
99
72
 
100
- #设置左右轮速度移动xLspeed:-100~100; Rspeed:-100~100; second:x秒
73
+ #设置左右轮速度移动x秒:Lspeed:-100~100;Rspeed:-100~100;second:1~255
101
74
  def run_speed_second(Lspeed:int,Rspeed:int,second:bytes) -> Optional[bytes]:
102
75
  move_str=[0xA0, 0x01, 0x14, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0xBE]
103
76
 
@@ -110,7 +83,7 @@ def run_speed_second(Lspeed:int,Rspeed:int,second:bytes) -> Optional[bytes]:
110
83
  elif Lspeed<=0 and Lspeed>=-100:
111
84
  m_par=256+Lspeed
112
85
 
113
- move_str[4]=m_par
86
+ move_str[6]=m_par
114
87
 
115
88
  if Rspeed>100:
116
89
  m_par=100
@@ -121,7 +94,7 @@ def run_speed_second(Lspeed:int,Rspeed:int,second:bytes) -> Optional[bytes]:
121
94
  elif Rspeed<=0 and Rspeed>=-100:
122
95
  m_par=256+Rspeed
123
96
 
124
- move_str[6]=m_par
97
+ move_str[4]=m_par
125
98
 
126
99
  move_str[8]=second
127
100
 
@@ -131,9 +104,9 @@ def run_speed_second(Lspeed:int,Rspeed:int,second:bytes) -> Optional[bytes]:
131
104
  else:
132
105
  return 0
133
106
 
134
- #设置左右轮速度移动 Lspeed:-100~100; Rspeed:-100~100;
107
+ #设置左右轮速度移动:Lspeed:-100~100;Rspeed:-100~100;
135
108
  def run_speed(Lspeed:int,Rspeed:int) -> Optional[bytes]:
136
- move_str=[0xA0, 0x01, 0x14, 0x71, 0x00, 0x71, 0x00, 0xBE]
109
+ move_str=[0xA0, 0x01, 0x15, 0x71, 0x00, 0x71, 0x00, 0xBE]
137
110
 
138
111
  if Lspeed>100:
139
112
  m_par=100
@@ -144,7 +117,7 @@ def run_speed(Lspeed:int,Rspeed:int) -> Optional[bytes]:
144
117
  elif Lspeed<=0 and Lspeed>=-100:
145
118
  m_par=256+Lspeed
146
119
 
147
- move_str[4]=m_par
120
+ move_str[6]=m_par
148
121
 
149
122
  if Rspeed>100:
150
123
  m_par=100
@@ -155,7 +128,7 @@ def run_speed(Lspeed:int,Rspeed:int) -> Optional[bytes]:
155
128
  elif Rspeed<=0 and Rspeed>=-100:
156
129
  m_par=256+Rspeed
157
130
 
158
- move_str[6]=m_par
131
+ move_str[4]=m_par
159
132
 
160
133
  response = base_driver.single_operate_sensor(move_str)
161
134
  if response == -1:
@@ -163,12 +136,12 @@ def run_speed(Lspeed:int,Rspeed:int) -> Optional[bytes]:
163
136
  else:
164
137
  return 0
165
138
 
166
- #设置左右轮功率移动 Lspeed:0~100; Rspeed:0~100;
139
+ #设置左右轮功率移动:Lpower:0~100;Rpower:0~100;
167
140
  def run_power(Lpower:bytes,Rpower:bytes) -> Optional[bytes]:
168
141
  move_str=[0xA0, 0x01, 0x17, 0x71, 0x00, 0x71, 0x00, 0xBE]
169
142
 
170
- move_str[4]=Lpower
171
- move_str[6]=Rpower
143
+ move_str[4]=Rpower
144
+ move_str[6]=Lpower
172
145
 
173
146
  response = base_driver.single_operate_sensor(move_str)
174
147
  if response == -1:
@@ -176,7 +149,7 @@ def run_power(Lpower:bytes,Rpower:bytes) -> Optional[bytes]:
176
149
  else:
177
150
  return 0
178
151
 
179
- #设置最大功率 Lspeed:0~100; Rspeed:0~100;
152
+ #设置最大功率:M1:0~100;M2:0~100;M3:0~100;M4:0~100;M5:0~100;M6:0~100;
180
153
  def set_maxpower(M1:bytes,M2:bytes,M3:bytes,M4:bytes,M5:bytes,M6:bytes) -> Optional[bytes]:
181
154
  move_str=[0xA0, 0x01, 0x18, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0xBE]
182
155
 
@@ -203,21 +176,21 @@ def stop() -> Optional[bytes]:
203
176
  else:
204
177
  return 0
205
178
 
206
- #设置左右轮方向 Lmotor:1~6; Rmotor:1~6; state: no_reversal、all_reversal、left_reversal、right_reversal
179
+ #设置左右轮方向:Lmotor:1~6;Rmotor:1~6;state: no_reversal、all_reversal、left_reversal、right_reversal
207
180
  def set_move_init(Lmotor:bytes,Rmotor:bytes,state:bytes) -> Optional[bytes]:
208
181
  move_str=[0xA0, 0x01, 0x19, 0x71, 0x00, 0x71, 0x00, 0x71, 0x00, 0xBE]
209
-
210
- move_str[4]=Lmotor
211
- move_str[6]=Rmotor
212
-
182
+
213
183
  if state=="no_reversal":
214
- move_str[8]=0x01
184
+ move_str[4]=0x01
215
185
  elif state=="all_reversal":
216
- move_str[8]=0x02
186
+ move_str[4]=0x02
217
187
  elif state=="left_reversal":
218
- move_str[8]=0x03
188
+ move_str[4]=0x03
219
189
  elif state=="right_reversal":
220
- move_str[8]=0x04
190
+ move_str[4]=0x04
191
+
192
+ move_str[6]=Rmotor
193
+ move_str[8]=Lmotor
221
194
 
222
195
  response = base_driver.single_operate_sensor(move_str)
223
196
  if response == -1:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smartpi
3
- Version: 0.1.8
3
+ Version: 0.1.10
4
4
  Summary: A library use for H2-RCU
5
5
  Author: ZMROBO
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,5 +1,5 @@
1
- smartpi/__init__.py,sha256=ntmh9G-IsdXNEPRe_52sLjRLb1hsWYsxo6nUiioBpJ4,54
2
- smartpi/base_driver.py,sha256=bFd1rZfjgVCq4UYPNNJQKbQunyLtv_IyEYhiZgHtB_Y,17988
1
+ smartpi/__init__.py,sha256=1D37WANsd4B0qjha8w25OFIvYG7gPmSKmAcbsLRRtvo,55
2
+ smartpi/base_driver.py,sha256=85buq4rHErH16lYjLPeQi6r4RDIXWztysjPbL7Upm1M,17995
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=1LpNlveTJLnObyD4nzbHIC0rlkPuPUwPtnF3sgr1t6g,6599
10
+ smartpi/move.py,sha256=51yj4sd3Yllk0jprMKyUtNThP82I8E4HGqpD1eyta3k,5992
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.8.dist-info/METADATA,sha256=Gi4SGmhnZmZnC9ROapd9jCoohhoEKJtv6epGUke4LqE,310
16
- smartpi-0.1.8.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
17
- smartpi-0.1.8.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
18
- smartpi-0.1.8.dist-info/RECORD,,
15
+ smartpi-0.1.10.dist-info/METADATA,sha256=VaNgj97czc_Uy1YTmZtVm05z7-bYm7zGr3kG26FN0qI,311
16
+ smartpi-0.1.10.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
17
+ smartpi-0.1.10.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
18
+ smartpi-0.1.10.dist-info/RECORD,,