Maestro icon indicating copy to clipboard operation
Maestro copied to clipboard

Add context support

Open ercius opened this issue 4 years ago • 0 comments

Thanks for this excellent module. Im using it to automate control of a Maestro for electron microscopy. Its very useful.

I added a feature to simplify opening and closing the USB port. Then it never stays open by accident. This is called 'context' and implements the with statement in python.

An example using context support:

with maestro.Controller(ttyStr='COM4') as servo:
        position = 6532
        servo.setSpeed(1, 10)

The USB port is closed automatically at the end.

ercius avatar Jul 25 '20 22:07 ercius