From 15954964d3a0f1972e7e4a63220498bfde03e3dc Mon Sep 17 00:00:00 2001 From: Andreas Demmelbauer Date: Sun, 17 Mar 2019 22:57:10 +0000 Subject: [PATCH] more --- discobert.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ lircrc | 9 +++++++++ 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/discobert.py b/discobert.py index 1c5311a..fe87d9e 100644 --- a/discobert.py +++ b/discobert.py @@ -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 diff --git a/lircrc b/lircrc index 7b0cb30..7baeade 100644 --- a/lircrc +++ b/lircrc @@ -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