Simplified keyboard.py
authorPi user <pi@njae.me.uk>
Mon, 21 Oct 2013 15:48:55 +0000 (16:48 +0100)
committerPi user <pi@njae.me.uk>
Mon, 21 Oct 2013 15:48:55 +0000 (16:48 +0100)
keyboard.py

index 9b4183c6dccf60ed0e765409d899675fe4c320aa..237d7c668b98533ffdf02ad1cc91b15be018a5b0 100644 (file)
@@ -1,35 +1,11 @@
 import pygame
 import RPi.GPIO as gpio
-import logging
-
-logger = logging.getLogger(__name__)
-loggerFileHandler = logging.FileHandler('keyboard.log')
-loggerFileHandlerFormatter = logging.Formatter('%(asctime)s %(levelname)-8s  %(message)s')
-loggerFileHandler.setFormatter(loggerFileHandlerFormatter)
-logger.addHandler(loggerFileHandler)
-logger.setLevel(logging.WARNING)
-logger.setLevel(logging.INFO)
 
 gpio.setmode(gpio.BCM)
 if gpio.RPI_REVISION == 1:
     pins = [22, 21, 17, 4, 25, 24, 23, 18]
 else:
     pins = [22, 27, 17, 4, 25, 24, 23, 18]
-# pins = [25]
-
-notes = ['sounds/keyboard-fsharp-low.wav',
-         'sounds/keyboard-g.wav',
-         'sounds/keyboard-gsharp.wav',
-         'sounds/keyboard-a.wav',
-         'sounds/keyboard-asharp.wav',
-         'sounds/keyboard-b.wav',
-         'sounds/keyboard-c.wav',
-         'sounds/keyboard-csharp.wav',
-         'sounds/keyboard-d.wav',
-         'sounds/keyboard-dsharp.wav',
-         'sounds/keyboard-e.wav',
-         'sounds/keyboard-f.wav',
-         'sounds/keyboard-fsharp-high.wav']
 
 notes = ['sounds/keyboard-g.wav',
          'sounds/keyboard-a.wav',
@@ -40,7 +16,6 @@ notes = ['sounds/keyboard-g.wav',
          'sounds/keyboard-f.wav',
          'sounds/keyboard-g-high.wav']
 
-
 pygame.mixer.init()
 
 sounds = {}
@@ -50,10 +25,8 @@ for pin, wav in zip(pins, notes):
 def handle_sound(pin):
     if gpio.input(pin):
         sounds[pin].play()
-        logger.info("Started playing {0}".format(pins.index(pin)))
     else:
         sounds[pin].stop()
-        logger.info("Stopped playing {0}".format(pins.index(pin)))
 
 for pin in pins:
     gpio.setup(pin, gpio.IN)