From 569cb0bf9439c9607e6f1488390dad7da81e27dc Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 15 Mar 2012 18:29:15 -0400 Subject: [PATCH] Add AFM.move_toward_surface() and fix AFM.move_away_from_surface(). 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 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pyafm/afm.py b/pyafm/afm.py index 3093a07..a6760c8 100644 --- a/pyafm/afm.py +++ b/pyafm/afm.py @@ -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) -- 2.26.2