@@ -1,13 +1,14 @@ | |||||
Discobert is a multimedial toilet experience device | Discobert is a multimedial toilet experience device | ||||
The Setup is pretty custom. It includes: | The Setup is pretty custom. It includes: | ||||
* Raspberry Pi 3b+ | * Raspberry Pi 3b+ | ||||
* Relay Board for switching 220V Devices | * Relay Board for switching 220V Devices | ||||
* Relay 1: | * Relay 1: | ||||
* Light Bulb | |||||
* Light Bulb | |||||
* Relay 3: | * Relay 3: | ||||
* DMX Light | |||||
* Disco Ball + Motor | |||||
* DMX Light | |||||
* Disco Ball + Motor | |||||
* PIR sensor | * PIR sensor | ||||
* Door open/closed Sensor | * Door open/closed Sensor | ||||
* IR Receiver | * IR Receiver | ||||
@@ -38,26 +39,33 @@ cd discobert | |||||
``` | ``` | ||||
configure mpd | configure mpd | ||||
``` | ``` | ||||
sudo cp mpd.conf /etc/mpd.conf | sudo cp mpd.conf /etc/mpd.conf | ||||
``` | ``` | ||||
configure samba share | configure samba share | ||||
``` | ``` | ||||
sudo cp smb.conf /etc/samba/smb.conf | sudo cp smb.conf /etc/samba/smb.conf | ||||
``` | ``` | ||||
install pip modules | install pip modules | ||||
``` | ``` | ||||
pip3 install -r requirements.txt | pip3 install -r requirements.txt | ||||
``` | ``` | ||||
add systemd service | add systemd service | ||||
``` | ``` | ||||
sudo cp disco.service /lib/systemd/system/disco.service | sudo cp disco.service /lib/systemd/system/disco.service | ||||
sudo systemctl daemon-reload | sudo systemctl daemon-reload | ||||
``` | ``` | ||||
### Setting up a random remote | ### Setting up a random remote | ||||
Use `irrecord` to create a lirc Config file and copy the generated file in `/etc/lirc/lircd.conf.d/your-remotes-name.lircd.conf` | |||||
Use `irrecord` to create a lirc Config file and copy the generated file in | |||||
`/etc/lirc/lircd.conf.d/your-remotes-name.lircd.conf` | |||||
You can find and edit the used keycodes: `~/discobert/lircrc` | You can find and edit the used keycodes: `~/discobert/lircrc` | ||||
@@ -114,6 +114,20 @@ def startMusic(playlist, single=False, shuffle=True, repeat=True): | |||||
client.setvol(80)# set volume | client.setvol(80)# set volume | ||||
client.play() # play | client.play() # play | ||||
def playMusic(): | |||||
try: | |||||
client.play() | |||||
except Exception: | |||||
client.connect("localhost", 6600) | |||||
client.play() | |||||
def pauseMusic(): | |||||
try: | |||||
client.pause() | |||||
except Exception: | |||||
client.connect("localhost", 6600) | |||||
client.pause() | |||||
def stopMusic(): | def stopMusic(): | ||||
try: | try: | ||||
client.stop() | client.stop() | ||||
@@ -121,6 +135,20 @@ def stopMusic(): | |||||
client.connect("localhost", 6600) | client.connect("localhost", 6600) | ||||
client.stop() | client.stop() | ||||
def nextSong(): | |||||
try: | |||||
client.next() | |||||
except Exception: | |||||
client.connect("localhost", 6600) | |||||
client.next() | |||||
def previousSong(): | |||||
try: | |||||
client.previous() | |||||
except Exception: | |||||
client.connect("localhost", 6600) | |||||
client.previous() | |||||
def muteMusic(): | def muteMusic(): | ||||
global uservolume | global uservolume | ||||
if getMpdVolume() != 0: # if not muted | if getMpdVolume() != 0: # if not muted | ||||
@@ -185,6 +213,13 @@ def setMpdVolume(vol): | |||||
uservolume = vol | uservolume = vol | ||||
return True | return True | ||||
def seek(secs): | |||||
try: | |||||
client.seekcur(secs) | |||||
except Exception: | |||||
client.connect("localhost", 6600) | |||||
client.seekcur(secs) | |||||
return True | |||||
def getTrackInfo(): | def getTrackInfo(): | ||||
try: | try: | ||||
@@ -255,6 +290,7 @@ def closeService(sleepsecs=0): | |||||
changeVolume(-5) | changeVolume(-5) | ||||
sleep(0.1) | sleep(0.1) | ||||
stopMusic() | stopMusic() | ||||
inUseBefore = False # Pfusch pfusch! | |||||
setMode('off') | setMode('off') | ||||
sleep(sleepsecs) | sleep(sleepsecs) | ||||
@@ -355,7 +391,6 @@ while True: | |||||
if doorstate == 1: | if doorstate == 1: | ||||
if (time.time() > (starttime + 15) and inUse == True): | if (time.time() > (starttime + 15) and inUse == True): | ||||
doorShutdown() | doorShutdown() | ||||
inUseBefore = False # Pfusch pfusch! | |||||
if pirstate == 1: | if pirstate == 1: | ||||
@@ -395,19 +430,40 @@ while True: | |||||
startMusic('http://185.85.29.141:8000') | startMusic('http://185.85.29.141:8000') | ||||
if(code == "mode_play_oe1"): | if(code == "mode_play_oe1"): | ||||
startMusic('http://185.85.29.142:8000') | startMusic('http://185.85.29.142:8000') | ||||
if(code == "mode_music_previous"): | |||||
previousSong() | |||||
if(code == "mode_music_next"): | |||||
nextSong() | |||||
if(code == "mode_music_play"): | |||||
playMusic() | |||||
if(code == "mode_music_stop"): | if(code == "mode_music_stop"): | ||||
stopMusic() | stopMusic() | ||||
if(code == "mode_music_mute"): | if(code == "mode_music_mute"): | ||||
muteMusic() | muteMusic() | ||||
if(code == "mode_music_pause"): | |||||
pauseMusic() | |||||
if(code == "mode_music_rewind"): | |||||
seek(-30) | |||||
if(code == "mode_music_back"): | |||||
seek(-5) | |||||
if(code == "mode_music_forward"): | |||||
seek(5) | |||||
if(code == "mode_music_fastforward"): | |||||
seek(30) | |||||
if(code == "mode_volume_up"): | if(code == "mode_volume_up"): | ||||
changeVolume(5) | changeVolume(5) | ||||
if(code == "mode_volume_down"): | if(code == "mode_volume_down"): | ||||
changeVolume(-5) | changeVolume(-5) | ||||
if(code == "mode_music_info"): | if(code == "mode_music_info"): | ||||
getTrackInfo() | getTrackInfo() | ||||
if(code == "mode_record"): | if(code == "mode_record"): | ||||
say("I'm sorry, I'm afraid I can't do that!") | say("I'm sorry, I'm afraid I can't do that!") | ||||
if(code == "mode_home"): | |||||
if(code == "mode_help"): | |||||
tour() | tour() | ||||
@@ -59,52 +59,106 @@ begin | |||||
end | end | ||||
begin | begin | ||||
button = KEY_HOME | |||||
button = KEY_CD | |||||
prog = disco | prog = disco | ||||
config = mode_home | |||||
config = mode_help | |||||
end | end | ||||
begin | begin | ||||
button = KEY_RADIO | |||||
button = KEY_VCR2 | |||||
prog = disco | prog = disco | ||||
config = mode_play_fm4 | config = mode_play_fm4 | ||||
end | end | ||||
begin | begin | ||||
button = KEY_SETUP | |||||
button = KEY_VCR | |||||
prog = disco | prog = disco | ||||
config = mode_play_oe1 | config = mode_play_oe1 | ||||
end | end | ||||
begin | begin | ||||
button = KEY_VIDEO | |||||
button = BTN_START | |||||
prog = disco | prog = disco | ||||
config = mode_disco | config = mode_disco | ||||
end | end | ||||
begin | begin | ||||
button = KEY_PICTURES | |||||
button = KEY_STOP | |||||
prog = disco | prog = disco | ||||
config = mode_work | config = mode_work | ||||
end | end | ||||
begin | begin | ||||
button = KEY_MUSIC | |||||
button = KEY_STOPCD | |||||
prog = disco | |||||
config = mode_work | |||||
end | |||||
begin | |||||
button = KEY_RECORD | |||||
prog = disco | prog = disco | ||||
config = mode_music_info | config = mode_music_info | ||||
end | end | ||||
begin | |||||
button = KEY_PAUSE | |||||
prog = disco | |||||
config = mode_music_pause | |||||
end | |||||
begin | |||||
button = KEY_PLAY | |||||
prog = disco | |||||
config = mode_music_play | |||||
end | |||||
begin | |||||
button = KEY_FORWARD | |||||
prog = disco | |||||
config = mode_music_forward | |||||
end | |||||
begin | begin | ||||
button = KEY_POWER | |||||
button = KEY_FASTFORWARD | |||||
prog = disco | prog = disco | ||||
config = mode_power | |||||
config = mode_music_fastforward | |||||
end | end | ||||
begin | begin | ||||
button = KEY_RECORD | |||||
button = KEY_BACK | |||||
prog = disco | |||||
config = mode_music_back | |||||
end | |||||
begin | |||||
button = KEY_REWIND | |||||
prog = disco | |||||
config = mode_music_rewind | |||||
end | |||||
begin | |||||
button = KEY_REWIND | |||||
prog = disco | |||||
config = mode_music_rewind | |||||
end | |||||
begin | |||||
button = KEY_NEXT | |||||
prog = disco | prog = disco | ||||
config = mode_record | |||||
config = mode_music_next | |||||
end | |||||
begin | |||||
button = KEY_PREVIOUS | |||||
prog = disco | |||||
config = mode_music_previous | |||||
end | |||||
begin | |||||
button = KEY_POWER | |||||
prog = disco | |||||
config = mode_power | |||||
end | end |