Intermediate Form


Previous Entry | Home | Next Entry

Because of the holidays, I've decided to write a single program of the week for last week and this week.


It's a quick bcd clock program, which can print out the time in binary-coded decimal. There's one option, --single, which causes it to print out only a single binary-coded decimal time. If --single is not given, then the time is displayed in a curses window, which is updated once a second. You can hit 'q' to stop the display.

The output looks like:

.. : .. : .O
.. : .O : O.
.O : OO : ..
O. : .. : OO

From left to right, this can be read as HH : MM : SS. From top to bottom, the four lines represents the 8, 4, 2, and 1s places of the number. You add together the lit-up digits (those with an O rather than a . to get the value for that digit.

In the example above, the first column has only the 1s place lit up, while the second column has only the second. So, the first two digits are 12, which is the hour. The third place is also 2. The fourth has both the 4s and the 2s places lit up, so we add them together to get 6, giving a time of 26 minutes after the hour. All told, the time shown here is 12:26:59.


This was inspired by the BCD clock that my sister got me for Christmas. (I have the red LED clock sold above.) It's hypnotic watching the patterns change as time advances. This program doesn't really do it justice.

The next program of the week will be up sometime during the week of January 5, 2004.

- Tom | permalink | changelog | Last updated: 2003-12-28 12:36

Previous Entry | Home | Next Entry


Commenting has been suspended due to spam.