Getting Back To Basics

Getting Back To Basics

Why and What?

As architects and programmers we are lucky to live in an era with ready-made libraries handling everything from on-screen window frames to fast sorts to network communication. Much of the low-level programming we used to do is gone. On the hardware front there are any number of powerful and affordable laptop and desktop machines with 4K monitors outfitted with more disk and memory than you can use.

This can make software development teams highly productive in that far more of each day is spent writing high-value business code as opposed to bookkeeping code for a linked list or binary tree search. And we spend less time waiting for the build thanks to our quad-core i7 CPU with16GB of RAM and a very smart IDE.

I would not want to go back to these “good-ole-days” but sometimes it’s fun to take on a project that exercises different muscles.

And so it was this past summer when I built my first Raspberry Pi-based project. But what to build? Hmmmm. . .

I had noticed some time ago that we no longer had a clock in our family room. All the boxes that typically have an LED clock were gone: We had long ago retired the VCR and eventually replaced the DVD player with a PlayStation; we had cut-the-cord almost 10 years ago and so don’t have a cable-box.

Thus we were relegated to our phones which, unfortunately some would say, are now our constant companion. While an iPhone is quick to glance at I wanted a clock and thought a Raspberry Pi project would fit the bill and provide a bit of nostalgia at the same time.

Scope

After some thought I decided that a combination clock/marquee would be fun. It would display both the time and a scrolling message that could be changed (“Hey Kids, Saturday is clean-the-house day!”). To realize my vision this project would require a number of components and steps (just as any of the projects we all do day-to-day). The fun part was some components are old-school and some are new.

  • Raspberry Pi – new
  • Soldering – old-school
  • 3D-printing – new
  • C/C++ – old-school
  • Redis and webdis – new
  • Alexa – new
  • init – old-school

What is completed?

  • Purchase a Raspberry Pi 3, an interface board (aka "hat") to control an LED array and a 64x32 LED array
  • Solder the hat onto the Pi and wired it all up
  • Configure redis (for it’s simple persistent caching feature)
  • Configure webdis (simple mechanism to publish web-services for redis)
  • Write the clock driver, turn it into a daemon, place it in init.d
  • Fashion a simple wooden stand
  • Turn it on

What is left?

  • 3D modeled and printed stand
  • Alexa interface - started but not finished (“Alexa, set marquee to ‘You gotta ski!’”)

This was a fun project and is actually functional.

How did it help me? Well, I got to brush off some very rusty soldering skills, I had to remember System V/Linux daemons and init and I learned about a number of cool new tools that I can use in future projects: webdis, redis and Alexa Skills.

Demo

In the pictures below you can see a static shot of the working clock in the middle of scrolling the message; this shows the LEDs at full brightness - which is pretty bright. I usually keep it at 20% of full brightness which is sufficient to read in most lighting conditions except direct sunlight.


The second and third picture show the Pi with the hat soldered on top and the back of the clock with a simple wooden frame holding the LED matrix.

The video shows it in action - apologies in advance for the quality. The demo starts out with a simple message at full brightness, then the brightness level is changed to 25% and finally a new message is set. Watch the clock on the left and web-service requests on the right. All requests are issued via curl but a browser works just as well, of course.


Commands issued:

  • curl http://<ip address>/sET/Bright/25
  • curl http://<ip address>/set/Marquee/You%20gotta%20ski

Since this is a raw HTTP command spaces and other control characters must be escaped - hence the %20.

Implementation Highlights

Four very simple web services are published that are used to set and retrieve the brightness and displayed message (aka marquee text):

  • GET Brightness        Returns brightness level between 1 and 100
  • SET Brightness        Set brightness level to between 1 and 100
  • GET Marquee          Get the currently displaying marquee text
  • SET Marquee          Set the marquee text

The great thing about webdis and redis in combination is that webdis provides a very simple mechanism to publish web-services and deposit the payload directly into redis; redis then is used as a simple persistent cache so it will provide the last message upon startup (read from disk). The clock application uses native redis calls to retrieve the marquee text and LED brightness.

The clock code enters a simple loop to get the time, read the message from redis and display it on the LED matrix. The time is retrieved during each update of the matrix in case the minute changes during the scroll while the displayed message is retrieved only after every full display loop (length determined by character count).

What Next?

I have a few other ideas for old-school projects that will exercise some fun hardware and software technologies that business software teams (programmers and architects) rarely get to use. I have long maintained that understanding low-level details of technology results in better architectures, more maintainable code and faster debugging. With the ever shrinking schedule and ever improving tools, libraries and frameworks it is easy to forget the ones-and-zeros or solder joints that make it all work.

Parts-list and source code is available upon request.

Impressive! Would have been a perfect addition to the Waverly Products catalog.

Like
Reply

haha...reminded me of my school projects...! nostalgic indeed and well articulated Terry.Coudln't agree more.

Like
Reply

These are the moments when I REALLY wish I could code !

To view or add a comment, sign in

More articles by Terence Davis

  • The Evolution of AI

    Artificial Intelligence (AI) has evolved from its inception in 1955, permeating through the technological and cultural…

    2 Comments

Others also viewed

Explore content categories