doc: delete existing inline examples

Those should be included as working and tested Python files instead. They should be toggled on/off.
This commit is contained in:
Laurens Valk
2019-12-09 14:31:53 +01:00
parent 893b23ce90
commit 8acab1898a
9 changed files with 1 additions and 234 deletions
-8
View File
@@ -11,14 +11,6 @@ Motor
:noindex:
:no-members:
Example::
# Initialize a motor.
example_motor = Motor(Port.A)
# Initialize a motor with positive speed as counterclockwise
right_motor = Motor(Port.B, Direction.COUNTERCLOCKWISE)
.. automethod:: pybricks._instances.Motor.angle
:noindex:
-14
View File
@@ -14,20 +14,6 @@
.. automethod:: pybricks._instances.light.off
Example::
# Initialize CityHub at the top of your script
hub = CityHub()
# Make the light red
hub.light.on(Color.RED)
# Wait
wait(1000)
# Turn the light off
hub.light.off()
.. rubric:: Using the battery
.. automethod:: pybricks._instances.battery.voltage
-84
View File
@@ -13,75 +13,20 @@
.. automethod:: pybricks._instances.buttons.pressed
Example::
# Initialize EV3 at the top of your script
brick = EV3Brick()
# Wait until any of the buttons are pressed
while not any(brick.buttons.pressed()):
wait(10)
# Do something if the left button is pressed
if Button.LEFT in brick.buttons.pressed():
print("The left button is pressed.")
# Wait until all buttons are released
while any(brick.buttons.pressed()):
wait(10)
.. rubric:: Using the brick status light
.. automethod:: pybricks._instances.light.on
.. automethod:: pybricks._instances.light.off
Example::
# Initialize EV3 at the top of your script
brick = EV3Brick()
# Make the light red
brick.light.on(Color.RED)
# Wait
wait(1000)
# Turn the light off
brick.light.off()
.. rubric:: Using the speaker
.. automethod:: pybricks._instances.speaker.volume
.. automethod:: pybricks._instances.speaker.beep
Example::
# Initialize EV3 at the top of your script
ev3 = EV3Brick()
# A simple beep
ev3.speaker.beep()
# A high pitch (1500 Hz) for one second (1000 ms)
ev3.speaker.beep(1500, 1000)
.. automethod:: pybricks._instances.speaker.play
Example::
# Initialize EV3 at the top of your script
ev3 = EV3Brick()
# Play one of the built-in sounds
ev3.speaker.play(SoundFile.HELLO)
# Play a sound file from your project folder
ev3.speaker.play('mysound.wav')
.. todo:: The following functionality is not yet implemented
.. automethod:: pybricks._instances.speaker.say
@@ -113,37 +58,8 @@
.. .. automethod:: pybricks._instances.display.text
Example::
# Initialize EV3 at the top of your script
brick = EV3Brick()
# Clear the display
brick.display.clear()
# Print ``Hello`` near the middle of the screen
brick.display.text("Hello", (60, 50))
# Print ``World`` directly underneath it
brick.display.text("World")
.. .. automethod:: pybricks._instances.display.image
Example::
# Initialize EV3 at the top of your script
brick = EV3Brick()
# Show a built-in image of two eyes looking upward
brick.display.image(ImageFile.UP)
# Display a custom image from your project folder
brick.display.image('pybricks.png')
# Display a custom image at the top right of the screen,
# without clearing the screen first
brick.display.image('arrow.png', Align.TOP_RIGHT, clear=False)
.. rubric:: Using the battery
.. automethod:: pybricks._instances.battery.voltage
-14
View File
@@ -13,20 +13,6 @@
.. automethod:: pybricks._instances.light.off
Example::
# Initialize MoveHub at the top of your script
hub = MoveHub()
# Make the light red
hub.light.on(Color.RED)
# Wait
wait(1000)
# Turn the light off
hub.light.off()
.. rubric:: Using the battery
.. automethod:: pybricks._instances.battery.voltage
+1 -14
View File
@@ -7,20 +7,7 @@ folder. You can also use any of the images and sounds built into Pybricks.
ev3dev
------
These images and sounds are only available for Pybricks on ev3dev. Example::
# Imports
from pybricks.hubs import EV3Brick
from pybricks.media.ev3dev import SoundFile, ImageFile
# Initialize the EV3 brick
brick = EV3Brick()
# Show an image file
brick.display.image(ImageFile.AWAKE)
# Play a sound file
brick.speaker.file(SoundFile.HELLO)
These images and sounds are only available for Pybricks on ev3dev.
.. autoclass:: pybricks.media.ev3dev.ImageFile
:no-members:
-53
View File
@@ -7,22 +7,6 @@ The Motor Class
.. autoclass:: pybricks.builtins.Motor
:no-members:
Example::
# Initialize a motor with default settings.
example_motor = Motor(Port.A)
# Initialize a motor with positive speed as counterclockwise.
right_motor = Motor(Port.B, Direction.COUNTERCLOCKWISE)
# Initialize a motor with a gear train, consisting of a 12-tooth gear
# and a 36-tooth gear. This normally slows down your output axle by a
# factor 3. But when you specify gears like this, the motor will
# compensate for them. For example, `robot_arm.run_angle(200, 90)` will
# now make the motor move faster and farther so that your output axle
# will still turn at the desired 200 deg/s for 90 degrees.
robot_arm = Motor(Port.C, Direction.CLOCKWISE, gears=[12, 36])
.. rubric:: Measuring
.. automethod:: pybricks.builtins.Motor.speed
@@ -47,53 +31,16 @@ The Motor Class
.. automethod:: pybricks.builtins.Motor.dc
Example::
# Set the motor duty cycle to 75%.
example_motor.duty(75)
.. rubric:: Moving the motor (advanced)
.. automethod:: pybricks.builtins.Motor.track_target
Example::
# Initialize motor and timer
from math import sin
motor = Motor(Port.A)
watch = StopWatch()
amplitude = 90
# In a fast loop, compute a reference angle
# and make the motor track it.
while True:
# Get the time in seconds
seconds = watch.time()/1000
# Compute a reference angle. This produces
# a sine wave that makes the motor move
# smoothly between -90 and +90 degrees.
angle_now = sin(seconds)*amplitude
# Make the motor track the given angle
motor.track_target(angle_now)
.. automethod:: pybricks.builtins.Motor.run_until_stalled
.. rubric:: Changing motor settings
.. automethod:: pybricks.builtins.Motor.set_run_settings
Example::
# Set the maximum speed to 200 deg/s and
# acceleration to 400 deg/s/s.
example_motor.set_run_settings(200, 400)
# Make the motor run for 5 seconds. Even though the
# speed argument is 300 deg/s in this example, the
# motor will move at only 200 deg/s because of
# the settings above.
example_motor.run_time(300, 5000)
.. automethod:: pybricks.builtins.Motor.set_dc_settings
.. automethod:: pybricks.builtins.Motor.set_pid_settings
-8
View File
@@ -11,14 +11,6 @@ Motor
:noindex:
:no-members:
Example::
# Initialize a motor.
example_motor = Motor(Port.A)
# Initialize a motor with positive speed as counterclockwise
right_motor = Motor(Port.B, Direction.COUNTERCLOCKWISE)
.. rubric:: Methods for motors with rotation sensors
.. automethod:: pybricks._instances.Motor.angle
-31
View File
@@ -8,39 +8,8 @@
.. autoclass:: pybricks.robotics.DriveBase
:no-members:
Example::
# Initialize two motors and a drive base
left = Motor(Port.B)
right = Motor(Port.C)
robot = DriveBase(left, right, 56, 114)
.. automethod:: pybricks.robotics.DriveBase.drive
Example::
# Initialize two motors and a drive base
left = Motor(Port.B)
right = Motor(Port.C)
robot = DriveBase(left, right, 56, 114)
# Initialize a sensor
sensor = UltrasonicSensor(Port.S4)
# Drive forward until an object is detected
robot.drive(100, 0)
while sensor.distance() > 500:
wait(10)
robot.stop()
.. automethod:: pybricks.robotics.DriveBase.drive_time
Example::
# Drive forward at 100 mm/s for two seconds
robot.drive_time(100, 0, 2000)
# Turn at 45 deg/s for three seconds
robot.drive_time(0, 45, 3000)
.. automethod:: pybricks.robotics.DriveBase.stop
-8
View File
@@ -6,14 +6,6 @@
.. autofunction:: print
Example::
# Print some text
print("Hello, world")
# Print some text and a number
print("Value:", 5)
.. autofunction:: wait
.. autoclass:: pybricks.tools.StopWatch