From b8d4400e30dc490e543018fe4de0a9d9775f18c2 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 16 Sep 2014 15:49:55 +0200 Subject: Auto stop alarm Currently triggers assert in timer.c --- ui.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'ui.c') 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; } } -- cgit v1.2.3