This commit is contained in:
2026-05-03 14:54:05 -04:00
parent d7b258bb51
commit d7ee473c15
+16 -48
View File
@@ -373,63 +373,31 @@ def run():
page_display_time = 8 page_display_time = 8
last_switch = time() last_switch = time()
current_games = get_all_scores()
preferred_team = [ preferred_team = [
"BUF", "BUF",
"TOR", "TOR",
"TB" "TB"
] ]
preferred_game = []
for game in current_games:
print(game)
if game['home'] in preferred_team or game['away'] in preferred_team:
if game['status'] != 'Final':
preferred_game_on = True
preferred_game.append(game)
if preferred_game_on: while True:
while True: games = get_all_scores()
draw_single_game(canvas, preferred_game[0])
canvas = matrix.SwapOnVSync(canvas)
sleep(0.03)
else:
while True:
now = time()
if now - last_fetch > 30: if games:
new_games = get_all_scores() for game in games:
if game['away'] in preferred_team or game['home'] in preferred_team:
# update prev_scores preferred_game_on = game
for game in new_games:
gid = game["id"] if preferred_game_on:
try: draw_single_game(canvas, preferred_game_on)
prev_scores[gid] = (
int(game["away_score"]),
int(game["home_score"]),
)
except ValueError:
pass
games = new_games
last_fetch = now
if not games:
current_page = 0
if games and now - last_switch > page_display_time:
current_page = (current_page + 4) % max(len(games), 1)
last_switch = now
canvas.Clear()
if games:
draw_all_games(canvas, games, current_page)
else: else:
graphics.DrawText( draw_all_games(games)
canvas, font, 10, 22, graphics.Color(Colors.RED), "No games today" else:
) graphics.DrawText(
canvas, font, 10, 22, graphics.Color(Colors.RED), "No games today"
)
canvas = matrix.SwapOnVSync(canvas) canvas = matrix.SwapOnVSync(canvas)
sleep(0.03) sleep(0.03)
if __name__ == "__main__": if __name__ == "__main__":