|
1 | 1 | import board |
2 | 2 | from adafruit_slideshow import SlideShow, PlayBackDirection |
3 | 3 | import audioio |
| 4 | +import digitalio |
4 | 5 | import touchio |
5 | 6 |
|
6 | 7 | # Create the slideshow object that plays through once alphabetically. |
7 | 8 | slideshow = SlideShow(board.DISPLAY) |
8 | 9 |
|
9 | | -# Create the touch objects on the first and last teeth |
10 | | -back_button = touchio.TouchIn(board.TOUCH1) |
11 | | -forward_button = touchio.TouchIn(board.TOUCH4) |
| 10 | +# Set the touch objects to the first and last teeth |
| 11 | +back_pin = board.TOUCH1 |
| 12 | +forward_pin = board.TOUCH4 |
| 13 | + |
| 14 | +# Perform a couple extra steps for the HalloWing M4 |
| 15 | +try: |
| 16 | + if getattr(board, "CAP_PIN"): |
| 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 |
| 26 | +except AttributeError: |
| 27 | + pass |
| 28 | + |
| 29 | +# Create the touchio objects for HalloWing M0 |
| 30 | +back_button = touchio.TouchIn(back_pin) |
| 31 | +forward_button = touchio.TouchIn(forward_pin) |
12 | 32 |
|
13 | 33 | # Setup the speaker output |
14 | 34 | a = audioio.AudioOut(board.SPEAKER) |
15 | 35 |
|
16 | | - |
17 | 36 | # Helper function that takes in the file name string, splits it at the period, and keeps only the |
18 | 37 | # beginning of the string. i.e. kitten.bmp becomes kitten. |
19 | 38 | def basename(file_name): |
|
0 commit comments