From 51ec39d43e2ef42b34b555a01ac0b57bb2f5eba7 Mon Sep 17 00:00:00 2001 From: Pi user Date: Mon, 21 Oct 2013 16:48:55 +0100 Subject: [PATCH] Simplified keyboard.py --- keyboard.py | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/keyboard.py b/keyboard.py index 9b4183c..237d7c6 100644 --- a/keyboard.py +++ b/keyboard.py @@ -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) -- 2.34.1