[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 btn_wait()
{ {
u32 res = 0, btn = btn_read(); u32 res = 0, btn = btn_read();
int pwr = 0;
// Power button down, raise a filter.
if (btn & BTN_POWER)
{
pwr = 1;
btn &= 0xFFFFFFFE;
}
do do
{ {
res = btn_read(); 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); } while (btn == res);
return res; return res;
} }

View file

@ -344,14 +344,11 @@ void print_fuseinfo()
gfx_puts(&gfx_con, "\nPress POWER to dump them to SD Card.\nPress VOL to go to the menu.\n"); gfx_puts(&gfx_con, "\nPress POWER to dump them to SD Card.\nPress VOL to go to the menu.\n");
sleep(1000000);
u32 btn = btn_wait(); u32 btn = btn_wait();
if (btn & BTN_POWER) if (btn & BTN_POWER)
{ {
if (sd_mount()) if (sd_mount())
{ {
FIL fuseFp;
char fuseFilename[9]; char fuseFilename[9];
memcpy(fuseFilename, "fuse.bin", 8); memcpy(fuseFilename, "fuse.bin", 8);
fuseFilename[8] = 0; fuseFilename[8] = 0;
@ -361,7 +358,7 @@ void print_fuseinfo()
else else
gfx_puts(&gfx_con, "\nDone!\n"); gfx_puts(&gfx_con, "\nDone!\n");
} }
sleep(2000000);
btn_wait(); btn_wait();
} }
} }
@ -380,14 +377,11 @@ void print_kfuseinfo()
gfx_puts(&gfx_con, "\nPress POWER to dump them to SD Card.\nPress VOL to go to the menu.\n"); gfx_puts(&gfx_con, "\nPress POWER to dump them to SD Card.\nPress VOL to go to the menu.\n");
sleep(1000000);
u32 btn = btn_wait(); u32 btn = btn_wait();
if (btn & BTN_POWER) if (btn & BTN_POWER)
{ {
if (sd_mount()) if (sd_mount())
{ {
FIL kfuseFp;
char kfuseFilename[10]; char kfuseFilename[10];
memcpy(kfuseFilename, "kfuse.bin", 9); memcpy(kfuseFilename, "kfuse.bin", 9);
kfuseFilename[9] = 0; kfuseFilename[9] = 0;
@ -397,7 +391,7 @@ void print_kfuseinfo()
else else
gfx_puts(&gfx_con, "\nDone!\n"); gfx_puts(&gfx_con, "\nDone!\n");
} }
sleep(2000000);
btn_wait(); btn_wait();
} }
} }
@ -541,7 +535,6 @@ void print_mmc_info()
out: out:
sdmmc_storage_end(&storage); sdmmc_storage_end(&storage);
sleep(1000000);
btn_wait(); btn_wait();
} }
@ -594,8 +587,6 @@ void print_sdcard_info()
sd_fs.free_clst * sd_fs.csize >> SECTORS_TO_MIB_COEFF, sd_fs.csize * 512); sd_fs.free_clst * sd_fs.csize >> SECTORS_TO_MIB_COEFF, sd_fs.csize * 512);
} }
sleep(1000000);
btn_wait(); btn_wait();
} }
@ -640,7 +631,6 @@ void print_tsec_key()
out:; out:;
free(pkg1); free(pkg1);
sdmmc_storage_end(&storage); sdmmc_storage_end(&storage);
sleep(1000000);
btn_wait(); btn_wait();
} }
@ -1014,7 +1004,6 @@ static void dump_emmc_selected(dumpType_t dumpType)
gfx_puts(&gfx_con, "\nDone. Press any key.\n"); gfx_puts(&gfx_con, "\nDone. Press any key.\n");
out:; out:;
sleep(1000000);
btn_wait(); btn_wait();
} }
@ -1099,7 +1088,7 @@ out:;
free(pkg1); free(pkg1);
free(secmon); free(secmon);
free(warmboot); free(warmboot);
sleep(1000000);
btn_wait(); btn_wait();
} }
@ -1187,7 +1176,6 @@ void toggle_autorcm(){
gfx_printf(&gfx_con, "%kAutoRCM mode toggled!%k\n", 0xFF00EE2C, 0xFFCCCCCC); gfx_printf(&gfx_con, "%kAutoRCM mode toggled!%k\n", 0xFF00EE2C, 0xFFCCCCCC);
out:; out:;
sleep(1000000);
btn_wait(); btn_wait();
} }
@ -1225,7 +1213,6 @@ void about()
gfx_printf(&gfx_con, octopus, 0xFFFFCC00, 0xFFCCCCCC, gfx_printf(&gfx_con, octopus, 0xFFFFCC00, 0xFFCCCCCC,
0xFFFFCC00, 0xFFCCFF00, 0xFFFFCC00, 0xFFCCCCCC); 0xFFFFCC00, 0xFFCCFF00, 0xFFFFCC00, 0xFFCCCCCC);
sleep(1000000);
btn_wait(); btn_wait();
} }