Skip to content

Commit 2f574e8

Browse files
committed
pybricks.pupdevices.ColorLightMatrix: add api and docs
This adds the SPIKE 3x3 Color Light Matrix to the API and docs.
1 parent 9d8531a commit 2f574e8

File tree

6 files changed

+65
-0
lines changed

6 files changed

+65
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
44

5+
## Unreleased
6+
7+
### Added
8+
- Added `ColorLightMatrix` class.
9+
510
## 1.6.0 - 2021-08-30
611

712
### Added
88.6 KB
Loading
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.. pybricks-requirements::
2+
3+
Color Light Matrix
4+
^^^^^^^^^^^^^^^^^^
5+
6+
.. figure:: ../../main/images/color_light_matrix.png
7+
:width: 35 %
8+
9+
.. autoclass:: pybricks.pupdevices.ColorLightMatrix
10+
:no-members:
11+
12+
.. automethod:: pybricks.pupdevices.ColorLightMatrix.on
13+
14+
.. automethod:: pybricks.pupdevices.ColorLightMatrix.off
15+

doc/main/pupdevices/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
colorsensor
2020
ultrasonicsensor
2121
forcesensor
22+
colorlightmatrix
2223
light
2324
remote
2425

@@ -76,6 +77,12 @@
7677
:width: 35 %
7778
:target: forcesensor.html
7879

80+
.. pybricks-classlink:: ColorLightMatrix
81+
82+
.. figure:: ../../main/images/color_light_matrix.png
83+
:width: 35 %
84+
:target: color-light-matrix.html
85+
7986
.. pybricks-classlink:: Light
8087

8188
.. figure:: ../../main/images/light.png

src/pybricks/pupdevices.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,39 @@ def touched(self):
377377
pass
378378

379379

380+
class ColorLightMatrix:
381+
"""
382+
LEGO® SPIKE 3x3 Color Light Matrix.
383+
"""
384+
385+
def __init__(self, port):
386+
"""
387+
388+
Arguments:
389+
port (Port): Port to which the device is connected.
390+
391+
"""
392+
...
393+
394+
def on(self, colors):
395+
"""
396+
Turns the lights on.
397+
398+
Arguments:
399+
colors (Color or list):
400+
If a single :class:`.Color` is given, then all 9 lights are set
401+
to that color. If a list of colors is given, then each light is
402+
set to that color.
403+
"""
404+
...
405+
406+
def off(self):
407+
"""
408+
Turns all of the lights off.
409+
"""
410+
...
411+
412+
380413
class InfraredSensor:
381414
"""LEGO® Powered Up Infrared Sensor."""
382415

src/pybricks/pupdevices.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class ForceSensor:
6060
def pressed(self, force: int = 3) -> bool: ...
6161
def touched(self) -> bool: ...
6262

63+
class ColorLightMatrix:
64+
def __init__(self, port: Port) -> None: ...
65+
def on(self, color: Union[Color, List[Color]]) -> None: ...
66+
def off(self)-> None: ...
67+
6368
class InfraredSensor:
6469
def __init__(self, port: Port): ...
6570
def reflection(self) -> int: ...

0 commit comments

Comments
 (0)