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) client.setvol(currentvol)
volume = currentvol volume = currentvol


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




def setWorkingMode(): def setWorkingMode():
@@ -190,17 +194,49 @@ def setWorkingMode():
setDmxScene('black') setDmxScene('black')
setMode('work') 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(): def closeService():
setSun('off') setSun('off')
sleep(0.3) sleep(0.3)
setKugel('off') setKugel('off')
setDmxScene('black') setDmxScene('black')

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


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



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


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



pirstate = wiringpi.digitalRead(6) pirstate = wiringpi.digitalRead(6)


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


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


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






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






+ 9
- 0
lircrc View File

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


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


begin
button = KEY_HOME
prog = disco
config = mode_home
end



begin begin
button = KEY_RADIO button = KEY_RADIO


Loading…
Cancel
Save