From 2108ce78fc6c3a588db73c42c094539afda41a5e Mon Sep 17 00:00:00 2001 From: 2ManyProjects Date: Sat, 10 Jan 2026 01:27:32 -0600 Subject: [PATCH] fixed state lock --- src/stitching_scanner.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/stitching_scanner.py b/src/stitching_scanner.py index 29ff753..8ff1c18 100644 --- a/src/stitching_scanner.py +++ b/src/stitching_scanner.py @@ -639,7 +639,8 @@ class StitchingScanner: self._displacement_since_append_x += dx self._displacement_since_append_y += dy total_x += dx - self.state.current_x += dx + with self._state_lock: + self.state.current_x += dx with self._state_lock: self.state.cumulative_x = self._displacement_since_append_x @@ -717,7 +718,8 @@ class StitchingScanner: self._displacement_since_append_y += dy total_y += dy - self.state.current_y += dy + with self._state_lock: + self.state.current_y += dy with self._state_lock: self.state.cumulative_y = total_y @@ -742,7 +744,8 @@ class StitchingScanner: # Done when we've moved enough if abs(total_y) >= target_displacement: self.log(f"Row transition complete: {abs(total_y):.1f}px") - self.state.current_y = 0 + with self._state_lock: + self.state.current_y = 0 self.motion.send_command('s') time.sleep(self.config.settle_time)