aboutsummaryrefslogtreecommitdiff
path: root/ui.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2014-09-16 15:49:55 +0200
committerLars-Dominik Braun <lars@6xq.net>2014-09-16 15:49:55 +0200
commitb8d4400e30dc490e543018fe4de0a9d9775f18c2 (patch)
treeb54d3dee8c07b49a2d7ea0896bd706e0088331e4 /ui.c
parentb742ab3a288a1164b4ceb6e58ae42115d320d580 (diff)
downloadhourglass-b8d4400e30dc490e543018fe4de0a9d9775f18c2.tar.gz
hourglass-b8d4400e30dc490e543018fe4de0a9d9775f18c2.tar.bz2
hourglass-b8d4400e30dc490e543018fe4de0a9d9775f18c2.zip
Auto stop alarm
Currently triggers assert in timer.c
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/ui.c b/ui.c
index 3a695ae..3f3179f 100644
--- a/ui.c
+++ b/ui.c
@@ -13,7 +13,7 @@
#define sign(x) ((x < 0) ? -1 : 1)
/* stop alarm after #seconds */
-#define ALARM_TIME 30
+#define ALARM_TIME ((uint32_t) 30*1000*1000)
typedef enum {
/* initialize */
@@ -200,6 +200,8 @@ static void doRun () {
mode = UIMODE_ALARM;
puts ("run->alarm");
speakerStart (SPEAKER_BEEP);
+ timerStop ();
+ timerStart (ALARM_TIME);
} else {
/* one step */
--brightness[currLed];
@@ -225,9 +227,13 @@ static void doRun () {
/* Run alarm for some time or user interaction, then stop
*/
static void doAlarm () {
- if (horizonChanged) {
- timerStop ();
- /* stop blinking */
+ const uint32_t t = timerHit ();
+ if (t > 0 || horizonChanged) {
+ /* stop */
+ for (uint8_t i = 0; i < PWM_LED_COUNT; i++) {
+ pwmSet (i, PWM_OFF);
+ }
+ puts ("alarm->idle");
mode = UIMODE_IDLE;
}
}