Add AFM.move_toward_surface() and fix AFM.move_away_from_surface().
authorW. Trevor King <wking@drexel.edu>
Thu, 15 Mar 2012 22:29:15 +0000 (18:29 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 15 Mar 2012 22:29:15 +0000 (18:29 -0400)
In everything else we do, numbers increase as you approach the
surface.  There's no need to invert that convention here, so we now
have `AFM.move_toward_surface()` which can be used for moving in both
directions.  `AFM.move_away_from_surface()` remains, because "Ahh!
What's going on!  Quick, save the tip!" moments will happen, and then
it's nice to have a method that gets you clear without you having to
pick how far away you'd like to go.

pyafm/afm.py

index 3093a07997cc0d47890cd36b0882aed80c798e7a..a6760c8bcec8030223c716605699f716f6e284d9 100644 (file)
@@ -455,11 +455,16 @@ class AFM (object):
             self.stepper.single_step(1)  # step in
             cd = self.piezo.read_deflection()
 
-    def move_away_from_surface(stepper, distance=None):
+    def move_toward_surface(self, distance):
+        """Step in approximately `distance` meters.
+        """
+        steps = int(distance/self.stepper.step_size)
+        _LOG.info('step in {} steps (~{} m)' % (steps, distance))
+        self.stepper.step_relative(steps)
+
+    def move_away_from_surface(self, distance=None):
         """Step back approximately `distance` meters.
         """
         if distance is None:
             distance = self.config['far']
-        steps = int(distance/self.stepper.step_size)
-        _LOG.info('step back {} steps (~{} m)' % (steps, distance))
-        self.stepper.step_relative(-steps)
+        self.move_toward_surface(-distance)