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.
Plaintext source is here; Prettyprinted HTML source here.
Term::ANSIScreenPerl module available from CPAN handles text positioning, color, and formatting. I think most terminal emulation programs do ANSI commands these days.
- The LED-on "dot" is a UTF-8 character. If your terminal program
doesn't handle UTF-8, the code has a commented out alternate that
might work: a space with a red background.
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.