Tuesday, November 29, 2016

Stark Envy

There is a lot to envy about Tony Stark. But what I mean in this case...well, several scenes (in the first movie especially) sum this up well. He's in his man cave, elbow-deep in the high-tech equivalent of grease. He's unshaven, he hasn't eaten, he's pretty much only keeping himself going on beer and hard rock.

But he's still going. He's thinking, he's innovating, he's building.

I can get about four hours at a stretch. Maybe six hours total in any given day. The rest of the day I'm spinning my wheels. I can stare at the screen or sketchpad, shove my nose into the books...doesn't matter. That four to six hours is all that I have available to actually, creatively, problem-solve.

Last night I got hauled off to an unexpected rehearsal. Before it started and between acts I worked on the misbehaving Holocron software. It took me something like an hour of actual hands-on-keyboard to see where I'd screwed it up this time.

There's a flag that sets the pulse direction, up or down. Two blocks that test for flag condition then execute various things (mostly, setting a new target value for the LEDs, either max bright or min bright). Oh, yeah. And when everything else is done they flip the flag.

Except I was getting worried about undefined behavior in some of my "if/else" loops. So I switched out the "else" block for an implicitly defined "if" block.

Strip out everything else, all the interior loops and tests and function calls. What did I just create?

if (toggle == 1)
toggle = 0;
if (toggle == 0)
toggle = 1;

Yes; in this case, "if/else" was a better logical construct, exactly because the "else" statement isn't evaluated. It doesn't run unless the conditions to run the "if" statement are false.

And that's the sort of stupid error I'm trying to fix in my Holocron software. Because most of that work has not happened in those four golden hours, but during time when I'm struggling to try to concentrate at all.

No comments:

Post a Comment