aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2015-06-09 14:26:01 +0200
committerLars-Dominik Braun <lars@6xq.net>2015-06-09 14:26:01 +0200
commit3738d2a2f8716614115e31ab5758a8f84a417578 (patch)
treea66d09b00a05d43ac6ef052f755f63ce99e0d5c2
parent3708927d2fe15a747270619d1467486c040e57dd (diff)
downloadhourglass-3738d2a2f8716614115e31ab5758a8f84a417578.tar.gz
hourglass-3738d2a2f8716614115e31ab5758a8f84a417578.tar.bz2
hourglass-3738d2a2f8716614115e31ab5758a8f84a417578.zip
ui: Horizon change more important than timer
We might miss a horizon change if the timer fires at the same time.
-rw-r--r--ui.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/ui.c b/ui.c
index e71db36..8f34591 100644
--- a/ui.c
+++ b/ui.c
@@ -277,19 +277,24 @@ static void doIdle () {
}
}
-/* Run timer, alarm when count==0 or abort when horizon changed
+/* Run timer
*/
static void doRun () {
+ /* horizon change is more important than timer, thus checked first */
+ if (horizonChanged) {
+ /* stop timer */
+ speakerStart (SPEAKER_BEEP);
+
+ enterIdle ();
+ return;
+ }
+
const uint32_t t = timerHit ();
if (t > 0) {
timerElapsed += t;
if (timerElapsed >= timerValue) {
- /* ring the alarm! */
- for (uint8_t i = 0; i < PWM_LED_COUNT; i++) {
- pwmSet (i, PWM_MAX_BRIGHTNESS);
- }
timerStop ();
- /* beep only once */
+ /* ring the alarm! */
speakerStart (SPEAKER_BEEP);
enterFlash (FLASH_ALARM);
} else if (currLed > 0) {
@@ -302,11 +307,6 @@ static void doRun () {
--currLed;
}
}
- } else if (horizonChanged) {
- /* stop timer */
- speakerStart (SPEAKER_BEEP);
-
- enterIdle ();
}
}