mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 01:24:17 +00:00
api/nxtdevices/ColorSensor: add rgb and light
also, remove detection of brown color, because this is not supported
This commit is contained in:
@@ -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
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user