Wednesday, August 27, 2014

Baseball Scoreboard - Update to display Box Scores

Overview

In previous posts (1 2), I discussed having programmed all of the graphical hooks to support real time box scores but had been unable to implement due to a lack of freely available sports feeds.  By leveraging some resources Mike Metral uncovered in building his sports ticker, I was able to finally implement the functionality fully.  (More including video of the finished update after the jump)



Background


Recently, I was fortunate enough to be highlighted for this project by adafruit (http://www.adafruit.com/blog/2014/08/22/custom-led-panel-baseball-scoreboard/).  A side effect of this is that I got tagged in the sports category along with a sports ticker project Mike Metral built(http://www.adafruit.com/blog/2014/04/18/build-your-own-homemade-sports-ticker-with-a-raspberry-pi-and-led-sign-raspberry_pi-piday-raspberrypi/).  Reading through his post, I was able to find references to some free streams that were easily parsed.  A couple of custom feed parsers and a few hooks into the GameChanger parser and web server, and I was in business.  Here is a video of the results:


How it Works

Two parsers are currently implemented for MLB and NFL scores.  (Since the initial post, I've rewritten the program to stream any sport available from the streaming website; configurable via the web server).  On scoreboard boot and every half inning, the control box reaches out to get scores for the configured sports, parse them, and then displays them to the scoreboard.  Hooks are also written into the web server to turn the different sports scores on/off and to do an instantaneous display of scores (instead of waiting until the next half inning).

Quick Start Guide

 For those who just want to get this up and running, do the following and you should be good to go:

  • cd
  • wget https://github.com/ScratchesTheItch/ScoreboardRaspberryPiCode_Configs/raw/master/BoxScores/BoxScores.tar.gz
  • cd /
  • tar -xvzf ~/BoxScores.tar.gz

A Little More Detail

Code is available here.  On top of the BoxScore specific code, this code also makes changes to the gc-parser (to support Inning half detection and score streaming) and the web server (to support configuration)

Heres the expanded how it works, for those who are interested:
  • User configures which sports they want from the web server's Configure Box Scores web page.  Sports available is based upon the sports.txt file in the BoxScores directory.  Default configuration is all available sports
  • Based upon the Half changing ($Half variable changes) or someone hitting the Show Scores Now button on the web page, the server starts generate_scores.sh 
  • Generate_scores.sh sources sports.sh, a file containing the sports configured for display.
  • The configured sports are  passed to the all-in-one-scores.pl script that:
    • first requests a webpage to determine the current period and 
    • then requests the stream for each sport in term (using the current period).  
  • When scores are received, they are further screened for the current date and whether or not the game has started (only in-progress and final scores are reported).
  • For each configured sport, a title screen is provided to let the fans now what score is being streamed, followed by each game score at 3 second intervals.  In-progress games are shown before final scores.
  • The sequence ends with a "Let's Go Team" x3 prior to restoration of normal function.

Once again, thanks for reading!

1 comment:

  1. electronic display boards india

    I had a great time reading around your post as I read it extensively. Excellent writing! I am looking forward to hearing more from you.

    ReplyDelete