Browse Source

Code cleanup

9and3r 11 years ago
parent
commit
3102375e63
2 changed files with 33 additions and 20 deletions
  1. 7 0
      .travis.yml
  2. 26 20
      mopidy_touchscreen/gpio_inpput_manager.py

+ 7 - 0
.travis.yml

@@ -21,3 +21,10 @@ script:
 after_success:
   - "if [ $TOX_ENV == 'py27' ]; then pip install coveralls; coveralls; fi"
 
+notifications:
+  email:
+    recipients:
+      - 9and3r@gmail.com
+    on_success: change
+    on_failure: change
+

+ 26 - 20
mopidy_touchscreen/gpio_inpput_manager.py

@@ -1,34 +1,40 @@
-import RPi.GPIO as GPIO
 import logging
 import pygame
 
+import RPi.GPIO as GPIO
+
+
 logger = logging.getLogger(__name__)
 
 
 class GPIOManager():
-
     def __init__(self, pins):
         GPIO.setmode(GPIO.BCM)
 
         # Left Button
-        GPIO.setup(pins['left'], GPIO.IN, pull_up_down = GPIO.PUD_UP)
-        GPIO.add_event_detect(pins['left'], GPIO.BOTH, callback=left, bouncetime=30)
-
-         # Right Button
-        GPIO.setup(pins['right'], GPIO.IN, pull_up_down = GPIO.PUD_UP)
-        GPIO.add_event_detect(pins['right'], GPIO.BOTH, callback=right, bouncetime=30)
-
-         # Up Button
-        GPIO.setup(pins['up'], GPIO.IN, pull_up_down = GPIO.PUD_UP)
-        GPIO.add_event_detect(pins['up'], GPIO.BOTH, callback=up, bouncetime=30)
-
-         # Down Button
-        GPIO.setup(pins['down'], GPIO.IN, pull_up_down = GPIO.PUD_UP)
-        GPIO.add_event_detect(pins['down'], GPIO.BOTH, callback=right, bouncetime=30)
-
-         # Enter Button
-        GPIO.setup(pins['enter'], GPIO.IN, pull_up_down = GPIO.PUD_UP)
-        GPIO.add_event_detect(pins['enter'], GPIO.BOTH, callback=right, bouncetime=30)
+        GPIO.setup(pins['left'], GPIO.IN, pull_up_down=GPIO.PUD_UP)
+        GPIO.add_event_detect(pins['left'], GPIO.BOTH, callback=left,
+                              bouncetime=30)
+
+        # Right Button
+        GPIO.setup(pins['right'], GPIO.IN, pull_up_down=GPIO.PUD_UP)
+        GPIO.add_event_detect(pins['right'], GPIO.BOTH, callback=right,
+                              bouncetime=30)
+
+        # Up Button
+        GPIO.setup(pins['up'], GPIO.IN, pull_up_down=GPIO.PUD_UP)
+        GPIO.add_event_detect(pins['up'], GPIO.BOTH, callback=up,
+                              bouncetime=30)
+
+        # Down Button
+        GPIO.setup(pins['down'], GPIO.IN, pull_up_down=GPIO.PUD_UP)
+        GPIO.add_event_detect(pins['down'], GPIO.BOTH, callback=right,
+                              bouncetime=30)
+
+        # Enter Button
+        GPIO.setup(pins['enter'], GPIO.IN, pull_up_down=GPIO.PUD_UP)
+        GPIO.add_event_detect(pins['enter'], GPIO.BOTH, callback=right,
+                              bouncetime=30)
 
 
 def right(channel):