Skip to content

Commit 600b51f

Browse files
committed
Add attr check for BOOT0 for backwards compat.
1 parent c84c33b commit 600b51f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

adafruit_magtag/peripherals.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ def __init__(self) -> None:
6464
self._light = AnalogIn(board.LIGHT)
6565

6666
# Buttons
67+
button_pins = [board.BUTTON_A, board.BUTTON_B, board.BUTTON_C, board.BUTTON_D]
68+
69+
# Add BOOT0 as a button pin, only if it's defined.
70+
if hasattr(board, "BOOT0"):
71+
button_pins.append(board.BOOT0)
72+
6773
self.buttons = []
68-
for pin in (
69-
board.BUTTON_A,
70-
board.BUTTON_B,
71-
board.BUTTON_C,
72-
board.BUTTON_D,
73-
board.BOOT0,
74-
):
74+
for pin in button_pins:
7575
switch = DigitalInOut(pin)
7676
switch.direction = Direction.INPUT
7777
switch.pull = Pull.UP

0 commit comments

Comments
 (0)