mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 09:37:25 +00:00
doc: make all the examples say "Example:"
This commit is contained in:
@@ -22,7 +22,7 @@ class Display():
|
||||
text (str): The text to display.
|
||||
coordinate (tuple): ``(x, y)`` coordinate tuple. It is the top-left corner of the first character. If no location is specified, it is printed on the next line.
|
||||
|
||||
::
|
||||
Example::
|
||||
|
||||
# Clear the display
|
||||
brick.display.clear()
|
||||
@@ -52,7 +52,7 @@ class Display():
|
||||
coordinate (tuple): ``(x, y)`` coordinate tuple. It is the top-left corner of the image (*Default*: None).
|
||||
clear (bool): Whether to clear the screen before showing the image. (*Default*: ``True``)
|
||||
|
||||
::
|
||||
Example::
|
||||
|
||||
# Show a built-in image showing two eyes looking upward
|
||||
brick.display.image(Image.up)
|
||||
|
||||
@@ -15,7 +15,8 @@ class Speaker():
|
||||
frequency (:ref:`frequency`): Frequency of the beep (*Default*: 500).
|
||||
duration (:ref:`time`): Duration of the beep (*Default*: 100).
|
||||
volume (:ref:`percentage`): Volume of the beep (*Default*: 30).
|
||||
::
|
||||
|
||||
Example::
|
||||
|
||||
# A simple beep
|
||||
brick.sound.beep()
|
||||
@@ -31,7 +32,7 @@ class Speaker():
|
||||
Arguments:
|
||||
number (int): Number of beeps
|
||||
|
||||
::
|
||||
Example::
|
||||
|
||||
# Make 5 simple beeps
|
||||
brick.sound.beeps(5)
|
||||
@@ -45,7 +46,7 @@ class Speaker():
|
||||
file_name (str): Path to the sound file, including extension.
|
||||
volume (:ref:`percentage`): Volume of the sound (*Default*: 100).
|
||||
|
||||
::
|
||||
Example::
|
||||
|
||||
# Play one of the built-in sounds
|
||||
brick.sound.file(Sound.hello)
|
||||
|
||||
@@ -10,7 +10,7 @@ def buttons():
|
||||
:returns: List of pressed buttons.
|
||||
:rtype: List of :class:`Button <parameters.Button>`
|
||||
|
||||
::
|
||||
Example::
|
||||
|
||||
if Button.left in brick.buttons():
|
||||
print("The left button is pressed.")
|
||||
@@ -25,7 +25,7 @@ def light(color):
|
||||
Arguments:
|
||||
color (Color): Color of the light. Choose ``Color.black`` or ``None`` to turn the light off.
|
||||
|
||||
::
|
||||
Example::
|
||||
|
||||
# Make the light red
|
||||
brick.light(Color.red)
|
||||
|
||||
@@ -33,7 +33,7 @@ class Motor():
|
||||
|
||||
The ``gears`` setting is only available for motors with rotation sensors.
|
||||
|
||||
::
|
||||
Example::
|
||||
|
||||
# Initialize a motor (by default this means clockwise, without any gears).
|
||||
example_motor = Motor(Port.A)
|
||||
@@ -53,7 +53,7 @@ class Motor():
|
||||
duty (:ref:`percentage`): The duty cycle (-100.0 to 100).
|
||||
limit (:ref:`percentage`): Limit on the maximum ``duty`` value. (*Default*: 100). This overrides the first argument when it exceeds the limit. This ensures that ``abs(duty)`` <``limit``. This is useful when you use your own formula to set the duty cycle, because provides a limit when your formula gives a very big number. For example, you could use this to prevent your LEGO train from unintentionally going at full speed.
|
||||
|
||||
::
|
||||
Example::
|
||||
|
||||
# Set the motor duty cycle to 75%.
|
||||
example_motor.duty(75)
|
||||
@@ -199,7 +199,7 @@ class Motor():
|
||||
Arguments:
|
||||
target_angle (:ref:`angle`): Target angle that the motor should go to.
|
||||
|
||||
::
|
||||
Example::
|
||||
|
||||
# Initialize motor and timer
|
||||
from math import sin
|
||||
@@ -231,7 +231,7 @@ class Motor():
|
||||
max_speed (:ref:`speed`): Maximum speed of the motor during a motor command.
|
||||
acceleration (:ref:`acceleration`): Acceleration towards the target speed and deceleration towards standstill. This should be a positive value. The motor will automatically change the sign to decelerate as needed.
|
||||
|
||||
::
|
||||
Example::
|
||||
|
||||
# Set the maximum speed to 200 deg/s and set the acceleration to 400 deg/s/s.
|
||||
example_motor.set_run_settings(200, 400)
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ def print():
|
||||
|
||||
Prints the values to the terminal or a stream.
|
||||
|
||||
::
|
||||
Example::
|
||||
|
||||
# Print some text
|
||||
print("Hello, world")
|
||||
|
||||
Reference in New Issue
Block a user