From 7d8fb375f0d42fba3de314259c6873190e05e319 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Thu, 16 Apr 2015 18:16:30 +0200 Subject: [PATCH] seconds counter during pin lockdown --- firmware/protect.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/firmware/protect.c b/firmware/protect.c index d3d77a2..b79dae8 100644 --- a/firmware/protect.c +++ b/firmware/protect.c @@ -147,13 +147,25 @@ bool protectPin(bool use_cached) } uint32_t fails = storage_getPinFails(); if (fails) { - if (fails > 2) { - layoutDialogSwipe(DIALOG_ICON_INFO, NULL, NULL, NULL, "Wrong PIN entered", NULL, "Please wait ...", NULL, NULL, NULL); - } uint32_t wait; wait = (fails < 32) ? (1u << fails) : 0xFFFFFFFF; while (--wait > 0) { - delay(10000000); + // convert wait to secstr string + char secstrbuf[20]; + strlcpy(secstrbuf, "________0 seconds", sizeof(secstrbuf)); + char *secstr = secstrbuf + 9; + uint32_t secs = wait; + while (secs > 0 && secstr >= secstrbuf) { + secstr--; + *secstr = (secs % 10) + '0'; + secs /= 10; + } + if (wait == 1) { + secstrbuf[16] = 0; + } + layoutDialog(DIALOG_ICON_INFO, NULL, NULL, NULL, "Wrong PIN entered", NULL, "Please wait", secstr, "to continue ...", NULL); + // wait one second + delay(24000000); } } const char *pin;