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
|
# Parse stepper gear_ratio config parameter
|
||||||
def parse_gear_ratio(config, note_valid):
|
def parse_gear_ratio(config, note_valid):
|
||||||
gear_ratio = config.get('gear_ratio', None, note_valid=note_valid)
|
gear_ratio = config.getlists('gear_ratio', (), seps=(':', ','), count=2,
|
||||||
if gear_ratio is None:
|
parser=float, note_valid=note_valid)
|
||||||
return 1.
|
|
||||||
result = 1.
|
result = 1.
|
||||||
try:
|
for g1, g2 in gear_ratio:
|
||||||
gears = gear_ratio.split(',')
|
result *= g1 / g2
|
||||||
for gear in gears:
|
|
||||||
g1, g2 = [float(v.strip()) for v in gear.split(':')]
|
|
||||||
result *= g1 / g2
|
|
||||||
except:
|
|
||||||
raise config.error("Unable to parse gear_ratio: %s" % (gear_ratio,))
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# Obtain "step distance" information from a config section
|
# Obtain "step distance" information from a config section
|
||||||
|
|
Loading…
Reference in New Issue