Browse Source

Merge branch 'master' of git.notice.at:redplanet/discobert

master
Andreas Demmelbauer 4 years ago
parent
commit
8c1c9a32aa
2 changed files with 38 additions and 10 deletions
  1. +14
    -10
      discobert.py
  2. +24
    -0
      lircrc

+ 14
- 10
discobert.py View File

@@ -23,13 +23,13 @@ class Simple(resource.Resource):
def render_GET(self, request): def render_GET(self, request):
statustext = "" statustext = ""
if inUse: if inUse:
statustext = "Disco in use!"
statustext = "true"
else: else:
statustext = "Ready to Disco!"
html = '<html><body style="min-height:100vh;display:flex;flex-grow:1;align-items:center;justify-content:center;"><div style="display:flex;font-size:10vw">%s</div></body></html>' % statustext
statustext = "false"
html = '[{"inuse":"%s"}]' % statustext
return html.encode('utf-8') return html.encode('utf-8')



# GPIO # GPIO
pin_kugel = 2 # Input: dico ball + DMX on/off pin_kugel = 2 # Input: dico ball + DMX on/off
pin_sun = 4 # Input: light bulb on/off pin_sun = 4 # Input: light bulb on/off
@@ -317,6 +317,10 @@ def startTimeoutCountdown():
tts.say('Shutting down now.', 'en') tts.say('Shutting down now.', 'en')
closeService() closeService()


def inactiveShutdown():
closeService()


def closeService(sleepsecs=0): def closeService(sleepsecs=0):
setSun('off') setSun('off')
sleep(0.3) sleep(0.3)
@@ -366,7 +370,7 @@ def setOnOff():
initService() initService()


def doorShutdown(): def doorShutdown():
tts.say(random.choice(bye_sayings), "en")
#tts.say(random.choice(bye_sayings), "en")
# sleep to give user some time to close the door # sleep to give user some time to close the door
# (pir sensor also stays up for 2 sec) # (pir sensor also stays up for 2 sec)
closeService(5) closeService(5)
@@ -402,7 +406,6 @@ reactor.listenTCP(8080, site)
reactor.startRunning(False) reactor.startRunning(False)




lirc.init("disco", "~/discobert/lircrc", blocking=False)


starttime = time.time() # helper for doorshutdown starttime = time.time() # helper for doorshutdown
lastUsed = time.time() # helper for timeout lastUsed = time.time() # helper for timeout
@@ -418,6 +421,7 @@ setSun('off')


print(timestamp(), "Ready!") print(timestamp(), "Ready!")


lirc.init("disco", "~/discobert/lircrc", blocking=False)


# Main event loop ... # Main event loop ...
while True: while True:
@@ -446,7 +450,7 @@ while True:




remotesignal = lirc.nextcode() remotesignal = lirc.nextcode()
#print('remotesignal: ', remotesignal)
print('remotesignal: ', remotesignal)


if remotesignal: if remotesignal:
lastUsed = time.time() # user is active! lastUsed = time.time() # user is active!
@@ -511,19 +515,19 @@ while True:
startMusic(oejournalUrl) startMusic(oejournalUrl)





if(inUseBefore != inUse): if(inUseBefore != inUse):
print(timestamp(), "State change inUse:", inUseBefore, inUse) print(timestamp(), "State change inUse:", inUseBefore, inUse)
if inUse: if inUse:
initService() initService()
else: else:
startTimeoutCountdown()
inactiveShutdown()
#startTimeoutCountdown()
inUseBefore = inUse inUseBefore = inUse


# Webserver # Webserver
reactor.iterate() reactor.iterate()



lirc.deinit() # Clean up lirc lirc.deinit() # Clean up lirc



dev.close() dev.close()

+ 24
- 0
lircrc View File

@@ -2,54 +2,63 @@ begin
button = KEY_STARTPHONO button = KEY_STARTPHONO
prog = disco prog = disco
config = mode_disco config = mode_disco
repeat = 20
end end


begin begin
button = KEY_STOPPHONO button = KEY_STOPPHONO
prog = disco prog = disco
config = mode_work config = mode_work
repeat = 20
end end


begin begin
button = KEY_TAPE button = KEY_TAPE
prog = disco prog = disco
config = mode_power config = mode_power
repeat = 20
end end


begin begin
button = KEY_1 button = KEY_1
prog = disco prog = disco
config = mode_music_play_1 config = mode_music_play_1
repeat = 20
end end


begin begin
button = KEY_2 button = KEY_2
prog = disco prog = disco
config = mode_music_play_2 config = mode_music_play_2
repeat = 20
end end


begin begin
button = KEY_3 button = KEY_3
prog = disco prog = disco
config = mode_music_play_3 config = mode_music_play_3
repeat = 20
end end


begin begin
button = KEY_4 button = KEY_4
prog = disco prog = disco
config = mode_music_play_4 config = mode_music_play_4
repeat = 20
end end


begin begin
button = KEY_5 button = KEY_5
prog = disco prog = disco
config = mode_music_play_5 config = mode_music_play_5
repeat = 20
end end


begin begin
button = KEY_STOP button = KEY_STOP
prog = disco prog = disco
config = mode_music_stop config = mode_music_stop
repeat = 20
end end




@@ -65,12 +74,14 @@ begin
button = KEY_VCR2 button = KEY_VCR2
prog = disco prog = disco
config = mode_play_fm4 config = mode_play_fm4
repeat = 20
end end


begin begin
button = KEY_VCR button = KEY_VCR
prog = disco prog = disco
config = mode_play_oe1 config = mode_play_oe1
repeat = 20
end end




@@ -78,60 +89,70 @@ begin
button = KEY_STOPCD button = KEY_STOPCD
prog = disco prog = disco
config = mode_music_stop config = mode_music_stop
repeat = 20
end end


begin begin
button = KEY_RECORD button = KEY_RECORD
prog = disco prog = disco
config = mode_music_info config = mode_music_info
repeat = 20
end end


begin begin
button = KEY_PAUSE button = KEY_PAUSE
prog = disco prog = disco
config = mode_music_pause config = mode_music_pause
repeat = 20
end end


begin begin
button = KEY_PLAY button = KEY_PLAY
prog = disco prog = disco
config = mode_music_play config = mode_music_play
repeat = 20
end end


begin begin
button = KEY_REWIND button = KEY_REWIND
prog = disco prog = disco
config = mode_music_rewind config = mode_music_rewind
repeat = 20
end end


begin begin
button = KEY_BACK button = KEY_BACK
prog = disco prog = disco
config = mode_music_back config = mode_music_back
repeat = 20
end end


begin begin
button = KEY_FORWARD button = KEY_FORWARD
prog = disco prog = disco
config = mode_music_forward config = mode_music_forward
repeat = 20
end end


begin begin
button = KEY_FASTFORWARD button = KEY_FASTFORWARD
prog = disco prog = disco
config = mode_music_fastforward config = mode_music_fastforward
repeat = 20
end end


begin begin
button = KEY_NEXT button = KEY_NEXT
prog = disco prog = disco
config = mode_music_next config = mode_music_next
repeat = 20
end end


begin begin
button = KEY_PREVIOUS button = KEY_PREVIOUS
prog = disco prog = disco
config = mode_music_previous config = mode_music_previous
repeat = 20
end end


begin begin
@@ -139,6 +160,7 @@ begin
prog = disco prog = disco
repeat = 2 repeat = 2
config = mode_volume_up config = mode_volume_up
repeat = 20
end end


begin begin
@@ -146,10 +168,12 @@ begin
prog = disco prog = disco
repeat = 2 repeat = 2
config = mode_volume_down config = mode_volume_down
repeat = 20
end end


begin begin
button = KEY_MUTE button = KEY_MUTE
prog = disco prog = disco
config = mode_music_mute config = mode_music_mute
repeat = 20
end end

Loading…
Cancel
Save