mlb-led-scoreboard / mlb-led-scoreboard Goto Github PK
View Code? Open in Web Editor NEWAn LED scoreboard for Major League Baseball :baseball:
License: GNU General Public License v3.0
An LED scoreboard for Major League Baseball :baseball:
License: GNU General Public License v3.0
Currently if it goes to the 10th inning the number runs out of room.
The Rays color scheme isn't working, the really light blue and the white ain't gonna fly.
Need to test some different colors out from their palette, might have to use a dark font.
This is based on a hypothetical that I would enjoy in terms of functionality. I currently have Alexa dev accounts and have built skills. It'd be nice to be able to say "Alexa, turn on the scoreboard" and the scoreboard turns on.
I realize there's a number of challenges associated with this issue, but it's a good opportunity for us to implement this feature. This is low on the totem pole for now.
Magic numbers galore in here, all for the various RGB values I'm setting for text colors and other goodies.
Need to store these off somewhere so everything's easier to deal with.
The outs rendered on screen are always 1 greater than the number returned from the API.
"No games today :("
I hate the offseason.
Once the command line arguments get fleshed out, use argparse.
Until that happens I'm just gonna read sysargv
If the data returned from MLB is incomplete we don't render anything, we should show something to the user indicating that the game can't be displayed.
When we go to do a full refresh of all the games, it causes the scoreboard to start flashing quickly. This continues until restarting. Only present while displaying pregames, I didn't have this issue while it was rotating through final scores.
A game is marked by MLB as "In Progress" but there are 0 atbats, causing an index out of bounds error when trying to create the scoreboard.
Traceback (most recent call last):
File "main.py", line 44, in <module>
GameRenderer(matrix, canvas, games[0], config).render()
File "/home/pi/shared/mlb-led-scoreboard/renderers/games.py", line 64, in render
self.__refresh_game(game, overview.status)
File "/home/pi/shared/mlb-led-scoreboard/renderers/games.py", line 97, in __refresh_game
scoreboard = Scoreboard(game)
File "/home/pi/shared/mlb-led-scoreboard/data/scoreboard.py", line 16, in __init__
self.game_data = self.__current_game_data(game)
File "/home/pi/shared/mlb-led-scoreboard/data/scoreboard.py", line 27, in __current_game_data
game_data['inning'] = self.__current_inning(game_id)
File "/home/pi/shared/mlb-led-scoreboard/data/scoreboard.py", line 44, in __current_inning
inning_status['at_bat'] = self.__current_at_bat(at_bats[-1])
IndexError: list index out of range
Need to display something during warmup. Probably just the team banners then instead of the bases and pitches, show "WARMUP"
During the middle of an inning, display "MIDDLE #" where # is the inning number. Don't display pitches, outs, or bases.
Before a game starts, display something like:
STL @ CHC
7:30pm
you may want to look at the matrix folder, it throws a 404 right now.
With #29 a couple new dependencies have been added so it would be good to clean up the installation process where we can.
Would it be possible to include the jersey number of the pitcher and batter for each team? If you're only using a single 32x32 matrix then there's not enough room for the pitcher and hitter. But if it was possible to put the jersey number or the pitcher and hitter at the end of the team's color block (far right behind the score) then it would still be visible who was up and who was pitching. Similar to how some ballparks do the out of town scoreboard
Rows in the board constantly flicker when running the MLB program. I have not seen the issue running any of the sample programs.
Currently I'm just defaulting to the Cubs game if a team isn't provided. main.py
refreshes the board every 15 seconds and it would be neat to show a different game every time it comes back around.
On the second board, when a player strikes out, flash "STRIKEOUT". The board should barely have enough room for a word that large. If it looks ugly, just "K" might be good enough.
If the home team won by mercy rule the board is still rendering the bottom of the 9th instead of the final at-bat of the top.
This is going to be fixed by #8 but I'm logging this cause it is a bug and should be tracked.
Some small changes have been made since those were taken.
I'll wait till the season starts before doing it.
For early spring training games, sometimes a team will play a college team. Luckily mlbgame already brings back data, but we currently don't handle teams without colors in colors.json
.
Let's just not fill in their banner and fall back to the fill color (dark blue/purple)
Leaving the scoreboard running for a while, it looks like it's possible for the Pi to run into some kind of strange network hiccup that completely crashes the scoreboard. We should fail more gracefully on this kind of issue.
File "/home/pi/mlb-led-scoreboard/main.py", line 42, in <module>
GameRenderer(matrix, matrix.CreateFrameCanvas(), games, config).render()
File "/home/pi/mlb-led-scoreboard/renderers/games.py", line 65, in render
overview = mlbgame.overview(game.game_id)
File "/usr/local/lib/python2.7/dist-packages/mlbgame/__init__.py", line 198, in overview
return mlbgame.game.Overview(mlbgame.game.overview(game_id))
File "/usr/local/lib/python2.7/dist-packages/mlbgame/game.py", line 324, in overview
data = mlbgame.data.get_overview(game_id)
File "/usr/local/lib/python2.7/dist-packages/mlbgame/data.py", line 82, in get_overview
'linescore.xml'))
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 429, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 447, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1228, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1198, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>
Provide a way to display MLB standings. Ideally this would be launched from a menu of sorts (see #6) but for now passing a separate command line flag is good.
I would also accept passing in a flag for the division to display.
Use arrow keys to scroll through games of the day.
Along with the game time, add some scrolling text below for the probable starting pitchers.
Logging this issue to see if there's any interest. I'll keep it open throughout the season and if nothing happens I'll close this, otherwise, anybody interested in this project can throw out some ideas.
Current ideas:
Display pitcher vs. batter info on the second board, including ERA, avg/obp/ops, etc.
Display flashing marquees similar to MLB's GameDay, such as "HOME RUN!"
I was trying to add the python script to launch on boot but it doesn't work unless I'm in the mlb-led directory. For example:
$ sudo python ~/mlb-led-scoreboard/main.py -r
Traceback (most recent call last):
File "/home/pi/mlb-led-scoreboard/main.py", line 33, in
render_games(matrix, canvas, games[0], args)
File "/home/pi/mlb-led-scoreboard/renderer.py", line 30, in render_games
success = __refresh_scoreboard(canvas, game)
File "/home/pi/mlb-led-scoreboard/renderer.py", line 89, in __refresh_scoreboard
renderer = ScoreboardRenderer(canvas, scoreboard)
File "/home/pi/mlb-led-scoreboard/scoreboard_renderer.py", line 9, in init
self.colors = json.load(open('Assets/colors.json'))
IOError: [Errno 2] No such file or directory: 'Assets/colors.json'
Traceback (most recent call last):
File "main.py", line 44, in <module>
GameRenderer(matrix, canvas, games[0], config).render()
File "/home/pi/shared/mlb-led-scoreboard/renderers/games.py", line 64, in render
self.__refresh_game(game, overview.status)
File "/home/pi/shared/mlb-led-scoreboard/renderers/games.py", line 97, in __refresh_game
scoreboard = Scoreboard(game)
File "/home/pi/shared/mlb-led-scoreboard/data/scoreboard.py", line 16, in __init__
self.game_data = self.__current_game_data(game)
File "/home/pi/shared/mlb-led-scoreboard/data/scoreboard.py", line 27, in __current_game_data
game_data['inning'] = self.__current_inning(game_id)
File "/home/pi/shared/mlb-led-scoreboard/data/scoreboard.py", line 44, in __current_inning
inning_status['at_bat'] = self.__current_at_bat(at_bats[-1])
IndexError: list index out of range
pi@raspberrypi:~/shared/mlb-led-scoreboard $ sudo python main.py
> /home/pi/shared/mlb-led-scoreboard/data/scoreboard.py(44)__current_inning()
-> inning_status['bottom'] = is_bottom
(Pdb) at_bats
[]
(Pdb) inning_status
{'number': 2}
Some fast reaction time and a quick breakpoint before the next inning started determined that a new inning is created but there are no at bats, causing an index error. Need to display "END #" where the number is the previous inning. If inning - 1 is 0, then see #49 as both will be handled in a similar fashion.
Work is underway to upgrade mlbgame to use the new MLB Stats API instead of the existing XML files. Once this is done, the scoreboard will need to consume the new changes.
A suggestion for the current rotate feature would be to check if a team was also passed and stop rotating while that team is playing and continue shortly after their game ends.
A config option that can tell the scoreboard to rotate only through live games. If there are no live games, rotate through all the final scores for the day.
Can we embed division standings as an option for off days? Example move of:
standings = mlbgame.standings(datetime.datetime(year, month, day))
division = next(division for division in standings.divisions if division.name == config.preferred_division)
renderers.standings.render(matrix, matrix.CreateFrameCanvas(), division)
to the branch logic of:
if not len(games):
from main.py.
We don't handle postponed games at all. The Cubs game on 5/20/2017 was postponed. Innings is an empty string so it's not processed very well.
Display two games at once.
The scoreboard does some flickering and eventually crashes to a blank matrix when switching from rotating the games from the day before to displaying the next days games.
Display list of current games with the team names, color banners, and scores and provide a way through keyboard nav to pick a game.
If #6 isn't done yet, it's fine to use a command line flag to get to it.
Currently the 32x32 has to swap wins and losses being rendered due to the small real estate.
64x32 should be able to show wins and losses at a minimum.
MLB returns everything in Eastern, use the local system clock to convert the game time to local time.
When the inning is in an End state, display "END #" where # is the inning. Don't display bases, pitches, or outs.
Wrote up some detailed instructions, from fresh image to finished, to get people going. Use them if you'd like. (not really an issue, just didn't know how else to submit it)
Distribution: Raspbian Lite
Enable SSH: Place a file named 'ssh', without any extension, onto the boot partition of the SD card
Connect to raspberry Pi with Putty via SSH
Default user: pi / raspberry
#change password: passwd
Disable snd_bcm2835 (see: https://github.com/hzeller/rpi-rgb-led-matrix#bad-interaction-with-sound)
cd /etc/modprobe.d
sudo nano alsa-blacklist.conf
Type: blacklist snd_bcm2835
Save: CTRL-O
Hit: enter to overwrite the existing file
Exit nano: CTRL-X
Restart: sudo reboot
Install Dependencies For The LED Matrix
sudo apt-get install python-pip
sudo apt-get install libxml2-dev libxslt-dev
Install Git Command
sudo apt-get install git
Git MLB LED Scoreboard
git clone --recursive https://github.com/ajbowler/mlb-led-scoreboard
cd mlb-led-scoreboard/matrix/bindings/python
Building the RGBMatrix binaries (what controls the LED board)
sudo apt-get update && sudo apt-get install python2.7-dev python-pillow -y
sudo HARDWARE_DESC=adafruit-hat make build-python #If using the Adafruit hat with the flicker mod: adafruit-hat-pwm
sudo HARDWARE_DESC=adafruit-hat make install-python #If using the Adafruit hat with the flicker mod: adafruit-hat-pwm
Demo (Scrolling text: Hello world!)
cd samples
sudo ./runtext.py
Finish up with MLB LED Scoreboard install
cd ../.. #should be in bindings folder now
sudo pip install -e python/
cd ../../ #should be in mlb-led-scoreboard/ now
sudo pip install mlbgame #takes awhile
make
Let's Run It!
sudo python main.py #To stop the script: CTRL-C
To Edit settings
sudo nano config.json.example
Edit the file to how you see fit
Save: CTRL-O
Delete: .example
Confirm: New file
Exit: CTRL-X
#Now when you run 'sudo python main.py' it will display the team, standings, and anything else you have configured
//Thanks to:
//https://github.com/ajbowler/mlb-led-scoreboard
//https://github.com/hzeller/rpi-rgb-led-matrix
//https://learn.adafruit.com/raspberry-pi-rgb-led-matrix-webapp?view=all
//http://www.instructables.com/id/Disable-the-Built-in-Sound-Card-of-Raspberry-Pi/
Currently the games (and pregames) rotate every 15 seconds, but for pregames, it may take longer than that to scroll the entire probable starters string across the LED board.
As more features come into play we'll want a settings menu.
Create a settings menu that can be accessed via main menu (#6) and port all scoreboard related command line args to it, then remove the command line args.
The rpi-rgb-led-matrix command line args will stay as command line args.
Currently we rotate games in progress every 15 seconds, and it would be an easy feature if that duration could be configured via config.json
rotation_rate
to config.json.example
that uses the number provided (in seconds) for rotating games.refresh_rate
and default back to 15 seconds if it isn't provided. Additional code will need to be added to reset the rotation clock to the new start time, similar to how refresh_rate
is reset after rotating.Currently it shows the last at-bat when a game is over, instead it would be nice to show something like "Final" with the winning and losing pitchers below the scores.
During warmup, the scoreboard just shows the scores and then 1st on the bottom. Shouldn't be difficult to fix.
Right now, we get the current day based on the current time. An option that could be set to a time before switching to the next day so the scoreboard, after midnight, still rotates through scores from the previous day.
Center (as best we can, even numbers and all that) the pregame matchup text depending on matrix width.
@swemoney has a pretty sweet setup that could use just a little love here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.