api/nxtdevices/ColorSensor: add rgb and light

also, remove detection of brown color, because this is not supported
This commit is contained in:
Laurens Valk
2020-02-14 19:26:05 +01:00
parent 3c2f1b8444
commit 9c6d2267bd
2 changed files with 33 additions and 1 deletions
+18
View File
@@ -38,6 +38,24 @@ NXT Light Sensor
NXT Color Sensor
^^^^^^^^^^^^^^^^
.. autoclass:: pybricks.nxtdevices.ColorSensor
:no-members:
.. automethod:: pybricks.nxtdevices.ColorSensor.color
.. automethod:: pybricks.nxtdevices.ColorSensor.ambient
.. automethod:: pybricks.nxtdevices.ColorSensor.reflection
.. automethod:: pybricks.nxtdevices.ColorSensor.rgb
.. rubric:: Built-in light
This sensor has a built-in light. You can make it red, green, blue, or turn
it off.
.. automethod:: pybricks.nxtdevices::ColorSensor.light.on
.. automethod:: pybricks.nxtdevices::ColorSensor.light.off
NXT Ultrasonic Sensor
^^^^^^^^^^^^^^^^^^^^^
+15 -1
View File
@@ -2,6 +2,7 @@
from pybricks.iodevices import AnalogSensor
from pybricks.builtins import ColorLight
class TouchSensor():
@@ -61,6 +62,8 @@ class LightSensor():
class ColorSensor():
"""LEGO® MINDSTORMS® NXT Color Sensor."""
light = ColorLight()
def __init__(self, port):
"""
@@ -75,7 +78,7 @@ class ColorSensor():
:returns:
``Color.BLACK``, ``Color.BLUE``, ``Color.GREEN``, ``Color.YELLOW``,
``Color.RED``, ``Color.WHITE``, ``Color.BROWN`` or ``None``.
``Color.RED``, ``Color.WHITE`` or ``None``.
:rtype: :class:`Color <.parameters.Color>`, or ``None`` if no color is
detected.
@@ -101,6 +104,17 @@ class ColorSensor():
"""
pass
def rgb(self):
"""Measure the reflection of a surface using a red, green, and then a
blue light.
Returns:
tuple of three :ref:`percentages <percentage>`: Reflection for red,
green, and blue light, each ranging from 0.0 (no reflection) to
100.0 (high reflection).
"""
pass
class UltrasonicSensor():
"""LEGO® MINDSTORMS® NXT Ultrasonic Sensor."""