]> git.parisson.com Git - piplayer.git/commitdiff
fix gpio parasite filter, goto 0.3
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 24 Oct 2013 17:20:17 +0000 (19:20 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 24 Oct 2013 17:20:17 +0000 (19:20 +0200)
piplayer/__init__.py
piplayer/player.py
setup.py

index 7e860d935202373666ab5dd3da5242997d83257a..56d8dedfe89168116f4c06184f9b1e9771353638 100644 (file)
@@ -1,3 +1,3 @@
 
-__version__ = '0.2'
+__version__ = '0.3'
 
index 1e64f75e02dad29ecd14bb77b288d12451cc0446..7fab4972a37930b3fbc2b1c7e109c713cabf564c 100644 (file)
@@ -32,6 +32,7 @@ import pygst
 pygst.require("0.10")
 import gst
 import os, sys
+import time
 
 from piplayer.tools import *
 from piplayer.controller import *
@@ -46,7 +47,7 @@ class PiPlayer(object):
     looping = False
     auto_next = False
     alsa_device = 'hw:0'
-    parasite_filter_time = 0.02
+    gpio_parasite_filter_time = 0.02
     
     def __init__(self, play_dir):
         # Playlist
@@ -157,16 +158,14 @@ class PiPlayer(object):
         if DEBUG:
             print self.play_id, self.uri
 
-    def parasite_filter(self):
-        import RPi.GPIO as GPIO
-        time.sleep(self.parasite_filter_time)
-        return GPIO.input(self.gpio_channel_play):
+    def gpio_parasite_filter(self):
+        time.sleep(self.gpio_parasite_filter_time)
+        return self.gpio_controller.server.input(self.gpio_channel_play)
             
     def play(self):
-        if not self.playing:
-            if self.parasite_filter():
-                self.pipeline.set_state(gst.STATE_PLAYING)
-                self.playing = True
+        if not self.playing:    
+            self.pipeline.set_state(gst.STATE_PLAYING)
+            self.playing = True
         elif self.auto_next:
             self.next()
 
@@ -183,10 +182,12 @@ class PiPlayer(object):
             self.stop()
             
     def gpio_play(self, channel):
-        self.play()
+        if self.gpio_parasite_filter():
+            self.play()
 
     def gpio_stop(self, channel):
-        self.stop()
+        if self.gpio_parasite_filter():
+            self.stop()
             
     def run(self):
         self.mainloop.run()
index 15f2c27bb4b33f5d24fbe4fb6cd4b6fcba919eb6..fab5920279ea997edd59161ef1d0fe2b70856812 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,7 @@ setup(
   long_description = open('README.md').read(),
   author = "Guillaume Pellerin",
   author_email = "yomguy@parisson.com",
-  version = '0.2',
+  version = '0.3',
   install_requires = [
         'setuptools',
         'pyliblo',