It was a cold winter morning and I was sitting on an even colder bench on a railway platform in London, cursing myself for hitting snooze. Because of that moment of weakness, I had to wait around for the next train. Did I mention it was cold?
So I started thinking about solutions — after all, I had time to kill. A 30-minute snooze function? No good, the gap between trains wasn’t always 30 minutes. Any alarm clock would have to be aware of the railway timetable, or better still, be aware of delays.
That night, I thought about what I’d need to build such an alarm clock. I could figure out how to do almost everything: the snooze button, the music to wake me up, the web lookups — but I couldn’t figure out how to easily build a display for the current time.
A couple of weeks passed until I ended up at a dinner party talking about the idea. A friend, Kate Pugh, pointed out the obvious — I already had an alarm clock with a display, so why not just use it?
The very next day, I built a new alarm clock that has a snooze button made mainly from Legos and an old mouse (my favorite bit was the wonderful contact that a thumbtack, pushed upside down into the Blu Tack-filled base of a Lego brick, made with the microswitch of the mouse). The snooze connects by a long cable to my Linux workstation, my old alarm clock, an AirPort Express, and a program quickly hacked together in Perl.
The program was made a lot easier by using various bits of code from CPAN (cpan.org) where possible. (I even managed to give a little back by releasing the module that I wrote to screen-scrape the train information.) To be honest, it was just a simple state machine that slept until it got close to wake-up time, then started monitoring the departure boards.
So I now have an alarm clock that wakes me a little later if trains are delayed, and works out the length of time to let me snooze based on the next departure needed to get me to work. Best of all, my employer agreed that if all the trains were canceled, the clock would email my workplace that I’d be working at home, and let me sleep in.