mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +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 "string.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "qr_encode.h"
|
#include "qr_encode.h"
|
||||||
|
#include "timer.h"
|
||||||
|
|
||||||
void *layoutLast = layoutHome;
|
void *layoutLast = layoutHome;
|
||||||
|
|
||||||
@ -81,6 +82,9 @@ void layoutHome(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
oledRefresh();
|
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)
|
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
|
for (;;) {} // loop forever
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t saver_counter = 0;
|
|
||||||
|
|
||||||
void check_lock_screen(void)
|
void check_lock_screen(void)
|
||||||
{
|
{
|
||||||
buttonUpdate();
|
buttonUpdate();
|
||||||
|
|
||||||
// wake from screensaver on any button
|
// wake from screensaver on any button
|
||||||
if (layoutLast == layoutScreensaver && (button.NoUp || button.YesUp)) {
|
if (layoutLast == layoutScreensaver && (button.NoUp || button.YesUp)) {
|
||||||
saver_counter = 0;
|
|
||||||
layoutHome();
|
layoutHome();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -82,15 +79,11 @@ void check_lock_screen(void)
|
|||||||
|
|
||||||
// if homescreen is shown for longer than 10 minutes, lock too
|
// if homescreen is shown for longer than 10 minutes, lock too
|
||||||
if (layoutLast == layoutHome) {
|
if (layoutLast == layoutHome) {
|
||||||
saver_counter++;
|
if (system_millis >= system_millis_lock) {
|
||||||
if (saver_counter > 285000 * 60 * 10) {
|
|
||||||
// lock the screen
|
// lock the screen
|
||||||
session_clear(true);
|
session_clear(true);
|
||||||
layoutScreensaver();
|
layoutScreensaver();
|
||||||
saver_counter = 0;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
saver_counter = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
timer.c
3
timer.c
@ -26,6 +26,9 @@
|
|||||||
/* 1 tick = 1 ms */
|
/* 1 tick = 1 ms */
|
||||||
volatile uint32_t system_millis;
|
volatile uint32_t system_millis;
|
||||||
|
|
||||||
|
/* Screen timeout */
|
||||||
|
uint32_t system_millis_lock;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialise the Cortex-M3 SysTick timer
|
* Initialise the Cortex-M3 SysTick timer
|
||||||
*/
|
*/
|
||||||
|
5
timer.h
5
timer.h
@ -23,6 +23,11 @@
|
|||||||
/* 1 tick = 1 ms */
|
/* 1 tick = 1 ms */
|
||||||
extern volatile uint32_t system_millis;
|
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 timer_init(void);
|
||||||
|
|
||||||
void sys_tick_handler(void);
|
void sys_tick_handler(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user