def render(self): color = self.data.config.scoreboard_colors.color("default.background") self.canvas.Fill(color["r"], color["g"], color["b"]) starttime = time.time() # Main and only loop while True: # If we need to refresh the overview data, do that if self.data.needs_refresh: self.data.refresh_overview() # Draw the current game self.__draw_game(self.data.current_game(), self.data.overview) # Check if we need to scroll until it's finished if self.data.config.rotation_scroll_until_finished == False: self.scrolling_finished = True # Set the refresh rate refresh_rate = self.data.config.scrolling_speed # If we're not scrolling anything, scroll is always finished. if Status.is_static(self.data.overview.status) and not Scoreboard( self.data.overview).get_text_for_reason(): self.scrolling_finished = True time.sleep(refresh_rate) endtime = time.time() time_delta = endtime - starttime rotate_rate = self.__rotate_rate_for_status( self.data.overview.status) # If we're ready to rotate, let's do it if time_delta >= rotate_rate and self.scrolling_finished: starttime = time.time() self.scrolling_finished = False self.data.needs_refresh = True if Status.is_fresh(self.data.overview.status): self.scrolling_text_pos = self.canvas.width if self.__should_rotate_to_next_game(self.data.overview): self.scrolling_text_pos = self.canvas.width game = self.data.advance_to_next_game() if endtime - self.data.games_refresh_time >= GAMES_REFRESH_RATE: self.data.refresh_games() if self.data.needs_refresh: self.data.refresh_overview() if Status.is_complete(self.data.overview.status): if Final(self.data.current_game() ).winning_pitcher == 'Unknown': self.data.refresh_games()
def __render_game(self): while True: # If we need to refresh the overview data, do that if self.data.needs_refresh: self.data.refresh_overview() # Draw the current game self.__draw_game(self.data.current_game(), self.data.overview) # Check if we need to scroll until it's finished if self.data.config.rotation_scroll_until_finished == False: self.scrolling_finished = True # Set the refresh rate refresh_rate = self.data.config.scrolling_speed # Currently the only thing that's always static is the live scoreboard if Status.is_static(self.data.overview.status): self.scrolling_finished = True # If the status is irregular and there's no 'reason' text, finish scrolling if Status.is_irregular(self.data.overview.status) and Scoreboard( self.data.overview).get_text_for_reason() is None: self.scrolling_finished = True time.sleep(refresh_rate) endtime = time.time() time_delta = endtime - self.starttime rotate_rate = self.__rotate_rate_for_status( self.data.overview.status) # If we're ready to rotate, let's do it if time_delta >= rotate_rate and self.scrolling_finished: self.starttime = time.time() self.scrolling_finished = False self.scrolling_period = 0.0 self.data.needs_refresh = True if Status.is_fresh(self.data.overview.status): self.scrolling_text_pos = self.canvas.width if self.__should_rotate_to_next_game(self.data.overview): self.scrolling_text_pos = self.canvas.width game = self.data.advance_to_next_game() if endtime - self.data.games_refresh_time >= GAMES_REFRESH_RATE: self.data.refresh_games() if self.data.needs_refresh: self.data.refresh_overview() if Status.is_complete(self.data.overview.status): if Final(self.data.current_game() ).winning_pitcher == 'Unknown': self.data.refresh_games()
def render(self): self.canvas.Fill(*ledcolors.scoreboard.fill) starttime = time.time() # Main and only loop while True: # If we need to refresh the overview data, do that if self.data.needs_refresh: self.data.refresh_overview() # Draw the current game self.__draw_game(self.data.current_game(), self.data.overview) # Check if we need to scroll until it's finished if self.data.config.scroll_until_finished == False: self.scrolling_finished = True # Set the refresh rate refresh_rate = SCROLL_TEXT_FAST_RATE if self.data.config.slower_scrolling == True: refresh_rate = SCROLL_TEXT_SLOW_RATE # If we're not scrolling anything, scroll is always finished. if Status.is_static(self.data.overview.status): self.scrolling_finished = True time.sleep(refresh_rate) endtime = time.time() time_delta = endtime - starttime rotate_rate = self.__rotate_rate_for_status( self.data.overview.status) # If we're ready to rotate, let's do it if time_delta >= rotate_rate and self.scrolling_finished: starttime = time.time() self.scrolling_finished = False self.data.needs_refresh = True if Status.is_fresh(self.data.overview.status): self.scrolling_text_pos = self.canvas.width if self.__should_rotate_to_next_game(self.data.overview): self.scrolling_text_pos = self.canvas.width game = self.data.advance_to_next_game() self.data.refresh_overview() if endtime - self.data.games_refresh_time >= GAMES_REFRESH_RATE: self.data.refresh_games()
def __render_game(self): while True: # If we need to refresh the overview data, do that if self.data.needs_refresh: self.data.refresh_overview() # Draw the current game self.__draw_game(self.data.current_game(), self.data.overview) # Check if we need to scroll until it's finished if self.data.config.rotation_scroll_until_finished == False: self.scrolling_finished = True # Set the refresh rate refresh_rate = self.data.config.scrolling_speed # If we're not scrolling anything, scroll is always finished. if Status.is_static(self.data.overview.status) and not Scoreboard(self.data.overview).get_text_for_reason(): self.scrolling_finished = True time.sleep(refresh_rate) endtime = time.time() time_delta = endtime - self.starttime rotate_rate = self.__rotate_rate_for_status(self.data.overview.status) # If we're ready to rotate, let's do it if time_delta >= rotate_rate and self.scrolling_finished: self.starttime = time.time() self.scrolling_finished = False self.data.needs_refresh = True if Status.is_fresh(self.data.overview.status): self.scrolling_text_pos = self.canvas.width if self.__should_rotate_to_next_game(self.data.overview): self.scrolling_text_pos = self.canvas.width game = self.data.advance_to_next_game() if endtime - self.data.games_refresh_time >= GAMES_REFRESH_RATE: self.data.refresh_games() if self.data.needs_refresh: self.data.refresh_overview() if Status.is_complete(self.data.overview.status): if Final(self.data.current_game()).winning_pitcher == 'Unknown': self.data.refresh_games()