test
This commit is contained in:
+29
-24
@@ -277,37 +277,42 @@ def run():
|
|||||||
last_switch = time()
|
last_switch = time()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
now = time()
|
govee_api.set_diy_scene(os.environ['GOVEE_SKU'], os.environ['GOVEE_DEVICE'])
|
||||||
|
play_goal_celebration()
|
||||||
|
govee_api.set_to_original_color(os.environ['GOVEE_SKU'], os.environ['GOVEE_DEVICE'])
|
||||||
|
|
||||||
if now - last_fetch > 30:
|
# while True:
|
||||||
new_games = get_all_scores()
|
# now = time()
|
||||||
|
|
||||||
# update prev_scores
|
# if now - last_fetch > 30:
|
||||||
for game in new_games:
|
# new_games = get_all_scores()
|
||||||
gid = game["id"]
|
|
||||||
try:
|
|
||||||
prev_scores[gid] = (int(game["away_score"]), int(game["home_score"]))
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
games = new_games
|
# # update prev_scores
|
||||||
last_fetch = now
|
# for game in new_games:
|
||||||
if not games:
|
# gid = game["id"]
|
||||||
current_page = 0
|
# try:
|
||||||
|
# prev_scores[gid] = (int(game["away_score"]), int(game["home_score"]))
|
||||||
|
# except ValueError:
|
||||||
|
# pass
|
||||||
|
|
||||||
if games and now - last_switch > page_display_time:
|
# games = new_games
|
||||||
current_page = (current_page + 4) % max(len(games), 1)
|
# last_fetch = now
|
||||||
last_switch = now
|
# if not games:
|
||||||
|
# current_page = 0
|
||||||
|
|
||||||
canvas.Clear()
|
# if games and now - last_switch > page_display_time:
|
||||||
|
# current_page = (current_page + 4) % max(len(games), 1)
|
||||||
|
# last_switch = now
|
||||||
|
|
||||||
if games:
|
# canvas.Clear()
|
||||||
draw_all_games(canvas, games, current_page)
|
|
||||||
else:
|
|
||||||
graphics.DrawText(canvas, font, 10, 22, graphics.Color(Colors.RED), "No games today")
|
|
||||||
|
|
||||||
canvas = matrix.SwapOnVSync(canvas)
|
# if games:
|
||||||
sleep(0.03)
|
# draw_all_games(canvas, games, current_page)
|
||||||
|
# else:
|
||||||
|
# graphics.DrawText(canvas, font, 10, 22, graphics.Color(Colors.RED), "No games today")
|
||||||
|
|
||||||
|
# canvas = matrix.SwapOnVSync(canvas)
|
||||||
|
# sleep(0.03)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
run()
|
run()
|
||||||
Reference in New Issue
Block a user