[UPDATE: 2019-10-15. I got a GitHub account, and am playing around with it. The script can now be downloaded from there, and I've updated the links below.]
I got a "binary-coded decimal clock" (made by the good folks at Anelace Inc.) a few Christmases back. Picture via Amazon link at right, if you're not seeing it, turn off your ad blocker. The time shown is 10:48:36.
[And make no mistake, Anelace is a Good Company. I shorted out the power supply adapter by clumsy accident. I emailed, asked where I could buy a replacement, they just sent me one, free. Whoa.]
When I worked at UNH, I kept it in my cubicle as a conversation piece. The thing that sticks in my mind today is how many IT managers needed me to explain what it was and how to interpret the LEDs. No geeks they.
Shortly afterward, on a lark, I wrote a small Perl script to simulate the clock display in a terminal window. I recently exhumed and updated the script to more modern standards. It's short and (I think) fun.
Here's a screen snapshot of what it looks like in action. The red dots inside indicate "on" LEDs. The LED array is updated every second, as is the time displayed at the bottom.
The script is available at GitHub. I hope.
- I use Fedora distribution, and (as I type) all the required
modules, except one, are available in the normal Fedora repositiory,
and (hence) easily installable. The
Term::ANSIScreenPerl module available from CPAN handles text positioning, color, and formatting. I think most terminal emulation programs do ANSI commands these days.
cpanmto download and install non-Fedora Perl modules. The default behavior there is to install modules in
$HOME/perl5. The line
in the script does everything necessary to "see" the
- The LED-on "dot" is a UTF-8 character. If your terminal program
doesn't handle UTF-8, I suggest replacing it with a space with a red background.
(Exercise for the reader.)
Term::ReadKeymodule handles non-blocking terminal reads. This was implemented so that pressing the
Qkey will quit. [Pressing control-C might leave your terminal window in a funny "raw input" state. Fixing that left as an exercise for the reader.]
It could well be that a more judicious selection of fonts,
characters, etc. would make the display more pleasing.
Obviously, it's easy to play with.
There's a "
sleep 1" in the script's main loop. Since the calculations inside the loop also take a finite amount of time, it's likely that a second will be skipped every so often. I haven't noticed that happening, though.
Questions? Comments? Let me know.