From e4866248bbc3fa55e65189446e3bf35119e5c3db Mon Sep 17 00:00:00 2001 From: pawptart Date: Sat, 8 Jul 2023 11:40:04 -0400 Subject: [PATCH 1/6] Add option to display team record on game screen --- coordinates/w128h32.json.example | 11 +++++++++++ coordinates/w128h64.json.example | 11 +++++++++++ coordinates/w192h64.json.example | 11 +++++++++++ coordinates/w32h32.json.example | 11 +++++++++++ coordinates/w64h32.json.example | 11 +++++++++++ coordinates/w64h64.json.example | 12 ++++++++++++ data/game.py | 8 +++++++- data/scoreboard/__init__.py | 4 ++-- data/scoreboard/team.py | 3 ++- renderers/games/teams.py | 14 ++++++++++++++ 10 files changed, 92 insertions(+), 4 deletions(-) diff --git a/coordinates/w128h32.json.example b/coordinates/w128h32.json.example index d3c59047..ffe92541 100644 --- a/coordinates/w128h32.json.example +++ b/coordinates/w128h32.json.example @@ -291,6 +291,17 @@ "y": 10 } }, + "record": { + "_comment": "Offscreen by default.", + "away": { + "x": -10, + "y": -10 + }, + "home": { + "x": -10, + "y": -10 + } + }, "runs": { "runs_hits_errors": { "show": false, diff --git a/coordinates/w128h64.json.example b/coordinates/w128h64.json.example index 52fe6f11..f246729f 100644 --- a/coordinates/w128h64.json.example +++ b/coordinates/w128h64.json.example @@ -271,6 +271,17 @@ "y": 29 } }, + "record": { + "_comment": "Offscreen by default.", + "away": { + "x": -10, + "y": -10 + }, + "home": { + "x": -10, + "y": -10 + } + }, "runs": { "runs_hits_errors": { "show": true, diff --git a/coordinates/w192h64.json.example b/coordinates/w192h64.json.example index 9a10db27..4d6d61ec 100644 --- a/coordinates/w192h64.json.example +++ b/coordinates/w192h64.json.example @@ -271,6 +271,17 @@ "y": 29 } }, + "record": { + "_comment": "Offscreen by default.", + "away": { + "x": -10, + "y": -10 + }, + "home": { + "x": -10, + "y": -10 + } + }, "runs": { "runs_hits_errors": { "show": true, diff --git a/coordinates/w32h32.json.example b/coordinates/w32h32.json.example index f872886a..0da7dba4 100644 --- a/coordinates/w32h32.json.example +++ b/coordinates/w32h32.json.example @@ -278,6 +278,17 @@ "y": 13 } }, + "record": { + "_comment": "Offscreen by default.", + "away": { + "x": -10, + "y": -10 + }, + "home": { + "x": -10, + "y": -10 + } + }, "runs": { "runs_hits_errors": { "show": false, diff --git a/coordinates/w64h32.json.example b/coordinates/w64h32.json.example index d36bd9e6..552f9bee 100644 --- a/coordinates/w64h32.json.example +++ b/coordinates/w64h32.json.example @@ -263,6 +263,17 @@ "y": 7 } }, + "record": { + "_comment": "Offscreen by default.", + "away": { + "x": -10, + "y": -10 + }, + "home": { + "x": -10, + "y": -10 + } + }, "runs": { "runs_hits_errors": { "show": true, diff --git a/coordinates/w64h64.json.example b/coordinates/w64h64.json.example index bde2213a..c18b4cda 100644 --- a/coordinates/w64h64.json.example +++ b/coordinates/w64h64.json.example @@ -247,6 +247,18 @@ "y": 10 } }, + , + "record": { + "_comment": "Offscreen by default.", + "away": { + "x": -10, + "y": -10 + }, + "home": { + "x": -10, + "y": -10 + } + }, "runs": { "runs_hits_errors": { "show": false, diff --git a/data/game.py b/data/game.py index ef7da6c8..9996bec4 100644 --- a/data/game.py +++ b/data/game.py @@ -10,7 +10,7 @@ API_FIELDS = ( "gameData,game,id,datetime,dateTime,officialDate,flags,noHitter,perfectGame,status,detailedState,abstractGameState," - + "reason,probablePitchers,teams,home,away,abbreviation,teamName,players,id,boxscoreName,fullName,liveData,plays," + + "reason,probablePitchers,teams,home,away,abbreviation,teamName,record,wins,losses,players,id,boxscoreName,fullName,liveData,plays," + "currentPlay,result,eventType,playEvents,isPitch,pitchData,startSpeed,details,type,code,description,decisions," + "winner,loser,save,id,linescore,outs,balls,strikes,note,inningState,currentInning,currentInningOrdinal,offense," + "batter,inHole,onDeck,first,second,third,defense,pitcher,boxscore,teams,runs,players,seasonStats,pitching,wins," @@ -88,6 +88,12 @@ def home_name(self): def home_abbreviation(self): return self._current_data["gameData"]["teams"]["home"]["abbreviation"] + + def home_record(self): + return self._current_data["gameData"]["teams"]["home"]["record"] or {} + + def away_record(self): + return self._current_data["gameData"]["teams"]["away"]["record"] or {} def pregame_weather(self): try: diff --git a/data/scoreboard/__init__.py b/data/scoreboard/__init__.py index 6ac59f6d..93ff5eb6 100644 --- a/data/scoreboard/__init__.py +++ b/data/scoreboard/__init__.py @@ -15,10 +15,10 @@ class Scoreboard: def __init__(self, game: Game): self.away_team = Team( - game.away_abbreviation(), game.away_score(), game.away_name(), game.away_hits(), game.away_errors() + game.away_abbreviation(), game.away_score(), game.away_name(), game.away_hits(), game.away_errors(), game.away_record() ) self.home_team = Team( - game.home_abbreviation(), game.home_score(), game.home_name(), game.home_hits(), game.home_errors() + game.home_abbreviation(), game.home_score(), game.home_name(), game.home_hits(), game.home_errors(), game.home_record() ) self.inning = Inning(game) self.bases = Bases(game) diff --git a/data/scoreboard/team.py b/data/scoreboard/team.py index 08510776..535808ce 100644 --- a/data/scoreboard/team.py +++ b/data/scoreboard/team.py @@ -1,7 +1,8 @@ class Team: - def __init__(self, abbrev, runs, name, hits, errors): + def __init__(self, abbrev, runs, name, hits, errors, record): self.abbrev = abbrev self.runs = runs self.name = name self.hits = hits self.errors = errors + self.record = record diff --git a/renderers/games/teams.py b/renderers/games/teams.py index fc3d6ea5..29e39bc9 100644 --- a/renderers/games/teams.py +++ b/renderers/games/teams.py @@ -58,6 +58,9 @@ def render_team_banner( __render_team_text(canvas, layout, away_colors, away_team, "away", use_full_team_names, default_colors) __render_team_text(canvas, layout, home_colors, home_team, "home", use_full_team_names, default_colors) + __render_record_text(canvas, layout, away_colors, away_team, "away", default_colors) + __render_record_text(canvas, layout, home_colors, home_team, "home", default_colors) + if show_score: # Number of characters in each score. score_spacing = { @@ -110,6 +113,17 @@ def __render_team_text(canvas, layout, colors, team, homeaway, full_team_names, team_text = "{:13s}".format(team.name) graphics.DrawText(canvas, font["font"], coords["x"], coords["y"], text_color_graphic, team_text) +def __render_record_text(canvas, layout, colors, team, homeaway, default_colors): + if "losses" not in team.record or "wins" not in team.record: + return + + text_color = colors.get("text", default_colors["text"]) + text_color_graphic = graphics.Color(text_color["r"], text_color["g"], text_color["b"]) + coords = layout.coords("teams.record.{}".format(homeaway)) + font = layout.font("teams.record.{}".format(homeaway)) + record_text = "({}-{})".format(team.record["wins"], team.record["losses"]) + graphics.DrawText(canvas, font["font"], coords["x"], coords["y"], text_color_graphic, record_text) + def __render_score_component(canvas, layout, colors, homeaway, default_colors, coords, component_val, width_chars): # The coords passed in are the rightmost pixel. From 8216dd1d3dca50d2026c28c173fd1b9a05bd98b3 Mon Sep 17 00:00:00 2001 From: pawptart Date: Sat, 8 Jul 2023 15:06:54 -0400 Subject: [PATCH 2/6] Provide good example values, add a toggle --- coordinates/w128h32.json.example | 12 +++++++----- coordinates/w128h64.json.example | 10 +++++----- coordinates/w192h64.json.example | 10 +++++----- coordinates/w32h32.json.example | 10 +++++----- coordinates/w64h32.json.example | 10 +++++----- coordinates/w64h64.json.example | 13 +++++++------ renderers/games/teams.py | 2 ++ 7 files changed, 36 insertions(+), 31 deletions(-) diff --git a/coordinates/w128h32.json.example b/coordinates/w128h32.json.example index ffe92541..75e49010 100644 --- a/coordinates/w128h32.json.example +++ b/coordinates/w128h32.json.example @@ -292,14 +292,16 @@ } }, "record": { - "_comment": "Offscreen by default.", + "enabled": false, "away": { - "x": -10, - "y": -10 + "font_name": "4x6", + "x": 19, + "y": 7 }, "home": { - "x": -10, - "y": -10 + "font_name": "4x6", + "x": 19, + "y": 17 } }, "runs": { diff --git a/coordinates/w128h64.json.example b/coordinates/w128h64.json.example index f246729f..92c0feb2 100644 --- a/coordinates/w128h64.json.example +++ b/coordinates/w128h64.json.example @@ -272,14 +272,14 @@ } }, "record": { - "_comment": "Offscreen by default.", + "enabled": false, "away": { - "x": -10, - "y": -10 + "x": 30, + "y": 13 }, "home": { - "x": -10, - "y": -10 + "x": 30, + "y": 29 } }, "runs": { diff --git a/coordinates/w192h64.json.example b/coordinates/w192h64.json.example index 4d6d61ec..87cdd9dc 100644 --- a/coordinates/w192h64.json.example +++ b/coordinates/w192h64.json.example @@ -272,14 +272,14 @@ } }, "record": { - "_comment": "Offscreen by default.", + "enabled": false, "away": { - "x": -10, - "y": -10 + "x": 30, + "y": 13 }, "home": { - "x": -10, - "y": -10 + "x": 30, + "y": 29 } }, "runs": { diff --git a/coordinates/w32h32.json.example b/coordinates/w32h32.json.example index 0da7dba4..7a71fad6 100644 --- a/coordinates/w32h32.json.example +++ b/coordinates/w32h32.json.example @@ -279,14 +279,14 @@ } }, "record": { - "_comment": "Offscreen by default.", + "enabled": false, "away": { - "x": -10, - "y": -10 + "x": 4, + "y": 6 }, "home": { - "x": -10, - "y": -10 + "x": 4, + "y": 13 } }, "runs": { diff --git a/coordinates/w64h32.json.example b/coordinates/w64h32.json.example index 552f9bee..6c98341a 100644 --- a/coordinates/w64h32.json.example +++ b/coordinates/w64h32.json.example @@ -264,14 +264,14 @@ } }, "record": { - "_comment": "Offscreen by default.", + "enabled": false, "away": { - "x": -10, - "y": -10 + "x": 15, + "y": 6 }, "home": { - "x": -10, - "y": -10 + "x": 15, + "y": 13 } }, "runs": { diff --git a/coordinates/w64h64.json.example b/coordinates/w64h64.json.example index c18b4cda..36c5ef64 100644 --- a/coordinates/w64h64.json.example +++ b/coordinates/w64h64.json.example @@ -247,16 +247,17 @@ "y": 10 } }, - , "record": { - "_comment": "Offscreen by default.", + "enabled": false, "away": { - "x": -10, - "y": -10 + "font_name": "4x6", + "x": 18, + "y": 7 }, "home": { - "x": -10, - "y": -10 + "font_name": "4x6", + "x": 18, + "y": 17 } }, "runs": { diff --git a/renderers/games/teams.py b/renderers/games/teams.py index 29e39bc9..5bc59b76 100644 --- a/renderers/games/teams.py +++ b/renderers/games/teams.py @@ -116,6 +116,8 @@ def __render_team_text(canvas, layout, colors, team, homeaway, full_team_names, def __render_record_text(canvas, layout, colors, team, homeaway, default_colors): if "losses" not in team.record or "wins" not in team.record: return + if not layout.coords("teams.record.enabled"): + return text_color = colors.get("text", default_colors["text"]) text_color_graphic = graphics.Color(text_color["r"], text_color["g"], text_color["b"]) From 14199b74c5b31777a14e815258d249d700da28e9 Mon Sep 17 00:00:00 2001 From: c2mfj <119268254+c2mfj@users.noreply.github.com> Date: Tue, 11 Jul 2023 15:13:42 -0400 Subject: [PATCH 3/6] added boot logo for w128h32 --- assets/mlb-w128h32.png | Bin 0 -> 2489 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/mlb-w128h32.png diff --git a/assets/mlb-w128h32.png b/assets/mlb-w128h32.png new file mode 100644 index 0000000000000000000000000000000000000000..5a8ebe4af2e64afe7a357f8104d7d0f830aa2158 GIT binary patch literal 2489 zcmV;q2}bsbP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D2~J5wK~#8N?VAfw zRM#2D|GRs4m-j>7Pc5u~5Ur!MQ439COu)oYTOWy0(K_)#4brA+$Jc0xWcV`@ecwX{`H3bv^gO>2B5g9K3l*_Fov`?`0x-?@9K+9)iI%U+rOm~YuV=kDcj z&;Nes`_4I60l-1#X>4R>_9h@8K(S`c8cj}44i^*@1VIqsaLA#FgGZrIK&4WlqoV_d z4jtl)ii)g8qp|Ow@h0P(Z#{=x1RxR@7l+!~TExf4qs`EXhNfnylnU`e4i$F0gD!{z zDT(p$_w$iT0inkXW8EdF{He^<_Kq}Gc&REo!??p(O$q}1=MP1D~Af^ZCdr1|LS~{?c698I;neRIa-b#fv?vnI?OJW z_5+>DZnHt5)ga;Zq{cLTjVpj6ToAtTY9|H~-^MMYs!dYbb)gkN$3Zoc<1 z1l~%TRKr1SbI>^-Xe1_uLJ8hx#LZ&|5tuX`LH8s*%J&SAvuzvk|=yW=4 zE-b;73k^`mMng&Cr&7&59MhV15FRu+V&8_uDJ7qD>gI_Nu%(n)~C%_|V78xM=IRlK`hfejZb_`uP_ zVqJ>-IFHAE|3Nka=tJ#}i$g&h-`s{#d!YPg8mIfgRYs`wgI@3kVIu zwTl;#yZnxmRQhN!dfTfIC~2`M3}#(Kb^>q<#va6u zOGZw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Gd433J53ck3w*lIGFq+0ROaQ29}2Lb*KquP>EzGsNg00000NkvXXu0mjf DM_i9e literal 0 HcmV?d00001 From 95f450b27915933188e103935f66a0d84b5d06d9 Mon Sep 17 00:00:00 2001 From: pawptart Date: Tue, 11 Jul 2023 22:24:36 -0400 Subject: [PATCH 4/6] Version bump to 6.4.0 --- version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.py b/version.py index b26f5cb4..82b432be 100644 --- a/version.py +++ b/version.py @@ -1,5 +1,5 @@ SCRIPT_NAME = "MLB LED Scoreboard" -SCRIPT_VERSION = "6.3.5" +SCRIPT_VERSION = "6.4.0" if __name__ == "__main__": From 6200091d8b4540de9e4d80ea1279be387c41ebc0 Mon Sep 17 00:00:00 2001 From: pawptart Date: Fri, 14 Jul 2023 20:38:05 -0400 Subject: [PATCH 5/6] Fix for games in warmup status --- data/config/layout.py | 14 +++++++++----- renderers/games/teams.py | 2 +- version.py | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/data/config/layout.py b/data/config/layout.py index 89a8134f..99cc75ad 100644 --- a/data/config/layout.py +++ b/data/config/layout.py @@ -1,6 +1,7 @@ from driver import graphics import os.path +import debug FONTNAME_DEFAULT = "4x6" FONTNAME_KEY = "font_name" @@ -36,14 +37,17 @@ def font(self, keypath): def coords(self, keypath): try: - d = self.__find_at_keypath(keypath) + coord_dict = self.__find_at_keypath(keypath) except KeyError as e: raise e - if self.state in AVAILABLE_OPTIONAL_KEYS: - if self.state in d: - return d[self.state] - return d + if not isinstance(coord_dict, dict) or not self.state in AVAILABLE_OPTIONAL_KEYS: + return coord_dict + + if self.state in coord_dict: + return coord_dict[self.state] + + return coord_dict def set_state(self, new_state=None): if new_state in AVAILABLE_OPTIONAL_KEYS: diff --git a/renderers/games/teams.py b/renderers/games/teams.py index 5bc59b76..5d7bb78f 100644 --- a/renderers/games/teams.py +++ b/renderers/games/teams.py @@ -116,7 +116,7 @@ def __render_team_text(canvas, layout, colors, team, homeaway, full_team_names, def __render_record_text(canvas, layout, colors, team, homeaway, default_colors): if "losses" not in team.record or "wins" not in team.record: return - if not layout.coords("teams.record.enabled"): + if not layout.coords("teams.record").get("enabled", False): return text_color = colors.get("text", default_colors["text"]) diff --git a/version.py b/version.py index 82b432be..6bb344b1 100644 --- a/version.py +++ b/version.py @@ -1,5 +1,5 @@ SCRIPT_NAME = "MLB LED Scoreboard" -SCRIPT_VERSION = "6.4.0" +SCRIPT_VERSION = "6.4.1" if __name__ == "__main__": From 7ef8414ca642b65bf1468a98f9c514b982fd02c5 Mon Sep 17 00:00:00 2001 From: pawptart Date: Fri, 14 Jul 2023 20:39:16 -0400 Subject: [PATCH 6/6] remove unnecessary import --- data/config/layout.py | 1 - 1 file changed, 1 deletion(-) diff --git a/data/config/layout.py b/data/config/layout.py index 99cc75ad..88fdef50 100644 --- a/data/config/layout.py +++ b/data/config/layout.py @@ -1,7 +1,6 @@ from driver import graphics import os.path -import debug FONTNAME_DEFAULT = "4x6" FONTNAME_KEY = "font_name"