aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras
diff options
context:
space:
mode:
Diffstat (limited to 'klippy/extras')
-rw-r--r--klippy/extras/bed_screws.py8
-rw-r--r--klippy/extras/manual_probe.py9
-rw-r--r--klippy/extras/probe.py22
-rw-r--r--klippy/extras/safe_z_home.py41
4 files changed, 25 insertions, 55 deletions
diff --git a/klippy/extras/bed_screws.py b/klippy/extras/bed_screws.py
index c10a791f..483fc7ef 100644
--- a/klippy/extras/bed_screws.py
+++ b/klippy/extras/bed_screws.py
@@ -46,13 +46,7 @@ class BedScrews:
self.cmd_BED_SCREWS_ADJUST,
desc=self.cmd_BED_SCREWS_ADJUST_help)
def move(self, coord, speed):
- toolhead = self.printer.lookup_object('toolhead')
- curpos = toolhead.get_position()
- for i in range(len(coord)):
- if coord[i] is not None:
- curpos[i] = coord[i]
- toolhead.move(curpos, speed)
- self.gcode.reset_last_position()
+ self.printer.lookup_object('toolhead').manual_move(coord, speed)
def move_to_screw(self, state, screw):
# Move up, over, and then down
self.move((None, None, self.horizontal_move_z), self.lift_speed)
diff --git a/klippy/extras/manual_probe.py b/klippy/extras/manual_probe.py
index 663f3c8e..f42aaba8 100644
--- a/klippy/extras/manual_probe.py
+++ b/klippy/extras/manual_probe.py
@@ -93,11 +93,10 @@ class ManualProbeHelper:
def move_z(self, z_pos):
curpos = self.toolhead.get_position()
try:
- if curpos[2] - z_pos < Z_BOB_MINIMUM:
- curpos[2] = z_pos + Z_BOB_MINIMUM
- self.toolhead.move(curpos, self.speed)
- curpos[2] = z_pos
- self.toolhead.move(curpos, self.speed)
+ z_bob_pos = z_pos + Z_BOB_MINIMUM
+ if curpos[2] < z_bob_pos:
+ self.toolhead.manual_move([None, None, z_bob_pos], self.speed)
+ self.toolhead.manual_move([None, None, z_pos], self.speed)
except homing.CommandError as e:
self.finalize(False)
raise
diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py
index 539a6572..d97a5e7f 100644
--- a/klippy/extras/probe.py
+++ b/klippy/extras/probe.py
@@ -125,13 +125,7 @@ class PrinterProbe:
% (pos[0], pos[1], pos[2]))
return pos[:3]
def _move(self, coord, speed):
- toolhead = self.printer.lookup_object('toolhead')
- curpos = toolhead.get_position()
- for i in range(len(coord)):
- if coord[i] is not None:
- curpos[i] = coord[i]
- toolhead.move(curpos, speed)
- self.gcode.reset_last_position()
+ self.printer.lookup_object('toolhead').manual_move(coord, speed)
def _calc_mean(self, positions):
count = float(len(positions))
return [sum([pos[i] for pos in positions]) / count
@@ -354,24 +348,20 @@ class ProbePointsHelper:
if not self.results:
# Use full speed to first probe position
speed = self.speed
- curpos = toolhead.get_position()
- curpos[2] = self.horizontal_move_z
- toolhead.move(curpos, speed)
+ toolhead.manual_move([None, None, self.horizontal_move_z], speed)
# Check if done probing
if len(self.results) >= len(self.probe_points):
- self.gcode.reset_last_position()
toolhead.get_last_move_time()
res = self.finalize_callback(self.probe_offsets, self.results)
if res != "retry":
return True
self.results = []
# Move to next XY probe point
- curpos[:2] = self.probe_points[len(self.results)]
+ nextpos = list(self.probe_points[len(self.results)])
if self.use_offsets:
- curpos[0] -= self.probe_offsets[0]
- curpos[1] -= self.probe_offsets[1]
- toolhead.move(curpos, self.speed)
- self.gcode.reset_last_position()
+ nextpos[0] -= self.probe_offsets[0]
+ nextpos[1] -= self.probe_offsets[1]
+ toolhead.manual_move(nextpos, self.speed)
return False
def start_probe(self, gcmd):
manual_probe.verify_no_manual_probe(self.printer)
diff --git a/klippy/extras/safe_z_home.py b/klippy/extras/safe_z_home.py
index 9f6dd7bd..21d6f12e 100644
--- a/klippy/extras/safe_z_home.py
+++ b/klippy/extras/safe_z_home.py
@@ -30,23 +30,23 @@ class SafeZHoming:
def cmd_G28(self, gcmd):
toolhead = self.printer.lookup_object('toolhead')
- curtime = self.printer.get_reactor().monotonic()
- kin_status = toolhead.get_kinematics().get_status(curtime)
# Perform Z Hop if necessary
if self.z_hop != 0.0:
- pos = toolhead.get_position()
# Check if Z axis is homed or has a known position
+ curtime = self.printer.get_reactor().monotonic()
+ kin_status = toolhead.get_kinematics().get_status(curtime)
if 'z' in kin_status['homed_axes']:
# Check if the zhop would exceed the printer limits
+ pos = toolhead.get_position()
if pos[2] + self.z_hop > self.max_z:
gcmd.respond_info(
"No zhop performed, target Z out of bounds: " +
str(pos[2] + self.z_hop))
elif pos[2] < self.z_hop:
- self._perform_z_hop(pos)
+ self._perform_z_hop()
else:
- self._perform_z_hop(pos)
+ self._perform_z_hop()
if hasattr(toolhead.get_kinematics(), "note_z_not_homed"):
toolhead.get_kinematics().note_z_not_homed()
@@ -66,46 +66,33 @@ class SafeZHoming:
g28_gcmd = self.gcode.create_gcode_command("G28", "G28", new_params)
self.prev_G28(g28_gcmd)
- # Update the currently homed axes
- curtime = self.printer.get_reactor().monotonic()
- kin_status = toolhead.get_kinematics().get_status(curtime)
-
# Home Z axis if necessary
if need_z:
- pos = toolhead.get_position()
- prev_x = pos[0]
- prev_y = pos[1]
- pos[0] = self.home_x_pos
- pos[1] = self.home_y_pos
# Throw an error if X or Y are not homed
+ curtime = self.printer.get_reactor().monotonic()
+ kin_status = toolhead.get_kinematics().get_status(curtime)
if ('x' not in kin_status['homed_axes'] or
'y' not in kin_status['homed_axes']):
raise gcmd.error("Must home X and Y axes first")
# Move to safe XY homing position
- toolhead.move(pos, self.speed)
- self.gcode.reset_last_position()
+ prevpos = toolhead.get_position()
+ toolhead.manual_move([self.home_x_pos, self.home_y_pos], self.speed)
# Home Z
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:
- pos[2] = self.z_hop
- toolhead.move(pos, self.z_hop_speed)
+ toolhead.manual_move([None, None, self.z_hop], self.z_hop_speed)
# Move XY back to previous positions
if self.move_to_previous:
- pos[0] = prev_x
- pos[1] = prev_y
- toolhead.move(pos, self.speed)
- self.gcode.reset_last_position()
+ toolhead.manual_move(prevpos[:2], self.speed)
- def _perform_z_hop(self, pos):
+ def _perform_z_hop(self):
toolhead = self.printer.lookup_object('toolhead')
# Perform the Z-Hop
+ pos = toolhead.get_position()
toolhead.set_position(pos, homing_axes=[2])
- pos[2] = pos[2] + self.z_hop
- toolhead.move(pos, self.z_hop_speed)
- self.gcode.reset_last_position()
+ toolhead.manual_move([None, None, pos[2]+self.z_hop], self.z_hop_speed)
def load_config(config):
return SafeZHoming(config)