Skip to content

Turn a MAX7219-controlled line of 8x8 LED matrices into a text ticker

License

Notifications You must be signed in to change notification settings

saylorsd/led-matrix-ticker

Repository files navigation

LED Matrix Text Ticker

Enable SPI

Step aken from https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial. Refer to there for more information.

  1. Run sudo raspi-config.
  2. Use the down arrow to select Advanced Options
  3. Arrow down to SPI.
  4. Select yes when it asks you to enable SPI,
  5. Also select yes when it asks about automatically loading the kernel module.
  6. Use the right arrow to select the <Finish> button.
  7. Select yes when it asks to reboot.

Pin Layout

Pin Layout Diagrams

Board Pin Name RPi Pin RPi Function
1 VCC 2 5V
2 GND 6 GND
3 DIN 19 GPIO 10 (MOSI)
4 CS 24 GPIO 8 (SPI CS0)
5 CLK 23 GPIO 11 (SPI CLK)

Acknowlegements

I used a lot of code (especially the low-level technical parts) from tutRPi's multilinemAX7219 repo.
Which is an "improved and extended version" of JonA1961's MAX7219array.

PATransitTicker

Display upcoming Port Authority of Allegheny County bus/T times on a scrolling LED message board connected to a Raspberry Pi.

The Ticker

Required Parts

  1. RaspberryPi (pretty sure any version will work)
    a. SD Card
    b. WiFi dongle (optional: can use ethernet) (note: WiFi is built into v3 and ZeroW)
    c. USB Micro-B USB cable/charger (same as most - if not all - Android phones/tablets)
    d. HDMI Cable and HDMI compatible monitor (or necessary adapters) (for initial setup)
    e. USB Keyboard (for initial setup)
  2. MAX7219 controlled LED matrix(ces) I happened to use this one but any MAX7219-controlled LED Matrix(ces) should work (with a little coding).

Accessing TrueTime API

Make an account here to request an API key.
An account is also necessary to access the TrueTime documentation.

Hardware Installation

Check out The LED Matrix Ticker Driver used for this project for installation instructions.
If using differently hardware, you will likely need to use a different driver and follow different installation instructions.

Installation

  1. Connect Matrix to Raspberry Pi (see my LED Ticker's readme for an example)
  2. Clone this repo onto your Raspberry Pi and generate a settings file.
git clone --recursive https://github.com/saylorsd/PATransitTicker

cd PATransitTicker

cp settings-example.py settings.py
  1. Open settings.py in your favorite text editor and copy your API key in place of "YOUR_API_KEY_HERE!"
nano settings.py
  1. Adjust the other settings if necessary.
  2. Install the necessary python libraries
pip install -r requirements.txt  
  1. Run the ticker
python ticker.py

Settings

settings.py

API_KEY = "YOUR_API_KEY_HERE!"              # TrueTime API key from Port Authority

FONT = CP437_FONT_ROTATED                   # !! Change this to your font of choice (be sure to import it above!)
LOG_FILE = "/home/pi/logs/bus-ticker.log"   # Where the log file will go.  Use Falsey value to log to stdout
DURATION = 30                               # Number of minutes you want it to run for
SPEED = 5
PREDICTIONS = [
    {
        'stpid': 8161,      # stop id
        'rt': 'P3',         # bus route name
        'dir': 'INBOUND'    # direction: 'INBOUND' or 'OUTBOUND'
    },
    {
        'stpid': 18141,
        'rt': '75',
        'dir': 'INBOUND'
    }
]

The Predictions Request

This code uses the getpredictions endpoint for the TrueTime API. For this use case, it sends a bus stop ID, a route ID, and the direction (inbound/outbound).

You can find your bus stops' IDs on the Port Authority's Transit Stop Data on the Western Pennsylvania Regional Data Center. Find your stop on the map, click it, and look for 'ID' in the popup.

More info can be found in the documentation. (requires you to be logged into the TrueTime site first)

Cron Job

I built this around my use case wherein I run this script as a cron job that starts around the time I'm getting ready in the morning. For those unfamliar with cron, here's a nice resource.

To edit your cron jobs:
crontab -e
Then add a line like this:
0 7 * * * python /path/to/ticker.py

Extra Resources

About

Turn a MAX7219-controlled line of 8x8 LED matrices into a text ticker

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages