From f08a1fc8cbd260822e2d7cae272e015564638288 Mon Sep 17 00:00:00 2001 From: raspbeguy Date: Sun, 12 Mar 2017 17:57:56 +0100 Subject: [PATCH] MPD: added rotate_pause parameter --- mpd_dot3k.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/mpd_dot3k.py b/mpd_dot3k.py index 9b48a4d..93d5cc7 100644 --- a/mpd_dot3k.py +++ b/mpd_dot3k.py @@ -5,6 +5,8 @@ import threading import dot3k.lcd as lcd from mpd import MPDClient +rotate_pause = 10 # delay in rotation steps + char_play = [ 0b10000, 0b11000, @@ -57,7 +59,7 @@ def display(): step_title = step_artist = step_album = 0 while True: try: - arg = q.get(timeout=0.5) + arg = q.get(timeout=0.2) status = arg['status']['state'] if status == "play": @@ -74,6 +76,7 @@ def display(): album = arg['song']['album'] step_title = step_artist = step_album = 0 + delay_title = delay_artist = delay_album = rotate_pause lcd.clear() lcd.set_cursor_position(0, 0) @@ -90,9 +93,24 @@ def display(): lcd.write(album) except queue.Empty: - step_title = (step_title + 1) % (len(title) + 3) - step_artist = (step_artist + 1) % (len(artist) + 3) - step_album = (step_album + 1) % (len(album) + 3) + if step_title == 0 and delay_title > 0: + delay_title -= 1 + else: + step_title = (step_title + 1) % (len(title) + 3) + if delay_title == 0: + delay_title = rotate_pause + if step_artist == 0 and delay_artist > 0: + delay_artist -= 1 + else: + step_artist = (step_artist + 1) % (len(artist) + 3) + if delay_title == 0: + delay_artist = rotate_pause + if step_album == 0 and delay_album > 0: + delay_album -= 1 + else: + step_album = (step_album + 1) % (len(album) + 3) + if delay_title == 0: + delay_album = rotate_pause if len(title) > 15: lcd.set_cursor_position(1, 0) @@ -103,7 +121,7 @@ def display(): if len(album) > 16: lcd.set_cursor_position(0, 2) lcd.write(stringrotate(album, 16, step_album)) - + client = MPDClient() client.connect("localhost", 6600)