From 91cb514e087c45edee18d6ad30941f4b5b36b2c1 Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Thu, 4 Jan 2024 10:46:27 +0000 Subject: [PATCH] Use blocking, non-cancellable moves in autofocus Autofocus timing is pretty critical. I've introduced the ability to abort moves, which introduces ~50ms timing jitter. This commit reverts the tming-critical move in autofocus to the old behaviour. I've only reverted the move that really matters - this means that if you start a massive sweep by accident, you can still abort it when it's moving down to the start of the sweep. --- src/openflexure_microscope_server/things/autofocus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openflexure_microscope_server/things/autofocus.py b/src/openflexure_microscope_server/things/autofocus.py index 626c4a1e..426fcdac 100644 --- a/src/openflexure_microscope_server/things/autofocus.py +++ b/src/openflexure_microscope_server/things/autofocus.py @@ -157,7 +157,7 @@ class AutofocusThing(Thing): # Move to dz while monitoring sharpness # i: Sharpness monitor index for this move # z: Final z position after move - i, z = m.focus_rel(dz) + i, z = m.focus_rel(dz, block_cancellation=True) # Get the z position with highest sharpness from the previous move (index i) fz: int = m.sharpest_z_on_move(i) # Move all the way to the start so it's consistent