|
17 | 17 | # GPIO pins for each button (from top to bottom)
|
18 | 18 | # These will vary depending on platform and the ones
|
19 | 19 | # below should be correct for Raspberry Pi 5.
|
20 |
| -# Run "gpioinfo" to find out what yours might be |
21 |
| -BUTTONS = ["PIN29", "PIN31", "PIN36", "PIN18"] |
| 20 | +# Run "gpioinfo" to find out what yours might be. |
| 21 | +# |
| 22 | +# Raspberry Pi 5 Header pins used by Inky Impression: |
| 23 | +# PIN29, PIN31, PIN36, PIN18. |
| 24 | +# These header pins correspond to BCM GPIO numbers: |
| 25 | +# GPIO05, GPIO06, GPIO16, GPIO24. |
| 26 | +# These GPIO numbers are what is used below and not the |
| 27 | +# header pin numbers. |
| 28 | +BUTTONS = [5, 6, 16, 24] |
22 | 29 |
|
23 | 30 | # These correspond to buttons A, B, C and D respectively
|
24 | 31 | LABELS = ["A", "B", "C", "D"]
|
|
43 | 50 | # It receives one argument: the associated gpiod event object.
|
44 | 51 | def handle_button(event):
|
45 | 52 | index = OFFSETS.index(event.line_offset)
|
46 |
| - pin = BUTTONS[index] |
| 53 | + gpio_number = BUTTONS[index] |
47 | 54 | label = LABELS[index]
|
48 |
| - print(f"Button press detected on pin: {pin} label: {label}") |
| 55 | + print(f"Button press detected on GPIO #{gpio_number} label: {label}") |
49 | 56 |
|
50 | 57 |
|
51 | 58 | while True:
|
|
0 commit comments