Break AFM.stepper_approach out of ._stepper_approach_again.
authorW. Trevor King <wking@drexel.edu>
Tue, 17 Jan 2012 22:38:54 +0000 (17:38 -0500)
committerW. Trevor King <wking@drexel.edu>
Tue, 17 Jan 2012 22:38:54 +0000 (17:38 -0500)
pyafm/afm.py

index ada5b130b21c22addbb88e6e9f9996d9b04e8a03..d99835eb0f31cbed9c6aa9aef392e420965e6fa6 100644 (file)
@@ -146,18 +146,9 @@ class AFM (object):
     def _stepper_approach_again(self, target_deflection, far):
         _LOG.info('back off %d half steps and approach until deflection > %g'
                  % (far, target_deflection))
-
         # back away
         self.stepper.step_relative(-far, backlash_safe=True)
-
-        cd = self.piezo.read_deflection()  # cd = current deflection in bits
-        _LOG.debug('single stepping approach')
-        while cd < target_deflection:
-            _LOG.debug('deflection %g < setpoint %g.  step closer'
-                      % (cd, target_deflection))
-            self.stepper.single_step(1)  # step in
-            cd = self.piezo.read_deflection()
-
+        self.stepper_approach(target_deflection=target_deflection)
         for i in range(2*max(1, self.stepper.backlash)):
             _LOG.debug(
                 'additional surface location attempt (stepping backwards)')
@@ -171,3 +162,14 @@ class AFM (object):
         _LOG.debug('giving up on finding the surface')
         _LOG.warn(e)
         raise e
+
+    def stepper_approach(self, target_deflection):
+        _LOG.info('approach with stepper until deflection > {}'.format(
+                target_deflection))
+        cd = self.piezo.read_deflection()  # cd = current deflection in bits
+        _LOG.debug('single stepping approach')
+        while cd < target_deflection:
+            _LOG.debug('deflection {} < setpoint {}.  step closer'.format(
+                    cd, target_deflection))
+            self.stepper.single_step(1)  # step in
+            cd = self.piezo.read_deflection()