mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
timer: Replace screen timeout with SysTick
This provides an incredibly accurate screen timeout and removes the superfluous screen timeout counter
This commit is contained in:
parent
25b9bfd97b
commit
0ec32a6146
@ -28,6 +28,7 @@
|
||||
#include "string.h"
|
||||
#include "util.h"
|
||||
#include "qr_encode.h"
|
||||
#include "timer.h"
|
||||
|
||||
void *layoutLast = layoutHome;
|
||||
|
||||
@ -81,6 +82,9 @@ void layoutHome(void)
|
||||
}
|
||||
}
|
||||
oledRefresh();
|
||||
|
||||
// Reset lock screen timeout
|
||||
system_millis_lock = system_millis + SCREEN_TIMEOUT_MILLIS;
|
||||
}
|
||||
|
||||
const char *str_amount(uint64_t amnt, const char *abbr, char *buf, int len)
|
||||
|
@ -38,15 +38,12 @@ void __attribute__((noreturn)) __stack_chk_fail(void)
|
||||
for (;;) {} // loop forever
|
||||
}
|
||||
|
||||
static uint32_t saver_counter = 0;
|
||||
|
||||
void check_lock_screen(void)
|
||||
{
|
||||
buttonUpdate();
|
||||
|
||||
// wake from screensaver on any button
|
||||
if (layoutLast == layoutScreensaver && (button.NoUp || button.YesUp)) {
|
||||
saver_counter = 0;
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
@ -82,15 +79,11 @@ void check_lock_screen(void)
|
||||
|
||||
// if homescreen is shown for longer than 10 minutes, lock too
|
||||
if (layoutLast == layoutHome) {
|
||||
saver_counter++;
|
||||
if (saver_counter > 285000 * 60 * 10) {
|
||||
if (system_millis >= system_millis_lock) {
|
||||
// lock the screen
|
||||
session_clear(true);
|
||||
layoutScreensaver();
|
||||
saver_counter = 0;
|
||||
}
|
||||
} else {
|
||||
saver_counter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
3
timer.c
3
timer.c
@ -26,6 +26,9 @@
|
||||
/* 1 tick = 1 ms */
|
||||
volatile uint32_t system_millis;
|
||||
|
||||
/* Screen timeout */
|
||||
uint32_t system_millis_lock;
|
||||
|
||||
/*
|
||||
* Initialise the Cortex-M3 SysTick timer
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user