Skip to content
Snippets Groups Projects
Commit 517f292c authored by Damien George's avatar Damien George
Browse files

examples, switch: Make run_loop take sequence of LED objects.

parent 15a5738e
No related branches found
No related tags found
No related merge requests found
...@@ -22,17 +22,16 @@ red_led = pyb.LED(1) ...@@ -22,17 +22,16 @@ red_led = pyb.LED(1)
green_led = pyb.LED(2) green_led = pyb.LED(2)
orange_led = pyb.LED(3) orange_led = pyb.LED(3)
blue_led = pyb.LED(4) 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. Start the loop.
:param `use_leds`: Which leds to light up upon switch press. :param `use_leds`: Which LEDs to light up upon switch press.
:type `use_leds`: list of integers [1-4] :type `use_leds`: sequence of LED objects
""" """
print('Loop started.\nPress Ctrl+C to break out of the loop.') print('Loop started.\nPress Ctrl+C to break out of the loop.')
leds = [all_leds[i - 1] for i in use_leds]
while 1: while 1:
try: try:
if switch(): if switch():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment