Skip to content

Commit

Permalink
revert gpiozero
Browse files Browse the repository at this point in the history
  • Loading branch information
amcolash committed Sep 13, 2024
1 parent 7eeff57 commit bef7ad2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/python/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from board import SCL, SDA
import busio
from PIL import Image, ImageDraw, ImageFont, ImageOps
from gpiozero import Button
import RPi.GPIO as GPIO
import sys
import time

Expand Down Expand Up @@ -64,13 +64,16 @@ def __init__(self):
self.lastNotesTime = time.time()

# Set up GPIO Pins
down = Button(DOWN_BUTTON, bounce_time=0.3)
enter = Button(ENTER_BUTTON, bounce_time=0.3)
up = Button(UP_BUTTON, bounce_time=0.3)

down.when_pressed = lambda: self.button_callback(DOWN_BUTTON)
enter.when_pressed = lambda: self.button_callback(ENTER_BUTTON)
up.when_pressed = lambda: self.button_callback(UP_BUTTON)
GPIO.setup(DOWN_BUTTON, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(ENTER_BUTTON, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(UP_BUTTON, GPIO.IN, pull_up_down=GPIO.PUD_UP)

try:
GPIO.add_event_detect(DOWN_BUTTON, GPIO.FALLING, callback=self.button_callback, bouncetime=300)
GPIO.add_event_detect(ENTER_BUTTON, GPIO.FALLING, callback=self.button_callback, bouncetime=300)
GPIO.add_event_detect(UP_BUTTON, GPIO.FALLING, callback=self.button_callback, bouncetime=300)
except RuntimeError as e:
print(f"Error: {e}")

# Init i2c bus
i2c = busio.I2C(SCL, SDA)
Expand Down

0 comments on commit bef7ad2

Please sign in to comment.