From a9353001743edc3fafd46771e70229af66d6a1e8 Mon Sep 17 00:00:00 2001 From: Linnnus Date: Fri, 19 Apr 2024 11:22:11 +0200 Subject: Be consistent about returning after setupX() THis fixes a bug where you could unlock the device but then immediately enter STATE_RINGING, by removing an item whilst the victory animation plays. --- det_hele/det_hele.ino | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/det_hele/det_hele.ino b/det_hele/det_hele.ino index 93ac90f..c4f5939 100644 --- a/det_hele/det_hele.ino +++ b/det_hele/det_hele.ino @@ -267,17 +267,20 @@ bool handlePasscode() { void armedLoop() { if (handlePasscode()) { unarmedSetup(); + return; } double deviation = weightDeviation(); if (deviation > MAX_DEVIATION) { awareSetup(); + return; } } void awareLoop() { if (handlePasscode()) { unarmedSetup(); + return; } double deviation = weightDeviation(); @@ -291,6 +294,7 @@ void awareLoop() { Serial.println(remainingTime); if (remainingTime <= 0) { ringingSetup(); + return; } } @@ -300,6 +304,7 @@ void ringingLoop() { if (handlePasscode()) { digitalWrite(NOISE_ENABLE_PIN, LOW); unarmedSetup(); + return; } // FIXME: SHouldn't be able to do this for non-testing purposes. @@ -308,6 +313,7 @@ void ringingLoop() { if (deviation < MAX_DEVIATION) { digitalWrite(NOISE_ENABLE_PIN, LOW); armedSetup(); + return; } } -- cgit v1.2.3