MPD: added rotate_pause parameter

This commit is contained in:
raspbeguy 2017-03-12 17:57:56 +01:00
parent aebb254b82
commit f08a1fc8cb
1 changed files with 23 additions and 5 deletions

View File

@ -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:
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)