doc/pupdevices/motor: split examples

Now that each device is on its own page, we no longer need to collapse snippets to reduce page size. Now they can just all be at the bottom of the page. This also gives each a dedicated link which is easier when giving support.
This commit is contained in:
Laurens Valk
2020-12-29 14:35:07 +01:00
parent 2375a1abcb
commit 4e2aec6c35
2 changed files with 117 additions and 96 deletions
+21 -18
View File
@@ -11,24 +11,6 @@ Motors without Rotation Sensors
Powered Up motors without rotation sensors. The arrows indicate the default
positive direction.
.. toggle-header::
:header: **Show/hide examples**
**Example 1: Making the motor move back and forth**
.. literalinclude::
../../../examples/pup/motor_dc/motor_dc_init_basic.py
**Example 2: Setting the positive direction as counterclockwise**
.. literalinclude::
../../../examples/pup/motor_dc/motor_dc_init_direction.py
**Example 3: Starting and stopping**
.. literalinclude::
../../../examples/pup/motor_dc/motor_dc_stop.py
.. autoclass:: pybricks._common.DCMotor
:noindex:
:no-members:
@@ -41,3 +23,24 @@ Motors without Rotation Sensors
.. automethod:: pybricks._common.DCMotor.brake
:noindex:
Examples
-------------------
Making the motor move back and forth
************************************
.. literalinclude::
../../../examples/pup/motor_dc/motor_dc_init_basic.py
Changing the positive direction
*******************************
.. literalinclude::
../../../examples/pup/motor_dc/motor_dc_init_direction.py
Starting and stopping
*********************
.. literalinclude::
../../../examples/pup/motor_dc/motor_dc_stop.py
+96 -78
View File
@@ -16,44 +16,8 @@ Motors with Rotation Sensors
:noindex:
:no-members:
.. toggle-header::
:header: **Show/hide examples**
**Example 1: Making the motor move back and forth**
.. literalinclude::
../../../examples/pup/motor/motor_init_basic.py
**Example 2: Using more than one motor**
.. literalinclude::
../../../examples/pup/motor/motor_init_multiple.py
**Example 3: Setting the positive direction as counterclockwise**
.. literalinclude::
../../../examples/pup/motor/motor_init_direction.py
**Example 4: Using gears**
.. literalinclude::
../../../examples/pup/motor/motor_init_gears.py
.. rubric:: Measuring
.. toggle-header::
:header: **Show/hide examples**
**Example 1: Measuring the angle and speed**
.. literalinclude::
../../../examples/pup/motor/motor_measure.py
**Example 2: Resetting the measured angle**
.. literalinclude::
../../../examples/pup/motor/motor_reset_angle.py
.. automethod:: pybricks.pupdevices.Motor.speed
.. automethod:: pybricks.pupdevices.Motor.angle
@@ -62,14 +26,6 @@ Motors with Rotation Sensors
.. rubric:: Stopping
.. toggle-header::
:header: **Show/hide example**
**Example: Stopping the motor in different ways**
.. literalinclude::
../../../examples/pup/motor/motor_stop.py
.. automethod:: pybricks.pupdevices.Motor.stop
.. automethod:: pybricks.pupdevices.Motor.brake
@@ -78,40 +34,6 @@ Motors with Rotation Sensors
.. rubric:: Action
.. toggle-header::
:header: **Show/hide examples**
**Example 1: Basic usage of all action methods**
.. literalinclude::
../../../examples/pup/motor/motor_action_basic.py
**Example 2: Using the** ``then`` **argument to change how a motor stops**
.. literalinclude::
../../../examples/pup/motor/motor_action_then.py
**Example 3: Using the** ``wait`` **argument to run motors in parallel**
.. literalinclude::
../../../examples/pup/motor/motor_action_wait.py
**Example 4: Waiting for two actions to complete in parallel**
.. literalinclude::
../../../examples/pup/motor/motor_action_wait_advanced.py
**Example 5: Running a motor until a mechanical endpoint**
.. literalinclude::
../../../examples/pup/motor/motor_until_stalled.py
**Example 6: Centering a steering mechanism**
.. literalinclude::
../../../examples/pup/motor/motor_until_stalled.py
.. automethod:: pybricks.pupdevices.Motor.run
.. automethod:: pybricks.pupdevices.Motor.run_time
@@ -134,3 +56,99 @@ Motors with Rotation Sensors
.. FIXME: above should point to pupdevices but inherited class attributes
do not work yet (https://github.com/sphinx-doc/sphinx/issues/741).
Initialization Examples
-----------------------
Making the motor move back and forth
*******************************************************
.. literalinclude::
../../../examples/pup/motor/motor_init_basic.py
Initializing multiple motors
*******************************************************
.. literalinclude::
../../../examples/pup/motor/motor_init_multiple.py
Setting the positive direction as counterclockwise
*******************************************************
.. literalinclude::
../../../examples/pup/motor/motor_init_direction.py
Using gears
*******************************************************
.. literalinclude::
../../../examples/pup/motor/motor_init_gears.py
Measurement Examples
-----------------------
Measuring the angle and speed
*******************************************************
.. literalinclude::
../../../examples/pup/motor/motor_measure.py
Resetting the measured angle
*******************************************************
.. literalinclude::
../../../examples/pup/motor/motor_reset_angle.py
Movement Examples
-----------------------
Basic usage of all run methods
*******************************************************
.. literalinclude::
../../../examples/pup/motor/motor_action_basic.py
Stopping ongoing movements in different ways
*******************************************************
.. literalinclude::
../../../examples/pup/motor/motor_stop.py
Using the ``then`` argument to change how a run command stops
*************************************************************
.. literalinclude::
../../../examples/pup/motor/motor_action_then.py
Stall Examples
-----------------------
Running a motor until a mechanical endpoint
*******************************************************
.. literalinclude::
../../../examples/pup/motor/motor_until_stalled.py
Centering a steering mechanism
*******************************************************
.. literalinclude::
../../../examples/pup/motor/motor_until_stalled.py
Parallel Movement Examples
--------------------------
Using the ``wait`` argument to run motors in parallel
*********************************************************
.. literalinclude::
../../../examples/pup/motor/motor_action_wait.py
Waiting for two parallel actions to complete
*******************************************************
.. literalinclude::
../../../examples/pup/motor/motor_action_wait_advanced.py