Browse Source

more

master
Andreas Demmelbauer 5 years ago
parent
commit
15954964d3
2 changed files with 55 additions and 6 deletions
  1. +46
    -6
      discobert.py
  2. +9
    -0
      lircrc

+ 46
- 6
discobert.py View File

@@ -181,6 +181,10 @@ def getTrackInfo():
client.setvol(currentvol)
volume = currentvol

def tour():
tts.say('Willkommen am Discoklo!', 'de')
sleep(0.3)
tts.say('Willkommen am Discoklo!')


def setWorkingMode():
@@ -190,17 +194,49 @@ def setWorkingMode():
setDmxScene('black')
setMode('work')

def startTimeoutCountdown():
global lastUsed
global inUse
tts.say('Timeout in')
countdown = [5,4,3,2,1] #10,9,8,7,6,
for sec in countdown:
tts.say(str(sec))
sleep(0.5)
remotesignal = lirc.nextcode()
print(remotesignal)
if wiringpi.digitalRead(pin_pir) == 1 or remotesignal:
lastUsed = time.time()
tts.say('Timeout cancelled!')
inUse = True
toilet = lirc.nextcode()
break

if not inUse:
tts.say('Shutting down now. Good bye!', 'en')
closeService()

def closeService():
setSun('off')
sleep(0.3)
setKugel('off')
setDmxScene('black')

for x in range(0, 20):
changeVolume(-5)
sleep(0.1)
stopMusic()
setMode('off')

def initService():
startMusic('0', True)
startMusic('0', True) # start intro music
setDiscoMode()
global defaultvolume
try:
client.setvol(defaultvolume)
except Exception:
client.connect("localhost", 6600)
client.setvol(defaultvolume)


def setOnOff():
global mode
@@ -229,10 +265,11 @@ client = mpd.MPDClient()
client.connect("localhost", 6600)

tts = talkey.Talkey(
preferred_languages=['en', 'de'],
preferred_languages=['en'],
engine_preference=['pico'],
)


pirstate = wiringpi.digitalRead(6)

lirc.init("disco", "~/discobert/lircrc", blocking=False)
@@ -241,8 +278,9 @@ lastUsed = time.time()
inUse = True
mode = "none"
inUseBefore = True
timeout = 2 * 60
volume = 80
timeout = 2 * 60 - 10
defaultvolume = 90
volume = 90
isMuted = False

initService()
@@ -251,7 +289,7 @@ initService()

# Main event loop ...
while True:
sleep(0.2)
sleep(0.25)
pirstate = wiringpi.digitalRead(pin_pir)
#print('pirstate: ', pirstate)
if pirstate == 1:
@@ -299,6 +337,8 @@ while True:
changeVolume(-5)
if(code == "mode_music_info"):
getTrackInfo()
if(code == "mode_home"):
tour()



@@ -307,7 +347,7 @@ while True:
if inUse:
initService()
else:
closeService()
startTimeoutCountdown()
inUseBefore = inUse




+ 9
- 0
lircrc View File

@@ -47,15 +47,24 @@ end
begin
button = KEY_VOLUMEUP
prog = disco
repeat = 100
config = mode_volume_up
end

begin
button = KEY_VOLUMEDOWN
prog = disco
repeat = 100
delay = 1
config = mode_volume_down
end

begin
button = KEY_HOME
prog = disco
config = mode_home
end


begin
button = KEY_RADIO


Loading…
Cancel
Save