more cleanup

This commit is contained in:
2026-05-05 16:46:37 -04:00
parent 3359e89027
commit a5a15de69b
+1 -16
View File
@@ -35,17 +35,11 @@ font_small = graphics.Font()
font_big = graphics.Font() font_big = graphics.Font()
font.LoadFont(os.path.join(ASSET_DIR, "fonts/7x13.bdf")) font.LoadFont(os.path.join(ASSET_DIR, "fonts/7x13.bdf"))
font_small.LoadFont(os.path.join(ASSET_DIR, "fonts/5x7.bdf")) font_small.LoadFont(os.path.join(ASSET_DIR, "fonts/5x7.bdf"))
# try to load a big font for GOAL!, fall back to regular if not available
try:
font_big.LoadFont(os.path.join(ASSET_DIR, "fonts/9x18.bdf")) font_big.LoadFont(os.path.join(ASSET_DIR, "fonts/9x18.bdf"))
except:
font_big = font
# --- Logo cache --- # --- Logo cache ---
logo_cache = {} logo_cache = {}
# --- Pre-built colors --- # --- Pre-built colors ---
class Colors(Enum): class Colors(Enum):
WHITE = (255, 255, 255) WHITE = (255, 255, 255)
@@ -54,7 +48,6 @@ class Colors(Enum):
SABRES_BLUE = (0, 135, 48) SABRES_BLUE = (0, 135, 48)
SABRES_GOLD = (252, 20, 210) SABRES_GOLD = (252, 20, 210)
# --- Govee API --- # --- Govee API ---
if os.environ['GOVEE_API_KEY']: if os.environ['GOVEE_API_KEY']:
govee_api = govee.GoveeApi(key=os.environ["GOVEE_API_KEY"]) govee_api = govee.GoveeApi(key=os.environ["GOVEE_API_KEY"])
@@ -119,7 +112,6 @@ def render_goal_frame(text, text_scale, bg_color, text_color):
return scaled return scaled
def play_goal_celebration(text, color1, color2): def play_goal_celebration(text, color1, color2):
global canvas global canvas
@@ -176,12 +168,10 @@ def play_goal_celebration(text, color1, color2):
# Hold for a moment then return to scoreboard # Hold for a moment then return to scoreboard
sleep(0.5) sleep(0.5)
def play_audio(filename): def play_audio(filename):
pygame.mixer.music.load(os.path.join(ASSET_DIR, filename)) pygame.mixer.music.load(os.path.join(ASSET_DIR, filename))
pygame.mixer.music.play() pygame.mixer.music.play()
# --- Utilities --- # --- Utilities ---
def draw_pil_image(canvas, img): def draw_pil_image(canvas, img):
for x in range(img.width): for x in range(img.width):
@@ -189,7 +179,6 @@ def draw_pil_image(canvas, img):
r, g, b = img.getpixel((x, y)) r, g, b = img.getpixel((x, y))
canvas.SetPixel(x, y, b, g, r) # bgr panels canvas.SetPixel(x, y, b, g, r) # bgr panels
def load_logo(league, abbr): def load_logo(league, abbr):
key = f"{league}_{abbr}" key = f"{league}_{abbr}"
if key in logo_cache: if key in logo_cache:
@@ -210,7 +199,6 @@ def load_logo(league, abbr):
logo_cache[key] = None logo_cache[key] = None
return None return None
def draw_logo(canvas, img, x, y): def draw_logo(canvas, img, x, y):
if img is None: if img is None:
return return
@@ -219,7 +207,6 @@ def draw_logo(canvas, img, x, y):
r, g, b = img.getpixel((px, py)) r, g, b = img.getpixel((px, py))
canvas.SetPixel(x + px, y + py, r, g, b) # bgr panels canvas.SetPixel(x + px, y + py, r, g, b) # bgr panels
# --- Fetch scores --- # --- Fetch scores ---
def get_scores(sport, league): def get_scores(sport, league):
url = f"https://site.api.espn.com/apis/site/v2/sports/{sport}/{league}/scoreboard" url = f"https://site.api.espn.com/apis/site/v2/sports/{sport}/{league}/scoreboard"
@@ -249,7 +236,6 @@ def get_scores(sport, league):
print(f"Fetch error ({league}): {e}") print(f"Fetch error ({league}): {e}")
return [] return []
def get_all_scores(): def get_all_scores():
print('fetching game scores from espn') print('fetching game scores from espn')
games = [] games = []
@@ -259,8 +245,7 @@ def get_all_scores():
games += get_scores("baseball", "mlb") games += get_scores("baseball", "mlb")
return games return games
# --- Game drawing ---
# --- Draw all games across all panels ---
def draw_all_games(canvas, games, start_index): def draw_all_games(canvas, games, start_index):
for i in range(4): for i in range(4):
game_index = (start_index + i) % len(games) game_index = (start_index + i) % len(games)