Clock using a Max7219 Matrix Display

I guess many of us find lighting up loads of LEDs to be rather interesting, so when I saw this group of 4 Matrix displays for sale cheaply, I had to pounce and find a use for them later.

There are a number of methods described for running them with the Raspberry Pi but I stumbled on an excellent library which does all of the hard work. The documentation is comprehensive and the examples really show what is possible.

matrixdisplay

Matrix Display resting on a Lego compatible case. The sizes fit perfectly, so I guess a construction brick display device is on the way soon!

I started out with just an 8×8 display originally, not trusting that I’d have any success with a larger module, but soon I got bored and upgraded. Woah… this thing works well, especially once the correct rotation had been added.


#!/usr/bin/env python

import time
from random import randrange

import max7219.led as led
from max7219.font import proportional, SINCLAIR_FONT, TINY_FONT, CP437_FONT
import feedparser

python_wiki_rss_url = "http://open.live.bbc.co.uk/weather/feeds/en/2649808/3dayforecast.rss"

# create matrix device
device = led.matrix(cascaded=4)
device.orientation(90)
print("Created device")

while True:
        print("Getting feed")
        feed = feedparser.parse( python_wiki_rss_url)

        for repeats in range(10):
                print(repeats)
                for items in feed["items"]:

                        msg = items["title"]
                        msg = msg[0:msg.find(",")]
                        print(msg)
                        device.show_message(msg, font=proportional(SINCLAIR_FONT))
                        time.sleep(1)

                        msg = time.asctime()
                        msg= time.strftime("%H:%M")
                        print(msg)
                        device.show_message(msg, font=proportional(SINCLAIR_FONT))
                        time.sleep(10)

I quickly looked up reading RSS feeds as well as strftime for python, and in a short period of time the program above shows a clock for 10 seconds and then parts of the 3 day forecast.

Advertisement