api/pupdevices: add InfraredSensor

This commit is contained in:
Laurens Valk
2020-07-01 12:02:13 +02:00
parent 3554814c86
commit 55fe666dac
2 changed files with 55 additions and 0 deletions
+16
View File
@@ -189,6 +189,22 @@ Force Sensor
.. automethod:: pybricks.pupdevices.ForceSensor.touched
Infrared Sensor
^^^^^^^^^^^^^^^^^^^^^^^^^
.. figure:: ../api/images/sensor_proximity.png
:width: 35 %
.. autoclass:: pybricks.pupdevices.InfraredSensor
:no-members:
.. automethod:: pybricks.pupdevices.InfraredSensor.distance
.. automethod:: pybricks.pupdevices.InfraredSensor.reflection
.. automethod:: pybricks.pupdevices.InfraredSensor.count
.. Tilt Sensor
.. ^^^^^^^^^^^^^^^^^^^^^^^^^
+39
View File
@@ -313,6 +313,45 @@ class ForceSensor:
pass
class InfraredSensor:
"""LEGO® Powered Up Infrared Sensor."""
def __init__(self, port):
"""
Arguments:
port (Port): Port to which the sensor is connected.
"""
pass
def reflection(self):
"""Measures the reflection of a surface using an infrared light.
Returns:
:ref:`percentage`: Reflection, ranging from 0.0 (no reflection) to
100.0 (high reflection).
"""
pass
def distance(self):
"""Measures the relative distance between the sensor and an object
using infrared light.
Returns:
:ref:`relativedistance`: Relative distance ranging from 0 (closest)
to 100 (farthest).
"""
pass
def count(self):
"""Counts the number of objects that have passed by the sensor.
Returns:
int: Number of objects counted.
"""
pass
class Light(_Light):
"""LEGO® Powered Up Light."""