summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-06-01 18:34:58 +0100
committerDamien George <damien.p.george@gmail.com>2014-06-01 18:34:58 +0100
commit517f292c8dbd59ac78edc6a9e619f6c9973c814a (patch)
treea45fe56d5e847cbae669b3db6b6a450f393610c7
parent15a5738e1d428880ce9a80cc4fe40635d21941c0 (diff)
downloadmicropython-517f292c8dbd59ac78edc6a9e619f6c9973c814a.tar.gz
micropython-517f292c8dbd59ac78edc6a9e619f6c9973c814a.zip
examples, switch: Make run_loop take sequence of LED objects.
-rw-r--r--examples/switch.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/examples/switch.py b/examples/switch.py
index 200caa4a4c..23c4b5e2b0 100644
--- a/examples/switch.py
+++ b/examples/switch.py
@@ -22,17 +22,16 @@ red_led = pyb.LED(1)
green_led = pyb.LED(2)
orange_led = pyb.LED(3)
blue_led = pyb.LED(4)
-all_leds = [red_led, green_led, orange_led, blue_led]
+all_leds = (red_led, green_led, orange_led, blue_led)
-def run_loop(use_leds=[]):
+def run_loop(leds=all_leds):
"""
Start the loop.
- :param `use_leds`: Which leds to light up upon switch press.
- :type `use_leds`: list of integers [1-4]
+ :param `use_leds`: Which LEDs to light up upon switch press.
+ :type `use_leds`: sequence of LED objects
"""
print('Loop started.\nPress Ctrl+C to break out of the loop.')
- leds = [all_leds[i - 1] for i in use_leds]
while 1:
try:
if switch():