Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ambiguous GPIO numbers in buttons.py example code #193

Open
wants to merge 2 commits into
base: gpiod
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions examples/7color/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@
# GPIO pins for each button (from top to bottom)
# These will vary depending on platform and the ones
# below should be correct for Raspberry Pi 5.
# Run "gpioinfo" to find out what yours might be
BUTTONS = ["PIN29", "PIN31", "PIN36", "PIN18"]
# Run "gpioinfo" to find out what yours might be.
#
# Raspberry Pi 5 Header pins used by Inky Impression:
# PIN29, PIN31, PIN36, PIN18.
# These header pins correspond to BCM GPIO numbers:
# GPIO05, GPIO06, GPIO16, GPIO24.
# These GPIO numbers are what is used below and not the
# header pin numbers.
BUTTONS = [5, 6, 16, 24]

# These correspond to buttons A, B, C and D respectively
LABELS = ["A", "B", "C", "D"]
Expand All @@ -43,9 +50,9 @@
# It receives one argument: the associated gpiod event object.
def handle_button(event):
index = OFFSETS.index(event.line_offset)
pin = BUTTONS[index]
gpio_number = BUTTONS[index]
label = LABELS[index]
print(f"Button press detected on pin: {pin} label: {label}")
print(f"Button press detected on GPIO #{gpio_number} label: {label}")


while True:
Expand Down
Loading