9and3r 11 жил өмнө
parent
commit
cae59ca388

+ 11 - 5
mopidy_touchscreen/gpio_inpput_manager.py

@@ -3,12 +3,18 @@ import logging
 
 
 logger = logging.getLogger(__name__)
 logger = logging.getLogger(__name__)
 
 
-def printFunction():
-    logger.error("Sakatu da")
 
 
-GPIO.setmode(GPIO.BCM)
-GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
-GPIO.add_event_detect(23, GPIO.RISING, callback=printFunction, bouncetime=300)
+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=self.printFunction, bouncetime=30)
+
+    def printFunction(self, channel):
+        logger.error(channel)
+
+
 
 
 
 
 
 

+ 2 - 1
mopidy_touchscreen/touch_screen.py

@@ -31,7 +31,8 @@ class TouchScreen(pykka.ThreadingActor, core.CoreListener):
         # Raspberry pi GPIO
         # Raspberry pi GPIO
         self.gpio = config['touchscreen']['gpio']
         self.gpio = config['touchscreen']['gpio']
         if self.gpio:
         if self.gpio:
-            import GPIOManager
+            from .gpio_inpput_manager import GPIOManager
+            self.gpio_manager = GPIOManager()
 
 
     def start_thread(self):
     def start_thread(self):
         clock = pygame.time.Clock()
         clock = pygame.time.Clock()