smartpi 0.1.34__py3-none-any.whl → 0.1.35__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
@@ -4,5 +4,5 @@ from .base_driver import P1, P2, P3, P4, P5, P6, M1, M2, M3, M4, M5, M6
4
4
  __all__ = ["base_driver","gui","ultrasonic","touch_sensor","temperature","humidity","light_sensor","color_sensor","motor","servo","led","flash",
5
5
  "P1", "P2", "P3", "P4", "P5", "P6", "M1", "M2", "M3", "M4", "M5", "M6"]
6
6
 
7
- __version__ = "0.1.34"
7
+ __version__ = "0.1.35"
8
8
 
smartpi/base_driver.py CHANGED
@@ -415,6 +415,7 @@ def single_operate_sensor(op_struct: bytes, block_time: float) -> Optional[bytes
415
415
  def P_port_init(port:bytes) -> Optional[bytes]:
416
416
  servo_str=[0xA0, 0x0F, 0x00, 0xBE]
417
417
  servo_str[0]=0XA0+port
418
+ time.sleep(0.005)
418
419
  response = single_operate_sensor(servo_str,0)
419
420
  if response:
420
421
  return 0
smartpi/color_sensor.py CHANGED
@@ -8,6 +8,7 @@ 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
+ time.sleep(0.005)
11
12
  response = base_driver.single_operate_sensor(color_str,0)
12
13
  if response == None:
13
14
  return None
smartpi/humidity.py CHANGED
@@ -9,6 +9,7 @@ def get_value(port:bytes) -> Optional[bytes]:
9
9
  humi_str=[0XA0, 0X0C, 0X01, 0X71, 0X00, 0XBE]
10
10
  humi_str[0]=0XA0+port
11
11
  humi_str[4]=0X01
12
+ time.sleep(0.005)
12
13
  response = base_driver.single_operate_sensor(humi_str,0)
13
14
  if response == None:
14
15
  return None
smartpi/led.py CHANGED
@@ -10,6 +10,7 @@ def set_color(port:bytes,command:bytes) -> Optional[bytes]:
10
10
  color_lamp_str[0]=0XA0+port
11
11
  color_lamp_str[2]=command
12
12
  # response = base_driver.single_operate_sensor(color_lamp_str,0)
13
+ time.sleep(0.005)
13
14
  base_driver.write_data(0X01, 0X02, color_lamp_str)
14
15
  # if response == None:
15
16
  # return None
smartpi/light_sensor.py CHANGED
@@ -9,7 +9,7 @@ def turn_off(port:bytes) -> Optional[bytes]:
9
9
  light_str[0]=0XA0+port
10
10
  light_str[2]=0x03
11
11
  # response = base_driver.single_operate_sensor(light_str,0)
12
- # base_driver.write_data(0X01, 0X02, light_str)
12
+ base_driver.write_data(0X01, 0X02, light_str)
13
13
  # if response == None:
14
14
  # return None
15
15
  # else:
@@ -20,6 +20,7 @@ def get_value(port:bytes) -> Optional[bytes]:
20
20
  light_str=[0xA0, 0x02, 0x00, 0xBE]
21
21
  light_str[0]=0XA0+port
22
22
  light_str[2]=0x01
23
+ time.sleep(0.005)
23
24
  response = base_driver.single_operate_sensor(light_str,0)
24
25
  if response == None:
25
26
  return None
@@ -35,17 +36,20 @@ def set_threshold(port:bytes,threshold:int) -> Optional[bytes]:
35
36
  light_str[2]=0x04
36
37
  light_str[4]=threshold//256
37
38
  light_str[5]=threshold%256
38
- response = base_driver.single_operate_sensor(light_str,0)
39
- if response == None:
40
- return None
41
- else:
42
- return 0
39
+ time.sleep(0.005)
40
+ base_driver.write_data(0X01, 0X02, light_str)
41
+ # response = base_driver.single_operate_sensor(light_str,0)
42
+ # if response == None:
43
+ # return None
44
+ # else:
45
+ return 0
43
46
 
44
47
  #�����ֵ��ȡ port:����P�˿ڣ�
45
48
  def get_threshold(port:bytes) -> Optional[bytes]:
46
49
  light_str=[0xA0, 0x02, 0x00, 0xBE]
47
50
  light_str[0]=0XA0+port
48
51
  light_str[2]=0x05
52
+ time.sleep(0.005)
49
53
  response = base_driver.single_operate_sensor(light_str,0)
50
54
  if response == None:
51
55
  return None
@@ -59,6 +63,7 @@ def get_bool_data(port:bytes) -> Optional[bytes]:
59
63
  light_str=[0xA0, 0x02, 0x00, 0xBE]
60
64
  light_str[0]=0XA0+port
61
65
  light_str[2]=0x06
66
+ time.sleep(0.005)
62
67
  response = base_driver.single_operate_sensor(light_str,0)
63
68
  if response == None:
64
69
  return None
smartpi/motor.py CHANGED
@@ -8,7 +8,8 @@ from smartpi import base_driver
8
8
  #��������ȡ port:����M�˿ڣ�
9
9
  def get_motor_encoder(port:bytes) -> Optional[bytes]:
10
10
  motor_str=[0xA0, 0x01, 0x01, 0xBE]
11
- motor_str[0]=0XA0+port
11
+ motor_str[0]=0XA0+port
12
+ time.sleep(0.005)
12
13
  response = base_driver.single_operate_sensor(motor_str,0)
13
14
  if response == None:
14
15
  return None
@@ -22,6 +23,7 @@ def reset_motor_encoder(port:bytes) -> Optional[bytes]:
22
23
  motor_str=[0xA0, 0x01, 0x03, 0xBE]
23
24
  motor_str[0]=0XA0+port
24
25
  # response = base_driver.single_operate_sensor(motor_str,0)
26
+ time.sleep(0.005)
25
27
  base_driver.write_data(0X01, 0X02, motor_str)
26
28
  # if response == None:
27
29
  # return None
@@ -34,6 +36,7 @@ def set_motor_direction(port:bytes,direc:bytes) -> Optional[bytes]:
34
36
  motor_str[0]=0XA0+port
35
37
  motor_str[4]=direc
36
38
  # response = base_driver.single_operate_sensor(motor_str,0)
39
+ time.sleep(0.005)
37
40
  base_driver.write_data(0X01, 0X02, motor_str)
38
41
  # if response == None:
39
42
  # return None
@@ -56,6 +59,7 @@ def set_motor(port:bytes,speed:int) -> Optional[bytes]:
56
59
  motor_str[4]=m_par
57
60
 
58
61
  # response = base_driver.single_operate_sensor(motor_str,0)
62
+ time.sleep(0.005)
59
63
  base_driver.write_data(0X01, 0X02, motor_str)
60
64
  # if response == None:
61
65
  # return None
@@ -67,6 +71,7 @@ def set_motor_stop(port:bytes) -> Optional[bytes]:
67
71
  motor_str=[0xA0, 0x01, 0x0B, 0xBE]
68
72
  motor_str[0]=0XA0+port
69
73
  # response = base_driver.single_operate_sensor(motor_str,0)
74
+ time.sleep(0.005)
70
75
  base_driver.write_data(0X01, 0X02, motor_str)
71
76
  # if response == None:
72
77
  # return None
@@ -91,6 +96,7 @@ def set_motor_angle(port:bytes,speed:int,degree:int) -> Optional[bytes]:
91
96
  motor_str[6]=degree//256
92
97
  motor_str[7]=degree%256
93
98
  # response = base_driver.single_operate_sensor(motor_str,0)
99
+ time.sleep(0.005)
94
100
  base_driver.write_data(0X01, 0X02, motor_str)
95
101
  # if response == None:
96
102
  # return None
@@ -122,6 +128,7 @@ def set_motor_second(port:bytes,speed:int,second:float) -> Optional[bytes]:
122
128
  motor_str[9]=byte_array[3]
123
129
 
124
130
  # response = base_driver.single_operate_sensor(motor_str,0)
131
+ time.sleep(0.005)
125
132
  base_driver.write_data(0X01, 0X02, motor_str)
126
133
  # if response == None:
127
134
  # return None
@@ -145,6 +152,7 @@ def set_motor_constspeed(port:bytes,speed:int) -> Optional[bytes]:
145
152
  motor_str[4]=m_par
146
153
 
147
154
  # response = base_driver.single_operate_sensor(motor_str,0)
155
+ time.sleep(0.005)
148
156
  base_driver.write_data(0X01, 0X02, motor_str)
149
157
  # if response == None:
150
158
  # return None
@@ -154,7 +162,8 @@ def set_motor_constspeed(port:bytes,speed:int) -> Optional[bytes]:
154
162
  #�����ٶȶ�ȡ port:����M�˿ڣ�
155
163
  def get_motor_speed(port:bytes) -> Optional[bytes]:
156
164
  motor_str=[0xA0, 0x01, 0x10, 0xBE]
157
- motor_str[0]=0XA0+port
165
+ motor_str[0]=0XA0+port
166
+ time.sleep(0.005)
158
167
  response = base_driver.single_operate_sensor(motor_str,0)
159
168
  if response == None:
160
169
  return None
smartpi/move.py CHANGED
@@ -19,12 +19,13 @@ def run_second(dir:bytes,speed:bytes,second:bytes) -> Optional[bytes]:
19
19
 
20
20
  move_str[6]=speed
21
21
  move_str[8]=second
22
-
23
- response = base_driver.single_operate_sensor(move_str,0)
24
- if response == None:
25
- return None
26
- else:
27
- return 0
22
+ time.sleep(0.005)
23
+ base_driver.write_data(0X01, 0X02, move_str)
24
+ # response = base_driver.single_operate_sensor(move_str,0)
25
+ # if response == None:
26
+ # return None
27
+ # else:
28
+ return 0
28
29
 
29
30
  #以速度移动x度:dir:方向forward、backward、turnright、turnleft:speed:0~100:angle:65535
30
31
  def run_angle(dir:bytes,speed:bytes,angle:int) -> Optional[bytes]:
@@ -43,11 +44,13 @@ def run_angle(dir:bytes,speed:bytes,angle:int) -> Optional[bytes]:
43
44
  move_str[8]=angle//256
44
45
  move_str[9]=angle%256
45
46
 
46
- response = base_driver.single_operate_sensor(move_str,0)
47
- if response == None:
48
- return None
49
- else:
50
- return 0
47
+ time.sleep(0.005)
48
+ base_driver.write_data(0X01, 0X02, move_str)
49
+ # response = base_driver.single_operate_sensor(move_str,0)
50
+ # if response == None:
51
+ # return None
52
+ # else:
53
+ return 0
51
54
 
52
55
  #以速度移动:dir:方向forward、backward、turnright、turnleft;speed:0~100;
53
56
  def run(dir:bytes,speed:bytes) -> Optional[bytes]:
@@ -64,11 +67,13 @@ def run(dir:bytes,speed:bytes) -> Optional[bytes]:
64
67
 
65
68
  move_str[6]=speed
66
69
 
67
- response = base_driver.single_operate_sensor(move_str,0)
68
- if response == None:
69
- return None
70
- else:
71
- return 0
70
+ time.sleep(0.005)
71
+ base_driver.write_data(0X01, 0X02, move_str)
72
+ # response = base_driver.single_operate_sensor(move_str,0)
73
+ # if response == None:
74
+ # return None
75
+ # else:
76
+ return 0
72
77
 
73
78
  #设置左右轮速度移动x秒:Lspeed:-100~100;Rspeed:-100~100;second:1~255
74
79
  def run_speed_second(Lspeed:int,Rspeed:int,second:bytes) -> Optional[bytes]:
@@ -98,11 +103,13 @@ def run_speed_second(Lspeed:int,Rspeed:int,second:bytes) -> Optional[bytes]:
98
103
 
99
104
  move_str[8]=second
100
105
 
101
- response = base_driver.single_operate_sensor(move_str,0)
102
- if response == None:
103
- return None
104
- else:
105
- return 0
106
+ time.sleep(0.005)
107
+ base_driver.write_data(0X01, 0X02, move_str)
108
+ # response = base_driver.single_operate_sensor(move_str,0)
109
+ # if response == None:
110
+ # return None
111
+ # else:
112
+ return 0
106
113
 
107
114
  #设置左右轮速度移动:Lspeed:-100~100;Rspeed:-100~100;
108
115
  def run_speed(Lspeed:int,Rspeed:int) -> Optional[bytes]:
@@ -130,11 +137,13 @@ def run_speed(Lspeed:int,Rspeed:int) -> Optional[bytes]:
130
137
 
131
138
  move_str[4]=m_par
132
139
 
133
- response = base_driver.single_operate_sensor(move_str,0)
134
- if response == None:
135
- return None
136
- else:
137
- return 0
140
+ time.sleep(0.005)
141
+ base_driver.write_data(0X01, 0X02, move_str)
142
+ # response = base_driver.single_operate_sensor(move_str,0)
143
+ # if response == None:
144
+ # return None
145
+ # else:
146
+ return 0
138
147
 
139
148
  #设置左右轮功率移动:Lpower:0~100;Rpower:0~100;
140
149
  def run_power(Lpower:bytes,Rpower:bytes) -> Optional[bytes]:
@@ -143,11 +152,13 @@ def run_power(Lpower:bytes,Rpower:bytes) -> Optional[bytes]:
143
152
  move_str[4]=Rpower
144
153
  move_str[6]=Lpower
145
154
 
146
- response = base_driver.single_operate_sensor(move_str,0)
147
- if response == None:
148
- return None
149
- else:
150
- return 0
155
+ time.sleep(0.005)
156
+ base_driver.write_data(0X01, 0X02, move_str)
157
+ # response = base_driver.single_operate_sensor(move_str,0)
158
+ # if response == None:
159
+ # return None
160
+ # else:
161
+ return 0
151
162
 
152
163
  #设置最大功率:M1:0~100;M2:0~100;M3:0~100;M4:0~100;M5:0~100;M6:0~100;
153
164
  def set_maxpower(M1:bytes,M2:bytes,M3:bytes,M4:bytes,M5:bytes,M6:bytes) -> Optional[bytes]:
@@ -160,21 +171,25 @@ def set_maxpower(M1:bytes,M2:bytes,M3:bytes,M4:bytes,M5:bytes,M6:bytes) -> Optio
160
171
  move_str[12]=M5
161
172
  move_str[14]=M6
162
173
 
163
- response = base_driver.single_operate_sensor(move_str,0)
164
- if response == None:
165
- return None
166
- else:
167
- return 0
174
+ time.sleep(0.005)
175
+ base_driver.write_data(0X01, 0X02, move_str)
176
+ # response = base_driver.single_operate_sensor(move_str,0)
177
+ # if response == None:
178
+ # return None
179
+ # else:
180
+ return 0
168
181
 
169
182
  #马达停止
170
183
  def stop() -> Optional[bytes]:
171
184
  move_str=[0xA0, 0x01, 0x0A, 0xBE]
172
185
 
173
- response = base_driver.single_operate_sensor(move_str,0)
174
- if response == None:
175
- return None
176
- else:
177
- return 0
186
+ time.sleep(0.005)
187
+ base_driver.write_data(0X01, 0X02, move_str)
188
+ # response = base_driver.single_operate_sensor(move_str,0)
189
+ # if response == None:
190
+ # return None
191
+ # else:
192
+ return 0
178
193
 
179
194
  #设置左右轮方向:Lmotor:1~6;Rmotor:1~6;state: no_reversal、all_reversal、left_reversal、right_reversal
180
195
  def set_move_init(Lmotor:bytes,Rmotor:bytes,state:bytes) -> Optional[bytes]:
@@ -192,10 +207,12 @@ def set_move_init(Lmotor:bytes,Rmotor:bytes,state:bytes) -> Optional[bytes]:
192
207
  move_str[6]=Rmotor
193
208
  move_str[8]=Lmotor
194
209
 
195
- response = base_driver.single_operate_sensor(move_str,0)
196
- if response == None:
197
- return None
198
- else:
199
- return 0
210
+ time.sleep(0.005)
211
+ base_driver.write_data(0X01, 0X02, move_str)
212
+ # response = base_driver.single_operate_sensor(move_str,0)
213
+ # if response == None:
214
+ # return None
215
+ # else:
216
+ return 0
200
217
 
201
218
 
smartpi/servo.py CHANGED
@@ -9,6 +9,7 @@ def steer_angle(port:bytes,angle:bytes) -> Optional[bytes]:
9
9
  servo_str[0]=0XA0+port
10
10
  servo_str[4]=angle
11
11
  # response = base_driver.single_operate_sensor(servo_str,0)
12
+ time.sleep(0.005)
12
13
  base_driver.write_data(0X01, 0X02, servo_str)
13
14
  # if response == None:
14
15
  # return None
@@ -23,6 +24,7 @@ def steer_angle_delay(port:bytes,angle:bytes,second:bytes) -> Optional[bytes]:
23
24
  servo_str[5]=angle%256
24
25
  servo_str[7]=second
25
26
  # response = base_driver.single_operate_sensor(servo_str,0)
27
+ time.sleep(0.005)
26
28
  base_driver.write_data(0X01, 0X02, servo_str)
27
29
  # if response == None:
28
30
  # return None
@@ -35,6 +37,7 @@ def set_dir(port:bytes,dir:bytes) -> Optional[bytes]:
35
37
  servo_str[0]=0XA0+port
36
38
  servo_str[4]=dir
37
39
  # response = base_driver.single_operate_sensor(servo_str,0)
40
+ time.sleep(0.005)
38
41
  base_driver.write_data(0X01, 0X02, servo_str)
39
42
  # if response == None:
40
43
  # return None
@@ -65,6 +68,7 @@ def set_angle_ms(port:bytes,angle:bytes,ms:int) -> Optional[bytes]:
65
68
  servo_str[7]=ms//256
66
69
  servo_str[8]=ms%256
67
70
  # response = base_driver.single_operate_sensor(servo_str,0)
71
+ time.sleep(0.005)
68
72
  base_driver.write_data(0X01, 0X02, servo_str)
69
73
  # if response == None:
70
74
  # return None
@@ -76,6 +80,7 @@ def set_init(port:bytes) -> Optional[bytes]:
76
80
  servo_str=[0xA0, 0x12, 0x01, 0xBE]
77
81
  servo_str[0]=0XA0+port
78
82
  # response = base_driver.single_operate_sensor(servo_str,0)
83
+ time.sleep(0.005)
79
84
  base_driver.write_data(0X01, 0X02, servo_str)
80
85
  # if response == None:
81
86
  # return None
@@ -86,6 +91,7 @@ def set_init(port:bytes) -> Optional[bytes]:
86
91
  def get_angle(port:bytes) -> Optional[bytes]:
87
92
  servo_str=[0xA0, 0x13, 0x01, 0xBE]
88
93
  servo_str[0]=0XA0+port
94
+ time.sleep(0.005)
89
95
  response = base_driver.single_operate_sensor(servo_str,0)
90
96
  if response == None:
91
97
  return None
@@ -109,6 +115,7 @@ def set_speed(port:bytes,speed:int) -> Optional[bytes]:
109
115
 
110
116
  servo_str[4]=m_par
111
117
  # response = base_driver.single_operate_sensor(servo_str,0)
118
+ time.sleep(0.005)
112
119
  base_driver.write_data(0X01, 0X02, servo_str)
113
120
  # if response == None:
114
121
  # return None
@@ -134,6 +141,7 @@ def set_code_speed(port:bytes,code:int,speed:int) -> Optional[bytes]:
134
141
  servo_str[7]=m_par
135
142
 
136
143
  # response = base_driver.single_operate_sensor(servo_str,0)
144
+ time.sleep(0.005)
137
145
  base_driver.write_data(0X01, 0X02, servo_str)
138
146
  # if response == None:
139
147
  # return None
@@ -145,6 +153,7 @@ def reset_encode(port:bytes) -> Optional[bytes]:
145
153
  servo_str=[0xA0, 0x16, 0x01, 0xBE]
146
154
  servo_str[0]=0XA0+port
147
155
  # response = base_driver.single_operate_sensor(servo_str,0)
156
+ time.sleep(0.005)
148
157
  base_driver.write_data(0X01, 0X02, servo_str)
149
158
  # if response == None:
150
159
  # return None
@@ -155,6 +164,7 @@ def reset_encode(port:bytes) -> Optional[bytes]:
155
164
  def get_encoder(port:bytes) -> Optional[bytes]:
156
165
  servo_str=[0xA0, 0x17, 0x01, 0xBE]
157
166
  servo_str[0]=0XA0+port
167
+ time.sleep(0.005)
158
168
  response = base_driver.single_operate_sensor(servo_str,0)
159
169
  if response == None:
160
170
  return None
smartpi/temperature.py CHANGED
@@ -9,6 +9,7 @@ def get_value(port:bytes) -> Optional[bytes]:
9
9
  temp_str=[0XA0, 0X0C, 0X01, 0X71, 0X00, 0XBE]
10
10
  temp_str[0]=0XA0+port
11
11
  temp_str[4]=0
12
+ time.sleep(0.005)
12
13
  response = base_driver.single_operate_sensor(temp_str,0)
13
14
  if response == None:
14
15
  return None
smartpi/touch_sensor.py CHANGED
@@ -7,6 +7,7 @@ from smartpi import base_driver
7
7
  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
+ time.sleep(0.005)
10
11
  response = base_driver.single_operate_sensor(read_sw_str,0)
11
12
  if response == None:
12
13
  return None
smartpi/trace.py CHANGED
@@ -27,6 +27,7 @@ def get_chn_data(port:bytes, chn:bytes) -> Optional[bytes]:
27
27
  trace_str=[0xA0, 0x18, 0x01, 0x71, 0x00, 0xBE]
28
28
  trace_str[0]=0XA0+port
29
29
  trace_str[4]=chn
30
+ time.sleep(0.005)
30
31
  response = base_driver.single_operate_sensor(trace_str,0)
31
32
  if response == None:
32
33
  return None
@@ -44,28 +45,33 @@ def set_chn_color(port:bytes, color1:bytes, color2:bytes, color3:bytes, color4:b
44
45
  trace_str[12]=color5
45
46
  trace_str[14]=color6
46
47
  trace_str[16]=color7
47
- response = base_driver.single_operate_sensor(trace_str,0)
48
- if response == None:
49
- return None
50
- else:
51
- return response[4]
48
+ time.sleep(0.005)
49
+ base_driver.write_data(0X01, 0X02, trace_str)
50
+ # response = base_driver.single_operate_sensor(trace_str,0)
51
+ # if response == None:
52
+ # return None
53
+ # else:
54
+ return 0
52
55
 
53
56
  #循迹卡设置全部颜色 port:连接P端口;color:全部彩灯的颜色1~7(红、绿、蓝、黄、紫、青、白)
54
57
  def set_color(port:bytes, color:bytes) -> Optional[bytes]:
55
58
  trace_str=[0xA0, 0x20, 0x01, 0x71, 0x00, 0xBE]
56
59
  trace_str[0]=0XA0+port
57
60
  trace_str[4]=color
58
- response = base_driver.single_operate_sensor(trace_str,0)
59
- if response == None:
60
- return None
61
- else:
62
- return response[4]
61
+ time.sleep(0.005)
62
+ base_driver.write_data(0X01, 0X02, trace_str)
63
+ # response = base_driver.single_operate_sensor(trace_str,0)
64
+ # if response == None:
65
+ # return None
66
+ # else:
67
+ return 0
63
68
 
64
69
  #循迹卡单通道光值读取 port:连接P端口;chn:检测通道;正常返回:通道光值数据; 读取错误:None
65
70
  def get_analog(port:bytes, chn:bytes) -> Optional[bytes]:
66
71
  trace_str=[0xA0, 0x21, 0x01, 0x71, 0x00, 0xBE]
67
72
  trace_str[0]=0XA0+port
68
73
  trace_str[4]=20+chn
74
+ time.sleep(0.005)
69
75
  response = base_driver.single_operate_sensor(trace_str,0)
70
76
  if response == None:
71
77
  return None
@@ -78,6 +84,7 @@ def get_line_state(port:bytes, state:bytes) -> Optional[bytes]:
78
84
  trace_str=[0xA0, 0x22, 0x01, 0x71, 0x00, 0xBE]
79
85
  trace_str[0]=0XA0+port
80
86
  trace_str[4]=state
87
+ time.sleep(0.005)
81
88
  response = base_driver.single_operate_sensor(trace_str,0)
82
89
  if response == None:
83
90
  return None
@@ -90,7 +97,7 @@ def set_threshold(port:bytes, second:int) -> Optional[bytes]:
90
97
  trace_str[0]=0XA0+port
91
98
  trace_str[4]=second//256
92
99
  trace_str[5]=second%256
93
-
100
+ time.sleep(0.005)
94
101
  serial_lock.acquire() #获取线程锁
95
102
  fcntl.flock(ser.fileno(), fcntl.LOCK_EX) # 进程锁,阻塞其他进程
96
103
  base_driver.write_data(0X01, 0X02, trace_str)
smartpi/ultrasonic.py CHANGED
@@ -8,6 +8,7 @@ def get_value(port:bytes) -> Optional[bytes]:
8
8
  ultrasonic_str=[0xA0, 0x06, 0x00, 0xBE]
9
9
  ultrasonic_str[0]=0XA0+port
10
10
  ultrasonic_str[2]=1
11
+ time.sleep(0.005)
11
12
  response = base_driver.single_operate_sensor(ultrasonic_str,0)
12
13
 
13
14
  if response == None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smartpi
3
- Version: 0.1.34
3
+ Version: 0.1.35
4
4
  Summary: A library use for H2-RCU
5
5
  Author: ZMROBO
6
6
  Classifier: Programming Language :: Python :: 3
@@ -0,0 +1,20 @@
1
+ smartpi/__init__.py,sha256=Xv8M38iKLdE8r7cDHJp0q8-0ixIWWpXee6GlYQzobuU,356
2
+ smartpi/_gui.py,sha256=ij-6HZAEIwdy_hvU7f0NkyQjx_-eephijlKbGUhf8Uo,2177
3
+ smartpi/base_driver.py,sha256=difi-MhGoxvodSsQt1hYg-nx5fk4b-qU7D-5-A61LaY,20632
4
+ smartpi/color_sensor.py,sha256=ckIXD81YnqPo6nENAnipNp3gY12FJ235QKj0e8Cul9E,521
5
+ smartpi/cw2015.py,sha256=1lAF-pi_ye_ya1AZQS1sjbgsDf7MThO5IAskKsNGBzA,5695
6
+ smartpi/flash.py,sha256=-pUqg6FSVoBiLFKqrG9B4dFqn8lICnQsSPJr_MtZLIU,4132
7
+ smartpi/humidity.py,sha256=uoSFt5mAKr-dHz125uznHXAPeTN61ZR92_2nQmytQ5M,522
8
+ smartpi/led.py,sha256=6-y5MFGk0tN5N_WHclXbSRyP-anhCHhgXI3MdAQCKWM,617
9
+ smartpi/light_sensor.py,sha256=-ICMwQcWIZ6LGOz_A2WL5h5CL1v4opmlfacN35veMSE,2398
10
+ smartpi/motor.py,sha256=DvFzREEzyRafGmSCagU6ASeoE8fnAsKYI4oYMrkXXJc,5351
11
+ smartpi/move.py,sha256=s1ZnkFtp6SCBnxhBxp6qQjGbifdsY5hjVCwlarTsZto,6688
12
+ smartpi/servo.py,sha256=0p09Jk-IVk5nLXz2AqFvytiYSSe4sMxdy1FaNMQijoY,5770
13
+ smartpi/temperature.py,sha256=xfM9V5dvJ9M-3rqnE2AjaYXEH9jP5s1_Myo4GEwH3NY,485
14
+ smartpi/touch_sensor.py,sha256=Zp7z0qnaZ99cuamakqDwI2tFd2a3CnjQ1rngdn_mZlM,463
15
+ smartpi/trace.py,sha256=HkoTleJnwseAue2J9wTFSXPgXaLx2Y-LE7Ip8UdoreE,4791
16
+ smartpi/ultrasonic.py,sha256=qrGge3G9_1s3ZdKYZRJ_FP8l_VhbpYEe-anlShooMwA,647
17
+ smartpi-0.1.35.dist-info/METADATA,sha256=QyvalvCaiz4jeqZWk6Fn9gkJNiE_Y-TMxO8s-vlwfJI,399
18
+ smartpi-0.1.35.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
19
+ smartpi-0.1.35.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
20
+ smartpi-0.1.35.dist-info/RECORD,,
@@ -1,20 +0,0 @@
1
- smartpi/__init__.py,sha256=ezLA647rfQ9QqjycJlgQhprLoRFWSnEO7MOlflsklaM,356
2
- smartpi/_gui.py,sha256=ij-6HZAEIwdy_hvU7f0NkyQjx_-eephijlKbGUhf8Uo,2177
3
- smartpi/base_driver.py,sha256=WtRBSkjcOHikU402lU1cBSVlRHhyWGZMll_zffg2F2U,20609
4
- smartpi/color_sensor.py,sha256=YXJjknYjp7teTZsHYZRAWgi73CH0MhBp1go9y0Inxyo,498
5
- smartpi/cw2015.py,sha256=1lAF-pi_ye_ya1AZQS1sjbgsDf7MThO5IAskKsNGBzA,5695
6
- smartpi/flash.py,sha256=-pUqg6FSVoBiLFKqrG9B4dFqn8lICnQsSPJr_MtZLIU,4132
7
- smartpi/humidity.py,sha256=nZwiBtMWKNipVM83ymajZACPHxkC2vUJjDMmCOPN9lw,499
8
- smartpi/led.py,sha256=HXebd7mRO6HUjO2Xc2LBgJlAew0-IAAKpvcmVRhdGcA,594
9
- smartpi/light_sensor.py,sha256=oG6hHr1Tb9Xcv-Y-OjhkED5DS1u82F-kduHKAiM3B5Q,2256
10
- smartpi/motor.py,sha256=HTH0JqZ0d8D2HRdQ6UT9wwqBkyqErq6QaMuS_ZsDq9A,5144
11
- smartpi/move.py,sha256=mYw5li1qQe97845cqclMksuaKOL9n_0E0n9652EIMcI,6046
12
- smartpi/servo.py,sha256=2KYMjjF72cTTq2RtPTDlVwIj7i5tMMGeXzKnk8SLdbE,5540
13
- smartpi/temperature.py,sha256=VT79CYA41q1d_4AM-Y0eIMeIw7AtCkSXjWVws6Yx5yE,462
14
- smartpi/touch_sensor.py,sha256=P57RRQlqY0KexpMi-ydqwF5albOKCBOGb0Rb6zeVTqk,440
15
- smartpi/trace.py,sha256=tut7BMbq87ShaR5eNuv7PZtAEz9DS5_BDf0_muIZ-tQ,4577
16
- smartpi/ultrasonic.py,sha256=kmVpUfvE1oHoqgv92ZU6Fi-sO6DSwm10ssKsImNeOkY,624
17
- smartpi-0.1.34.dist-info/METADATA,sha256=v0qlefo-v66aK6_3cxWr57MOAMlaEzWGajiEH5OcAzI,399
18
- smartpi-0.1.34.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
19
- smartpi-0.1.34.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
20
- smartpi-0.1.34.dist-info/RECORD,,