util: Add btn_read_vol

This commit is contained in:
CTCaer 2020-04-14 17:51:42 +03:00
parent 281e5a138e
commit 9af4c717a8
7 changed files with 28 additions and 13 deletions

View file

@ -34,6 +34,16 @@ u8 btn_read()
return res; return res;
} }
u8 btn_read_vol()
{
u8 res = 0;
if (!gpio_read(GPIO_PORT_X, GPIO_PIN_7))
res |= BTN_VOL_DOWN;
if (!gpio_read(GPIO_PORT_X, GPIO_PIN_6))
res |= BTN_VOL_UP;
return res;
}
u8 btn_wait() u8 btn_wait()
{ {
u8 res = 0, btn = btn_read(); u8 res = 0, btn = btn_read();

View file

@ -26,6 +26,7 @@
#define BTN_SINGLE (1 << 7) #define BTN_SINGLE (1 << 7)
u8 btn_read(); u8 btn_read();
u8 btn_read_vol();
u8 btn_wait(); u8 btn_wait();
u8 btn_wait_timeout(u32 time_ms, u8 mask); u8 btn_wait_timeout(u32 time_ms, u8 mask);

View file

@ -143,7 +143,6 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32
FIL fp; FIL fp;
FIL hashFp; FIL hashFp;
u8 sparseShouldVerify = 4; u8 sparseShouldVerify = 4;
u32 btn = 0;
u32 prevPct = 200; u32 prevPct = 200;
u32 sdFileSector = 0; u32 sdFileSector = 0;
int res = 0; int res = 0;
@ -301,8 +300,7 @@ static int _dump_emmc_verify(emmc_tool_gui_t *gui, sdmmc_storage_t *storage, u32
sparseShouldVerify++; sparseShouldVerify++;
// Check for cancellation combo. // Check for cancellation combo.
btn = btn_wait_timeout(0, BTN_VOL_DOWN | BTN_VOL_UP); if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN))
if ((btn & BTN_VOL_DOWN) && (btn & BTN_VOL_UP))
{ {
s_printf(gui->txt_buf, "#FFDD00 Verification was cancelled!#\n"); s_printf(gui->txt_buf, "#FFDD00 Verification was cancelled!#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
@ -352,7 +350,6 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t
u32 currPartIdx = 0; u32 currPartIdx = 0;
u32 numSplitParts = 0; u32 numSplitParts = 0;
u32 maxSplitParts = 0; u32 maxSplitParts = 0;
u32 btn = 0;
bool isSmallSdCard = false; bool isSmallSdCard = false;
bool partialDumpInProgress = false; bool partialDumpInProgress = false;
int res = 0; int res = 0;
@ -662,8 +659,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t
} }
// Check for cancellation combo. // Check for cancellation combo.
btn = btn_wait_timeout(0, BTN_VOL_DOWN | BTN_VOL_UP); if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN))
if ((btn & BTN_VOL_DOWN) && (btn & BTN_VOL_UP))
{ {
s_printf(gui->txt_buf, "\n#FFDD00 The backup was cancelled!#\n"); s_printf(gui->txt_buf, "\n#FFDD00 The backup was cancelled!#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);

View file

@ -217,8 +217,7 @@ static int _dump_emummc_file_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_sto
} }
// Check for cancellation combo. // Check for cancellation combo.
u32 btn = btn_wait_timeout(0, BTN_VOL_DOWN | BTN_VOL_UP); if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN))
if ((btn & BTN_VOL_DOWN) && (btn & BTN_VOL_UP))
{ {
s_printf(gui->txt_buf, "#FFDD00 The emuMMC was cancelled!#\n"); s_printf(gui->txt_buf, "#FFDD00 The emuMMC was cancelled!#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
@ -482,7 +481,6 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part
lv_label_set_text(gui->label_pct, " "SYMBOL_DOT" 0%"); lv_label_set_text(gui->label_pct, " "SYMBOL_DOT" 0%");
manual_system_maintenance(true); manual_system_maintenance(true);
s_printf(gui->txt_buf, "#96FF00 Base folder:#\n%s\n#96FF00 Partition offset:# #FF8000 0x%08X#", s_printf(gui->txt_buf, "#96FF00 Base folder:#\n%s\n#96FF00 Partition offset:# #FF8000 0x%08X#",
gui->base_path, sd_part_off); gui->base_path, sd_part_off);
lv_label_ins_text(gui->label_info, LV_LABEL_POS_LAST, gui->txt_buf); lv_label_ins_text(gui->label_info, LV_LABEL_POS_LAST, gui->txt_buf);
@ -503,8 +501,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part
while (totalSectors > 0) while (totalSectors > 0)
{ {
// Check for cancellation combo. // Check for cancellation combo.
u32 btn = btn_wait_timeout(0, BTN_VOL_DOWN | BTN_VOL_UP); if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN))
if ((btn & BTN_VOL_DOWN) && (btn & BTN_VOL_UP))
{ {
s_printf(gui->txt_buf, "#FFDD00 The emuMMC was cancelled!#\n"); s_printf(gui->txt_buf, "#FFDD00 The emuMMC was cancelled!#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf); lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);

View file

@ -364,8 +364,8 @@ int touch_power_on()
// Wait for the touchscreen module to get ready. // Wait for the touchscreen module to get ready.
touch_wait_event(STMFTS_EV_CONTROLLER_READY, 0, 20); touch_wait_event(STMFTS_EV_CONTROLLER_READY, 0, 20);
u32 btn = btn_wait_timeout(0, BTN_VOL_DOWN | BTN_VOL_UP); // Check for forced boot time calibration.
if ((btn & BTN_VOL_DOWN) && (btn & BTN_VOL_UP)) if (btn_read_vol() == (BTN_VOL_UP | BTN_VOL_DOWN))
{ {
u8 err[2]; u8 err[2];
if (touch_panel_ito_test(err)) if (touch_panel_ito_test(err))

View file

@ -34,6 +34,16 @@ u8 btn_read()
return res; return res;
} }
u8 btn_read_vol()
{
u8 res = 0;
if (!gpio_read(GPIO_PORT_X, GPIO_PIN_7))
res |= BTN_VOL_DOWN;
if (!gpio_read(GPIO_PORT_X, GPIO_PIN_6))
res |= BTN_VOL_UP;
return res;
}
u8 btn_wait() u8 btn_wait()
{ {
u8 res = 0, btn = btn_read(); u8 res = 0, btn = btn_read();

View file

@ -25,6 +25,7 @@
#define BTN_VOL_UP (1 << 2) #define BTN_VOL_UP (1 << 2)
u8 btn_read(); u8 btn_read();
u8 btn_read_vol();
u8 btn_wait(); u8 btn_wait();
u8 btn_wait_timeout(u32 time_ms, u8 mask); u8 btn_wait_timeout(u32 time_ms, u8 mask);