mirror of
https://github.com/Febbweiss/mopidy-touchscreen.git
synced 2026-03-05 06:35:43 +00:00
31 lines
554 B
Python
31 lines
554 B
Python
import RPi.GPIO as GPIO
|
|
import logging
|
|
import pygame
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class GPIOManager():
|
|
|
|
def __init__(self):
|
|
GPIO.setmode(GPIO.BCM)
|
|
GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP)
|
|
GPIO.add_event_detect(24, GPIO.BOTH, callback=right, bouncetime=30)
|
|
|
|
|
|
def right(channel):
|
|
dict = {}
|
|
if GPIO.input(channel) == 1:
|
|
type = pygame.KEYUP
|
|
else:
|
|
type = pygame.KEYDOWN
|
|
dict['key'] = pygame.K_RIGHT
|
|
event = pygame.event.Event(type, dict)
|
|
pygame.event.post(event)
|
|
|
|
|
|
|
|
|
|
|
|
|