mirror of https://github.com/Desuuuu/klipper.git
stepper: Use config.getlists() for gear_ratio config option
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
f9ca5b9098
commit
67d99fe8a8
|
@ -215,17 +215,11 @@ def PrinterStepper(config, units_in_radians=False):
|
|||
|
||||
# Parse stepper gear_ratio config parameter
|
||||
def parse_gear_ratio(config, note_valid):
|
||||
gear_ratio = config.get('gear_ratio', None, note_valid=note_valid)
|
||||
if gear_ratio is None:
|
||||
return 1.
|
||||
gear_ratio = config.getlists('gear_ratio', (), seps=(':', ','), count=2,
|
||||
parser=float, note_valid=note_valid)
|
||||
result = 1.
|
||||
try:
|
||||
gears = gear_ratio.split(',')
|
||||
for gear in gears:
|
||||
g1, g2 = [float(v.strip()) for v in gear.split(':')]
|
||||
for g1, g2 in gear_ratio:
|
||||
result *= g1 / g2
|
||||
except:
|
||||
raise config.error("Unable to parse gear_ratio: %s" % (gear_ratio,))
|
||||
return result
|
||||
|
||||
# Obtain "step distance" information from a config section
|
||||
|
|
Loading…
Reference in New Issue