diff --git a/modes/score.py b/modes/score.py index 57fa3b5..9d9b104 100644 --- a/modes/score.py +++ b/modes/score.py @@ -30,11 +30,13 @@ GAME_WIDTH = 64 # each game slot is one panel wide DIVIDER_COLOR = (40, 40, 40) # --- Color helpers --- -def _grb(color_tuple): - """Convert an (R, G, B) tuple to a graphics.Color with R and G swapped - to correct for GRB panel channel ordering on Waveshare P2.5 panels.""" +def _rbg(color_tuple): + """Convert an (R, G, B) tuple to a graphics.Color with G and B swapped + to correct for RBG panel channel ordering on Waveshare P2.5 panels. + Hardware channel order is (R, B, G) but the API expects (R, G, B), + so we swap G and B before passing values in.""" r, g, b = color_tuple - return graphics.Color(g, r, b) + return graphics.Color(r, b, g) # --- Fetch --- def _get_scores(sport, league): @@ -121,7 +123,7 @@ def _blit_slice(canvas, pil_img, x_offset): src_x = (x_offset + x) % total_width for y in range(PANEL_HEIGHT): r, g, b = pil_img.getpixel((src_x, y)) - canvas.SetPixel(x, y, g, r, b) # GRB panels: swap R and G + canvas.SetPixel(x, y, r, b, g) # RBG panels: swap G and B # --- Draw text onto the virtual canvas using PIL (since rgbmatrix fonts need a real canvas) --- # We use rgbmatrix DrawText on the live canvas offset by -scroll_x for text only, @@ -143,18 +145,18 @@ def _draw_text_overlay(canvas, ordered, scroll_x): continue graphics.DrawText(canvas, font_small, x + 18, 11, - _grb(Colors.RED.value), game["away"]) + _rbg(Colors.RED.value), game["away"]) graphics.DrawText(canvas, font_small, x + 18, 27, - _grb(Colors.WHITE.value), game["home"]) + _rbg(Colors.WHITE.value), game["home"]) graphics.DrawText(canvas, font, x + 40, 13, - _grb(Colors.WHITE.value), str(game["away_score"])) + _rbg(Colors.WHITE.value), str(game["away_score"])) graphics.DrawText(canvas, font, x + 40, 29, - _grb(Colors.WHITE.value), str(game["home_score"])) + _rbg(Colors.WHITE.value), str(game["home_score"])) # status line — only on preferred games (they get a wider single-game view) if game["id"] in set(_preferred_games): graphics.DrawText(canvas, font_small, x + 18, 20, - _grb(Colors.YELLOW.value), game["status"]) + _rbg(Colors.YELLOW.value), game["status"]) # --- Preferred / stale game management --- def _update_preferred(): @@ -190,7 +192,7 @@ def draw_frame(canvas): if not _games: canvas.Clear() graphics.DrawText(canvas, font, 10, 22, - _grb(Colors.RED.value), "No games today") + _rbg(Colors.RED.value), "No games today") return canvas # rebuild virtual canvas if data changed