fix bar length on song switch

This commit is contained in:
barry 2025-01-11 18:57:23 +01:00
parent 7ee49b9cf6
commit 9765756d7b
2 changed files with 5 additions and 4 deletions

View File

@ -1,8 +1,8 @@
refresh_token: "AQBGNOL-iocPZ_zxtr_sNXx4BZRaxPmg2Ea0cJGorcEu2IW2wSnLdkYDJpVDOuQQHWIQ-LjuNpBcY9PurPtdfPoT5ljXnGpso9CqX6n2alBXaYc767oKya_52qxqWPE0o7k" refresh_token: "AQBGNOL-iocPZ_zxtr_sNXx4BZRaxPmg2Ea0cJGorcEu2IW2wSnLdkYDJpVDOuQQHWIQ-LjuNpBcY9PurPtdfPoT5ljXnGpso9CqX6n2alBXaYc767oKya_52qxqWPE0o7k"
base_64: "ZTI5Mzg3NWI3YWQ5NDQzZDg1NDMxYzkwOTEyZTdiMWQ6MjlmNDEzZTJiOTRlNGU0NDlkOWRiYmU0NmM2OTY5MTY=" base_64: "ZTI5Mzg3NWI3YWQ5NDQzZDg1NDMxYzkwOTEyZTdiMWQ6MjlmNDEzZTJiOTRlNGU0NDlkOWRiYmU0NmM2OTY5MTY="
api_interval: 5 # (float) number of seconds in-between API requests api_interval: 3 # (float) number of seconds in-between API requests
refresh_interval: 0.4 # (float) number of seconds in-between progress bar refreshes refresh_interval: 0.8 # (float) number of seconds in-between progress bar refreshes
# Set Color Theme # Set Color Theme
color_theme: color_theme:

View File

@ -143,7 +143,7 @@ def display_loop(api: Api, cfg: Dict):
data["progress_ms"] + int((time.time() - last_api_call) * 1000), data["progress_ms"] + int((time.time() - last_api_call) * 1000),
) )
progress = min(1, progress_time / data["duration_ms"]) progress = min(1, progress_time / data["duration_ms"])
bar_width = int(w * progress) bar_width = int((w - 10) * progress)
draw.rectangle( draw.rectangle(
[(7, h - 23), (w + 3, h - 7)], [(7, h - 23), (w + 3, h - 7)],
# outline=cfg["color_theme"]["text"], # outline=cfg["color_theme"]["text"],
@ -158,7 +158,7 @@ def display_loop(api: Api, cfg: Dict):
[(10, h - 20), (w, h - 10)], fill=cfg["color_theme"]["background"] [(10, h - 20), (w, h - 10)], fill=cfg["color_theme"]["background"]
) )
draw.rectangle( draw.rectangle(
[(10, h - 20), (bar_width, h - 10)], [(10, h - 20), (10 + bar_width, h - 10)],
fill=cfg["color_theme"]["bar_inside"], fill=cfg["color_theme"]["bar_inside"],
) )
f_current_time = "{:02.0f}:{:02.0f}".format( f_current_time = "{:02.0f}:{:02.0f}".format(
@ -177,6 +177,7 @@ def display_loop(api: Api, cfg: Dict):
fill=cfg["color_theme"]["text"], fill=cfg["color_theme"]["text"],
) )
d.ShowImage(bg) d.ShowImage(bg)
print(bar_width)
time.sleep(cfg["refresh_interval"]) time.sleep(cfg["refresh_interval"])
except IOError as e: except IOError as e: