From 760d5af625b4b68626d2a0205968af49d68f8f44 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 13 Jan 2012 13:41:14 -0500 Subject: [PATCH] Add default position, deflection, and step to AFMPiezo.move_to_pos_or_def. --- pypiezo/afm.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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)) -- 2.26.2