From a3ab41422302e7f9ac916b2def708648d6ae01a6 Mon Sep 17 00:00:00 2001 From: thomaswwp Date: Mon, 18 Nov 2013 20:37:10 +0000 Subject: [PATCH] Fixed a bug that stopped the display exiting "Off" mode when it was actually paused. Changed the handling of the messages on reboot/shut down. --- RPizeBox.log | 138 +++++++++++++++++++++++++++++++++++++++++++++++++ RPizeBox.py | 14 ++--- buttonWatch.py | 13 +++-- 3 files changed, 154 insertions(+), 11 deletions(-) diff --git a/RPizeBox.log b/RPizeBox.log index ff4e7b5..80bcae6 100755 --- a/RPizeBox.log +++ b/RPizeBox.log @@ -129,3 +129,141 @@ 11/17/2013 08:57:12 PM Success: Logged in to LMS. 11/17/2013 08:57:12 PM Success: In contact with SqueezeLite. 11/17/2013 08:57:12 PM Track changed, now: BBC Radio 4 +11/17/2013 09:03:00 PM Success: Logged in to LMS. +11/17/2013 09:03:00 PM Success: In contact with SqueezeLite. +11/17/2013 09:03:00 PM Track changed, now: BBC Radio 4 +11/18/2013 07:36:44 AM LMS not there. Trying again in 5 seconds. +11/18/2013 07:36:49 AM LMS not there. Trying again in 5 seconds. +11/18/2013 07:37:38 AM LMS not there. Trying again in 5 seconds. +11/18/2013 07:37:43 AM LMS not there. Trying again in 5 seconds. +11/18/2013 07:37:48 AM LMS not there. Trying again in 5 seconds. +11/18/2013 07:37:53 AM LMS not there. Trying again in 5 seconds. +11/18/2013 07:37:59 AM LMS not there. Trying again in 5 seconds. +11/18/2013 07:38:04 AM LMS not there. Trying again in 5 seconds. +11/18/2013 07:38:09 AM LMS not there. Trying again in 5 seconds. +11/18/2013 07:38:14 AM LMS not there. Trying again in 5 seconds. +11/18/2013 07:38:23 AM Success: Logged in to LMS. +11/18/2013 07:38:23 AM Success: In contact with SqueezeLite. +11/18/2013 07:38:23 AM Track changed, now: BBC Radio 4 +11/18/2013 04:06:51 PM Play +11/18/2013 04:06:57 PM Power OFF +11/18/2013 04:07:03 PM Power ON +11/18/2013 04:07:06 PM Power ON +11/18/2013 04:07:07 PM Power ON +11/18/2013 04:07:09 PM Power ON +11/18/2013 04:07:11 PM Play +11/18/2013 04:07:20 PM Play +11/18/2013 04:08:23 PM Track changed, now: Royals +11/18/2013 04:11:36 PM Track changed, now: You're Nobody 'Til Somebody Loves You +11/18/2013 04:12:29 PM Vol- +11/18/2013 04:12:29 PM Volume is: 46 +11/18/2013 04:12:31 PM Vol- +11/18/2013 04:12:31 PM Volume is: 41 +11/18/2013 04:12:32 PM Vol- +11/18/2013 04:12:32 PM Volume is: 36 +11/18/2013 04:12:34 PM Vol- +11/18/2013 04:12:34 PM Volume is: 31 +11/18/2013 04:12:35 PM Vol- +11/18/2013 04:12:35 PM Volume is: 26 +11/18/2013 04:12:37 PM Vol- +11/18/2013 04:12:37 PM Volume is: 21 +11/18/2013 04:12:38 PM Vol- +11/18/2013 04:12:38 PM Volume is: 16 +11/18/2013 04:12:52 PM Vol+ +11/18/2013 04:12:52 PM Volume is: 21 +11/18/2013 04:13:12 PM Vol+ +11/18/2013 04:13:12 PM Volume is: 26 +11/18/2013 04:13:14 PM Vol+ +11/18/2013 04:13:14 PM Volume is: 31 +11/18/2013 04:13:16 PM Vol+ +11/18/2013 04:13:16 PM Volume is: 36 +11/18/2013 04:14:57 PM Track changed, now: Counting Stars +11/18/2013 04:19:15 PM Track changed, now: Roar +11/18/2013 04:20:17 PM SkipForward +11/18/2013 04:20:17 PM Track changed, now: Booyah - Original Mix +11/18/2013 04:25:31 PM Track changed, now: Wrecking Ball +11/18/2013 04:25:41 PM SkipForward +11/18/2013 04:25:42 PM Track changed, now: Bonfire Heart +11/18/2013 04:29:42 PM Track changed, now: Beautiful Life +11/18/2013 04:33:46 PM Track changed, now: Afterglow +11/18/2013 04:37:32 PM Track changed, now: Hold On, We're Going Home +11/18/2013 04:41:21 PM Track changed, now: R U Crazy +11/18/2013 04:45:35 PM Track changed, now: What I Might Do - Radio Edit +11/18/2013 04:48:51 PM Track changed, now: Juliet +11/18/2013 04:52:06 PM Track changed, now: Can We Dance - Radio Edit +11/18/2013 04:55:18 PM Track changed, now: Give It 2 U +11/18/2013 04:59:08 PM Track changed, now: Talk Dirty - feat. 2 Chainz +11/18/2013 05:02:06 PM Track changed, now: The Fox (What Does The Fox Say?) +11/18/2013 05:05:41 PM Track changed, now: Rap God +11/18/2013 05:06:09 PM Track changed, now: You Make Me +11/18/2013 05:10:05 PM Track changed, now: Wake Me Up - Radio Edit +11/18/2013 05:14:15 PM Track changed, now: Berzerk +11/18/2013 05:14:24 PM SkipForward +11/18/2013 05:14:24 PM Track changed, now: Survival +11/18/2013 05:15:04 PM Track changed, now: Burn +11/18/2013 05:16:30 PM Track changed, now: 70s +11/18/2013 05:16:35 PM Track changed, now: Daniel +11/18/2013 05:20:29 PM Track changed, now: Wig Wam Bam +11/18/2013 05:23:30 PM Track changed, now: Saturday Night's Alright (For Fighting) +11/18/2013 05:28:25 PM Track changed, now: Second Hand News +11/18/2013 05:31:19 PM Track changed, now: Heroes - 1999 Digital Remaster +11/18/2013 05:37:28 PM Track changed, now: Don't Stop +11/18/2013 05:40:40 PM Track changed, now: Papa Was A Rollin' Stone - Single Version +11/18/2013 05:45:49 PM Track changed, now: I Know What I Like (In Your Wardrobe) - 2008 Digital Remaster +11/18/2013 05:50:00 PM Track changed, now: Fire And Rain +11/18/2013 05:53:23 PM Track changed, now: Dreams +11/18/2013 05:57:37 PM Track changed, now: Walk On The Wild Side +11/18/2013 06:01:51 PM Track changed, now: Escape (The Pina Colada Song) - Single Version +11/18/2013 06:04:56 PM Power OFF +11/18/2013 06:05:06 PM Power ON +11/18/2013 06:05:12 PM Power ON +11/18/2013 06:05:40 PM Power ON +11/18/2013 06:10:40 PM Success: Logged in to LMS. +11/18/2013 06:10:40 PM Success: In contact with SqueezeLite. +11/18/2013 06:10:40 PM Track changed, now: Escape (The Pina Colada Song) - Single Version +11/18/2013 06:10:45 PM Power ON +11/18/2013 06:10:49 PM Power OFF +11/18/2013 06:13:30 PM Success: Logged in to LMS. +11/18/2013 06:13:30 PM Success: In contact with SqueezeLite. +11/18/2013 06:13:30 PM Track changed, now: Escape (The Pina Colada Song) - Single Version +11/18/2013 06:15:16 PM Success: Logged in to LMS. +11/18/2013 06:15:17 PM Success: In contact with SqueezeLite. +11/18/2013 06:15:17 PM Track changed, now: Escape (The Pina Colada Song) - Single Version +11/18/2013 06:15:44 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:15:49 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:16:22 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:16:27 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:16:33 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:16:38 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:16:43 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:16:49 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:16:54 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:17:08 PM Success: Logged in to LMS. +11/18/2013 06:17:08 PM Success: In contact with SqueezeLite. +11/18/2013 06:17:08 PM Track changed, now: Escape (The Pina Colada Song) - Single Version +11/18/2013 06:17:14 PM Power ON +11/18/2013 06:17:46 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:17:51 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:18:22 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:18:27 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:18:33 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:18:38 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:18:43 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:18:49 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:18:54 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:18:56 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:19:01 PM LMS not there. Trying again in 5 seconds. +11/18/2013 06:19:12 PM Success: Logged in to LMS. +11/18/2013 06:19:12 PM Success: In contact with SqueezeLite. +11/18/2013 06:19:13 PM Track changed, now: Escape (The Pina Colada Song) - Single Version +11/18/2013 06:31:20 PM Track changed, now: Classical +11/18/2013 06:31:21 PM Track changed, now: Johann Sebastian Bach: Suite for Cello Solo No.1 in G, BWV 1007 - 1. PrAlude +11/18/2013 06:33:51 PM Track changed, now: The Planets, Op. 32: 1. Mars, the Bringer of War (Allegro) +11/18/2013 06:41:08 PM Track changed, now: Fanfare for the Common Man +11/18/2013 06:44:25 PM Track changed, now: The Heart Asks Pleasure First/The Promise - Edit +11/18/2013 06:47:38 PM Track changed, now: Marianelli: Dawn +11/18/2013 06:50:17 PM Track changed, now: Danse Macabre In G Minor, Op. 40 +11/18/2013 06:57:30 PM Track changed, now: Cello Suite Bwv1007: Prelude +11/18/2013 06:59:59 PM Track changed, now: Vivaldi: Gloria - Gloria Inexcelsis +11/18/2013 07:02:11 PM Track changed, now: Clarinet Concerto K.622: Adagio +11/18/2013 07:04:46 PM Power OFF diff --git a/RPizeBox.py b/RPizeBox.py index 782fdd6..09de24e 100755 --- a/RPizeBox.py +++ b/RPizeBox.py @@ -93,9 +93,9 @@ class RPizeBox: blocking = 0; # no idea what this does, but in the demo code! configFile = "/remoteCodes.conf" # has the codes we'll respond to -#some messages = "123456789ABCDEF0" -welcomeMessage1 = " Welcome to " -welcomeMessage2 = "TWW-P's RPizeBox" +#some messages = "123456789ABCDEF0", "123456789ABCDEF0" +welcomeMessage = [" Welcome to ", "TWW-P's RPizeBox"] + ####################################################################### @@ -160,9 +160,9 @@ def getExternalIP(ifname): except: logging.debug('LMS not there. Trying again in %i seconds.' % RPizeBox.logInWait) wp.lcdPosition(lcd, 0, 0) - wp.lcdPuts(lcd,welcomeMessage1[:16]) + wp.lcdPuts(lcd,welcomeMessage[0][:16]) wp.lcdPosition(lcd, 0, 1) - wp.lcdPuts(lcd,welcomeMessage2[:16]) + wp.lcdPuts(lcd,welcomeMessage[1][:16]) time.sleep(RPizeBox.logInWait) @@ -259,7 +259,7 @@ def getExternalIP(ifname): # title scrolling # deal with pause/stop - elif (sl.get_mode() == 'pause' or (sl.get_mode() == 'stop' and sl.get_power_state())): + elif (sl.get_mode() == 'pause' or (sl.get_mode() == 'stop' and sl.get_power_state())): wp.lcdPosition(lcd, 0, 0) wp.lcdPuts(lcd,(sl.get_track_artist() + " "*16)[:16]) wp.lcdPosition(lcd, 0, 1) @@ -269,7 +269,7 @@ def getExternalIP(ifname): # send "OFF" message to player sl.set_power_state(False) - elif (sl.get_mode() == 'stop'): + elif (not sl.get_power_state()): wp.lcdPosition(lcd, 0, 1) wp.lcdPuts(lcd," " + time.strftime("%H:%M", time.gmtime())[:16]) wp.lcdPosition(lcd, 0, 0) diff --git a/buttonWatch.py b/buttonWatch.py index 6f07251..a7b6350 100755 --- a/buttonWatch.py +++ b/buttonWatch.py @@ -7,6 +7,11 @@ #set up logging logging.basicConfig(filename='/home/pi/scripts/buttonwatch.log',level=logging.DEBUG,format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p') +#some messages = "123456789ABCDEF0", "123456789ABCDEF0" +shutdownMessage = ["Shutting down...", " ...bye bye. "] +rebootMessage = ["Rebooting - ", " Back in a mo..."] + + # set up the display - 4 bit to save pins - apparently slower but marginal # https://projects.drogon.net/raspberry-pi/wiringpi/lcd-library/ wp.wiringPiSetup(); @@ -49,9 +54,9 @@ os.system("kill $(pgrep -f RPizeBox.py)") wp.lcdClear(lcd) wp.lcdPosition(lcd, 0, 0) - wp.lcdPuts(lcd,"Shutting down "[:16]) + wp.lcdPuts(lcd,shutdownMessage[0][:16]) wp.lcdPosition(lcd, 0, 1) - wp.lcdPuts(lcd," right now..."[:16]) + wp.lcdPuts(lcd,shutdownMessage[1][:16]) os.system("shutdown -h now +1") break @@ -61,9 +66,9 @@ os.system("kill $(pgrep -f RPizeBox.py)") wp.lcdClear(lcd) wp.lcdPosition(lcd, 0, 0) - wp.lcdPuts(lcd,"Rebooting "[:16]) + wp.lcdPuts(lcd,rebootMessage[0][:16]) wp.lcdPosition(lcd, 0, 1) - wp.lcdPuts(lcd," right now."[:16]) + wp.lcdPuts(lcd,rebootMessage[1][:16]) os.system("reboot") #break elif (elapsed_time > 0 and elapsed_time <= accidental):