From 20b4307d05d9ff4ae26735fa529664c48e5721c1 Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Tue, 25 Jun 2019 14:55:38 +0200 Subject: [PATCH] api: standardize on method for light groups Turn on all the lights at the specified brightness. --- pybricks/_common.py | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/pybricks/_common.py b/pybricks/_common.py index ae0d47a..2056137 100644 --- a/pybricks/_common.py +++ b/pybricks/_common.py @@ -472,15 +472,12 @@ class LightArray(): """ pass - def on(self, *brightnesses): - """on(first_light, ..., last_light) - - Set the brightness of each light. + def on(self, brightness=100): + """Turn on all the lights at the specified brightness. Arguments: - brightnesses (:ref:`brightness`, ..., :ref:`brightness`): - Brightness of each light. If you give just one value, all - lights turn on with that same brightness. + brightness (:ref:`brightness`): + Brightness of the lights (*Default*: 100). """ pass @@ -488,6 +485,17 @@ class LightArray(): """Turn off all the lights.""" pass + def array(self, *brightnesses): + """array(first_light, ..., last_light) + + Set the brightness of each light individually. + + Arguments: + brightnesses (:ref:`brightness`, ..., :ref:`brightness`): + Brightness of each light. + """ + pass + class LightGrid(): """Control a rectangular grid of single-color lights.""" @@ -522,6 +530,15 @@ class LightGrid(): """ pass + def on(self, brightness=100): + """Turn on all the pixels at the specified brightness. + + Arguments: + brightness (:ref:`brightness`): + Brightness of the lights (*Default*: 100). + """ + pass + def off(self): """Turn off all the pixels.""" pass @@ -601,6 +618,7 @@ light.rgb = ColorLight.rgb lights = ModuleType('LightArray') lights.on = LightArray.on +lights.array = LightArray.array lights.off = LightArray.off buttons = ModuleType('KeyPad')