Skip to content

Commit e561e50

Browse files
hlym123lbuque
authored andcommitted
libs/base: Add Chinese documentation support.
Signed-off-by: hlym123 <[email protected]>
1 parent 14aba81 commit e561e50

File tree

5 files changed

+615
-231
lines changed

5 files changed

+615
-231
lines changed

docs/en/base/motion.rst

Lines changed: 188 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Motion Base
2-
===========
2+
============================
3+
4+
.. sku: A090
35
46
.. include:: ../refs/base.motion.ref
57

@@ -9,162 +11,266 @@ Atomic Motion Base v1.1 adds INA226 to implement current and voltage detection.
911

1012
Support the following products:
1113

12-
|Motion|
14+
|Motion|
15+
16+
|Motion Base v1.1|
17+
18+
19+
UiFlow2 Example:
20+
--------------------------
21+
22+
Motion Base
23+
^^^^^^^^^^^^^^^^^^^^^^^^
24+
25+
Open the |atoms3_lite_motion_base_example.m5f2| project in UiFlow2.
26+
27+
This example controls the servo to rotate to a specified angle and sets the motor to rotate.
28+
29+
UiFlow2 Code Block:
30+
31+
|example.png|
32+
33+
Example output:
34+
35+
None
36+
37+
Motion Base v1.1
38+
^^^^^^^^^^^^^^^^^^^^^^^^
1339

14-
|Motion Base v1.1|
40+
Open the |atoms3_motion_base_v1.1_example.m5f2| project in UiFlow2.
1541

42+
The example program switches the motor's running speed when the screen button is pressed, and the screen displays the current, voltage, and power.
1643

17-
Micropython Example:
18-
----------------------------
44+
UiFlow2 Code Block:
45+
46+
|motion_base_v1.1_example.png|
47+
48+
Example output:
49+
50+
None
51+
52+
MicroPython Example:
53+
--------------------------
1954

2055
Motion Base
21-
++++++++++++++++++++++++++++
56+
^^^^^^^^^^^^^^^^^^^^^^^^
57+
58+
This example controls the servo to rotate to a specified angle and sets the motor to rotate.
59+
60+
MicroPython Code Block:
2261

2362
.. literalinclude:: ../../../examples/base/motion/atoms3_lite_motion_base_example.py
2463
:language: python
2564
:linenos:
2665

66+
Example output:
67+
68+
None
69+
2770
Motion Base v1.1
28-
++++++++++++++++++++++++++++
71+
^^^^^^^^^^^^^^^^^^^^^^^^
72+
73+
The example program switches the motor's running speed when the screen button is pressed, and the screen displays the current, voltage, and power.
74+
75+
MicroPython Code Block:
2976

3077
.. literalinclude:: ../../../examples/base/motion/atoms3_motion_base_v1.1_example.py
3178
:language: python
3279
:linenos:
3380

34-
UIFlow2.0 Example:
35-
----------------------------
81+
Example output:
3682

37-
Motion Base
38-
++++++++++++++++++++++++++++
83+
None
3984

40-
|example.png|
4185

42-
.. only:: builder_html
86+
**API**
87+
--------------------------
4388

44-
|atoms3_lite_motion_base_example.m5f2|
89+
Motion
90+
^^^^^^^^^^^^^^^^^^^^^^^^
4591

46-
Motion Base v1.1
47-
++++++++++++++++++++++++++++
92+
.. class:: base.motion.Motion(i2c, address=0x38)
4893

49-
|motion_base_v1.1_example.png|
94+
Create an Motion object.
95+
96+
:param I2C i2c: The I2C port to use.
97+
:param int address: The device address. Default is 0x38.
5098

51-
.. only:: builder_html
99+
UiFlow2 Code Block:
52100

53-
|atoms3_motion_base_v1.1_example.m5f2|
101+
|__init__.png|
54102

103+
MicroPython Code Block:
55104

56-
class Motion
57-
------------
105+
.. code-block:: python
58106
59-
Constructors
60-
-------------
107+
from base import Motion
108+
from machine import I2C
61109
62-
.. method:: Motion(i2c, address)
110+
i2c0 = I2C(0, scl=Pin(39), sda=Pin(38), freq=100000)
111+
motion = Motion(i2c0, 0x38)
63112
64-
Initialize the Servo8.
113+
.. method:: get_servo_angle(ch)
65114

66-
- ``i2c``: I2C port to use.
67-
- ``address``: I2C address of the servo8.
115+
Get the angle of the servo.
68116

69-
UIFlow2.0:
117+
:param int ch: The servo channel. Range: 1~4.
118+
:returns: Specify the servo angle for the specified channel. Range: 0~180.
119+
:rtype: int
70120

71-
|__init__.png|
121+
UiFlow2 Code Block:
122+
123+
|get_servo_angle.png|
124+
125+
MicroPython Code Block:
126+
127+
.. code-block:: python
128+
129+
motion.get_servo_angle()
130+
131+
.. method:: set_servo_angle(ch, angle)
132+
133+
Set the angle of the servo.
134+
135+
:param int ch: The servo channel. Range: 1~4.
136+
:param int angle: The servo angle. Range: 0~180.
137+
138+
UiFlow2 Code Block:
139+
140+
|set_servo_angle.png|
141+
142+
MicroPython Code Block:
143+
144+
.. code-block:: python
145+
146+
motion.set_servo_angle()
147+
148+
.. method:: get_servo_pulse(ch)
149+
150+
Get the pulse of the servo.
151+
152+
:param int ch: The servo channel. Range: 1~4.
153+
:returns: Specify the servo pulse for the specified channel. Range: 500~2500.
154+
:rtype: int
155+
156+
UiFlow2 Code Block:
157+
158+
|get_servo_pulse.png|
159+
160+
MicroPython Code Block:
161+
162+
.. code-block:: python
163+
164+
motion.get_servo_pulse()
165+
166+
.. method:: write_servo_pulse(ch, pulse)
167+
168+
Write the pulse of the servo.
169+
170+
:param int ch: The servo channel. Range: 1~4.
171+
:param int pulse: The servo pulse. Range: 500~2500.
172+
173+
UiFlow2 Code Block:
72174

73-
Methods
74-
-------
175+
|write_servo_pulse.png|
75176

76-
.. method:: Motion.get_servo_angle(ch)
177+
MicroPython Code Block:
77178

78-
Get the angle of the servo.
179+
.. code-block:: python
79180
80-
- ``ch``: Servo channel (1 to 4).
181+
motion.write_servo_pulse()
81182
82-
UIFlow2.0:
183+
.. method:: get_motor_speed(ch)
83184

84-
|get_servo_angle.png|
185+
Get the speed of the motor.
85186

86-
.. method:: Motion.set_servo_angle(ch, angle)
187+
:param int ch: The motor channel. Range: 1~2.
188+
:returns: Specify the speed for the specified channel. Range: -127~127.
189+
:rtype: int
87190

88-
Set the angle of the servo.
191+
UiFlow2 Code Block:
89192

90-
- ``ch``: Servo channel (1 to 4).
91-
- ``angle``: Angle of the servo (0 to 180).
193+
|get_motor_speed.png|
92194

93-
UIFlow2.0:
195+
MicroPython Code Block:
94196

95-
|set_servo_angle.png|
197+
.. code-block:: python
96198
97-
.. method:: Motion.get_servo_pulse(ch)
199+
motion.get_motor_speed()
98200
99-
Get the pulse width of the servo.
201+
.. method:: set_motor_speed(ch, speed)
100202

101-
- ``ch``: Servo channel (1 to 4).
203+
Set motor speed.
102204

103-
UIFlow2.0:
205+
:param int ch: The motor channel. Range: 1~2.
206+
:param int speed: The motor speed. Range: -127~127.
104207

105-
|get_servo_pulse.png|
208+
UiFlow2 Code Block:
106209

107-
.. method:: Motion.write_servo_pulse(ch, pulse)
210+
|set_motor_speed.png|
108211

109-
Set the pulse width of the servo.
212+
MicroPython Code Block:
110213

111-
- ``ch``: Servo channel (1 to 4).
112-
- ``pulse``: Pulse width of the servo (500 to 2500).
214+
.. code-block:: python
113215
114-
UIFlow2.0:
216+
motion.set_motor_speed()
115217
116-
|write_servo_pulse.png|
218+
.. method:: read_voltage()
117219

118-
.. method:: Motion.get_motor_speed(ch)
220+
Read voltage (unit: V).
119221

120-
Get the speed of the motor.
222+
:returns: The voltage value in volts.
223+
:rtype: float
121224

122-
- ``ch``: Motor channel (1 or 2).
225+
.. note::
226+
This method is supported only on Motion Base v1.1 and later versions.
123227

124-
UIFlow2.0:
228+
UiFlow2 Code Block:
125229

126-
|get_motor_speed.png|
230+
|read_voltage.png|
127231

128-
.. method:: Motion.set_motor_speed(ch, speed)
232+
MicroPython Code Block:
129233

130-
Set the speed of the motor.
234+
.. code-block:: python
131235
132-
- ``ch``: Motor channel (1 or 2).
133-
- ``speed``: Speed of the motor (-127 to 127).
236+
motion.read_voltage()
134237
135-
UIFLOW2:
238+
.. method:: read_current()
136239

137-
|set_motor_speed.png|
240+
Read current (unit: A).
138241

139-
.. method:: Motion.read_voltage() -> float
242+
:returns: The current value in amperes.
243+
:rtype: float
140244

141-
Read voltage (unit: V)
245+
.. note::
246+
This method is supported only on Motion Base v1.1 and later versions.
142247

143-
.. note::
144-
This method is supported only on Motion Base v1.1 and later versions.
248+
UiFlow2 Code Block:
145249

146-
UIFlow2.0
250+
|read_current.png|
147251

148-
|read_voltage.png|
252+
MicroPython Code Block:
149253

150-
.. method:: Motion.read_current() -> float
254+
.. code-block:: python
151255
152-
Read voltage (unit: A)
256+
motion.read_current()
153257
154-
.. note::
155-
This method is supported only on Motion Base v1.1 and later versions.
258+
.. method:: read_power()
156259

157-
UIFlow2.0
260+
Read power (unit: W).
158261

159-
|read_current.png|
262+
:returns: The power value in watts.
263+
:rtype: float
160264

161-
.. method:: Motion.read_power() -> float
265+
.. note::
266+
This method is supported only on Motion Base v1.1 and later versions.
267+
268+
UiFlow2 Code Block:
162269

163-
Read power (unit: W)
270+
|read_power.png|
164271

165-
.. note::
166-
This method is supported only on Motion Base v1.1 and later versions.
272+
MicroPython Code Block:
167273

168-
UIFlow2.0
274+
.. code-block:: python
169275
170-
|read_power.png|
276+
motion.read_power()

docs/en/refs/base.motion.ref

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
:height: 200px
55
:width: 200px
66

7+
.. |Motion Base v1.1| image:: https://static-cdn.m5stack.com/resource/docs/products/atom/Atomic%20Motion%20Base/img-40a0d2ba-04b3-4aa3-8417-0624762b3cc3.webp
8+
:target: https://docs.m5stack.com/en/atom/Atomic%20Motion%20Base
9+
:height: 200px
10+
:width: 200px
11+
712
.. |__init__.png| image:: https://static-cdn.m5stack.com/mpy_docs/base/motion/init.png
813
.. |get_servo_angle.png| image:: https://static-cdn.m5stack.com/mpy_docs/base/motion/get_servo_angle.png
914
.. |set_servo_angle.png| image:: https://static-cdn.m5stack.com/mpy_docs/base/motion/set_servo_angle.png
@@ -12,7 +17,7 @@
1217
.. |get_motor_speed.png| image:: https://static-cdn.m5stack.com/mpy_docs/base/motion/get_motor_speed.png
1318
.. |set_motor_speed.png| image:: https://static-cdn.m5stack.com/mpy_docs/base/motion/set_motor_speed.png
1419
.. |read_voltage.png| image:: https://static-cdn.m5stack.com/mpy_docs/base/motion/read_voltage.png
15-
.. |read_voltage.png| image:: https://static-cdn.m5stack.com/mpy_docs/base/motion/read_current.png
20+
.. |read_current.png| image:: https://static-cdn.m5stack.com/mpy_docs/base/motion/read_current.png
1621
.. |read_power.png| image:: https://static-cdn.m5stack.com/mpy_docs/base/motion/read_power.png
1722

1823
.. |example.png| image:: https://static-cdn.m5stack.com/mpy_docs/base/motion/example.png

0 commit comments

Comments
 (0)