Pixel-y Panel Project: Clock & Serial Console

A neat thing about the MatrixPortal after you install CircuitPython on it, is that it's super easy to start writing projects. Plugging in the board mounts a USB mass storage device called CIRCUITPY:

Whatever functionality you need, you just copy from the Library Bundle on your host computer into the lib folder on the board. Your project code lives in the root folder; here, it's just called code.py. Any changes to the filesystem cause the MatrixPortal to restart and execute the new code.

This may seem a bit weird if you've never done embedded programming before, but it's because you don't have a shell (or even a traditional operating system!) running on the board. So no access to handy tools like pip or Homebrew to fetch dependencies. It also means that you'll have to pay more attention to inter-library dependencies.

Anyway, I tried out one of the simple projects, Network Connected RGB Matrix Clock. Here are some of the things I tweaked:

  • I customized the clock with a BDF font downloaded from https://github.com/Tecate/bitmap-fonts
  • To make the clock display 24-hour time, I commented out the lines that subtracted 12 from the hours. I also adjusted the label text to always format the hours with 2 digits.
  • I used the adafruit_fancyled library with a custom palette to slowly change the colours of the display.
  • Don't forget to get a free Adafruit IO account, and include your username and key in secrets.py. matrixportal.network.get_local_time() makes a network call to the Adafruit IO time server to get the time.
Tada! Now I know what time it is.

One thing I couldn't figure out is where the output of debug print() calls go. What is stdout on the board hooked up to!?

I found the answer in the Welcome to CircuitPython guide: the board exposes a serial console over the USB interface. The docs suggest using Mu, a simple Python editor that auto-detects the MatrixPortal and has built-in support for the serial console.

But since I'm a die-hard vim user, I wanted to connect to the serial console using screen.