api/builtins/Motor: separate methods for stop

stop(Stop.COAST)
stop(Stop.BRAKE)
stop(Stop.HOLD)

becomes

stop()
brake()
hold()

This is easier to type and remember.
This commit is contained in:
Laurens Valk
2020-03-17 15:19:55 +01:00
parent 1c576d5b11
commit 1158e4e45a
4 changed files with 31 additions and 20 deletions
+7 -1
View File
@@ -18,10 +18,16 @@ Motor
.. automethod:: pybricks.ev3devices.Motor.reset_angle
.. rubric:: Action
.. rubric:: Stopping
.. automethod:: pybricks.ev3devices.Motor.stop
.. automethod:: pybricks.ev3devices.Motor.brake
.. automethod:: pybricks.ev3devices.Motor.hold
.. rubric:: Action
.. automethod:: pybricks.ev3devices.Motor.run
.. automethod:: pybricks.ev3devices.Motor.run_time
+10 -1
View File
@@ -17,6 +17,9 @@ Motors without Rotation Sensors
.. automethod:: pybricks.builtins.DCMotor.stop
:noindex:
.. automethod:: pybricks.builtins.DCMotor.brake
:noindex:
Motors with Rotation Sensors
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -32,10 +35,16 @@ Motors with Rotation Sensors
.. automethod:: pybricks.pupdevices.Motor.reset_angle
.. rubric:: Action
.. rubric:: Stopping
.. automethod:: pybricks.pupdevices.Motor.stop
.. automethod:: pybricks.pupdevices.Motor.brake
.. automethod:: pybricks.pupdevices.Motor.hold
.. rubric:: Action
.. automethod:: pybricks.pupdevices.Motor.run
.. automethod:: pybricks.pupdevices.Motor.run_time
+12 -11
View File
@@ -30,12 +30,17 @@ class DCMotor:
"""
pass
def stop(self, stop_type=Stop.COAST):
"""Stop the motor.
def stop(self):
"""Stop the motor and let it spin freely.
Arguments:
stop_type (Stop): Whether to coast or brake the motor.
"""
The motor gradually stops due to friction."""
pass
def brake(self):
"""Passively brake the motor.
The motor stops due to friction, plus the voltage that
is generated while the motor is still moving."""
pass
@@ -194,12 +199,8 @@ class Motor(DCMotor):
"""
pass
def stop(self, stop_type=Stop.COAST):
"""Stop the motor.
Arguments:
stop_type (Stop): Whether to coast, brake, or hold.
"""
def hold(self):
"""Stop the motor and actively hold it at its current angle."""
pass
def run(self, speed):
+2 -7
View File
@@ -3,7 +3,6 @@
"""Robotics module for the Pybricks API."""
from .parameters import Stop
from .builtins import Control
@@ -46,12 +45,8 @@ class DriveBase:
"""
pass
def stop(self, stop_type=Stop.COAST):
"""Stop the robot.
Arguments:
stop_type (Stop): Whether to coast, brake, or hold.
"""
def stop(self):
"""Stop the robot by coasting the motors."""
pass
def distance(self):