delta_calibrate: Use new GCodeCommand wrappers

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2020-04-24 23:22:43 -04:00
parent b24465976e
commit 0197fec202
1 changed files with 13 additions and 15 deletions

View File

@ -221,8 +221,8 @@ class DeltaCalibrate:
"The SAVE_CONFIG command will update the printer config file\n" "The SAVE_CONFIG command will update the printer config file\n"
"with these parameters and restart the printer.") "with these parameters and restart the printer.")
cmd_DELTA_CALIBRATE_help = "Delta calibration script" cmd_DELTA_CALIBRATE_help = "Delta calibration script"
def cmd_DELTA_CALIBRATE(self, params): def cmd_DELTA_CALIBRATE(self, gcmd):
self.probe_helper.start_probe(params) self.probe_helper.start_probe(gcmd)
def add_manual_height(self, height): def add_manual_height(self, height):
# Determine current location of toolhead # Determine current location of toolhead
toolhead = self.printer.lookup_object('toolhead') toolhead = self.printer.lookup_object('toolhead')
@ -256,9 +256,9 @@ class DeltaCalibrate:
# Perform analysis # Perform analysis
self.calculate_params(self.last_probe_positions, distances) self.calculate_params(self.last_probe_positions, distances)
cmd_DELTA_ANALYZE_help = "Extended delta calibration tool" cmd_DELTA_ANALYZE_help = "Extended delta calibration tool"
def cmd_DELTA_ANALYZE(self, params): def cmd_DELTA_ANALYZE(self, gcmd):
# Check for manual height entry # Check for manual height entry
mheight = self.gcode.get_float('MANUAL_HEIGHT', params, None) mheight = gcmd.get_float('MANUAL_HEIGHT', None)
if mheight is not None: if mheight is not None:
self.add_manual_height(mheight) self.add_manual_height(mheight)
return return
@ -266,25 +266,23 @@ class DeltaCalibrate:
args = {'CENTER_DISTS': 6, 'CENTER_PILLAR_WIDTHS': 3, args = {'CENTER_DISTS': 6, 'CENTER_PILLAR_WIDTHS': 3,
'OUTER_DISTS': 6, 'OUTER_PILLAR_WIDTHS': 6, 'SCALE': 1} 'OUTER_DISTS': 6, 'OUTER_PILLAR_WIDTHS': 6, 'SCALE': 1}
for name, count in args.items(): for name, count in args.items():
if name not in params: data = gcmd.get(name, None)
if data is None:
continue continue
data = self.gcode.get_str(name, params)
try: try:
parts = map(float, data.split(',')) parts = map(float, data.split(','))
except: except:
raise self.gcode.error("Unable to parse parameter '%s'" % ( raise gcmd.error("Unable to parse parameter '%s'" % (name,))
name,))
if len(parts) != count: if len(parts) != count:
raise self.gcode.error("Parameter '%s' must have %d values" % ( raise gcmd.error("Parameter '%s' must have %d values"
name, count)) % (name, count))
self.delta_analyze_entry[name] = parts self.delta_analyze_entry[name] = parts
logging.info("DELTA_ANALYZE %s = %s", name, parts) logging.info("DELTA_ANALYZE %s = %s", name, parts)
# Perform analysis if requested # Perform analysis if requested
if 'CALIBRATE' in params: action = gcmd.get('CALIBRATE', None)
action = self.gcode.get_str('CALIBRATE', params) if action is not None:
actions = {'extended': 1} if action != 'extended':
if action not in actions: raise gcmd.error("Unknown calibrate action")
raise self.gcode.error("Unknown calibrate action")
self.do_extended_calibration() self.do_extended_calibration()
def load_config(config): def load_config(config):