api/pupdevices/UltrasonicSensor: add methods

This is identical to the EV3 Ultrasonic Sensor methods.
This commit is contained in:
Laurens Valk
2020-05-27 13:58:30 +02:00
committed by laurensvalk
parent 4da7b456bb
commit 8273c00881
2 changed files with 42 additions and 0 deletions
+4
View File
@@ -159,6 +159,10 @@ Ultrasonic Sensor
.. autoclass:: pybricks.pupdevices.UltrasonicSensor
:no-members:
.. automethod:: pybricks.pupdevices.UltrasonicSensor.distance
.. automethod:: pybricks.pupdevices.UltrasonicSensor.presence
.. rubric:: Built-in lights
This sensor has 4 built-in lights. You can adjust the brightness of each
+38
View File
@@ -226,6 +226,44 @@ class UltrasonicSensor:
lights = _LightArray(3)
def __init__(self, port):
"""UltrasonicSensor(port)
Arguments:
port (Port): Port to which the sensor is connected.
"""
pass
def distance(self, silent=False):
"""Measures the distance between the sensor and an object using
ultrasonic sound waves.
Arguments:
silent (bool): Choose ``True`` to turn the sensor off after
measuring the distance. This reduces interference
with other ultrasonic sensors.
Returns:
:ref:`distance`: Distance.
"""
pass
def presence(self):
"""Checks for the presence of other ultrasonic sensors by detecting
ultrasonic sounds.
If the other ultrasonic sensor is operating in silent mode, you can
only detect the presence of that sensor while it is taking a
measurement.
Returns:
bool: ``True`` if ultrasonic sounds are detected,
``False`` if not.
"""
pass
class ForceSensor:
"""LEGO® SPIKE Force Sensor."""