|
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 | +# Detect if this is the HalloWing M4 or M0 |
| 15 | +is_hallowing_m4 = False |
| 16 | +try: |
| 17 | + if getattr(board, "CAP_PIN"): |
| 18 | + is_hallowing_m4 = True |
| 19 | +except AttributeError: |
| 20 | + pass |
| 21 | + |
| 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) |
12 | 43 |
|
13 | 44 | # Setup the speaker output |
14 | 45 | a = audioio.AudioOut(board.SPEAKER) |
15 | 46 |
|
16 | | - |
17 | 47 | # Helper function that takes in the file name string, splits it at the period, and keeps only the |
18 | 48 | # beginning of the string. i.e. kitten.bmp becomes kitten. |
19 | 49 | def basename(file_name): |
|
0 commit comments