Skip to content

Commit 3c39c45

Browse files
authored
Merge pull request #193 from ttreker/gpiod
Fixed ambiguous GPIO numbers in buttons.py example code
2 parents 85e868b + 6aa87b4 commit 3c39c45

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

examples/7color/buttons.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@
1717
# GPIO pins for each button (from top to bottom)
1818
# These will vary depending on platform and the ones
1919
# 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]
2229

2330
# These correspond to buttons A, B, C and D respectively
2431
LABELS = ["A", "B", "C", "D"]
@@ -43,9 +50,9 @@
4350
# It receives one argument: the associated gpiod event object.
4451
def handle_button(event):
4552
index = OFFSETS.index(event.line_offset)
46-
pin = BUTTONS[index]
53+
gpio_number = BUTTONS[index]
4754
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}")
4956

5057

5158
while True:

0 commit comments

Comments
 (0)