|
11 | 11 | back_pin = board.TOUCH1 |
12 | 12 | forward_pin = board.TOUCH4 |
13 | 13 |
|
14 | | -# Detect if this is the HalloWing M4 or M0 |
15 | | -is_hallowing_m4 = False |
| 14 | +# Perform a couple extra steps for the HalloWing M4 |
16 | 15 | try: |
17 | 16 | if getattr(board, "CAP_PIN"): |
18 | | - is_hallowing_m4 = True |
| 17 | + # Create digitalio objects and pull low for HalloWing M4 |
| 18 | + cap_pin = digitalio.DigitalInOut(board.CAP_PIN) |
| 19 | + cap_pin.direction = digitalio.Direction.OUTPUT |
| 20 | + cap_pin.value = False |
| 21 | + if getattr(board, "SPEAKER_ENABLE"): |
| 22 | + # Enable the Speaker |
| 23 | + speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) |
| 24 | + speaker_enable.direction = digitalio.Direction.OUTPUT |
| 25 | + speaker_enable.value = True |
19 | 26 | except AttributeError: |
20 | 27 | pass |
21 | 28 |
|
22 | | -# Initialize the Buttons and Speaker |
23 | | -if is_hallowing_m4: |
24 | | - # Enable the Speaker |
25 | | - speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) |
26 | | - speaker_enable.direction = digitalio.Direction.OUTPUT |
27 | | - speaker_enable.value = True |
28 | | - |
29 | | - # Create digitalio objects and pull low for HalloWing M4 |
30 | | - back_button = digitalio.DigitalInOut(back_pin) |
31 | | - back_button.direction = digitalio.Direction.OUTPUT |
32 | | - back_button.value = False |
33 | | - back_button.direction = digitalio.Direction.INPUT |
34 | | - |
35 | | - forward_button = digitalio.DigitalInOut(forward_pin) |
36 | | - forward_button.direction = digitalio.Direction.OUTPUT |
37 | | - forward_button.value = False |
38 | | - forward_button.direction = digitalio.Direction.INPUT |
39 | | -else: |
40 | | - # Create the touchio objects for HalloWing M0 |
41 | | - back_button = touchio.TouchIn(back_pin) |
42 | | - forward_button = touchio.TouchIn(forward_pin) |
| 29 | +# Create the touchio objects for HalloWing M0 |
| 30 | +back_button = touchio.TouchIn(back_pin) |
| 31 | +forward_button = touchio.TouchIn(forward_pin) |
43 | 32 |
|
44 | 33 | # Setup the speaker output |
45 | 34 | a = audioio.AudioOut(board.SPEAKER) |
|
0 commit comments