summaryrefslogtreecommitdiffstats
path: root/app/state.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/state.c')
-rw-r--r--app/state.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/app/state.c b/app/state.c
index 8ba1b3d..0c23260 100644
--- a/app/state.c
+++ b/app/state.c
@@ -1,6 +1,6 @@
#include "project.h"
-uint32_t up_time, down_time;
+uint32_t up_time, down_time,usb_up_time,usb_down_time;
int locked;
@@ -28,7 +28,7 @@ state_show (void)
snprintf (buf, sizeof (buf), "%4s%3d %02d:%02d:%02d",
up_time ? "up" : "down", d, h, m, s);
- lcd_write (buf, 0, 0);
+ //lcd_write (buf, 0, 0);
lcd_write (have_key ? " Key " : "No Key", 0, 1);
@@ -42,7 +42,7 @@ void
state_tick (void)
{
- if (host_has_power && usb_running)
+ if (host_has_power)
{
down_time = 0;
up_time++;
@@ -54,11 +54,30 @@ state_tick (void)
locked = 0;
}
- if ((down_time > RETENTION_TIME) && have_key)
+ if ((down_time > POWER_RETENTION_TIME) && have_key)
{
key_wipe ();
}
+
+ if (usb_running)
+ {
+ usb_down_time = 0;
+ usb_up_time++;
+ }
+ else
+ {
+ usb_down_time++;
+ usb_up_time = 0;
+ locked = 0;
+ }
+
+ if ((usb_down_time > USB_RETENTION_TIME) && have_key)
+ {
+ key_wipe ();
+ }
+
+
state_show ();
}