GithubHelp home page GithubHelp logo

mlb-led-scoreboard / mlb-led-scoreboard Goto Github PK

View Code? Open in Web Editor NEW
572.0 47.0 102.0 24.7 MB

An LED scoreboard for Major League Baseball :baseball:

License: GNU General Public License v3.0

Python 96.78% Shell 3.22%
mlb baseball raspberry-pi rgb-led sports adafruit

mlb-led-scoreboard's Issues

Create Main Menu

This would be the new landing page when you spin up the board. Should have a nice graphic and a menu to navigate to either MLB Standings (see #4) or a list of games to pick from (see #7)

Because this requires a sexy graphic, I'm not gonna do it cause I lack the confidence.

Tampa Bay's too bright

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.

Add Alexa device support

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.

Store matrix colors off somewhere

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.

Use argparse

Once the command line arguments get fleshed out, use argparse.

Until that happens I'm just gonna read sysargv

Board crashes during warmup phase

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"

Pitcher/batter number for each team

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

32x64 board - rows flicker

Rows in the board constantly flicker when running the MLB program. I have not seen the issue running any of the sample programs.

Display flashing marquee for strikeouts

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.

Home mercy wins showing bottom of the ninth

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.

Handle non-MLB team banners

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)

Crash during a network issue

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>

Display MLB Standings

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.

64x32 enhancements

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!"

Launch script from a different directory?

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'

Board crashes during inning breaks

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.

Consume MLBGame v3

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.

Add option to display standings on an off 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.

Crash on postponed games

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.

Pick game from games list

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.

Display full standings

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.

Configure Time Zones

MLB returns everything in Eastern, use the local system clock to convert the game time to local time.

Update Install Instructions in README

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)


Install MLB LED Scoreboard

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/

Create Settings Menu

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.

Add rotation_rate option for games in progress

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

  • Add rotation_rate to config.json.example that uses the number provided (in seconds) for rotating games.
  • Throw an error and exit gracefully if the rotation rate isn't a number or is less than 1 second. Less than a second would probably bottleneck the board pretty hard.
  • Update the GameRenderer to use the provided 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.
  • Keep pregames on screen for 15 seconds, only implement this for games in progress (right now that means "not PREGAME"). #30 is logged for pregame refresh rates, and those will not be configurable by the user.
  • Update the README documenting the new config option

Add option for end of day

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 pregame matchup

Center (as best we can, even numbers and all that) the pregame matchup text depending on matrix width.

image

@swemoney has a pretty sweet setup that could use just a little love here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.