api/doc: pybricks is a package

This commit is contained in:
Laurens Valk
2019-06-05 12:47:24 +02:00
parent 727507d66d
commit 28a5329bb6
19 changed files with 122 additions and 122 deletions
+2 -2
View File
@@ -19,9 +19,9 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('../../pybricks'))
sys.path.insert(0, os.path.abspath('..'))
import _version # noqa E402
from pybricks import _version # noqa E402
# ON_RTD is whether we are on readthedocs.org
# this line of code grabbed from docs.readthedocs.org
+13 -13
View File
@@ -1,14 +1,14 @@
:mod:`ev3brick` -- The EV3 Programmable Brick
=============================================
.. automodule:: ev3brick
.. automodule:: pybricks.ev3brick
:no-members:
Buttons
-------
.. autofunction:: ev3brick.buttons
.. autofunction:: pybricks.ev3brick.buttons
Examples::
@@ -30,7 +30,7 @@ Buttons
Light
-----
.. automethod:: ev3brick.light.color
.. automethod:: pybricks.ev3brick.light.color
Example::
@@ -44,14 +44,14 @@ Light
brick.light.off()
.. automethod:: ev3brick.light.off
.. automethod:: pybricks.ev3brick.light.off
.. automethod:: ev3brick.light.brightness
.. automethod:: pybricks.ev3brick.light.brightness
Sound
-----
.. automethod:: ev3brick.sound.beep
.. automethod:: pybricks.ev3brick.sound.beep
Example::
@@ -62,14 +62,14 @@ Sound
brick.sound.beep(1500, 1000, 50)
.. automethod:: ev3brick.sound.beeps
.. automethod:: pybricks.ev3brick.sound.beeps
Example::
# Make 5 simple beeps
brick.sound.beeps(5)
.. automethod:: ev3brick.sound.file
.. automethod:: pybricks.ev3brick.sound.file
Example::
@@ -95,14 +95,14 @@ Display
(177, 127)
.. automethod:: ev3brick.display.clear
.. automethod:: pybricks.ev3brick.display.clear
Example::
# Clear the display
brick.display.clear()
.. automethod:: ev3brick.display.text
.. automethod:: pybricks.ev3brick.display.text
Example::
@@ -112,7 +112,7 @@ Display
# Print ``World`` directly underneath it
brick.display.text("World")
.. automethod:: ev3brick.display.image
.. automethod:: pybricks.ev3brick.display.image
Example::
@@ -129,6 +129,6 @@ Display
Battery
-------
.. automethod:: ev3brick.battery.voltage
.. automethod:: pybricks.ev3brick.battery.voltage
.. automethod:: ev3brick.battery.current
.. automethod:: pybricks.ev3brick.battery.current
+22 -22
View File
@@ -1,13 +1,13 @@
:mod:`ev3devices` -- EV3 Motors and Sensors
===========================================
.. automodule:: ev3devices
.. automodule:: pybricks.ev3devices
:no-members:
Motors
------
.. autoclass:: ev3devices.Motor
.. autoclass:: pybricks.ev3devices.Motor
:no-members:
Example::
@@ -23,7 +23,7 @@ Motors
.. rubric:: Methods for motors without rotation sensors
.. automethod:: ev3devices.Motor.dc
.. automethod:: pybricks.ev3devices.Motor.dc
Example::
@@ -32,25 +32,25 @@ Motors
.. rubric:: Methods for motors with rotation sensors
.. automethod:: ev3devices.Motor.angle
.. automethod:: pybricks.ev3devices.Motor.angle
.. automethod:: ev3devices.Motor.reset_angle
.. automethod:: pybricks.ev3devices.Motor.reset_angle
.. automethod:: ev3devices.Motor.speed
.. automethod:: pybricks.ev3devices.Motor.speed
.. automethod:: ev3devices.Motor.stop
.. automethod:: pybricks.ev3devices.Motor.stop
.. automethod:: ev3devices.Motor.run
.. automethod:: pybricks.ev3devices.Motor.run
.. automethod:: ev3devices.Motor.run_time
.. automethod:: pybricks.ev3devices.Motor.run_time
.. automethod:: ev3devices.Motor.run_angle
.. automethod:: pybricks.ev3devices.Motor.run_angle
.. automethod:: ev3devices.Motor.run_target
.. automethod:: pybricks.ev3devices.Motor.run_target
.. rubric:: Advanced methods for motors with rotation sensors
.. automethod:: ev3devices.Motor.track_target
.. automethod:: pybricks.ev3devices.Motor.track_target
Example::
@@ -72,13 +72,13 @@ Motors
# Make the motor track the given angle
motor.track_target(angle_now)
.. automethod:: ev3devices.Motor.stalled
.. automethod:: pybricks.ev3devices.Motor.stalled
.. automethod:: ev3devices.Motor.run_until_stalled
.. automethod:: pybricks.ev3devices.Motor.run_until_stalled
.. automethod:: ev3devices.Motor.set_dc_settings
.. automethod:: pybricks.ev3devices.Motor.set_dc_settings
.. automethod:: ev3devices.Motor.set_run_settings
.. automethod:: pybricks.ev3devices.Motor.set_run_settings
Example::
@@ -92,27 +92,27 @@ Motors
# the settings above.
example_motor.run_time(300, 5000)
.. automethod:: ev3devices.Motor.set_pid_settings
.. automethod:: pybricks.ev3devices.Motor.set_pid_settings
Sensors
-------
Touch Sensor
^^^^^^^^^^^^
.. autoclass:: ev3devices.TouchSensor
.. autoclass:: pybricks.ev3devices.TouchSensor
Color Sensor
^^^^^^^^^^^^
.. autoclass:: ev3devices.ColorSensor
.. autoclass:: pybricks.ev3devices.ColorSensor
Infrared Sensor and Beacon
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: ev3devices.InfraredSensor
.. autoclass:: pybricks.ev3devices.InfraredSensor
Ultrasonic Sensor
^^^^^^^^^^^^^^^^^
.. autoclass:: ev3devices.UltrasonicSensor
.. autoclass:: pybricks.ev3devices.UltrasonicSensor
Gyroscopic Sensor
^^^^^^^^^^^^^^^^^
.. autoclass:: ev3devices.GyroSensor
.. autoclass:: pybricks.ev3devices.GyroSensor
+9 -9
View File
@@ -1,29 +1,29 @@
:mod:`parameters` -- Parameters and Constants
=============================================
.. automodule:: parameters
.. automodule:: pybricks.parameters
:no-members:
.. autoclass:: parameters.Port
.. autoclass:: pybricks.parameters.Port
:no-members:
.. autoclass:: parameters.Direction
.. autoclass:: pybricks.parameters.Direction
:no-members:
.. autoclass:: parameters.Stop
.. autoclass:: pybricks.parameters.Stop
:no-members:
.. autoclass:: parameters.Color
.. autoclass:: pybricks.parameters.Color
:no-members:
.. autoclass:: parameters.Button
.. autoclass:: pybricks.parameters.Button
:no-members:
.. autoclass:: parameters.Align
.. autoclass:: pybricks.parameters.Align
:no-members:
.. autoclass:: parameters.ImageFile
.. autoclass:: pybricks.parameters.ImageFile
:no-members:
.. autoclass:: parameters.SoundFile
.. autoclass:: pybricks.parameters.SoundFile
:no-members:
+5 -5
View File
@@ -1,11 +1,11 @@
:mod:`robotics` -- Robotics module
===========================================
.. automodule:: robotics
.. automodule:: pybricks.robotics
:no-members:
.. autoclass:: robotics.DriveBase
.. autoclass:: pybricks.robotics.DriveBase
:no-members:
Example::
@@ -15,7 +15,7 @@
right = Motor(Port.C)
robot = DriveBase(left, right, 56, 114)
.. automethod:: robotics.DriveBase.drive
.. automethod:: pybricks.robotics.DriveBase.drive
Example::
@@ -33,7 +33,7 @@
wait(10)
robot.stop()
.. automethod:: robotics.DriveBase.drive_time
.. automethod:: pybricks.robotics.DriveBase.drive_time
Example::
@@ -43,4 +43,4 @@
# Turn at 45 deg/s for three seconds
robot.drive_time(0, 45, 3000)
.. automethod:: robotics.DriveBase.stop
.. automethod:: pybricks.robotics.DriveBase.stop
+6 -6
View File
@@ -1,7 +1,7 @@
:mod:`tools` -- Timing and Datalogging
======================================
.. automodule:: tools
.. automodule:: pybricks.tools
:no-members:
.. autofunction:: print
@@ -16,13 +16,13 @@
.. autofunction:: wait
.. autoclass:: tools.StopWatch
.. autoclass:: pybricks.tools.StopWatch
:no-members:
.. automethod:: tools.StopWatch.time
.. automethod:: pybricks.tools.StopWatch.time
.. automethod:: tools.StopWatch.pause
.. automethod:: pybricks.tools.StopWatch.pause
.. automethod:: tools.StopWatch.resume
.. automethod:: pybricks.tools.StopWatch.resume
.. automethod:: tools.StopWatch.reset
.. automethod:: pybricks.tools.StopWatch.reset
+8 -8
View File
@@ -1,34 +1,34 @@
:mod:`cityhub` -- LEGO® Power Functions 2.0 City Hub
=====================================================
.. automodule:: cityhub
.. automodule:: pybricks.cityhub
:no-members:
Light
-----
.. automethod:: cityhub.light.color
.. automethod:: pybricks.cityhub.light.color
Example::
# Make the light red
cityhub.light.color(Color.RED)
pybricks.cityhub.light.color(Color.RED)
# Wait
wait(1000)
# Turn the light off
cityhub.light.off()
pybricks.cityhub.light.off()
.. automethod:: cityhub.light.off
.. automethod:: pybricks.cityhub.light.off
.. automethod:: cityhub.light.brightness
.. automethod:: pybricks.cityhub.light.brightness
Battery
-------
.. automethod:: cityhub.battery.voltage
.. automethod:: pybricks.cityhub.battery.voltage
.. automethod:: cityhub.battery.current
.. automethod:: pybricks.cityhub.battery.current
+25 -25
View File
@@ -1,13 +1,13 @@
:mod:`lpf2devices` -- Power Function 2.0 Motors and Sensors
===========================================================
.. automodule:: lpf2devices
.. automodule:: pybricks.lpf2devices
:no-members:
Motors
------
.. autoclass:: lpf2devices.Motor
.. autoclass:: pybricks.lpf2devices.Motor
:no-members:
Example::
@@ -23,7 +23,7 @@ Motors
.. rubric:: Methods for motors without rotation sensors
.. automethod:: lpf2devices.Motor.dc
.. automethod:: pybricks.lpf2devices.Motor.dc
Example::
@@ -32,25 +32,25 @@ Motors
.. rubric:: Methods for motors with rotation sensors
.. automethod:: lpf2devices.Motor.angle
.. automethod:: pybricks.lpf2devices.Motor.angle
.. automethod:: lpf2devices.Motor.reset_angle
.. automethod:: pybricks.lpf2devices.Motor.reset_angle
.. automethod:: lpf2devices.Motor.speed
.. automethod:: pybricks.lpf2devices.Motor.speed
.. automethod:: lpf2devices.Motor.stop
.. automethod:: pybricks.lpf2devices.Motor.stop
.. automethod:: lpf2devices.Motor.run
.. automethod:: pybricks.lpf2devices.Motor.run
.. automethod:: lpf2devices.Motor.run_time
.. automethod:: pybricks.lpf2devices.Motor.run_time
.. automethod:: lpf2devices.Motor.run_angle
.. automethod:: pybricks.lpf2devices.Motor.run_angle
.. automethod:: lpf2devices.Motor.run_target
.. automethod:: pybricks.lpf2devices.Motor.run_target
.. rubric:: Advanced methods for motors with rotation sensors
.. automethod:: lpf2devices.Motor.track_target
.. automethod:: pybricks.lpf2devices.Motor.track_target
Example::
@@ -72,13 +72,13 @@ Motors
# Make the motor track the given angle
motor.track_target(angle_now)
.. automethod:: lpf2devices.Motor.stalled
.. automethod:: pybricks.lpf2devices.Motor.stalled
.. automethod:: lpf2devices.Motor.run_until_stalled
.. automethod:: pybricks.lpf2devices.Motor.run_until_stalled
.. automethod:: lpf2devices.Motor.set_dc_settings
.. automethod:: pybricks.lpf2devices.Motor.set_dc_settings
.. automethod:: lpf2devices.Motor.set_run_settings
.. automethod:: pybricks.lpf2devices.Motor.set_run_settings
Example::
@@ -92,7 +92,7 @@ Motors
# the settings above.
example_motor.run_time(300, 5000)
.. automethod:: lpf2devices.Motor.set_pid_settings
.. automethod:: pybricks.lpf2devices.Motor.set_pid_settings
Sensors
-------
@@ -100,19 +100,19 @@ Sensors
Color and Distance Sensor
^^^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: lpf2devices.ColorDistanceSensor
.. autoclass:: pybricks.lpf2devices.ColorDistanceSensor
:no-members:
.. automethod:: lpf2devices.ColorDistanceSensor.color
.. automethod:: pybricks.lpf2devices.ColorDistanceSensor.color
.. automethod:: lpf2devices.ColorDistanceSensor.ambient
.. automethod:: pybricks.lpf2devices.ColorDistanceSensor.ambient
.. automethod:: lpf2devices.ColorDistanceSensor.reflection
.. automethod:: pybricks.lpf2devices.ColorDistanceSensor.reflection
.. automethod:: lpf2devices.ColorDistanceSensor.rgb
.. automethod:: pybricks.lpf2devices.ColorDistanceSensor.rgb
.. automethod:: lpf2devices.ColorDistanceSensor.distance
.. automethod:: pybricks.lpf2devices.ColorDistanceSensor.distance
.. automethod:: _common.light.color
.. automethod:: pybricks._common.light.color
.. automethod:: _common.light.off
.. automethod:: pybricks._common.light.off
+6 -6
View File
@@ -1,13 +1,13 @@
:mod:`movehub` -- LEGO® Power Functions 2.0 Move Hub
======================================================
.. automodule:: movehub
.. automodule:: pybricks.movehub
:no-members:
Light
-----
.. automethod:: movehub.light.color
.. automethod:: pybricks.movehub.light.color
Example::
@@ -21,13 +21,13 @@ Light
movehub.light.off()
.. automethod:: movehub.light.off
.. automethod:: pybricks.movehub.light.off
.. automethod:: movehub.light.brightness
.. automethod:: pybricks.movehub.light.brightness
Battery
-------
.. automethod:: movehub.battery.voltage
.. automethod:: pybricks.movehub.battery.voltage
.. automethod:: movehub.battery.current
.. automethod:: pybricks.movehub.battery.current
+6 -6
View File
@@ -1,20 +1,20 @@
:mod:`parameters` -- Parameters and Constants
=============================================
.. automodule:: parameters
.. automodule:: pybricks.parameters
:no-members:
.. autoclass:: parameters.Port
.. autoclass:: pybricks.parameters.Port
:no-members:
.. autoclass:: parameters.Direction
.. autoclass:: pybricks.parameters.Direction
:no-members:
.. autoclass:: parameters.Stop
.. autoclass:: pybricks.parameters.Stop
:no-members:
.. autoclass:: parameters.Color
.. autoclass:: pybricks.parameters.Color
:no-members:
.. autoclass:: parameters.Button
.. autoclass:: pybricks.parameters.Button
:no-members:
+5 -5
View File
@@ -1,11 +1,11 @@
:mod:`robotics` -- Robotics module
===========================================
.. automodule:: robotics
.. automodule:: pybricks.robotics
:no-members:
.. autoclass:: robotics.DriveBase
.. autoclass:: pybricks.robotics.DriveBase
:no-members:
Example::
@@ -15,7 +15,7 @@
right = Motor(Port.B)
robot = DriveBase(left, right, 56, 114)
.. automethod:: robotics.DriveBase.drive
.. automethod:: pybricks.robotics.DriveBase.drive
Example::
@@ -28,7 +28,7 @@
wait(10)
robot.stop()
.. automethod:: robotics.DriveBase.drive_time
.. automethod:: pybricks.robotics.DriveBase.drive_time
Example::
@@ -38,4 +38,4 @@
# Turn at 45 deg/s for three seconds
robot.drive_time(0, 45, 3000)
.. automethod:: robotics.DriveBase.stop
.. automethod:: pybricks.robotics.DriveBase.stop
+6 -6
View File
@@ -1,7 +1,7 @@
:mod:`tools` -- Timing and Datalogging
======================================
.. automodule:: tools
.. automodule:: pybricks.tools
:no-members:
.. autofunction:: print
@@ -16,13 +16,13 @@
.. autofunction:: wait
.. autoclass:: tools.StopWatch
.. autoclass:: pybricks.tools.StopWatch
:no-members:
.. automethod:: tools.StopWatch.time
.. automethod:: pybricks.tools.StopWatch.time
.. automethod:: tools.StopWatch.pause
.. automethod:: pybricks.tools.StopWatch.pause
.. automethod:: tools.StopWatch.resume
.. automethod:: pybricks.tools.StopWatch.resume
.. automethod:: tools.StopWatch.reset
.. automethod:: pybricks.tools.StopWatch.reset
+2 -2
View File
@@ -2,7 +2,7 @@
speakers, and batteries."""
from types import ModuleType
from parameters import Align, Direction, Stop
from .parameters import Align, Direction, Stop
class Motor():
@@ -453,7 +453,7 @@ class ColorLight():
"""Control an RGB LED."""
@staticmethod
def color(color):
def color(self, color):
"""Turn on the light at the specified color.
Arguments:
+1 -1
View File
@@ -1,6 +1,6 @@
"""LEGO® Power Functions 2.0 City Hub."""
from _common import Battery, ColorLight
from ._common import Battery, ColorLight
battery = Battery()
light = ColorLight()
+1 -1
View File
@@ -1,6 +1,6 @@
"""LEGO® MINDSTORMS® EV3 Brick."""
from _common import Speaker, Display, Battery, ColorLight
from ._common import Speaker, Display, Battery, ColorLight
def buttons():
+2 -2
View File
@@ -1,7 +1,7 @@
"""LEGO® MINDSTORMS® EV3 motors and sensors."""
from parameters import Direction
from _common import Motor as CommonMotor
from .parameters import Direction
from ._common import Motor as CommonMotor
class Motor(CommonMotor):
+1 -1
View File
@@ -1,6 +1,6 @@
"""LEGO® Power Functions 2.0 motor, sensors, and lights."""
from _common import Motor as CommonMotor, ColorLight
from ._common import Motor as CommonMotor, ColorLight
class Motor(CommonMotor):
+1 -1
View File
@@ -1,6 +1,6 @@
"""LEGO® Power Functions 2.0 Move Hub."""
from _common import Battery, ColorLight
from ._common import Battery, ColorLight
battery = Battery()
light = ColorLight()
+1 -1
View File
@@ -1,6 +1,6 @@
"""Robotics module for the Pybricks API."""
from parameters import Stop
from .parameters import Stop
class DriveBase():