From: W. Trevor King Date: Wed, 14 Mar 2012 20:18:23 +0000 (-0400) Subject: Add `steps` and `sleep` options for gentler `jump()`s. X-Git-Tag: 0.6~21 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b66d6dbcb8cd381cf7515a42ab0aee4a4841beb3;p=pypiezo.git Add `steps` and `sleep` options for gentler `jump()`s. --- 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)