Just what I needed
that should fit in here very nicely
void sleep_until_switch_press() {
WDT_off(); // Turn the WDT off so it doesn't wake us from sleep
// Will also ensure interrupts are on or we will never wake up
press_duration = 0; // Need to reset press duration since a button release wasn't recorded
while (is_pressed()) { // Enable a pin change interrupt to wake us up. However, we have
_delay_ms(16); // to make sure the switch is released or we will wake when the user releases it
}
PCINT_on();
sleep_mode(); // Now go to sleep
// Hey, someone must have pressed the switch!!
PCINT_off(); // Disable pin change interrupt because it's only used to wake us up
WDT_on(); // Turn the WDT back on to check for switch presses
} // Go back to main program