smartpi 0.1.2__py3-none-any.whl → 0.1.3__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.2"
3
+ __version__ = "0.1.3"
4
4
 
smartpi/motor.py CHANGED
@@ -14,17 +14,40 @@ from smartpi import base_driver
14
14
  ##############################################################
15
15
 
16
16
  #��������ȡ port:����M�˿ڣ�
17
- def read_motor_code(port:bytes) -> Optional[bytes]:
17
+ def get_motor_encoder(port:bytes) -> Optional[bytes]:
18
18
  motor_str=[0xA0, 0x01, 0x01, 0xBE]
19
19
  motor_str[0]=0XA0+port
20
20
  response = base_driver.single_operate_sensor(motor_str)
21
+ if response:
22
+ code_data=response[4:-1]
23
+ code_num=int.from_bytes(code_data, byteorder='big', signed=True)
24
+ return code_num
25
+ else:
26
+ return -1
27
+
28
+ #����������� port:����M�˿ڣ�
29
+ def reset_motor_encoder(port:bytes) -> Optional[bytes]:
30
+ motor_str=[0xA0, 0x01, 0x03, 0xBE]
31
+ motor_str[0]=0XA0+port
32
+ response = base_driver.single_operate_sensor(motor_str)
33
+ if response:
34
+ return 0
35
+ else:
36
+ return -1
37
+
38
+ #���﷽����� port:����M�˿ڣ�dir:0��1
39
+ def set_motor_direction(port:bytes,direc:bytes) -> Optional[bytes]:
40
+ motor_str=[0xA0, 0x01, 0x06, 0x71, 0x00, 0xBE]
41
+ motor_str[0]=0XA0+port
42
+ motor_str[4]=direc
43
+ response = base_driver.single_operate_sensor(motor_str)
21
44
  if response:
22
45
  return 0
23
46
  else:
24
47
  return -1
25
48
 
26
- #�����ٶȿ��� port:����M�˿ڣ�speed:0~100
27
- def write_motor_speed(port:bytes,speed:bytes) -> Optional[bytes]:
49
+ #�������ٶ�ת�� port:����M�˿ڣ�speed:0~100
50
+ def set_motor(port:bytes,speed:bytes) -> Optional[bytes]:
28
51
  motor_str=[0xA0, 0x01, 0x02, 0x71, 0x00, 0xBE]
29
52
  motor_str[0]=0XA0+port
30
53
  motor_str[4]=speed
@@ -34,27 +57,28 @@ def write_motor_speed(port:bytes,speed:bytes) -> Optional[bytes]:
34
57
  else:
35
58
  return -1
36
59
 
37
- #�����ٶȱ������ port:����M�˿ڣ�speed:0~100��code:0~65535
38
- def motor_servoctl(port:bytes,speed:bytes,code:int) -> Optional[bytes]:
39
- motor_str=[0xA0, 0x01, 0x04, 0x81, 0x00, 0x81, 0x00, 0x00, 0xBE]
60
+ #����ֹͣ port:����M�˿ڣ�speed:0~100
61
+ def set_motor_stop(port:bytes) -> Optional[bytes]:
62
+ motor_str=[0xA0, 0x01, 0x0B, 0xBE]
40
63
  motor_str[0]=0XA0+port
41
- motor_str[4]=speed
42
- motor_str[6]=code//256
43
- motor_str[7]=code%256
44
64
  response = base_driver.single_operate_sensor(motor_str)
45
65
  if response:
46
66
  return 0
47
67
  else:
48
68
  return -1
49
69
 
50
- #���﷽����� port:����M�˿ڣ�dir:
51
- def write_motor_dir(port:bytes,direc:bytes) -> Optional[bytes]:
52
- motor_str=[0xA0, 0x01, 0x06, 0x71, 0x00, 0xBE]
70
+ #���������� port:����M�˿ڣ�speed:0~100��code:0~65535
71
+ def motor_servoctl(port:bytes,speed:bytes,code:int) -> Optional[bytes]:
72
+ motor_str=[0xA0, 0x01, 0x04, 0x81, 0x00, 0x81, 0x00, 0x00, 0xBE]
53
73
  motor_str[0]=0XA0+port
54
- motor_str[4]=direc
74
+ motor_str[4]=speed
75
+ motor_str[6]=code//256
76
+ motor_str[7]=code%256
55
77
  response = base_driver.single_operate_sensor(motor_str)
56
78
  if response:
57
79
  return 0
58
80
  else:
59
81
  return -1
82
+
83
+
60
84
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smartpi
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: A library use for H2-RCU
5
5
  Author-email: Driver_cai <1547363120@qq.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,11 +1,11 @@
1
1
  smartpi/GUI.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- smartpi/__init__.py,sha256=xdzDVGW4Uw7PG44QR4hHh12hTBDzyxg6RujH2fQAjnM,54
2
+ smartpi/__init__.py,sha256=4UycFLLmMwwRxajcaSr0T68R5vTZc35EXNWL9NN2hsc,54
3
3
  smartpi/base_driver.py,sha256=EIJp-H02io5S09u7oQTxV8plIfCcf9yvFUxhwVPF0zc,17197
4
4
  smartpi/color_sensor.py,sha256=COa4bh_yrcBMJbb-iFCf4k5fNwfEdpYvPdTbIwFis4M,101
5
5
  smartpi/humidity.py,sha256=CJVjulD4Gk_c9iwy4zmaGLv-Ta6M00koDmR2qfahkZ4,446
6
6
  smartpi/led.py,sha256=f8K7ebHFy9kIlCLWKEyQbmPQv4z2TMTNGs1vaKOtMAs,495
7
7
  smartpi/light_sensor.py,sha256=PHonOg7d3POjZnB6uETHeOQk8dWszxNoMfn6u9Tl1ow,726
8
- smartpi/motor.py,sha256=NPzDZ1kVpBu30JOntjcIqr8XslFu6nRehj31MROLCOY,1942
8
+ smartpi/motor.py,sha256=NhV4xNCVTgENKji4pBmq0K1wxr_qQgJySYiReC3e1lM,2688
9
9
  smartpi/move.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  smartpi/photosensitive.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  smartpi/servo.py,sha256=uoitiCWzh4dnfztpXXo5ABkGF-a3qdvXMxjlIBZZQaU,783
@@ -13,7 +13,7 @@ smartpi/temperature.py,sha256=p89_AYIeEQsF7UKKnTexOCIRNXipYKKZWrULqjKeMLM,426
13
13
  smartpi/touch_sensor.py,sha256=MyzghSoTkwAGp2_uNemYKRu9zeR3A2PeW3f0S8su3SI,386
14
14
  smartpi/trace.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  smartpi/ultrasonic.py,sha256=xdSZe6uyihbfaBLiGmFahKYXTsOgVailMyq5ZYHrlFU,768
16
- smartpi-0.1.2.dist-info/METADATA,sha256=mTtF5nXDibfCDSOUZuDgkzFOGrWneydBRDMIk0-4XnI,340
17
- smartpi-0.1.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
18
- smartpi-0.1.2.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
19
- smartpi-0.1.2.dist-info/RECORD,,
16
+ smartpi-0.1.3.dist-info/METADATA,sha256=b7bLyKyuslaR_vecXKPVVjUl4rToY3XaJ2Txi4hiyTk,340
17
+ smartpi-0.1.3.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
18
+ smartpi-0.1.3.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
19
+ smartpi-0.1.3.dist-info/RECORD,,