Compare commits

..

3 Commits

Author SHA1 Message Date
alex f1975de000 fix swapping 2026-06-26 00:00:27 -04:00
alex ff823809dd print 2026-06-25 23:58:57 -04:00
alex b132736a9f make fantasy cell smaller 2026-06-25 23:56:42 -04:00
3 changed files with 13 additions and 14 deletions
+9 -9
View File
@@ -2,7 +2,7 @@ import requests
from PIL import Image
from rgbmatrix import graphics
import utils.logos as logos
from utils.vars import Colors, font, font_small, PANEL_WIDTH, PANEL_HEIGHT, GAME_WIDTH, DIVIDER_COLOR
from utils.vars import Colors, font, font_small, PANEL_WIDTH, PANEL_HEIGHT, FANTASY_WIDTH, DIVIDER_COLOR
from time import time
FETCH_INTERVAL = 60 # seconds between API calls
@@ -122,13 +122,13 @@ def _build_virtual_canvas(cells):
if not cells:
return None
n = len(cells)
total_w = GAME_WIDTH * (n + 4) # +4 tail so wrap never shows black
total_w = FANTASY_WIDTH * (n + 4) # +4 tail so wrap never shows black
img = Image.new("RGB", (total_w, PANEL_HEIGHT), (0, 0, 0))
for i, cell in enumerate(cells * 2):
if i >= n + 4:
break
_render_pil(img, cell, i * GAME_WIDTH)
_render_pil(img, cell, i * FANTASY_WIDTH)
return img, n
@@ -136,7 +136,7 @@ def _build_virtual_canvas(cells):
def _render_pil(img, cell, x):
# right-edge divider
for y in range(PANEL_HEIGHT):
img.putpixel((x + GAME_WIDTH - 1, y), DIVIDER_COLOR)
img.putpixel((x + FANTASY_WIDTH - 1, y), DIVIDER_COLOR)
# NFL team logo for player cells
if cell["type"] == "player" and cell["nfl_team"]:
@@ -161,13 +161,13 @@ def _blit_slice(canvas, img, offset):
# Text overlay (drawn on top of the blitted PIL layer)
# ---------------------------------------------------------------------------
def _draw_overlay(canvas, cells, scroll_x):
total_w = GAME_WIDTH * len(cells)
total_w = FANTASY_WIDTH * len(cells)
for i, cell in enumerate(cells):
bx = i * GAME_WIDTH - scroll_x
bx = i * FANTASY_WIDTH - scroll_x
for wrap in [0, total_w]:
x = bx + wrap
if x + GAME_WIDTH < 0 or x >= PANEL_WIDTH:
if x + FANTASY_WIDTH < 0 or x >= PANEL_WIDTH:
continue
if cell["type"] == "team_info":
_draw_team_info(canvas, cell, x)
@@ -224,7 +224,7 @@ def _draw_player(canvas, cell, x):
ind_map = {"Questionable": "Q", "Doubtful": "D", "Out": "X", "IR": "IR"}
indicator = ind_map.get(injury, "?")
ind_color = Colors.YELLOW.value if injury in ("Questionable", "Doubtful") else Colors.RED.value
graphics.DrawText(canvas, font_small, x + GAME_WIDTH - 10, 7,
graphics.DrawText(canvas, font_small, x + FANTASY_WIDTH - 10, 7,
_rbg(ind_color), indicator)
# Position + fantasy points
@@ -265,7 +265,7 @@ def draw_frame(canvas):
_virtual_dirty = False
_scroll_x = 0
total_scroll_w = GAME_WIDTH * len(_cells)
total_scroll_w = FANTASY_WIDTH * len(_cells)
canvas.Clear()
+3 -5
View File
@@ -167,7 +167,6 @@ def draw_pil_image(canvas, img):
r, g, b = img.getpixel((x, y))
canvas.SetPixel(x, y, b, g, r) # bgr panels
# --- Main loop ---
def run():
global canvas
times_ran = 0
@@ -177,9 +176,8 @@ def run():
while True:
if times_ran >= 3:
times_ran = 0
++current_mode
if current_mode > len(supported_modes):
current_mode += 1
if current_mode >= len(supported_modes):
current_mode = 0
if supported_modes[current_mode] == "score":
@@ -189,7 +187,7 @@ def run():
canvas_ref = fantasy_mode.draw_frame(canvas)
canvas = matrix.SwapOnVSync(canvas_ref)
++times_ran
times_ran += 1
if __name__ == "__main__":
run()
+1
View File
@@ -18,6 +18,7 @@ LOGO_DIR = os.path.join(ASSET_DIR, "logos")
PANEL_WIDTH = 256
PANEL_HEIGHT = 32
GAME_WIDTH = 128
FANTASY_WIDTH = 64
DIVIDER_COLOR = (40, 40, 40)
font = graphics.Font()