From: W. Trevor King Date: Thu, 15 Mar 2012 22:29:15 +0000 (-0400) Subject: Add AFM.move_toward_surface() and fix AFM.move_away_from_surface(). X-Git-Tag: v0.4~20 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=569cb0bf9439c9607e6f1488390dad7da81e27dc;p=pyafm.git 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. --- 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)