summaryrefslogtreecommitdiff
path: root/src/common/button.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/button.c')
-rw-r--r--src/common/button.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/common/button.c b/src/common/button.c
index a733772..6079514 100644
--- a/src/common/button.c
+++ b/src/common/button.c
@@ -31,6 +31,9 @@
/** Delay for the button to be considered debounced. */
#define BUTTON_DEBOUNCE_MS 100
+/** Maximum mesured press duration. */
+#define BUTTON_PRESS_MAX_MS 11000
+
void
button_init (void)
{
@@ -63,8 +66,15 @@ button_wait (void)
else
{
debounce_ms = 0;
- if (press_ms < 60000)
+ if (press_ms < BUTTON_PRESS_MAX_MS)
press_ms++;
+ /* If press is really long, go to sleep and wait for interrupt. */
+ if (press_ms == BUTTON_PRESS_MAX_MS)
+ {
+ GIFR = _BV (PCIF); /* Clear previous interrupt. */
+ if (!IO_GET (BUTTON_IO))
+ power_sleep ();
+ }
}
}
return press_ms;