Commit graph

15 commits

Author SHA1 Message Date
Richard Bowman
9fd8fc37f1 Formatted with Ruff 2024-12-03 06:46:08 +00:00
Richard Bowman
27aec769a2 Linter fixes
NB I have permitted bare except: blocks in smart_scan. This should be reverted.
2024-12-03 06:43:45 +00:00
Richard Bowman
a0fbbc3e40 Convert Stage to a Protocol
The Stage is now implemented as a runtime-checkable Protocol.

Part of this led to the realisation that we can't create a DirectThingClient
based on a Protocol, only on a concrete Thing. While it might be
a good idea to address that in LabThings in due course, for now
we work around it by creating both a Protocol and a stub class. The stub class implements the protocol, and
can be used to declare a dependency.
2024-11-29 12:53:04 +00:00
Richard Bowman
adbb805556 Formal Protocol for camera interface
I've now split the base camera code into a runtime-checkable Protocol
and a concrete base class (which is optional). This removes the requirement
for cameras to subclass `openflexure_microscope.things.camera.Camera`
and instead uses duck typing that should
work both statically and dynamically.

As part of this, I've moved the commonly-used dependencies
on the camera inside `openflexure_microscope.things.camera` for consistency, and to make it easy to update them if it changes in the future.
2024-11-29 11:26:38 +00:00
Richard Bowman
2268425bf3 Depend only on generic Camera and Stage
I've now defined parent classes for camera and stage, and depend only on those. This allows
proper typing while enabling the actual hardware
classes to be swapped.

The interfaces definitely aren't final - this is a first
draft, largely to enable me to test out the concept
of a configuration server.
2024-08-09 02:41:39 +01:00
jaknapper
aed5a22983 Autofocus verify based on sharpness range, removed repetitive logging 2024-02-15 11:02:44 +00:00
Joe Knapper
f1c315783c Test the success of refocusing 2024-02-13 15:24:42 +00:00
jaknapper
e6e809cea4 Zip files as we scan, saving the regenerated ones to the end
Removed maximum scan size of 750 images

Save json of scan inputs and use it for future stitching (ensures consistent parameters)

Moved looping autofocus to autofocus thing from recentering thing

Rewrote looping autofocus to skip unneeded moves, as if peak is out of range, no need to nicely focus
2024-01-30 18:46:34 +00:00
jaknapper
a0b98a1adc Fixed autofocus to not combine logs 2024-01-29 19:56:24 +00:00
Joe Knapper
528406137f Start autofocus from base of range for speed 2024-01-29 18:10:11 +00:00
Richard Bowman
91cb514e08 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.
2024-01-04 10:46:27 +00:00
Richard Bowman
d561ff4484 Update blocking portal syntax
spawn_task should be replaced with start_task_soon as per the
anyio API for v4.
2024-01-03 17:09:36 +00:00
Richard Bowman
b9605fa2a0 Added module docstring 2023-11-29 23:37:54 +00:00
Richard Bowman
20a7fd52b1 Reinstate move_and_measure 2023-11-28 23:47:53 +00:00
Richard Bowman
6e04618051 Autofocus module!
Currently only has fast_autofocus, and there
may be some work to do on timing, but it works :)

Getting timestamps from the camera rather than
time.time() would be ideal, but it would take some thought to tie that up with
the encoder.

I'm using a low-res stream, as it seems impossible to
turn the bitrate control of the MJPEG stream off,
at least within the picamera2 API.
2023-08-30 21:34:06 +01:00