Code cleanup

This commit is contained in:
9and3r
2014-08-08 15:33:47 +02:00
parent 4abfb1e697
commit 3102375e63
2 changed files with 29 additions and 16 deletions

View File

@@ -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

View File

@@ -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)
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)
# 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)
# 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)
# 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)
# 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):