Skip to content

Commit 517f292

Browse files
committed
examples, switch: Make run_loop take sequence of LED objects.
1 parent 15a5738 commit 517f292

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

examples/switch.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@
2222
green_led = pyb.LED(2)
2323
orange_led = pyb.LED(3)
2424
blue_led = pyb.LED(4)
25-
all_leds = [red_led, green_led, orange_led, blue_led]
25+
all_leds = (red_led, green_led, orange_led, blue_led)
2626

27-
def run_loop(use_leds=[]):
27+
def run_loop(leds=all_leds):
2828
"""
2929
Start the loop.
3030
31-
:param `use_leds`: Which leds to light up upon switch press.
32-
:type `use_leds`: list of integers [1-4]
31+
:param `use_leds`: Which LEDs to light up upon switch press.
32+
:type `use_leds`: sequence of LED objects
3333
"""
3434
print('Loop started.\nPress Ctrl+C to break out of the loop.')
35-
leds = [all_leds[i - 1] for i in use_leds]
3635
while 1:
3736
try:
3837
if switch():

0 commit comments

Comments
 (0)