From 8acab1898a395aadcb7c72bc62b1fb5b04fc659e Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Mon, 9 Dec 2019 14:31:53 +0100 Subject: [PATCH] doc: delete existing inline examples Those should be included as working and tested Python files instead. They should be toggled on/off. --- doc/api/ev3devices.rst | 8 ---- doc/api/hubs_cityhub.inc | 14 ------- doc/api/hubs_ev3brick.inc | 84 --------------------------------------- doc/api/hubs_movehub.inc | 14 ------- doc/api/media.rst | 15 +------ doc/api/motors.rst | 53 ------------------------ doc/api/pupdevices.rst | 8 ---- doc/api/robotics.rst | 31 --------------- doc/api/tools.rst | 8 ---- 9 files changed, 1 insertion(+), 234 deletions(-) diff --git a/doc/api/ev3devices.rst b/doc/api/ev3devices.rst index 7a51bb2..7449fec 100644 --- a/doc/api/ev3devices.rst +++ b/doc/api/ev3devices.rst @@ -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: diff --git a/doc/api/hubs_cityhub.inc b/doc/api/hubs_cityhub.inc index 2d55564..eaf609c 100644 --- a/doc/api/hubs_cityhub.inc +++ b/doc/api/hubs_cityhub.inc @@ -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 diff --git a/doc/api/hubs_ev3brick.inc b/doc/api/hubs_ev3brick.inc index 6a668c4..ccd2d9a 100644 --- a/doc/api/hubs_ev3brick.inc +++ b/doc/api/hubs_ev3brick.inc @@ -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 diff --git a/doc/api/hubs_movehub.inc b/doc/api/hubs_movehub.inc index 79d3660..00e6d2b 100644 --- a/doc/api/hubs_movehub.inc +++ b/doc/api/hubs_movehub.inc @@ -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 diff --git a/doc/api/media.rst b/doc/api/media.rst index 0ed902b..4b44337 100644 --- a/doc/api/media.rst +++ b/doc/api/media.rst @@ -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: diff --git a/doc/api/motors.rst b/doc/api/motors.rst index b13187f..a2d2ade 100644 --- a/doc/api/motors.rst +++ b/doc/api/motors.rst @@ -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 diff --git a/doc/api/pupdevices.rst b/doc/api/pupdevices.rst index 2f671ac..b343f78 100644 --- a/doc/api/pupdevices.rst +++ b/doc/api/pupdevices.rst @@ -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 diff --git a/doc/api/robotics.rst b/doc/api/robotics.rst index 4dce83e..fbc4fbb 100644 --- a/doc/api/robotics.rst +++ b/doc/api/robotics.rst @@ -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 diff --git a/doc/api/tools.rst b/doc/api/tools.rst index f048d6b..6c5adb0 100644 --- a/doc/api/tools.rst +++ b/doc/api/tools.rst @@ -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