toolhead: Export "extra axes" coordinates in status

Update the "position" status to include extra axes.  Export a new
"extra_axes" value that describes the class associated with each
component of the coordinate.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2025-10-09 21:59:37 -04:00
parent 553d80cd57
commit abc32a2106
2 changed files with 15 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ from . import force_move
class ManualStepper:
def __init__(self, config):
self.printer = config.get_printer()
self.name = config.get_name()
if config.get('endstop_pin', None) is not None:
self.can_home = True
self.rail = stepper.LookupRail(
@@ -36,11 +37,13 @@ class ManualStepper:
self.instant_corner_v = 0.
self.gaxis_limit_velocity = self.gaxis_limit_accel = 0.
# Register commands
stepper_name = config.get_name().split()[1]
stepper_name = self.name.split()[1]
gcode = self.printer.lookup_object('gcode')
gcode.register_mux_command('MANUAL_STEPPER', "STEPPER",
stepper_name, self.cmd_MANUAL_STEPPER,
desc=self.cmd_MANUAL_STEPPER_help)
def get_name(self):
return self.name
def sync_print_time(self):
toolhead = self.printer.lookup_object('toolhead')
print_time = toolhead.get_last_move_time()

View File

@@ -237,6 +237,8 @@ class ToolHead:
self.Coord = gcode.Coord
extruder = kinematics.extruder.DummyExtruder(self.printer)
self.extra_axes = [extruder]
self.extra_axes_status = {}
self._build_extra_axes_status()
kin_name = config.get('kinematics')
try:
mod = importlib.import_module('kinematics.' + kin_name)
@@ -425,16 +427,21 @@ class ToolHead:
if not self.can_pause:
break
eventtime = self.reactor.pause(eventtime + 0.100)
def _build_extra_axes_status(self):
self.extra_axes_status = {ea.get_name(): e_index + 3
for e_index, ea in enumerate(self.extra_axes)}
def set_extruder(self, extruder, extrude_pos):
# XXX - should use add_extra_axis
self.extra_axes[0] = extruder
self.commanded_pos[3] = extrude_pos
self._build_extra_axes_status()
def get_extruder(self):
return self.extra_axes[0]
def add_extra_axis(self, ea, axis_pos):
self._flush_lookahead()
self.extra_axes.append(ea)
self.commanded_pos.append(axis_pos)
self._build_extra_axes_status()
self.printer.send_event("toolhead:update_extra_axes")
def remove_extra_axis(self, ea):
self._flush_lookahead()
@@ -443,6 +450,7 @@ class ToolHead:
ea_index = self.extra_axes.index(ea) + 3
self.commanded_pos.pop(ea_index)
self.extra_axes.pop(ea_index - 3)
self._build_extra_axes_status()
self.printer.send_event("toolhead:update_extra_axes")
def get_extra_axes(self):
return [None, None, None] + self.extra_axes
@@ -500,11 +508,12 @@ class ToolHead:
'stalls': self.print_stall,
'estimated_print_time': estimated_print_time,
'extruder': extruder.get_name(),
'position': self.Coord(self.commanded_pos[:4]),
'position': self.Coord(self.commanded_pos),
'max_velocity': self.max_velocity,
'max_accel': self.max_accel,
'minimum_cruise_ratio': self.min_cruise_ratio,
'square_corner_velocity': self.square_corner_velocity})
'square_corner_velocity': self.square_corner_velocity,
'extra_axes': self.extra_axes_status})
return res
def _handle_shutdown(self):
self.can_pause = False