Added (somewhat hacky) workaround for the pin change interrupt waking the device up after releasing a long press to power down
This commit is contained in:
parent
b7d7bf405f
commit
f92f7d8794
@ -33,7 +33,7 @@ int main()
|
||||
handleCurrentScreen();
|
||||
|
||||
if (!buttons_active() && !peekScreenInvalidated())
|
||||
sleepUntilButton(_BV(BUTTON_UP) | _BV(BUTTON_DOWN) | _BV(BUTTON_OPTION));
|
||||
sleepUntilButton(_BV(BUTTON_UP) | _BV(BUTTON_DOWN) | _BV(BUTTON_OPTION), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,10 @@ void checkPower()
|
||||
break;
|
||||
|
||||
case ManualOff:
|
||||
sleepUntilButton(_BV(BUTTON_OPTION));
|
||||
// Skip the next button change since it's on a long press. I don't
|
||||
// really like that this is set here instead of in the call to
|
||||
// setPowerState, but that's a refactoring for another day....
|
||||
sleepUntilButton(_BV(BUTTON_OPTION), 1);
|
||||
setPowerState(On);
|
||||
break;
|
||||
}
|
||||
@ -163,7 +166,9 @@ static inline void sleepEnd()
|
||||
}
|
||||
|
||||
|
||||
void sleepUntilButton(uint8_t pinMask)
|
||||
void sleepUntilButton(uint8_t pinMask, uint8_t ignoreEvents)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
// Enable pin change interrupts
|
||||
GIMSK |= _BV(PCIE);
|
||||
@ -174,6 +179,12 @@ void sleepUntilButton(uint8_t pinMask)
|
||||
sleepStart();
|
||||
PCMSK = 0;
|
||||
sleepEnd();
|
||||
|
||||
if (ignoreEvents == 0)
|
||||
break;
|
||||
|
||||
ignoreEvents--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@ extern uint16_t vcc;
|
||||
extern void checkPower();
|
||||
extern void setPowerState(PowerState newState);
|
||||
|
||||
extern void sleepUntilButton(uint8_t pinMask);
|
||||
extern void sleepUntilButton(uint8_t pinMask, uint8_t ignoreEvents);
|
||||
|
||||
// 0 = 16 ms
|
||||
// 1 = 32 ms
|
||||
|
Loading…
Reference in New Issue
Block a user