print game statuses
This commit is contained in:
+17
-7
@@ -269,6 +269,7 @@ def draw_all_games(canvas, games, start_index):
|
|||||||
# --- Main loop ---
|
# --- Main loop ---
|
||||||
def run():
|
def run():
|
||||||
global canvas
|
global canvas
|
||||||
|
preferred_game_on = False
|
||||||
games = []
|
games = []
|
||||||
prev_scores = {}
|
prev_scores = {}
|
||||||
last_fetch = 0
|
last_fetch = 0
|
||||||
@@ -276,12 +277,12 @@ def run():
|
|||||||
page_display_time = 8
|
page_display_time = 8
|
||||||
last_switch = time()
|
last_switch = time()
|
||||||
|
|
||||||
while True:
|
current_games = get_all_scores()
|
||||||
govee_api.set_diy_scene(os.environ['GOVEE_SKU'], os.environ['GOVEE_DEVICE'])
|
for game in current_games:
|
||||||
play_goal_celebration("SABRES GOAL!", Colors.SABRES_BLUE.value, Colors.SABRES_GOLD.value)
|
print(game.status, game.home, game.away)
|
||||||
govee_api.set_to_original_color(os.environ['GOVEE_SKU'], os.environ['GOVEE_DEVICE'])
|
|
||||||
|
while True:
|
||||||
|
|
||||||
# while True:
|
|
||||||
# now = time()
|
# now = time()
|
||||||
|
|
||||||
# if now - last_fetch > 30:
|
# if now - last_fetch > 30:
|
||||||
@@ -289,7 +290,6 @@ def run():
|
|||||||
|
|
||||||
# # update prev_scores
|
# # update prev_scores
|
||||||
# for game in new_games:
|
# for game in new_games:
|
||||||
# gid = game["id"]
|
|
||||||
# try:
|
# try:
|
||||||
# prev_scores[gid] = (int(game["away_score"]), int(game["home_score"]))
|
# prev_scores[gid] = (int(game["away_score"]), int(game["home_score"]))
|
||||||
# except ValueError:
|
# except ValueError:
|
||||||
@@ -304,7 +304,6 @@ def run():
|
|||||||
# current_page = (current_page + 4) % max(len(games), 1)
|
# current_page = (current_page + 4) % max(len(games), 1)
|
||||||
# last_switch = now
|
# last_switch = now
|
||||||
|
|
||||||
# canvas.Clear()
|
|
||||||
|
|
||||||
# if games:
|
# if games:
|
||||||
# draw_all_games(canvas, games, current_page)
|
# draw_all_games(canvas, games, current_page)
|
||||||
@@ -313,6 +312,17 @@ def run():
|
|||||||
|
|
||||||
# canvas = matrix.SwapOnVSync(canvas)
|
# canvas = matrix.SwapOnVSync(canvas)
|
||||||
# sleep(0.03)
|
# sleep(0.03)
|
||||||
|
now = time()
|
||||||
|
gid = game["id"]
|
||||||
|
except ValueError:
|
||||||
|
current_page = (current_page + 4) % max(len(games), 1)
|
||||||
|
if games:
|
||||||
|
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