diff --git a/doc/api/nxtdevices.rst b/doc/api/nxtdevices.rst index 1eecbfc..a7de681 100644 --- a/doc/api/nxtdevices.rst +++ b/doc/api/nxtdevices.rst @@ -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 ^^^^^^^^^^^^^^^^^^^^^ diff --git a/pybricks/nxtdevices.py b/pybricks/nxtdevices.py index 43554ea..43ef9b2 100644 --- a/pybricks/nxtdevices.py +++ b/pybricks/nxtdevices.py @@ -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 `: 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."""