重要的
如果您从 v7 升级到 v8,请务必阅读使用部分,因为启动命令已更改!
美国职业棒球大联盟的 LED 记分牌。显示您球队当天比赛的实时记分牌。
需要一个 Raspberry Pi 和一个通过 GPIO 引脚连接的 LED 板。
目前支持的主板:
如果您希望看到对另一组电路板尺寸的支持,或者对现有电路板尺寸有设计建议,请提出问题!
Pi 存在已知问题
它可以显示正在进行的现场比赛,并且可以选择每 15 秒轮播一次当天的每场比赛。
董事会每 15 分钟刷新一次游戏列表。
如果比赛尚未开始,将显示赛前屏幕,其中显示可能的先发投手。
它可以显示所提供部门的排名。由于 32x32 棋盘太小,无法同时显示胜负,因此棋盘上每 5 秒交替显示胜负。您还可以指定“NL Wild Card”或“AL Wild Card”作为“分区”,以查看每个联赛外卡比赛中前 5 名的球队。
请参阅原始项目的 wiki 页面以获取分步指南。本自述文件主要关注 MLB 软件,但对于那些从 Reddit 或其他地方从未使用 Raspberry Pi 构建过东西的人来说,这应该可以帮助您入门。
物料清单 (BOM) 示例位于此处
您需要 Git 来克隆此存储库,并需要 PIP 来安装记分板软件。
sudo apt-get update
sudo apt-get install git python3-pip
此安装过程大约需要 10-15 分钟。 Raspberry Pi 不是最快的计算机,因此请耐心等待!
git clone https://github.com/MLB-LED-Scoreboard/mlb-led-scoreboard.git
cd mlb-led-scoreboard/
sudo ./install.sh
这将创建一个 Python 虚拟环境并安装所有必需的依赖项。虚拟环境将位于mlb-led-scoreboard/venv/
。
这将安装 rgbmatrix 二进制文件,这是我们从另一个开源库获得的。它控制记分板在 LED 上的实际渲染。如果您好奇,您可以阅读他们的文档,了解所有较低级别的内容是如何工作的。
它还将安装记分板某些部分运行所需的以下 python 库。
其他标志可用于自定义您的安装:
-a, --skip-all Skip all dependencies and config installation (equivalent to -c -p -m).
-c, --skip-config Skip updating JSON configuration files.
-m, --skip-matrix Skip building matrix driver dependency. Video display will default to emulator mode.
-p, --skip-python Skip Python 3 installation. Requires manual Python 3 setup if not already installed.
-v, --no-venv Do not create a virtual environment for the dependencies.
-e, --emulator-only Do not install dependencies under sudo. Skips building matrix dependencies (equivalent to -m)
-d, --driver Specify a branch name or commit SHA for the rpi-rgb-led-matrix library. (Optional. Defaults may change.)
-h, --help Display this help message
安装脚本是为物理硬件设计的。当尝试在其他平台上安装它时,不应使用sudo
来安装依赖项。此外,您可以传递--emulator-only
参数来跳过不需要的安装步骤。
sh install.sh --emulator-only
git pull
以获取最新更改。很多时候,这已经足够了,但如果有什么东西看起来坏了:sudo ./install.sh
。随更新添加的任何其他依赖项都将以这种方式安装。如果您要迁移到新的主要版本,请回答“Y”,让它为您创建一个新的配置文件。应该是这样!您的最新版本现在应该可以使用刚刚添加的任何新功能。
您可以通过运行python3 version.py
检查安装的 mlb-led-scoreboard 的版本信息。
该软件的最新版本可在此处获取。
确保您的 Raspberry Pi 的时区配置为您当地的时区。默认情况下,他们通常会显示伦敦时间。您可以通过运行sudo raspi-config
更改树莓派的时区。
安装脚本在main.py
顶部添加一行以自动获取虚拟环境。这意味着不需要重新激活环境( source ./venv/bin/activate
)。
sudo ./main.py
以 root 身份运行是 100% 绝对必须的,否则矩阵将无法渲染。
Adafruit HAT/Bonnet 用户:您必须提供命令行标志:
sudo ./main.py --led-gpio-mapping="adafruit-hat"
请参阅下面的“标志”部分,了解您可以选择提供的更多标志。
记分板可以通过RGBMatrixEmulator
进行软件模拟在其他平台上运行。通过模拟器运行时,您不需要在启动命令前添加sudo
:
./main.py
您还可以使用--emulated
标志强制记分板进入模拟模式:
./main.py --emulated
在仿真模式下运行时,您可以继续照常使用现有的命令行标志。
有关模拟器配置选项,请参阅 RGBMatrixEmulator。
包含默认的config.json.example
文件以供参考。将此文件复制到config.json
并根据需要修改值。
"preferred": Options for team and division preference
"teams" Array An array of preferred teams. The first team in the list will be used as your 'favorite' team. Example: ["Cubs", "Brewers"]
"divisions" Array An array of preferred divisions that will be rotated through in the order they are entered. Example: ["NL Central", "AL Central"]
"news_ticker": Options for displaying a nice clock/weather/news ticker screen
"always_display" Bool Display the news ticker screen at all times. Supercedes the standings setting.
"team_offday" Bool Display the news ticker when your prefered team is on an offday.
"preferred_teams" Bool Include headlines from your list of preferred teams. Will only use the first 3 teams listed in your preferred teams.
"display_no_games_live" Bool Display news and weather when none of your games are currently live.
"traderumors" Bool Include headlines from mlbtraderumors.com for your list of preferred teams. Will only use the first 3 teams listed in your preferred teams.
"mlb_news" Bool Include MLB's frontpage news.
"countdowns" Bool Include various countdowns in the ticker.
"date" Bool Display today's date to start the ticker. This will always be enabled if no other ticker options are.
"date_format" String Display the date with a given format. You can check all of the date formatting options at https://strftime.org
"standings": Options for displaying standings for a division
"always_display" Bool Display standings for your preferred divisions.
"mlb_offday" Bool Display standings for your preferred divisions when there are no games on the current day.
"team_offday" Bool Display standings for your preferred divisions when the one of your preferred teams is not playing on the current day.
"display_no_games_live" Bool Display standings when none of your games are currently live.
"rotation": Options for rotation through the day's games
"enabled" Bool Rotate through each game of the day according to the configured `rates`.
"scroll_until_finished" Bool If scrolling text takes longer than the rotation rate, wait to rotate until scrolling is done.
"only_preferred" Bool Only rotate through games in your preferred teams.
"only_live" Bool Only rotate through games which are currently playing. Can be composed with `only_preferred`.
"rates" Dict Dictionary of Floats. Each type of screen can use a different rotation rate. Valid types: "live", "pregame", "final".
Float (DEPRECATED) A Float can be used to set all screen types to the same rotate rate.
"while_preferred_team_live": Options for rotating between screens while one of your preferred teams is live
"enabled" Bool Enable rotation while a preferred team is live.
"during_inning_breaks" Bool Enable rotation while a preferred team is live during an inning break.
"weather": Options for retrieving the weather
"apikey" String An API key is required to use the weather service.
You can get one for free at Open Weather Map (https://home.openweathermap.org/users/sign_up).
"location" String The `{city name},{state code},{country code}` according to ISO-3166 standards (https://www.iso.org/obp/ui/#search).
Check out the OpenWeather documentation (https://openweathermap.org/current#name) for more info.
Ex: `"Chicago,il,us"`
"metric_units" Bool Change the weather display to metric units (Celsius, m/s) instead of imperial (Fahrenheit, MPH).
"time_format" String Sets the preferred hour format for displaying time. Accepted values are "12h" or "24h" depending on which you prefer.
"end_of_day" String A 24-hour time you wish to consider the end of the previous day before starting to display the current day's games. Uses local time from your Pi.
"full_team_names" Bool If enabled on a board width >= 64, displays the full team name on the scoreboard instead of their abbreviation. This config option is ignored on 32-wide boards.
"short_team_names_for_runs_hits" Bool If full_team_names is enabled, will use abreviated team names when runs or hits > 9 to prevent overflow of long names into RHE.
"scrolling_speed" Integer Sets how fast the scrolling text scrolls. Supports an integer between 0 and 6.
"preferred_game_update_delay_in_10s_of_seconds" Integer Sets how long to wait before updating the preferred game. Must be positive.
"pregame_weather" Bool If enabled, will display the weather for the game's location on the pregame screen.
"debug" Bool Game and other debug data is written to your console.
"demo_date" String A date in the format YYYY-MM-DD from which to pull data to demonstrate the scoreboard. A value of `false` will disable demo mode.
跑分/安打/错误 - 跑分始终显示在游戏屏幕上,但您可以启用或调整“跑分、安打、错误”显示的间距。有关详细信息,请查看坐标自述文件。
俯仰数据 - 俯仰数据可以显示在游戏屏幕上,有关详细信息,请参阅坐标自述文件。另外, short
音高和long
音高的描述可以在data/pitchs.py中更改
之前的游戏数据 - 之前的游戏数据可以显示在游戏屏幕上。有关详细信息,请参阅坐标自述文件。长和短的游戏描述可以在 data/plays.py 中更改
您可以使用 rpi-rgb-led-matrix 库中使用的相同标志来配置 LED 矩阵。有关这些参数的更多信息可以在库文档中找到。
--led-rows Display rows. 16 for 16x32, 32 for 32x32. (Default: 32)
--led-cols Panel columns. Typically 32 or 64. (Default: 32)
--led-chain Daisy-chained boards. (Default: 1)
--led-parallel For Plus-models or RPi2: parallel chains. 1..3. (Default: 1)
--led-pwm-bits Bits used for PWM. Range 1..11. (Default: 11)
--led-brightness Sets brightness level. Range: 1..100. (Default: 100)
--led-gpio-mapping Hardware Mapping: regular, adafruit-hat, adafruit-hat-pwm
--led-scan-mode Progressive or interlaced scan. 0 = Progressive, 1 = Interlaced. (Default: 1)
--led-pwm-lsb-nanosecond Base time-unit for the on-time in the lowest significant bit in nanoseconds. (Default: 130)
--led-show-refresh Shows the current refresh rate of the LED panel.
--led-slowdown-gpio Slow down writing to GPIO. Range: 0..4. (Default: 1)
--led-no-hardware-pulse Don't use hardware pin-pulse generation.
--led-rgb-sequence Switch if your matrix has led colors swapped. (Default: RGB)
--led-pixel-mapper Apply pixel mappers. e.g Rotate:90, U-mapper
--led-row-addr-type 0 = default; 1 = AB-addressed panels. (Default: 0)
--led-multiplexing Multiplexing type: 0 = direct; 1 = strip; 2 = checker; 3 = spiral; 4 = Z-strip; 5 = ZnMirrorZStripe; 6 = coreman; 7 = Kaler2Scan; 8 = ZStripeUneven. (Default: 0)
--led-limit-refresh Limit refresh rate to this frequency in Hz. Useful to keep a constant refresh rate on loaded system. 0=no limit. Default: 0
--led-pwm-dither-bits Time dithering of lower bits (Default: 0)
--config Specify a configuration file name other, omitting json xtn (Default: config)
--emulated Force the scoreboard to run in software emulation mode.
--drop-privileges Force the matrix driver to drop root privileges after setup. (Default: true)
如果您喜欢冒险(我们强烈鼓励您这样做!),下面的部分概述了如何真正个性化您的记分板并使其成为您自己的!
您可以自定义事物在棋盘上的放置方式(也许您希望看到游戏前的滚动文本稍高或稍低)。有关更多信息,请参阅coordinates/
目录。
您可以自定义板上所有内容的颜色。请参阅colors/
目录以获取更多信息。
该记分板将使用天气 API 来收集不同时间的天气信息。此信息会在您所在区域的球队休息日显示,也会在每场比赛的赛前信息中显示。我们使用的天气 API 来自 OpenWeatherMaps。 OpenWeatherMaps API 需要 API 密钥来获取此数据,因此您需要花一点时间注册一个帐户并将您自己的 API 密钥复制到config.json
中。
您可以在 https://home.openweathermap.org/users/sign_up 找到 OpenWeatherMaps 的注册页面。登录后,您将找到一个API keys
选项卡,其中您会发现已为您创建了默认密钥。您可以复制此密钥并将其粘贴到"weather"
、 "apikey"
下的config.json
中。
您可以通过输入以逗号分隔的城市、州和国家/地区代码来更改所使用的位置。如果您希望使用公制测量,请将"metric"
选项设置为true
。
该项目依赖于两个库: MLB-StatsAPI 是用于检索实时比赛数据的 Python 库。 rpi-rgb-led-matrix 是用于使所有东西都能与 LED 板配合使用的库。
记分牌经常更新,但无法检索 MLB 尚未提供的信息。如果出现奇怪的情况或看起来落后了,第一个嫌疑人就是 MLB Web API。
如果您遇到任何问题并且有重现步骤,请提出问题。如果您有功能请求,请提出问题。如果您想贡献中小型更改,请打开拉取请求。如果您想贡献新功能,请先提出问题,然后再提出 PR。
使用pipreqs
管理依赖关系要求。如果您要添加或更改依赖项(例如更新其版本),请确保使用pipreqs
更新需求文件:
# If not already installed
pip3 install pipreqs
pipreqs . --force
该项目从 v1.1.0 开始使用 GNU 公共许可证。如果您打算出售这些,代码必须保持开源。
该板的原始版本
受此板的启发,查看 NHL 记分板?