From 4d2adddb202321cd4f65e41b9ffe6fac5d1fe566 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 23 Feb 2021 11:51:06 -0500 Subject: [PATCH] stepper: Improve error messages on missing rotation_distance If neither rotation_distance nor step_distance is present, then generate an error saying rotation_distance is needed (instead of an error about step_distance). Signed-off-by: Kevin O'Connor --- klippy/stepper.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/klippy/stepper.py b/klippy/stepper.py index b3da9237..5af26d66 100644 --- a/klippy/stepper.py +++ b/klippy/stepper.py @@ -225,11 +225,14 @@ def parse_step_distance(config, units_in_radians=None, note_valid=False): rotation_dist = 2. * math.pi config.get('gear_ratio', note_valid=note_valid) else: - rotation_dist = config.getfloat('rotation_distance', None, - above=0., note_valid=note_valid) - if rotation_dist is None: - # Older config format with step_distance - return config.getfloat('step_distance', above=0., note_valid=note_valid) + rd = config.get('rotation_distance', None, note_valid=False) + sd = config.get('step_distance', None, note_valid=False) + if rd is None and sd is not None: + # Older config format with step_distance + return config.getfloat('step_distance', above=0., + note_valid=note_valid) + rotation_dist = config.getfloat('rotation_distance', above=0., + note_valid=note_valid) # Newer config format with rotation_distance microsteps = config.getint('microsteps', minval=1, note_valid=note_valid) full_steps = config.getint('full_steps_per_rotation', 200, minval=1,