From f123108c3ee7d5953a4fe04b521a74a4d61f7272 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Fri, 23 Sep 2022 18:07:38 +0200 Subject: [PATCH] Added variable to cancel button press. Signed-off-by: Pol Henarejos --- src/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 9a32cd2..f3dc2af 100644 --- a/src/main.c +++ b/src/main.c @@ -74,13 +74,15 @@ bool is_req_button_pending() { } uint32_t button_timeout = 15000; +bool cancel_button = false; bool wait_button() { uint32_t start_button = board_millis(); bool timeout = false; + cancel_button = false; led_set_blink((1000 << 16) | 100); req_button_pending = true; - while (board_button_read() == false) { + while (board_button_read() == false && cancel_button == false) { execute_tasks(); //sleep_ms(10); if (start_button + button_timeout < board_millis()) { /* timeout */ @@ -89,7 +91,7 @@ bool wait_button() { } } if (!timeout) { - while (board_button_read() == true) { + while (board_button_read() == true && cancel_button == false) { execute_tasks(); //sleep_ms(10); if (start_button + 15000 < board_millis()) { /* timeout */ @@ -100,7 +102,7 @@ bool wait_button() { } led_set_blink(BLINK_PROCESSING); req_button_pending = false; - return timeout; + return timeout || cancel_button; } struct apdu apdu;