Skip to content

Commit

Permalink
toolhead: Report which axes are homed via get_status()
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Nov 25, 2019
1 parent 282af02 commit 3683273
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 24 deletions.
3 changes: 3 additions & 0 deletions docs/Command_Templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ The following are common printer attributes:
extruder. For example, one could use
`printer[printer.toolhead.extruder].target` to get the target
temperature of the current extruder.
- `printer.toolhead.homed_axes`: The current cartesian axes considered
to be in a "homed" state. This is a string containing one or more of
"x", "y", "z".

The above list is subject to change - if using an attribute be sure to
review the [Config Changes document](Config_Changes.md) when upgrading
Expand Down
6 changes: 3 additions & 3 deletions klippy/extras/safe_z_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ def __init__(self, config):

def cmd_G28(self, params):
toolhead = self.printer.lookup_object('toolhead')
kinematics = toolhead.get_kinematics()

# Perform Z Hop if necessary
if self.z_hop != 0.0:
pos = toolhead.get_position()
kin_status = kinematics.get_status()
curtime = self.printer.get_reactor().monotonic()
kin_status = toolhead.get_kinematics().get_status(curtime)
# Check if Z axis is homed or has a known position
if 'Z' in kin_status['homed_axes']:
if 'z' in kin_status['homed_axes']:
# Check if the zhop would exceed the printer limits
if pos[2] + self.z_hop > self.max_z:
self.gcode.respond_info(
Expand Down
7 changes: 3 additions & 4 deletions klippy/kinematics/cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,9 @@ def check_move(self, move):
z_ratio = move.move_d / abs(move.axes_d[2])
move.limit_speed(
self.max_z_velocity * z_ratio, self.max_z_accel * z_ratio)
def get_status(self):
return {'homed_axes': "".join([a
for a, (l, h) in zip("XYZ", self.limits) if l <= h])
}
def get_status(self, eventtime):
axes = [a for a, (l, h) in zip("xyz", self.limits) if l <= h]
return { 'homed_axes': "".join(axes) }
# Dual carriage support
def _activate_carriage(self, carriage):
toolhead = self.printer.lookup_object('toolhead')
Expand Down
7 changes: 3 additions & 4 deletions klippy/kinematics/corexy.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ def check_move(self, move):
z_ratio = move.move_d / abs(move.axes_d[2])
move.limit_speed(
self.max_z_velocity * z_ratio, self.max_z_accel * z_ratio)
def get_status(self):
return {'homed_axes': "".join([a
for a, (l, h) in zip("XYZ", self.limits) if l <= h])
}
def get_status(self, eventtime):
axes = [a for a, (l, h) in zip("xyz", self.limits) if l <= h]
return {'homed_axes': "".join(axes)}

def load_kinematics(toolhead, config):
return CoreXYKinematics(toolhead, config)
4 changes: 2 additions & 2 deletions klippy/kinematics/delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def check_move(self, move):
move.limit_speed(max_velocity * r, self.max_accel * r)
limit_xy2 = -1.
self.limit_xy2 = min(limit_xy2, self.slow_xy2)
def get_status(self):
return {'homed_axes': '' if self.need_home else 'XYZ'}
def get_status(self, eventtime):
return {'homed_axes': '' if self.need_home else 'xyz'}

# Helper function for DELTA_CALIBRATE script
def get_calibrate_params(self):
Expand Down
2 changes: 1 addition & 1 deletion klippy/kinematics/none.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def home(self, homing_state):
pass
def check_move(self, move):
pass
def get_status(self):
def get_status(self, eventtime):
return {'homed_axes': ''}

def load_kinematics(toolhead, config):
Expand Down
7 changes: 4 additions & 3 deletions klippy/kinematics/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ def check_move(self, move):
z_ratio = move.move_d / abs(move.axes_d[2])
move.limit_speed(
self.max_z_velocity * z_ratio, self.max_z_accel * z_ratio)
def get_status(self):
return {'homed_axes': (("XY" if self.limit_xy2 >= 0. else "") +
("Z" if self.limit_z[0] <= self.limit_z[1] else ""))}
def get_status(self, eventtime):
xy_home = "xy" if self.limit_xy2 >= 0. else ""
z_home = "z" if self.limit_z[0] <= self.limit_z[1] else ""
return {'homed_axes': xy_home + z_home}

def load_kinematics(toolhead, config):
return PolarKinematics(toolhead, config)
4 changes: 2 additions & 2 deletions klippy/kinematics/winch.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def home(self, homing_state):
def check_move(self, move):
# XXX - boundary checks and speed limits not implemented
pass
def get_status(self):
def get_status(self, eventtime):
# XXX - homed_checks and rail limits not implemented
return {'homed_axes': 'XYZ'}
return {'homed_axes': 'xyz'}

def load_kinematics(toolhead, config):
return WinchKinematics(toolhead, config)
12 changes: 7 additions & 5 deletions klippy/toolhead.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,13 @@ def get_status(self, eventtime):
status = "Printing"
else:
status = "Ready"
return { 'status': status, 'print_time': print_time,
'estimated_print_time': estimated_print_time,
'extruder': self.extruder.get_name(),
'position': homing.Coord(*self.commanded_pos),
'printing_time': print_time - last_print_start_time }
res = dict(self.kin.get_status(eventtime))
res.update({ 'status': status, 'print_time': print_time,
'estimated_print_time': estimated_print_time,
'extruder': self.extruder.get_name(),
'position': homing.Coord(*self.commanded_pos),
'printing_time': print_time - last_print_start_time })
return res
def _handle_shutdown(self):
self.can_pause = False
self.move_queue.reset()
Expand Down

0 comments on commit 3683273

Please sign in to comment.