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

View File

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