From 93eb4f4cacb92593d9e75510e5cfa3d3714b13df Mon Sep 17 00:00:00 2001 From: Hector van der Aa Date: Wed, 29 Jul 2026 22:16:10 +0100 Subject: [PATCH] Added safe unmount and fixed blue counter bug --- main.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 2e12b54..b5e0adb 100644 --- a/main.py +++ b/main.py @@ -43,6 +43,7 @@ class Config: class AppState: stopEvent = Event() cameraStopComplete = Event() + stopRecording = Event() diskEventQueue: Queue[DiskEvent] = Queue() diskState: DiskState = "disconnected" config = Config() @@ -155,6 +156,8 @@ def ledWorker(state: AppState) -> None: else: blue.off() + blueCtr += 1 + state.stopEvent.wait(0.25) @@ -198,6 +201,9 @@ def mountDisk(state: AppState) -> None: def unmountDisk(state: AppState) -> None: + state.cameraState = "armed" + state.stopRecording.wait() + state.stopRecording.clear() if not state.failedUmount: try: subprocess.run( @@ -362,7 +368,12 @@ def cameraWorker(state: AppState) -> None: state.cameraState = "recording" recording_trigger_time = now - elif recording and now - last_motion_time >= QUIET_SECONDS: + elif (recording and now - last_motion_time >= QUIET_SECONDS) or ( + recording and state.cameraState == "armed" + ): + setGlobalFlag = False + if recording and state.cameraState == "armed": + setGlobalFlag = True circular_output.stop() state.cameraState = "armed" recording = False @@ -371,6 +382,9 @@ def cameraWorker(state: AppState) -> None: recording_path = None + if setGlobalFlag: + state.stopRecording.set() + previous_frame = current_frame finally: if recording: