1
0
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:
Saleem Rashid 2016-11-17 19:10:57 +00:00 committed by Pavol Rusnak
parent 25b9bfd97b
commit 0ec32a6146
4 changed files with 13 additions and 8 deletions

View File

@ -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)

View File

@ -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;
}
}

View File

@ -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
*/

View File

@ -23,6 +23,11 @@
/* 1 tick = 1 ms */
extern volatile uint32_t system_millis;
/* Screen timeout */
extern uint32_t system_millis_lock;
#define SCREEN_TIMEOUT_MILLIS (1000 * 60 * 10) /* 10 minutes */
void timer_init(void);
void sys_tick_handler(void);