From 3738d2a2f8716614115e31ab5758a8f84a417578 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 9 Jun 2015 14:26:01 +0200 Subject: ui: Horizon change more important than timer We might miss a horizon change if the timer fires at the same time. --- ui.c | 22 +++++++++++----------- 1 file 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 (); } } -- cgit v1.2.3