Skip to content

Instantly share code, notes, and snippets.

@omsai
Last active August 29, 2015 14:03
Show Gist options
  • Save omsai/5fcc529c284ad10b1a62 to your computer and use it in GitHub Desktop.
Save omsai/5fcc529c284ad10b1a62 to your computer and use it in GitHub Desktop.
Micro-Manager beanshell script to close shutter after specified delay.
// Close shutter after specified delay.
//
// In response to James' question on the mailing list:
// http://micro-manager.3463995.n2.nabble.com/Tethered-Cam-Sutter-Shutter-Closure-Delay-td7583216.html
// Set this variable to however long you need your shutter to be open.
delayBeforeShutterCloseMs = 800;
// Opens shutter and sets timer to close shutter.
Runnable synchronizedShutter = new Runnable() {
public void run() {
shutterTimer = new Timer();
// One has to create a TimerTask each time it is run, since a
// TimerTask cannot be re-used after it is executed.
closeTask = new TimerTask() {
public void run() {
mmc.setShutterOpen(false);
}
};
mmc.setShutterOpen(true);
// The runnable executes before the image is taken. Using the
// timer here allows this run() method to return so the camera
// and snap an image, and then the shutter closes after the set
// delay.
shutterTimer.schedule(closeTask, delayBeforeShutterCloseMs);
}
};
// Boilerplate for runnable Beanshell scripts.
gui.clearRunnables();
// Disable auto-shutter since we are manually toggling the shutter in
// this script.
mmc.setAutoShutter(false);
// Run for every image captured.
gui.attachRunnable(-1,-1,-1,-1,synchronizedShutter);
print("Shutter runnable activated.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment