diff --git a/discobert.py b/discobert.py index 4d0c77a..b825c00 100644 --- a/discobert.py +++ b/discobert.py @@ -23,13 +23,13 @@ class Simple(resource.Resource): def render_GET(self, request): statustext = "" if inUse: - statustext = "Disco in use!" + statustext = "true" else: - statustext = "Ready to Disco!" - html = '
%s
' % statustext + statustext = "false" + + html = '[{"inuse":"%s"}]' % statustext return html.encode('utf-8') - # GPIO pin_kugel = 2 # Input: dico ball + DMX on/off pin_sun = 4 # Input: light bulb on/off @@ -317,6 +317,10 @@ def startTimeoutCountdown(): tts.say('Shutting down now.', 'en') closeService() +def inactiveShutdown(): + closeService() + + def closeService(sleepsecs=0): setSun('off') sleep(0.3) @@ -366,7 +370,7 @@ def setOnOff(): initService() 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 # (pir sensor also stays up for 2 sec) closeService(5) @@ -402,7 +406,6 @@ reactor.listenTCP(8080, site) reactor.startRunning(False) -lirc.init("disco", "~/discobert/lircrc", blocking=False) starttime = time.time() # helper for doorshutdown lastUsed = time.time() # helper for timeout @@ -418,6 +421,7 @@ setSun('off') print(timestamp(), "Ready!") +lirc.init("disco", "~/discobert/lircrc", blocking=False) # Main event loop ... while True: @@ -446,7 +450,7 @@ while True: remotesignal = lirc.nextcode() - #print('remotesignal: ', remotesignal) + print('remotesignal: ', remotesignal) if remotesignal: lastUsed = time.time() # user is active! @@ -511,19 +515,19 @@ while True: startMusic(oejournalUrl) - if(inUseBefore != inUse): print(timestamp(), "State change inUse:", inUseBefore, inUse) if inUse: initService() else: - startTimeoutCountdown() + inactiveShutdown() + #startTimeoutCountdown() inUseBefore = inUse # Webserver reactor.iterate() - lirc.deinit() # Clean up lirc + dev.close() diff --git a/lircrc b/lircrc index a7b987a..1b09c87 100644 --- a/lircrc +++ b/lircrc @@ -2,54 +2,63 @@ begin button = KEY_STARTPHONO prog = disco config = mode_disco + repeat = 20 end begin button = KEY_STOPPHONO prog = disco config = mode_work + repeat = 20 end begin button = KEY_TAPE prog = disco config = mode_power + repeat = 20 end begin button = KEY_1 prog = disco config = mode_music_play_1 + repeat = 20 end begin button = KEY_2 prog = disco config = mode_music_play_2 + repeat = 20 end begin button = KEY_3 prog = disco config = mode_music_play_3 + repeat = 20 end begin button = KEY_4 prog = disco config = mode_music_play_4 + repeat = 20 end begin button = KEY_5 prog = disco config = mode_music_play_5 + repeat = 20 end begin button = KEY_STOP prog = disco config = mode_music_stop + repeat = 20 end @@ -65,12 +74,14 @@ begin button = KEY_VCR2 prog = disco config = mode_play_fm4 + repeat = 20 end begin button = KEY_VCR prog = disco config = mode_play_oe1 + repeat = 20 end @@ -78,60 +89,70 @@ begin button = KEY_STOPCD prog = disco config = mode_music_stop + repeat = 20 end begin button = KEY_RECORD prog = disco config = mode_music_info + repeat = 20 end begin button = KEY_PAUSE prog = disco config = mode_music_pause + repeat = 20 end begin button = KEY_PLAY prog = disco config = mode_music_play + repeat = 20 end begin button = KEY_REWIND prog = disco config = mode_music_rewind + repeat = 20 end begin button = KEY_BACK prog = disco config = mode_music_back + repeat = 20 end begin button = KEY_FORWARD prog = disco config = mode_music_forward + repeat = 20 end begin button = KEY_FASTFORWARD prog = disco config = mode_music_fastforward + repeat = 20 end begin button = KEY_NEXT prog = disco config = mode_music_next + repeat = 20 end begin button = KEY_PREVIOUS prog = disco config = mode_music_previous + repeat = 20 end begin @@ -139,6 +160,7 @@ begin prog = disco repeat = 2 config = mode_volume_up + repeat = 20 end begin @@ -146,10 +168,12 @@ begin prog = disco repeat = 2 config = mode_volume_down + repeat = 20 end begin button = KEY_MUTE prog = disco config = mode_music_mute + repeat = 20 end