aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2025-03-21 22:44:43 -0400
committerKevin O'Connor <kevin@koconnor.net>2025-05-12 20:15:03 -0400
commit4c21e1d00f1d5c827e3213ffde0b7a43497d8033 (patch)
tree4f449fd7ea41b7424dd6a8847b2a2054e98bc44b /klippy/extras
parent20823003098748fe6808793fe5d0c01ae74d47f9 (diff)
downloadkutter-4c21e1d00f1d5c827e3213ffde0b7a43497d8033.tar.gz
kutter-4c21e1d00f1d5c827e3213ffde0b7a43497d8033.tar.xz
kutter-4c21e1d00f1d5c827e3213ffde0b7a43497d8033.zip
gcode_move: Internally track an axis_map to map gcode axis names
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras')
-rw-r--r--klippy/extras/gcode_move.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/klippy/extras/gcode_move.py b/klippy/extras/gcode_move.py
index ecdadc43..d5930dc2 100644
--- a/klippy/extras/gcode_move.py
+++ b/klippy/extras/gcode_move.py
@@ -1,6 +1,6 @@
# G-Code G1 movement commands (and associated coordinate manipulation)
#
-# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
+# Copyright (C) 2016-2025 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
@@ -42,6 +42,7 @@ class GCodeMove:
self.base_position = [0.0, 0.0, 0.0, 0.0]
self.last_position = [0.0, 0.0, 0.0, 0.0]
self.homing_position = [0.0, 0.0, 0.0, 0.0]
+ self.axis_map = {'X':0, 'Y': 1, 'Z': 2, 'E': 3}
self.speed = 25.
self.speed_factor = 1. / 60.
self.extrude_factor = 1.
@@ -114,23 +115,20 @@ class GCodeMove:
# Move
params = gcmd.get_command_parameters()
try:
- for pos, axis in enumerate('XYZ'):
+ for axis, pos in self.axis_map.items():
if axis in params:
v = float(params[axis])
- if not self.absolute_coord:
+ absolute_coord = self.absolute_coord
+ if axis == 'E':
+ v *= self.extrude_factor
+ if not self.absolute_extrude:
+ absolute_coord = False
+ if not absolute_coord:
# value relative to position of last move
self.last_position[pos] += v
else:
# value relative to base coordinate position
self.last_position[pos] = v + self.base_position[pos]
- if 'E' in params:
- v = float(params['E']) * self.extrude_factor
- if not self.absolute_coord or not self.absolute_extrude:
- # value relative to position of last move
- self.last_position[3] += v
- else:
- # value relative to base coordinate position
- self.last_position[3] = v + self.base_position[3]
if 'F' in params:
gcode_speed = float(params['F'])
if gcode_speed <= 0.: