diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2014-09-16 15:49:55 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2014-09-16 15:49:55 +0200 |
commit | b8d4400e30dc490e543018fe4de0a9d9775f18c2 (patch) | |
tree | b54d3dee8c07b49a2d7ea0896bd706e0088331e4 | |
parent | b742ab3a288a1164b4ceb6e58ae42115d320d580 (diff) | |
download | hourglass-b8d4400e30dc490e543018fe4de0a9d9775f18c2.tar.gz hourglass-b8d4400e30dc490e543018fe4de0a9d9775f18c2.tar.bz2 hourglass-b8d4400e30dc490e543018fe4de0a9d9775f18c2.zip |
Auto stop alarm
Currently triggers assert in timer.c
-rw-r--r-- | ui.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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; } } |