« "No Place Like London" | Main | The Modern Linux Desktop »

My new binary clock

I got tired of the binary clock dock app that I've been using: one column per digit displaying the hour:minute:second. Fortunately, it being open source and me being a programmer, I can look inside and modify it. It's a fairly simple C program using some X11 libraries. It uses localtime() from time.h and prints it to a string. It then parses that string to determine what the display should look like. The original code examined each char in the string and then used a case to compare the char to the digits 1-9 to set the "bits" to display (lame).

bin_clock.gif My new version gets the month (+1) and mday from the tm struct in addition to the time. It then examines the string two bytes at a time and does atoi() to get the actual numeric value, then checks the bits in the (now one) byte to store for display. I added one more row of "lights" and "rotated" the display 90 degrees to the right.

Can you tell what time it is in this .gif?

TrackBack

TrackBack URL for this entry:
http://mt.iheffner.com/mt-tb.cgi/33

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on January 9, 2008 12:03 PM.

The previous post in this blog was "No Place Like London".

The next post in this blog is The Modern Linux Desktop.

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.34