smartpi 0.1.10__py3-none-any.whl → 0.1.12__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.10"
3
+ __version__ = "0.1.12"
4
4
 
smartpi/base_driver.py CHANGED
@@ -208,7 +208,7 @@ def read_device_model() -> Optional[bytes]:
208
208
  if time.time() - start_time > 3:
209
209
  print("读取超时")
210
210
  buffer.clear()
211
- return -1
211
+ return None
212
212
 
213
213
  """读取版本号"""
214
214
  def read_version() -> Optional[bytes]:
@@ -224,7 +224,7 @@ def read_version() -> Optional[bytes]:
224
224
  if time.time() - start_time > 3:
225
225
  print("读取超时")
226
226
  buffer.clear()
227
- return -1
227
+ return None
228
228
 
229
229
  """读取工厂信息"""
230
230
  def read_factory_data() -> Optional[bytes]:
@@ -240,7 +240,7 @@ def read_factory_data() -> Optional[bytes]:
240
240
  if time.time() - start_time > 3:
241
241
  print("读取超时")
242
242
  buffer.clear()
243
- return -1
243
+ return None
244
244
 
245
245
  """读取硬件ID"""
246
246
  def read_hardware_ID() -> Optional[bytes]:
@@ -256,7 +256,7 @@ def read_hardware_ID() -> Optional[bytes]:
256
256
  if time.time() - start_time > 3:
257
257
  print("读取超时")
258
258
  buffer.clear()
259
- return -1
259
+ return None
260
260
 
261
261
  """读取设备名称"""
262
262
  def read_device_name() -> Optional[bytes]:
@@ -272,7 +272,7 @@ def read_device_name() -> Optional[bytes]:
272
272
  if time.time() - start_time > 3:
273
273
  print("读取超时")
274
274
  buffer.clear()
275
- return -1
275
+ return None
276
276
 
277
277
  """设置设备名称"""
278
278
  def write_device_name(send_data: str) -> Optional[bytes]:
@@ -289,7 +289,7 @@ def write_device_name(send_data: str) -> Optional[bytes]:
289
289
  if time.time() - start_time > 3:
290
290
  print("读取超时")
291
291
  buffer.clear()
292
- return -1
292
+ return None
293
293
 
294
294
  """读取连接方式"""
295
295
  def read_connected() -> Optional[bytes]:
@@ -305,7 +305,7 @@ def read_connected() -> Optional[bytes]:
305
305
  if time.time() - start_time > 3:
306
306
  print("读取超时")
307
307
  buffer.clear()
308
- return -1
308
+ return None
309
309
 
310
310
  """读取电池电量百分比"""
311
311
  def read_battery() -> Optional[bytes]:
@@ -313,7 +313,7 @@ def read_battery() -> Optional[bytes]:
313
313
  if sensor.init():
314
314
  return sensor.get_soc(0)
315
315
  else:
316
- return -1
316
+ return None
317
317
 
318
318
  ###############################################################################固件升级
319
319
 
@@ -331,7 +331,7 @@ def update_request() -> Optional[bytes]:
331
331
  if time.time() - start_time > 3:
332
332
  print("读取超时")
333
333
  buffer.clear()
334
- return -1
334
+ return None
335
335
 
336
336
  """查询最大通讯长度"""
337
337
  def read_max_com_len() -> Optional[bytes]:
@@ -347,7 +347,7 @@ def read_max_com_len() -> Optional[bytes]:
347
347
  if time.time() - start_time > 3:
348
348
  print("读取超时")
349
349
  buffer.clear()
350
- return -1
350
+ return None
351
351
 
352
352
  """下载文件的信息"""
353
353
  #def download_massage() -> Optional[bytes]:
@@ -363,7 +363,7 @@ def read_max_com_len() -> Optional[bytes]:
363
363
  # if time.time() - start_time > 3:
364
364
  # print("读取超时")
365
365
  # buffer.clear()
366
- # return -1
366
+ # return None
367
367
  #
368
368
  #"""查询设备状态"""
369
369
  #def read_device_status() -> Optional[bytes]:
@@ -379,7 +379,7 @@ def read_max_com_len() -> Optional[bytes]:
379
379
  # if time.time() - start_time > 3:
380
380
  # print("读取超时")
381
381
  # buffer.clear()
382
- # return -1
382
+ # return None
383
383
  #
384
384
  #"""发送页校验码"""
385
385
  #def write_page_check() -> Optional[bytes]:
@@ -395,7 +395,7 @@ def read_max_com_len() -> Optional[bytes]:
395
395
  # if time.time() - start_time > 3:
396
396
  # print("读取超时")
397
397
  # buffer.clear()
398
- # return -1
398
+ # return None
399
399
  #
400
400
  #"""发送页数据"""
401
401
  #def write_page_check() -> Optional[bytes]:
@@ -411,7 +411,7 @@ def read_max_com_len() -> Optional[bytes]:
411
411
  # if time.time() - start_time > 3:
412
412
  # print("读取超时")
413
413
  # buffer.clear()
414
- # return -1
414
+ # return None
415
415
 
416
416
  ###############################################################################读取传感器信息
417
417
 
@@ -431,7 +431,7 @@ def read_peripheral() -> Optional[bytes]:
431
431
  if time.time() - start_time > 3:
432
432
  print("读取超时")
433
433
  buffer.clear()
434
- return -1
434
+ return None
435
435
 
436
436
  """单次操作外设"""
437
437
  def single_operate_sensor(op_struct: bytes) -> Optional[bytes]:
@@ -449,7 +449,7 @@ def single_operate_sensor(op_struct: bytes) -> Optional[bytes]:
449
449
  if time.time() - start_time > 3:
450
450
  print("读取超时")
451
451
  buffer.clear()
452
- return -1
452
+ return None
453
453
 
454
454
  #P端口初始化释放
455
455
  def P_port_init(port:bytes) -> Optional[bytes]:
@@ -459,7 +459,7 @@ def P_port_init(port:bytes) -> Optional[bytes]:
459
459
  if response:
460
460
  return 0
461
461
  else:
462
- return -1
462
+ return None
463
463
 
464
464
  """从机模式转换"""
465
465
  def mode_change(send_data: str) -> Optional[bytes]:
@@ -477,7 +477,7 @@ def mode_change(send_data: str) -> Optional[bytes]:
477
477
  if time.time() - start_time > 3:
478
478
  print("读取超时")
479
479
  buffer.clear()
480
- return -1
480
+ return None
481
481
 
482
482
  """智能模式发送周期"""
483
483
  def mode_change(send_data: str) -> Optional[bytes]:
@@ -495,7 +495,7 @@ def mode_change(send_data: str) -> Optional[bytes]:
495
495
  if time.time() - start_time > 3:
496
496
  print("读取超时")
497
497
  buffer.clear()
498
- return -1
498
+ return None
499
499
 
500
500
  """H2-RCU初始化"""
501
501
  def smartpi_init():
smartpi/color_sensor.py CHANGED
@@ -9,8 +9,8 @@ def get_value(port:bytes) -> Optional[bytes]:
9
9
  color_str[0]=0XA0+port
10
10
  color_str[2]=1
11
11
  response = base_driver.single_operate_sensor(color_str)
12
- if response == -1:
13
- return -1
12
+ if response == None:
13
+ return None
14
14
  else:
15
15
  return response[4]
16
16
 
smartpi/gui.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import socket
2
2
  import json
3
3
  import sys
4
+ import time
4
5
 
5
6
  # 连接对象(模块级单例)
6
7
  _connection = None
@@ -16,8 +17,10 @@ def _send(cmd):
16
17
  """发送命令到服务器"""
17
18
  if _connection is None and "pytest" not in sys.modules: # 允许测试环境不初始化
18
19
  raise ConnectionError("GUI not initialized. Call gui.init() first.")
20
+ time.sleep(0.1)
19
21
  if _connection:
20
22
  _connection.sendall((json.dumps(cmd) + "\n").encode())
23
+ time.sleep(0.1)
21
24
 
22
25
  def show_text(x, y, text, color="black", size=16):
23
26
  _send({"type": "text", "x": x, "y": y, "text": text, "color": color, "size": size})
smartpi/humidity.py CHANGED
@@ -10,8 +10,8 @@ def get_value(port:bytes) -> Optional[bytes]:
10
10
  humi_str[0]=0XA0+port
11
11
  humi_str[4]=0X01
12
12
  response = base_driver.single_operate_sensor(humi_str)
13
- if response == -1:
14
- return -1
13
+ if response == None:
14
+ return None
15
15
  else:
16
16
  return response[4]
17
17
 
smartpi/led.py CHANGED
@@ -10,8 +10,8 @@ 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)
13
- if response:
14
- return 0
13
+ if response == None:
14
+ return None
15
15
  else:
16
- return -1
16
+ return 0
17
17
 
smartpi/light_sensor.py CHANGED
@@ -9,8 +9,8 @@ def get_value(port:bytes) -> Optional[bytes]:
9
9
  light_str[0]=0XA0+port
10
10
  light_str[2]=1
11
11
  response = base_driver.single_operate_sensor(light_str)
12
- if response == -1:
13
- return -1
12
+ if response == None:
13
+ return None
14
14
  else:
15
15
  light_data=response[4:-1]
16
16
  light_num=int.from_bytes(light_data, byteorder='big', signed=True)
smartpi/motor.py CHANGED
@@ -9,8 +9,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
11
  response = base_driver.single_operate_sensor(motor_str)
12
- if response == -1:
13
- return -1
12
+ if response == None:
13
+ return None
14
14
  else:
15
15
  code_data=response[4:-1]
16
16
  code_num=int.from_bytes(code_data, byteorder='big', signed=True)
@@ -21,10 +21,10 @@ def reset_motor_encoder(port:bytes) -> Optional[bytes]:
21
21
  motor_str=[0xA0, 0x01, 0x03, 0xBE]
22
22
  motor_str[0]=0XA0+port
23
23
  response = base_driver.single_operate_sensor(motor_str)
24
- if response:
25
- return 0
24
+ if response == None:
25
+ return None
26
26
  else:
27
- return -1
27
+ return 0
28
28
 
29
29
  #���﷽����� port:����M�˿ڣ�dir:0��1
30
30
  def set_motor_direction(port:bytes,direc:bytes) -> Optional[bytes]:
@@ -32,10 +32,10 @@ def set_motor_direction(port:bytes,direc:bytes) -> Optional[bytes]:
32
32
  motor_str[0]=0XA0+port
33
33
  motor_str[4]=direc
34
34
  response = base_driver.single_operate_sensor(motor_str)
35
- if response:
36
- return 0
35
+ if response == None:
36
+ return None
37
37
  else:
38
- return -1
38
+ return 0
39
39
 
40
40
  #�����ٶ�ת�� port:����M�˿ڣ�speed:-100~100
41
41
  def set_motor(port:bytes,speed:int) -> Optional[bytes]:
@@ -53,20 +53,20 @@ def set_motor(port:bytes,speed:int) -> Optional[bytes]:
53
53
  motor_str[4]=m_par
54
54
 
55
55
  response = base_driver.single_operate_sensor(motor_str)
56
- if response:
57
- return 0
56
+ if response == None:
57
+ return None
58
58
  else:
59
- return -1
59
+ return 0
60
60
 
61
61
  #����ֹͣ port:����M�˿ڣ�
62
62
  def set_motor_stop(port:bytes) -> Optional[bytes]:
63
63
  motor_str=[0xA0, 0x01, 0x0B, 0xBE]
64
64
  motor_str[0]=0XA0+port
65
65
  response = base_driver.single_operate_sensor(motor_str)
66
- if response:
67
- return 0
66
+ if response == None:
67
+ return None
68
68
  else:
69
- return -1
69
+ return 0
70
70
 
71
71
  #����Ƕȿ��� port:����M�˿ڣ�speed:-100~100��degree:0~65535
72
72
  def set_motor_angle(port:bytes,speed:int,degree:int) -> Optional[bytes]:
@@ -86,10 +86,10 @@ def set_motor_angle(port:bytes,speed:int,degree:int) -> Optional[bytes]:
86
86
  motor_str[6]=degree//256
87
87
  motor_str[7]=degree%256
88
88
  response = base_driver.single_operate_sensor(motor_str)
89
- if response:
90
- return 0
89
+ if response == None:
90
+ return None
91
91
  else:
92
- return -1
92
+ return 0
93
93
 
94
94
  #���ﶨʱת�� port:����M�˿ڣ�speed:-100~100��second:1~256
95
95
  def set_motor_second(port:bytes,speed:int,second:bytes) -> Optional[bytes]:
@@ -108,10 +108,10 @@ def set_motor_second(port:bytes,speed:int,second:bytes) -> Optional[bytes]:
108
108
  motor_str[4]=m_par
109
109
  motor_str[6]=second
110
110
  response = base_driver.single_operate_sensor(motor_str)
111
- if response:
112
- return 0
111
+ if response == None:
112
+ return None
113
113
  else:
114
- return -1
114
+ return 0
115
115
 
116
116
  #���ﶨ��ת�� port:����M�˿ڣ�speed:-100~100
117
117
  def set_motor_constspeed(port:bytes,speed:int) -> Optional[bytes]:
@@ -130,18 +130,18 @@ def set_motor_constspeed(port:bytes,speed:int) -> Optional[bytes]:
130
130
  motor_str[4]=m_par
131
131
 
132
132
  response = base_driver.single_operate_sensor(motor_str)
133
- if response:
134
- return 0
133
+ if response == None:
134
+ return None
135
135
  else:
136
- return -1
136
+ return 0
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
142
  response = base_driver.single_operate_sensor(motor_str)
143
- if response == -1:
144
- return -1
143
+ if response == None:
144
+ return None
145
145
  else:
146
146
  code_data=response[4:-1]
147
147
  code_num=int.from_bytes(code_data, byteorder='big', signed=True)
smartpi/move.py CHANGED
@@ -21,8 +21,8 @@ def run_second(dir:bytes,speed:bytes,second:bytes) -> Optional[bytes]:
21
21
  move_str[8]=second
22
22
 
23
23
  response = base_driver.single_operate_sensor(move_str)
24
- if response == -1:
25
- return -1
24
+ if response == None:
25
+ return None
26
26
  else:
27
27
  return 0
28
28
 
@@ -44,8 +44,8 @@ def run_angle(dir:bytes,speed:bytes,angle:int) -> Optional[bytes]:
44
44
  move_str[9]=angle%256
45
45
 
46
46
  response = base_driver.single_operate_sensor(move_str)
47
- if response == -1:
48
- return -1
47
+ if response == None:
48
+ return None
49
49
  else:
50
50
  return 0
51
51
 
@@ -65,8 +65,8 @@ def run(dir:bytes,speed:bytes) -> Optional[bytes]:
65
65
  move_str[6]=speed
66
66
 
67
67
  response = base_driver.single_operate_sensor(move_str)
68
- if response == -1:
69
- return -1
68
+ if response == None:
69
+ return None
70
70
  else:
71
71
  return 0
72
72
 
@@ -99,8 +99,8 @@ def run_speed_second(Lspeed:int,Rspeed:int,second:bytes) -> Optional[bytes]:
99
99
  move_str[8]=second
100
100
 
101
101
  response = base_driver.single_operate_sensor(move_str)
102
- if response == -1:
103
- return -1
102
+ if response == None:
103
+ return None
104
104
  else:
105
105
  return 0
106
106
 
@@ -131,8 +131,8 @@ def run_speed(Lspeed:int,Rspeed:int) -> Optional[bytes]:
131
131
  move_str[4]=m_par
132
132
 
133
133
  response = base_driver.single_operate_sensor(move_str)
134
- if response == -1:
135
- return -1
134
+ if response == None:
135
+ return None
136
136
  else:
137
137
  return 0
138
138
 
@@ -144,8 +144,8 @@ def run_power(Lpower:bytes,Rpower:bytes) -> Optional[bytes]:
144
144
  move_str[6]=Lpower
145
145
 
146
146
  response = base_driver.single_operate_sensor(move_str)
147
- if response == -1:
148
- return -1
147
+ if response == None:
148
+ return None
149
149
  else:
150
150
  return 0
151
151
 
@@ -161,8 +161,8 @@ def set_maxpower(M1:bytes,M2:bytes,M3:bytes,M4:bytes,M5:bytes,M6:bytes) -> Optio
161
161
  move_str[14]=M6
162
162
 
163
163
  response = base_driver.single_operate_sensor(move_str)
164
- if response == -1:
165
- return -1
164
+ if response == None:
165
+ return None
166
166
  else:
167
167
  return 0
168
168
 
@@ -171,8 +171,8 @@ def stop() -> Optional[bytes]:
171
171
  move_str=[0xA0, 0x01, 0x0A, 0xBE]
172
172
 
173
173
  response = base_driver.single_operate_sensor(move_str)
174
- if response == -1:
175
- return -1
174
+ if response == None:
175
+ return None
176
176
  else:
177
177
  return 0
178
178
 
@@ -193,8 +193,8 @@ def set_move_init(Lmotor:bytes,Rmotor:bytes,state:bytes) -> Optional[bytes]:
193
193
  move_str[8]=Lmotor
194
194
 
195
195
  response = base_driver.single_operate_sensor(move_str)
196
- if response == -1:
197
- return -1
196
+ if response == None:
197
+ return None
198
198
  else:
199
199
  return 0
200
200
 
smartpi/servo.py CHANGED
@@ -10,10 +10,10 @@ def steer_angle(port:bytes,angle:bytes) -> Optional[bytes]:
10
10
  servo_str[0]=0XA0+port
11
11
  servo_str[4]=angle
12
12
  response = base_driver.single_operate_sensor(servo_str)
13
- if response:
14
- return 0
13
+ if response == None:
14
+ return None
15
15
  else:
16
- return -1
16
+ return 0
17
17
 
18
18
  #С�����ʱ���� port:����P�˿ڣ�angle:�Ƕ�0~270��second:1~256
19
19
  def steer_angle_delay(port:bytes,angle:bytes,second:bytes) -> Optional[bytes]:
@@ -23,10 +23,10 @@ def steer_angle_delay(port:bytes,angle:bytes,second:bytes) -> Optional[bytes]:
23
23
  servo_str[5]=angle%256
24
24
  servo_str[7]=second
25
25
  response = base_driver.single_operate_sensor(servo_str)
26
- if response:
27
- return 0
26
+ if response == None:
27
+ return None
28
28
  else:
29
- return -1
29
+ return 0
30
30
 
31
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]:
@@ -36,10 +36,10 @@ def set_angle_speed(port:bytes,angle:bytes,speed:bytes) -> Optional[bytes]:
36
36
  servo_str[5]=angle%256
37
37
  servo_str[7]=speed
38
38
  response = base_driver.single_operate_sensor(servo_str)
39
- if response:
40
- return 0
39
+ if response == None:
40
+ return None
41
41
  else:
42
- return -1
42
+ return 0
43
43
 
44
44
  #���ֶ��ת�����Ƕ���ʱʱ�� port:����P�˿ڣ�angle:�Ƕ�(0~360)��ms:��ʱʱ��(0~65535)��
45
45
  def set_angle_ms(port:bytes,angle:bytes,ms:int) -> Optional[bytes]:
@@ -50,28 +50,28 @@ def set_angle_ms(port:bytes,angle:bytes,ms:int) -> Optional[bytes]:
50
50
  servo_str[7]=ms//256
51
51
  servo_str[8]=ms%256
52
52
  response = base_driver.single_operate_sensor(servo_str)
53
- if response:
54
- return 0
53
+ if response == None:
54
+ return None
55
55
  else:
56
- return -1
56
+ return 0
57
57
 
58
58
  #���ֶ����λ port:����P�˿ڣ�
59
59
  def set_init(port:bytes) -> Optional[bytes]:
60
60
  servo_str=[0xA0, 0x12, 0x01, 0xBE]
61
61
  servo_str[0]=0XA0+port
62
62
  response = base_driver.single_operate_sensor(servo_str)
63
- if response:
64
- return 0
63
+ if response == None:
64
+ return None
65
65
  else:
66
- return -1
66
+ return 0
67
67
 
68
68
  #��ȡ���ֶ���Ƕ� port:����P�˿ڣ�
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
72
  response = base_driver.single_operate_sensor(servo_str)
73
- if response == -1:
74
- return -1
73
+ if response == None:
74
+ return None
75
75
  else:
76
76
  angle_data=response[4:-1]
77
77
  angle_num=int.from_bytes(angle_data, byteorder='big', signed=True)
@@ -92,10 +92,10 @@ def set_speed(port:bytes,speed:int) -> Optional[bytes]:
92
92
 
93
93
  servo_str[4]=m_par
94
94
  response = base_driver.single_operate_sensor(servo_str)
95
- if response:
96
- return 0
95
+ if response == None:
96
+ return None
97
97
  else:
98
- return -1
98
+ return 0
99
99
 
100
100
  #���ֶ������ת�� port:����P�˿ڣ�code:����(0~65535)��speed:�ٶ�(-100~100)��
101
101
  def set_code_speed(port:bytes,code:int,speed:int) -> Optional[bytes]:
@@ -116,28 +116,28 @@ def set_code_speed(port:bytes,code:int,speed:int) -> Optional[bytes]:
116
116
  servo_str[7]=m_par
117
117
 
118
118
  response = base_driver.single_operate_sensor(servo_str)
119
- if response:
120
- return 0
119
+ if response == None:
120
+ return None
121
121
  else:
122
- return -1
122
+ return 0
123
123
 
124
124
  #���ֶ������ֵ���� port:����P�˿ڣ�
125
125
  def reset_encode(port:bytes) -> Optional[bytes]:
126
126
  servo_str=[0xA0, 0x16, 0x01, 0xBE]
127
127
  servo_str[0]=0XA0+port
128
128
  response = base_driver.single_operate_sensor(servo_str)
129
- if response:
130
- return 0
129
+ if response == None:
130
+ return None
131
131
  else:
132
- return -1
132
+ return 0
133
133
 
134
134
  #��ȡ���ֶ������ֵ port:����P�˿ڣ�
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
138
  response = base_driver.single_operate_sensor(servo_str)
139
- if response == -1:
140
- return -1
139
+ if response == None:
140
+ return None
141
141
  else:
142
142
  code_data=response[4:-1]
143
143
  code_num=int.from_bytes(code_data, byteorder='big', signed=True)
smartpi/temperature.py CHANGED
@@ -10,8 +10,8 @@ def get_value(port:bytes) -> Optional[bytes]:
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 == -1:
14
- return -1
13
+ if response == None:
14
+ return None
15
15
  else:
16
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 == -1:
12
- return -1
11
+ if response == None:
12
+ return None
13
13
  else:
14
14
  return response[4]
15
15
 
smartpi/ultrasonic.py CHANGED
@@ -10,8 +10,8 @@ def get_value(port:bytes) -> Optional[bytes]:
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
13
+ if response == None:
14
+ return None
15
15
  else:
16
16
  distance_data=response[4:-1]
17
17
  distance_num=int.from_bytes(distance_data, byteorder='big', signed=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smartpi
3
- Version: 0.1.10
3
+ Version: 0.1.12
4
4
  Summary: A library use for H2-RCU
5
5
  Author: ZMROBO
6
6
  Classifier: Programming Language :: Python :: 3
@@ -0,0 +1,18 @@
1
+ smartpi/__init__.py,sha256=ynl00MdZK44BRltFscnxPvaQB9vT8qwdufP2vRovzWc,55
2
+ smartpi/base_driver.py,sha256=FmnwZFqKE2HVUsDoqxXigdX1YlElcY07YkLnlvKY_x8,18033
3
+ smartpi/color_sensor.py,sha256=sTqD3jApjmc6qHMrDyEy2UjaRt8vhJZNR88vzgUiLKs,496
4
+ smartpi/cw2015.py,sha256=1lAF-pi_ye_ya1AZQS1sjbgsDf7MThO5IAskKsNGBzA,5695
5
+ smartpi/gui.py,sha256=VuZEhuM3M-Lz12dpzRhcdLxE8p-Hosdq4wa0jAbnnbc,2165
6
+ smartpi/humidity.py,sha256=xtALQ_IlcwR2RCYvopCSmeNajB45kQU_ckk6FZ0rqko,497
7
+ smartpi/led.py,sha256=n3_k1jGcQptfGXhezDLaYzH6UptgluP4Ze6qP_Y4WmU,536
8
+ smartpi/light_sensor.py,sha256=kWmoXklYS1QG0eDz4Qn9FF4WueR3GARb3OwQSkXqUNA,569
9
+ smartpi/motor.py,sha256=uvuAwt2j5LjdLaMfNisXqaGh1ro3fZDvHU8IXd2fn9Q,4527
10
+ smartpi/move.py,sha256=3qzrJCGA-qbsLXBpklY2DErtw0jlzMELzozjhEvRzKs,6028
11
+ smartpi/servo.py,sha256=B6X3yCoEz82qqpUIE5MSO0Eg9YZJ5zDzJEcRpioZpUo,4625
12
+ smartpi/temperature.py,sha256=px2YeqgG63nPkyhJA1wDg3dwYx_oOCYuhMjtsVm_YO0,460
13
+ smartpi/touch_sensor.py,sha256=F6IIQGewNRhC9U1RbHpVzuGYqb8H41lpeQ1Ejwsc_T8,438
14
+ smartpi/ultrasonic.py,sha256=0meczFKXFLUt92kLxipeEc37vb5duvJjPs4kgtlpO8M,622
15
+ smartpi-0.1.12.dist-info/METADATA,sha256=0HdhhFfnoSXNc6LVxBdE-zqiKdxdu1U7x7NxGLcAbcU,311
16
+ smartpi-0.1.12.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
17
+ smartpi-0.1.12.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
18
+ smartpi-0.1.12.dist-info/RECORD,,
@@ -1,18 +0,0 @@
1
- smartpi/__init__.py,sha256=1D37WANsd4B0qjha8w25OFIvYG7gPmSKmAcbsLRRtvo,55
2
- smartpi/base_driver.py,sha256=85buq4rHErH16lYjLPeQi6r4RDIXWztysjPbL7Upm1M,17995
3
- smartpi/color_sensor.py,sha256=IubJb8zd87oWf3qTn07wTHM2vjUADwgSdXUChGgovHw,492
4
- smartpi/cw2015.py,sha256=1lAF-pi_ye_ya1AZQS1sjbgsDf7MThO5IAskKsNGBzA,5695
5
- smartpi/gui.py,sha256=E98_soyWbEf_dwYhXZgMSXrgY5QuYoDTuFCPK63flIQ,2102
6
- smartpi/humidity.py,sha256=-awlSiy7ea6iwtirUMdDAMmmdIgVQZ3D7cDzgXmy314,493
7
- smartpi/led.py,sha256=92SBKjQbg1HN6rtKRH1NNWvAFRBP2-5OUGM9muOvhyQ,526
8
- smartpi/light_sensor.py,sha256=wsW0_ZnKeHN6IWRH3CIybKLdHPVK2I8jSTCqXlUECVk,565
9
- smartpi/motor.py,sha256=vdtLjHSwCodFkqhYh0y3l8RSl7IUlMwdNuktgQ3FdkQ,4449
10
- smartpi/move.py,sha256=51yj4sd3Yllk0jprMKyUtNThP82I8E4HGqpD1eyta3k,5992
11
- smartpi/servo.py,sha256=_eM3ZAcBA543iVyFi8agOAXt0K3LEauxwyq7SFCpygM,4537
12
- smartpi/temperature.py,sha256=JeuiwsV6AUjnFQsQxgvjM3AuBrVvK5DuSE-BbX1Di2s,456
13
- smartpi/touch_sensor.py,sha256=jlKqvcoSmfZzH9zJeafBeVEQhxIYkkzXe4_fifX0COI,434
14
- smartpi/ultrasonic.py,sha256=5MS0EdQNirAl8iZbdwZ63fnjp6axHRZHw6dJwcwuXnQ,618
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,,