From b66d6dbcb8cd381cf7515a42ab0aee4a4841beb3 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 14 Mar 2012 16:18:23 -0400 Subject: [PATCH] Add `steps` and `sleep` options for gentler `jump()`s. --- pypiezo/base.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pypiezo/base.py b/pypiezo/base.py index c74c876..8594646 100644 --- a/pypiezo/base.py +++ b/pypiezo/base.py @@ -516,9 +516,15 @@ class Piezo (object): _LOG.debug('current position: %s' % ret) return ret - def jump(self, axis_name, position): + def jump(self, axis_name, position, steps=1, sleep=None): "Move the output named `axis_name` to `position`." - _LOG.debug('jump %s to %s' % (axis_name, position)) + _LOG.debug('jump %s to %s in %d steps' % (axis_name, position, steps)) + if steps > 1: + orig_pos = self.last_output[axis_name] + for pos in _numpy.linspace(orig_pos, position, steps+1)[1:]: + self.jump(axis_name=axis_name, position=pos) + if sleep: + _sleep(sleep) position = int(position) channel = self.channel_by_name(name=axis_name) channel.data_write(position) -- 2.26.2