This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
Pi/Moped/UserLed.py

41 lines
776 B
Python
Raw Normal View History

2016-01-07 19:51:49 +00:00
#!/usr/bin/python
2016-01-07 19:03:21 +00:00
import ConfigParser
import RPi.GPIO as GPIO
yellowLed = 15
redLed = 17
greenLed = 18
2016-01-07 19:51:49 +00:00
mopidyConf = '/etc/mopidy/mopidy.conf'
2016-01-07 19:03:21 +00:00
def setLeds(yellow, red, green):
GPIO.output(yellowLed, yellow)
GPIO.output(redLed, red)
GPIO.output(greenLed, green)
2016-01-07 19:51:49 +00:00
def getConfiguredLedColor():
config = ConfigParser.ConfigParser()
config.read(mopidyConf)
return config.get('moped-switcher', 'led')
def setConfiguredLedColor():
ledColor = getConfiguredLedColor()
2016-01-07 19:03:21 +00:00
2016-01-07 19:51:49 +00:00
if ledColor == 'yellow':
setLeds(1, 0, 0)
elif ledColor == 'red':
setLeds(0, 1, 0)
elif ledColor == 'green':
setLeds(0, 0, 1)
2016-01-07 19:03:21 +00:00
GPIO.setmode(GPIO.BCM)
GPIO.setup(yellowLed, GPIO.OUT)
GPIO.setup(redLed, GPIO.OUT)
GPIO.setup(greenLed, GPIO.OUT)
2016-01-07 19:51:49 +00:00
setConfiguredLedColor()
2016-01-07 19:03:21 +00:00
GPIO.cleanup()