Friday, June 12, 2009

Outside the Box (or circle, in this case)

The MX-6000 has a feature that no previous URC remote has included: the combination 5-way and scroll wheel. I love the scroll wheel for page flipping (that feature is included in all the default MX-6000 templates). It’s also used extensively in some of the two-way modules for the MX-6000. The other day I was reading through the posts on the URC Control Room forum and came across a question about how to reduce the sensitivity of the scroll wheel on the MX-6000.

I replied that yes, there’s an easy way to reduce the sensitivity using variables. I gave the following example for the macro I use in my left scroll function:

IF (Variable(ScrollLeft),True)

.….Jump (Page-)
.….VAR (ScrollLeft = FALSE)
..ELSE

.….VAR (ScrollLeft = TRUE)

This works pretty well because it requires two scroll events to occur before issuing the Page- jump command. I patted myself on the back, posted the solution, and casually mentioned that you could make the scroll wheel even less sensitive by using the same technique, but nesting multiple variables and IF statements. I didn’t bother to explain how, because thinking about it gave me a Slurpee headache. I figured that anyone dedicated enough would figure out what I meant. They could have the headache instead of me.

I consider myself to be a fairly skilled MX-6000 programmer. Working for URC doesn’t hurt in that regard. But stop to consider the engineering team that designs Formula-1 race cars. Those are really smart folks, but I doubt a single one of them could qualify for a Formula-1 race if they had to sit behind the wheel themselves. Sure, they can probably out-drive you or me, but their specialty is in making the car. Driving it is a whole other art, and that’s where professional drivers shine.

Recognizing this, I mentioned my little Scroll Sensitivity solution to my good friend Bracken Baker over at tripleBsoftware. He’s a really polite guy, so instead of breaking out in a round of belly-busting guffaws, he kindly said, “Yeah, that’ll work.” But then, as I expected he would, he quickly showed me a sample of code with a multi-variable solution that made my solution look clunky.

I very nearly posted that solution to URC Control Room, but then Bracken said, “WAIT!!”

Spend enough time around brilliant engineers and you’ll learn that “WAIT” means My brain just told me there’s a better solution, but it hasn’t told me what words to use to describe it yet! But before he could get the new idea fully typed, he jumped in again with, “HOLD ON!!” With our previous example, I’m sure you understand that “HOLD ON” means I’ve got an even BETTER idea! So I held… uh… on.

Bracken’s mind went through several iterations of the problem, considering angles I’d never have thought of. He wanted the solution to work well and be dead-simple to implement. Before I knew it, he came up with a way that any MX-6000 programmer can adjust the sensitivity of the MX-6000 scroll wheel without using any variables at all!

Bracken’s solution takes advantage of the often-misunderstood Toggle feature. It’s just downright genius, so I wanted to share it with you here:

TOGGLE
.….TEXT (hold)
.….JUMP (Page-)


The beauty of this solution is that the TEXT step doesn’t really do anything except “waste” a step of the Toggle command. Specifically, it tells the left scroll function to display the text “hold.” But since there’s no button text on the scroll wheel, “hold” never appears. However, while not displaying anything, the remote is also waiting for the user to continue moving the scroll wheel. It’s only when the wheel has moved enough times to step through all the toggle steps that the remote finally issues the “Jump (Page-)” command.

So in three lines of code, Bracken accomplished what took me five lines, plus I had to create and name the macro in the first place.

But it gets better. Because if I wanted my solution to reduce the sensitivity of the wheel any further, I had to nest IF’s and add more variables, putting me right back in SlurpeeTown. But Bracken’s solution is elegant: just keep adding TEXT statements until you reach the level of sensitivity you want. Here’s the same macro, made four times less sensitive:

TOGGLE
.….TEXT (hold)
.….TEXT (hold)
.….TEXT (hold)
.….TEXT (hold)
.….JUMP (Page-)

See how that works? Each TEXT command adds a tiny delay, then the Toggle function waits for the scroll wheel to continue moving before finally landing on the JUMP command, which actually issues the page flip.

So there you have it—a super-simple way to make the MX-6000 scroll wheel precisely as sensitive as you want it to be. Once you understand the technique, it’s easy to see ways to do things like give audio feedback to the wheel (add a “tick” sound after the jump) or turn it into an absolute volume control (add discrete RS-232 volume commands to each step of the Toggle control), or a thousand other cool ideas. It’s a whole new way of thinking of the scroll wheel!

My thanks again to Bracken for helping me out and coming up with this cool technique. It’s the Formula-1 drivers like him that prevent us regular-old programmers from having Brain Freeze on an everyday basis.