DAVE'S LIFE ON HOLD

Playing with LEDs and Cameras

catch(e) " href="http://3.bp.blogspot.com/_XCDTVvEbBMU/SicStX9UIjI/AAAAAAAAAC4/SFayIykeD-o/s1600-h/nagasaki.png">
So a few weeks ago, my partner in crime and I were playing around with his homebrewed projector, a Wiimote, and a bunch of different software drivers for driving a mouse. Aaron did this little picture of a "happy little mushroom cloud" using MSPaint and a magic wand. A day or two later, I got some multipoint logic working on my MacBook Air's camera and a set of 2 LEDs scrounged out of Apple remotes. And have come to the conclusion that I must live in a cave.


That is not to say that I want to live in a cave, but rather in my experience the places that I tend to work have a maximum R+G+B+A value of 500 or so. So I started thinking about all the fun things I could take apart that had more LEDs in them. catch(e) " href="http://3.bp.blogspot.com/_XCDTVvEbBMU/SicU014elvI/AAAAAAAAADA/B0x8nxtC5KQ/s1600-h/MeLED.png">
One of the cool ones was an old TV remote for a TV which no longer serves any purpose other than taking up space on the floor, as the digital tuner is hooked up to one of the computers. It had this nice pad of surface mounted LEDs that would take some serious voltage. So I mashed a 9V up against some of the pads on the back of the PCB and lit them up on the camera.

As you can see from this photo, my little prototyping app for doing all things iSight related does terrible things to video. This unfiltered image is a compressed version of the raw data. But you can clearly see a fairly wide rage of color values from near black to fairly bright white. When you filter out all of the R+G+B+A values beneath a certain threshold, however, you can get this pretty version of the picture.

catch(e) " href="http://4.bp.blogspot.com/_XCDTVvEbBMU/SicWuyp3ADI/AAAAAAAAADI/DOEFaIOsztM/s1600-h/SampleData.png">
This doesn't look like much but there are clearly visible 3 lights. What is so interesting about using a simple cutoff threshold is that it is terribly easy to compute. While the Wiimote hack is certainly a hell of a lot easier to use to do useful stuff, in a pinch you can use the built-in camera to do much the same thing. Using CoreImage filters and the Quicktime Capture routines make video capture an exercise in rather mindless programming. I've got maybe 20 lines of code in my entire demo app, and most of that is just wrapping Apple's classes and methods with nicer to use names. If the CPU/power draw wasn't so stupidly high I could see using it as a general input device.

Firefox Hacking: Part 1

And speaking of silly hacks and input devices, today I tweaked my Firefox build to add two minor properties to the DOMMouseScroll event. By tweaking a few IDL settings and adding a few lines to the widget/src/cocoa/ event handling code, I added two incredibly useful properties to the Javascript event object:
  • event.wheelDeltaX
  • event.wheelDeltaY
I also went through and changed all of my event.axis code to use the existing Horizontal and Vertical values (1 and 2) as bit flags, rather than exclusive values. Why the people who implemented these kept excluding the possibility that you might scroll in two directions at once is beyond me. While I doubt that anyone will accept these patches, I'm going to make them available for people who would like to actually use their trackpads in web apps.

On the plus side, if you're running my personal debug build of Firefox, NewScript.org now supports two finger scrolling on Firefox on the Mac. Oh wait, you can't cause I didn't release the patch! :)