From: W. Trevor King Date: Fri, 13 Jan 2012 18:41:14 +0000 (-0500) Subject: Add default position, deflection, and step to AFMPiezo.move_to_pos_or_def. X-Git-Tag: 0.6~30 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=760d5af625b4b68626d2a0205968af49d68f8f44;p=pypiezo.git Add default position, deflection, and step to AFMPiezo.move_to_pos_or_def. --- diff --git a/pypiezo/afm.py b/pypiezo/afm.py index 616c6f4..bfc9585 100644 --- a/pypiezo/afm.py +++ b/pypiezo/afm.py @@ -167,14 +167,17 @@ class AFMPiezo (_base.Piezo): "Return a Numpy dtype suitable for deflection bit values." return self._deflection_channel().subdevice.get_dtype() - def move_to_pos_or_def(self, axis_name, position, deflection, step, - return_data=False, pre_move_steps=0): + def move_to_pos_or_def(self, axis_name, position=None, deflection=None, + step=1, return_data=False, pre_move_steps=0): """TODO pre_move_steps : int number of 'null' steps to take before moving (confirming a stable input deflection). """ + if position is None and deflection is None: + raise ValueError('must specify position, deflection, or both') + if return_data or _package_config['matplotlib']: aquire_data = True else: @@ -187,6 +190,18 @@ class AFMPiezo (_base.Piezo): elif step > 0 and position < self.last_output[axis_name]: step = -step + if position is None: + # default to the extreme value in the step direction + if step > 0: + axis = self.axis_by_name(axis_name) + position = axis.channel.get_maxdata() + else: + position = 0 + elif deflection is None: + # default to the extreme value + channel = self._deflection_channel(self) + deflection = channel.get_maxdata() + log_string = ( 'move to position %d or deflection %g on axis %s in steps of %d' % (position, deflection, axis_name, step))