diff --git a/CHANGELOG.md b/CHANGELOG.md index 12f0b21..83b0f59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ +## Unreleased + +### Added +- Added `ColorLightMatrix` class. + ## 1.6.0 - 2021-08-30 ### Added diff --git a/doc/main/images/color_light_matrix.png b/doc/main/images/color_light_matrix.png new file mode 100644 index 0000000..319e4e2 Binary files /dev/null and b/doc/main/images/color_light_matrix.png differ diff --git a/doc/main/pupdevices/colorlightmatrix.rst b/doc/main/pupdevices/colorlightmatrix.rst new file mode 100644 index 0000000..039f2d0 --- /dev/null +++ b/doc/main/pupdevices/colorlightmatrix.rst @@ -0,0 +1,15 @@ +.. pybricks-requirements:: + +Color Light Matrix +^^^^^^^^^^^^^^^^^^ + +.. figure:: ../../main/images/color_light_matrix.png + :width: 35 % + +.. autoclass:: pybricks.pupdevices.ColorLightMatrix + :no-members: + + .. automethod:: pybricks.pupdevices.ColorLightMatrix.on + + .. automethod:: pybricks.pupdevices.ColorLightMatrix.off + diff --git a/doc/main/pupdevices/index.rst b/doc/main/pupdevices/index.rst index 1b99fa3..0550ae8 100644 --- a/doc/main/pupdevices/index.rst +++ b/doc/main/pupdevices/index.rst @@ -19,6 +19,7 @@ colorsensor ultrasonicsensor forcesensor + colorlightmatrix light remote @@ -76,6 +77,12 @@ :width: 35 % :target: forcesensor.html +.. pybricks-classlink:: ColorLightMatrix + +.. figure:: ../../main/images/color_light_matrix.png + :width: 35 % + :target: color-light-matrix.html + .. pybricks-classlink:: Light .. figure:: ../../main/images/light.png diff --git a/src/pybricks/pupdevices.py b/src/pybricks/pupdevices.py index a7838a3..9ebb396 100644 --- a/src/pybricks/pupdevices.py +++ b/src/pybricks/pupdevices.py @@ -377,6 +377,39 @@ class ForceSensor: pass +class ColorLightMatrix: + """ + LEGO® SPIKE 3x3 Color Light Matrix. + """ + + def __init__(self, port): + """ + + Arguments: + port (Port): Port to which the device is connected. + + """ + ... + + def on(self, colors): + """ + Turns the lights on. + + Arguments: + colors (Color or list): + If a single :class:`.Color` is given, then all 9 lights are set + to that color. If a list of colors is given, then each light is + set to that color. + """ + ... + + def off(self): + """ + Turns all of the lights off. + """ + ... + + class InfraredSensor: """LEGO® Powered Up Infrared Sensor.""" diff --git a/src/pybricks/pupdevices.pyi b/src/pybricks/pupdevices.pyi index 7cb4ca7..3776336 100644 --- a/src/pybricks/pupdevices.pyi +++ b/src/pybricks/pupdevices.pyi @@ -60,6 +60,11 @@ class ForceSensor: def pressed(self, force: int = 3) -> bool: ... def touched(self) -> bool: ... +class ColorLightMatrix: + def __init__(self, port: Port) -> None: ... + def on(self, color: Union[Color, List[Color]]) -> None: ... + def off(self)-> None: ... + class InfraredSensor: def __init__(self, port: Port): ... def reflection(self) -> int: ...