STAR mom code change - would this work?

Hi all,

I've been thinking about this on and off for months and I'm finally at the point where my light is physically ready for a momentary switch driver, but the code isn't quite what I want. I'm hoping to modify JonnyC's Star-momentary-temp (http://bazaar.launchpad.net/~toykeeper/flashlight-firmware/trunk/files/head:/JonnyC/STAR/MTN_momentary_temp/).

I would like to switch between High and Medium with a short press, while still retaining the "short press > up mode" and "long press > down mode" functions. My idea was to identify High by PWM value (255), same as how Turbo is coded by JonnyC. If press < Long press and mode = 255, then previous mode. Else next mode. Does this code look like it'll work? I'm going to get everything set up (flasher, driver, LED etc) to test it, but figured it might be quicker to get your thoughts first.

Also, I don't really understand why different bits of that sequence are bracketed by #ifdef and #enddif and others aren't - are they like sub-menus/ clauses?

Code

if (is_pressed()) {

if (press_duration < 255) {

press_duration++;

}

if (press_duration == LONG_PRESS_DUR) {

// Long press

if (low_to_high) {

prev_mode();

} else {

next_mode();

}

}

if (press_duration == LONGER_PRESS_DUR) {

// Long press turn off the light

mode_idx=0;

in_momentary = 0;

}

// Not pressed

if (press_duration > 0 && press_duration < LONG_PRESS_DUR) {

// Short press

if (modes[mode_idx] == 255) {

prev_mode();

} else {

next_mode();

}

} else {