From: Guillaume Pellerin Date: Tue, 23 Jul 2013 01:17:30 +0000 (+0200) Subject: working well with DOWN method X-Git-Tag: 0.3~33 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=93e01d17ae38db1c85a33d366d2e2f8bdea8a092;p=piplayer.git working well with DOWN method --- diff --git a/piplayer.py b/piplayer.py index 6687fe6..b55db7a 100644 --- a/piplayer.py +++ b/piplayer.py @@ -55,18 +55,18 @@ class GPIOController(Thread): def __init__(self, channel): Thread.__init__(self) - self.gpio_channel = channel - - def add_callback(self, callback): import RPi.GPIO as GPIO + self.server = GPIO + self.gpio_channel = channel GPIO.setmode(GPIO.BCM) - GPIO.setup(self.gpio_channel, GPIO.IN, pull_up_down=GPIO.PUD_UP) - GPIO.add_event_detect(self.gpio_channel, GPIO.PUD_UP, callback=callback) + GPIO.setup(self.gpio_channel, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) + + def add_callback(self, callback): + GPIO.add_event_detect(self.gpio_channel, GPIO.PUD_DOWN, callback=callback, bouncetime=100) def run(self): - while True: - time.sleep(0.1) - + pass + class AudioPlayer(object):