mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-15 02:54:52 +00:00
api/_common.LightArray: merge on and array method
Make it simpler with only one method to turn the lights on.
This commit is contained in:
committed by
laurensvalk
parent
a48b77fea8
commit
2d3e85f531
+8
-17
@@ -435,20 +435,22 @@ class ColorLight:
|
||||
class LightArray:
|
||||
"""Control an array of single-color lights."""
|
||||
|
||||
def __init__(self, lights):
|
||||
def __init__(self, n):
|
||||
"""Initializes the light array.
|
||||
|
||||
Arguments:
|
||||
lights (int): Number of lights
|
||||
n (int): Number of lights
|
||||
"""
|
||||
pass
|
||||
|
||||
def on(self, brightness=100):
|
||||
"""Turns on all the lights at the specified brightness.
|
||||
def on(self, *brightness):
|
||||
"""Turns on the lights at the specified brightness.
|
||||
|
||||
Arguments:
|
||||
brightness (:ref:`brightness`):
|
||||
Brightness of the lights.
|
||||
*brightness (:ref:`brightness`, :ref:`brightness`, ...):
|
||||
Brightness of each light. If you give only one value, it is
|
||||
applied to all lights at once.
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -456,17 +458,6 @@ class LightArray:
|
||||
"""Turns off all the lights."""
|
||||
pass
|
||||
|
||||
def array(self, *brightnesses):
|
||||
"""array(first_light, ..., last_light)
|
||||
|
||||
Sets the brightness of each light individually.
|
||||
|
||||
Arguments:
|
||||
brightness (:ref:`brightness`, ..., :ref:`brightness`):
|
||||
Brightness of each light.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class LightGrid:
|
||||
"""Control a rectangular grid of single-color lights."""
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
"""LEGO® Powered Up motor, sensors, and lights."""
|
||||
|
||||
from ._common import (KeyPad as _KeyPad, Accelerometer as _Accelerometer,
|
||||
ColorLight as _ColorLight, Motor as _Motor)
|
||||
ColorLight as _ColorLight, Motor as _Motor,
|
||||
LightArray as _LightArray)
|
||||
|
||||
|
||||
class Motor(_Motor):
|
||||
@@ -135,3 +136,9 @@ class ColorDistanceSensor:
|
||||
Choose ``None`` if you don't want to press
|
||||
any button.
|
||||
"""
|
||||
|
||||
|
||||
class ColorSensor:
|
||||
"""LEGO® SPIKE Color Sensor."""
|
||||
|
||||
lights = _LightArray(3)
|
||||
|
||||
Reference in New Issue
Block a user