From dd9343c59ff1a4273c9d80eb9a8acb07f077f834 Mon Sep 17 00:00:00 2001 From: Alex Frantz Date: Thu, 25 Jun 2026 23:45:40 -0400 Subject: [PATCH] support other modes --- modes/score.py | 9 ++------- scoreboard.py | 16 ++++++++++++++-- utils/vars.py | 5 +++++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/modes/score.py b/modes/score.py index 107df60..00879c5 100644 --- a/modes/score.py +++ b/modes/score.py @@ -1,8 +1,8 @@ import requests import utils.logos as logos -from PIL import Image, ImageDraw +from PIL import Image from rgbmatrix import graphics -from utils.vars import Colors, font, font_small +from utils.vars import Colors, font, font_small, PANEL_WIDTH, PANEL_HEIGHT, GAME_WIDTH, DIVIDER_COLOR from time import time # --- State --- @@ -25,11 +25,6 @@ _tick = 0 _virtual_canvas = None # PIL Image of the full wide render _virtual_dirty = True # rebuild the virtual canvas on next frame -PANEL_WIDTH = 256 # 4 × 64px panels -PANEL_HEIGHT = 32 -GAME_WIDTH = 128 # each game slot is one panel wide -DIVIDER_COLOR = (40, 40, 40) - # --- Color helpers --- def _rbg(color_tuple): """Convert an (R, G, B) tuple to a graphics.Color with G and B swapped diff --git a/scoreboard.py b/scoreboard.py index ef1c826..03901a6 100644 --- a/scoreboard.py +++ b/scoreboard.py @@ -167,10 +167,22 @@ def draw_pil_image(canvas, img): # --- Main loop --- def run(): global canvas + times_ran = 0 + supported_modes = ["score", "fantasy"] + current_mode = 0 while True: - canvas_ref = score_mode.draw_frame(canvas) - canvas = matrix.SwapOnVSync(canvas_ref) + if times_ran >= 3: + times_ran = 0 + + ++current_mode + if current_mode > len(supported_modes): + current_mode = 0 + + if supported_modes[current_mode] == "score": + canvas_ref = score_mode.draw_frame(canvas) + canvas = matrix.SwapOnVSync(canvas_ref) + ++times_ran if __name__ == "__main__": run() \ No newline at end of file diff --git a/utils/vars.py b/utils/vars.py index 52ea50b..5252643 100644 --- a/utils/vars.py +++ b/utils/vars.py @@ -15,6 +15,11 @@ SCRIPT_DIR = Path(__file__).parent.resolve() ASSET_DIR = os.path.join(SCRIPT_DIR, "../assets") LOGO_DIR = os.path.join(ASSET_DIR, "logos") +PANEL_WIDTH = 256 +PANEL_HEIGHT = 32 +GAME_WIDTH = 128 +DIVIDER_COLOR = (40, 40, 40) + font = graphics.Font() font_small = graphics.Font() font_big = graphics.Font()