Programming an Open Source Flashlight

2013-02-01 00:39:00 -0500

Originally posted on tumblr

After a year and a half, the HexBright Kickstarter actually delivered. Personally I think it was entirely worth the wait - the developer is clearly kind of obsessive and it's wonderful the way the internet supports (and/or exploits :-) that. Mechanically, it is very impressive, I've been carrying it for a couple of weeks - it's definitely my large flashlight of choice though I'm still wearing my Fenix E11 as well.

I've only done moderately well at using the stream of technology that KickStarter has supplied me, so it was notable that I was able to get "up and coding" for the HexBright in a couple of hours... On an ubuntu box,

$ apt-get install arduino
$ git clone https://github.com/dhiltonp/hexbright.git
$ less hexbright/README.md

and follow the instructions. (Note that if you're on precise rather than quantal or later, you want to grab the precise-backports version of arduino-core - 1.0.1 is the lowest tested version, though there are some patches that sort of work with 1.0, at least they work well enough to build and upload tactical.ino, a basic brightness-and-flashing firmware.)

The tactical firmware is a good starting point; the main loop is only around 35 lines of code, and if you just want to do custom flashing patterns (sliding rate changes, or morse code or something) you've got the right starting points at hand. I just made the pulse rate drop by 10ms every 1/2s which is obnoxious to look at but does visibly do something :-)

My next step is to drop the arduino GUI and just use avr-gcc and avrdude directly (since that's all the GUI does anyway.) There's an arduino-mk package that I suspect will help with that. As someone who worked at Cygnus on G++ as an embedded systems cross-compiler in the mid 90's, though, I'm a little boggled that I'm using a standard prepackaged 32 bit compiler to upload code into my flashlight :-)