Narsil has the support, so could check there as well, 7/11 version is the latest: Shared project folder on Google Drive
Here's the full function:
/**************************************************************************************
* SleepUntilSwitchPress - only called with the light OFF
* =====================
**************************************************************************************/
void SleepUntilSwitchPress()
{
// This routine takes up a lot of program memory :(
// Turn the WDT off so it doesn't wake us from sleep. Will also ensure interrupts
// are on or we will never wake up.
WDT_off();
ADC_off(); // Save more power -- turn the AtoD OFF
// Need to reset press duration since a button release wasn't recorded
wPressDuration = 0;
// Enable a pin change interrupt to wake us up. However, we have to make sure the switch
// is released otherwise we will wake when the user releases the switch
while (IsPressed()) {
_delay_ms(16);
}
PCINT_on();
//-----------------------------------------
sleep_mode(); // Now go to sleep
//-----------------------------------------
// Alternate method? --> set_sleep_mode(SLEEP_MODE_PWR_DOWN);
// Hey, someone must have pressed the switch!!
PCINT_off(); // Disable pin change interrupt because it's only used to wake us up
ADC_on(); // Turn the AtoD back ON
WDT_on(); // Turn the WDT back on to check for switch presses
} // Go back to main program