Fix premature evaluation after blinking completes

When transitioning from STATE_BLINKING to STATE_WAIT_FOR_INPUT, the script used a stale timestamp `now` from before the blocking `blink_led` function. This caused the puzzle to immediately evaluate as failed. Updated to use `time.time()` after blinking finishes to ensure the user gets the full 3 seconds to enter their answer.
This commit is contained in:
Markus Graf
2026-05-10 07:41:00 +02:00
parent a7c4febd67
commit 5b5b845e41
2 changed files with 15 additions and 1 deletions
+1 -1
View File
@@ -101,7 +101,7 @@ class AlarmClock:
logging.info("Blinking finished. Waiting for input...")
self.state = STATE_WAIT_FOR_INPUT
self.user_presses = 0
self.last_interaction_time = now # Use the current update time!
self.last_interaction_time = time.time() # Use time.time() to account for blocking blink_led
if 'GPIO' in globals() and hasattr(GPIO, 'input'):
self.button_was_pressed = (GPIO.input(BUTTON_PIN) == GPIO.LOW)