Badger2040: Lint examples, launcher tweaks
@@ -26,7 +26,7 @@ button_up = machine.Pin(badger2040.BUTTON_UP, machine.Pin.IN, machine.Pin.PULL_D
button_down = machine.Pin(badger2040.BUTTON_DOWN, machine.Pin.IN, machine.Pin.PULL_DOWN)
# Early exit if a button is pressed
-if button_a.value():
+if button_a.value() or button_b.value() or button_c.value():
sys.exit(0)
@@ -68,24 +68,22 @@ def launch(file):
__import__(file)
-def get_example(index):
+def launch_example(index):
try:
- return examples[(page * 3) + index]
+ launch(examples[(page * 3) + index])
+ return True
except IndexError:
- return None
+ return False
def button(pin):
global page
if pin == button_a:
- example = get_example(0)
- if example: launch(example)
+ launch_example(0)
if pin == button_b:
- example = get_example(1)
- if example: launch(example)
+ launch_example(1)
if pin == button_c:
- example = get_example(2)
- if example: launch(example)
+ launch_example(2)
if pin == button_up:
if page > 0:
page -= 1
@@ -106,4 +104,3 @@ render()
while True:
time.sleep(1.0)
-
