mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 01:24:17 +00:00
api/pupdevices/UltrasonicSensor: add methods
This is identical to the EV3 Ultrasonic Sensor methods.
This commit is contained in:
committed by
laurensvalk
parent
4da7b456bb
commit
8273c00881
@@ -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
|
||||
|
||||
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user