Skip to content

Commit

Permalink
Fix games list refresh after the 15 minute window
Browse files Browse the repository at this point in the history
Closes #54
  • Loading branch information
ajbowler committed Feb 25, 2018
1 parent 8c4f2b4 commit fa191b7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions renderers/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from renderers.scoreboard import Scoreboard as ScoreboardRenderer
from renderers.pregame import Pregame as PregameRenderer
from utils import bump_counter
import debug
import mlbgame
import ledcolors.scoreboard
import math
Expand Down Expand Up @@ -45,6 +46,7 @@ def __init__(self, matrix, canvas, games, config):
self.config = config
self.current_scrolling_text_pos = self.canvas.width
self.creation_time = time.time()
debug.log(self)

def render(self):
"""Renders a game or games depending on the configuration.
Expand All @@ -61,7 +63,6 @@ def render(self):
self.__refresh_game(overview)

refresh_rate = PREGAME_RATE if (overview.status == PRE_GAME or overview.status == SCHEDULED) else SCOREBOARD_RATE
self.canvas.Fill(*ledcolors.scoreboard.fill)

time.sleep(refresh_rate)

Expand All @@ -70,6 +71,8 @@ def render(self):
return
time_delta = endtime - starttime

self.canvas.Fill(*ledcolors.scoreboard.fill)

# TODO: https://github.com/ajbowler/mlb-led-scoreboard/issues/30
# The time_delta comparison will need to change depending on scrolling text size
if self.config.rotate_games and time_delta >= FIFTEEN_SECONDS:
Expand All @@ -93,7 +96,7 @@ def __get_game_from_args(self):

def __refresh_game(self, overview):
"""Draws the provided game on the canvas."""
if overview.status == PRE_GAME:
if overview.status == PRE_GAME or overview.status == SCHEDULED:
pregame = Pregame(overview)
renderer = PregameRenderer(self.canvas, pregame, self.current_scrolling_text_pos)
self.__update_scrolling_text_pos(renderer.render())
Expand All @@ -109,3 +112,8 @@ def __update_scrolling_text_pos(self, new_pos):
self.current_scrolling_text_pos = self.canvas.width
else:
self.current_scrolling_text_pos = pos_after_scroll

def __str__(self):
s = "<%s %s> " % (self.__class__.__name__, hex(id(self)))
s += "%s %s" % (self.current_scrolling_text_pos, time.strftime("%H:%M", time.localtime(self.creation_time)))
return s

0 comments on commit fa191b7

Please sign in to comment.