Last night, NASA sent LADEE, an atmospheric observation satellite, to the moon. Satellites are pretty cool. It launched from Virginia, about 100 miles from Lafayette college. A satellite that I can see going to space is much cooler.
Last night, some friends and I headed to Pardee, a great big building with a tall south-facing windows. We burned a few hours playing games and waiting for the launch. I decided to code a little something.
As a disclaimer, I love having fun playing with being serious. So I decided to code a fullscreen red on black countdown timer for the launch.
As usual for these quick little graphics projects, I used Processing. In about an hour, I wrote a little script that calculates the difference in a hardcoded time and the current time. It's a little harder than just subtracting the two times: the naive approach of simply subtracting target hours, minutes, and seconds from current time will result in negative minutes and seconds as the timer runs.
Instead, I needed to calculate the number of seconds between now and launch, then use modulo division to pull out hours, minutes, and seconds.
That's as far as I got last night. Today, I substantially rewrote the code to add more features. It now handles both positive and negative times, switching from T-xx:xx:xx to T+xx:xx:xx at launch time. It's using a digital font now, complete with a background overlay of 88:88:88. There's also a bit of fading as the numbers change, and target time can be changed on-the-fly. It's also set to roll over daily: the timer always reports between T-12 and T+12 hours. That way, a countdown to the wee hours of the morning doesn't report T+23.
It looks a lot like NASA's own countdown timers do. And fullscreen, it's beautiful. Later, I might pack it into a class and use it as part of a larger mission control panel, but for now, it's a nice counter.
As always, the source code is attached below. (All processing libraries are included in the compiled version, which makes the application prohibitively heavy to upload.)