gcode: Create new wrapper class for gcode command parameters
Instead of passing a dictionary to the command handlers, create a wrapper class and pass that class to the command handlers. This can simplify the command handler code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -54,7 +54,8 @@ class ArcSupport:
|
||||
g1_params['E'] = asE / len(coords)
|
||||
if asF is not None:
|
||||
g1_params['F'] = asF
|
||||
self.gcode.cmd_G1(g1_params)
|
||||
g1_gcmd = self.gcode.create_gcode_command("G1", "G1", g1_params)
|
||||
self.gcode.cmd_G1(g1_gcmd)
|
||||
|
||||
# function planArc() originates from marlin plan_arc()
|
||||
# https://github.com/MarlinFirmware/Marlin
|
||||
|
||||
@@ -154,10 +154,10 @@ class GCodeMacro:
|
||||
value,))
|
||||
self.variables[variable] = literal
|
||||
cmd_desc = "G-Code macro"
|
||||
def cmd(self, params):
|
||||
def cmd(self, gcmd):
|
||||
if self.in_script:
|
||||
raise self.gcode.error(
|
||||
"Macro %s called recursively" % (self.alias,))
|
||||
raise gcmd.error("Macro %s called recursively" % (self.alias,))
|
||||
params = gcmd.get_command_parameters()
|
||||
kwparams = dict(self.kwparams)
|
||||
kwparams.update(params)
|
||||
kwparams.update(self.variables)
|
||||
|
||||
@@ -54,7 +54,7 @@ class HomingOverride:
|
||||
self.gcode.reset_last_position()
|
||||
# Perform homing
|
||||
kwparams = { 'printer': self.template.create_status_wrapper() }
|
||||
kwparams['params'] = params
|
||||
kwparams['params'] = params.get_command_parameters()
|
||||
try:
|
||||
self.in_script = True
|
||||
self.template.run_gcode_from_command(kwparams)
|
||||
|
||||
@@ -57,7 +57,7 @@ class PauseResume:
|
||||
self.pause_command_sent = False
|
||||
if self.sd_paused:
|
||||
# Printing from virtual sd, run pause command
|
||||
self.v_sd.cmd_M24({})
|
||||
self.v_sd.cmd_M24(gcmd)
|
||||
else:
|
||||
self.gcode.respond_info("action:resumed")
|
||||
def cmd_CLEAR_PAUSE(self, params):
|
||||
|
||||
@@ -410,7 +410,8 @@ class ProbePointsHelper:
|
||||
def _manual_probe_start(self):
|
||||
done = self._move_next()
|
||||
if not done:
|
||||
manual_probe.ManualProbeHelper(self.printer, {},
|
||||
gcmd = self.gcode.create_gcode_command("", "", {})
|
||||
manual_probe.ManualProbeHelper(self.printer, gcmd,
|
||||
self._manual_probe_finalize)
|
||||
def _manual_probe_finalize(self, kin_pos):
|
||||
if kin_pos is None:
|
||||
|
||||
@@ -63,7 +63,8 @@ class SafeZHoming:
|
||||
if need_y:
|
||||
new_params['Y'] = '0'
|
||||
if new_params:
|
||||
self.prev_G28(new_params)
|
||||
g28_gcmd = self.gcode.create_gcode_command("G28", "G28", new_params)
|
||||
self.prev_G28(g28_gcmd)
|
||||
# Home Z axis if necessary
|
||||
if need_z:
|
||||
# Move to safe XY homing position
|
||||
@@ -75,7 +76,8 @@ class SafeZHoming:
|
||||
toolhead.move(pos, self.speed)
|
||||
self.gcode.reset_last_position()
|
||||
# Home Z
|
||||
self.prev_G28({'Z': '0'})
|
||||
g28_gcmd = self.gcode.create_gcode_command("G28", "G28", {'Z': '0'})
|
||||
self.prev_G28(g28_gcmd)
|
||||
# Perform Z Hop again for pressure-based probes
|
||||
pos = toolhead.get_position()
|
||||
if self.z_hop:
|
||||
|
||||
Reference in New Issue
Block a user