From cfab03313af57fc3608b051d73171cfdc60bf502 Mon Sep 17 00:00:00 2001 From: mandlm Date: Thu, 7 Jan 2016 20:03:21 +0100 Subject: [PATCH] Turn on user-configured led --- Moped/UserLed.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 Moped/UserLed.py diff --git a/Moped/UserLed.py b/Moped/UserLed.py new file mode 100755 index 0000000..8c812a7 --- /dev/null +++ b/Moped/UserLed.py @@ -0,0 +1,33 @@ +#!/usr/bin/python + +import ConfigParser +import RPi.GPIO as GPIO + +yellowLed = 15 +redLed = 17 +greenLed = 18 + +def setLeds(yellow, red, green): + GPIO.output(yellowLed, yellow) + GPIO.output(redLed, red) + GPIO.output(greenLed, green) + +config = ConfigParser.ConfigParser() +config.read('/etc/mopidy/mopidy.conf') + +ledColor = config.get('moped-switcher', 'led') + +GPIO.setmode(GPIO.BCM) +GPIO.setup(yellowLed, GPIO.OUT) +GPIO.setup(redLed, GPIO.OUT) +GPIO.setup(greenLed, GPIO.OUT) + +if ledColor == 'yellow': + print 'yellow' + setLeds(1, 0, 0) +elif ledColor == 'red': + setLeds(0, 1, 0) +elif ledColor == 'green': + setLeds(0, 0, 1) + +GPIO.cleanup()