[Main] Filter POWER button down

And remove uneeded double press protection through sleep().
This commit is contained in:
Kostas Missos
2018-05-25 00:37:30 +03:00
committed by nwert
parent 997e250c43
commit 81eb1d0972
2 changed files with 18 additions and 16 deletions

View File

@@ -34,9 +34,24 @@ u32 btn_read()
u32 btn_wait()
{
u32 res = 0, btn = btn_read();
int pwr = 0;
// Power button down, raise a filter.
if (btn & BTN_POWER)
{
pwr = 1;
btn &= 0xFFFFFFFE;
}
do
{
res = btn_read();
// Power button up, remove filter.
if (!(res & BTN_POWER) && pwr)
pwr = 0;
// Power button still down.
else if (pwr)
res &= 0xFFFFFFFE;
} while (btn == res);
return res;
}