mirror of
https://github.com/andreili/klipper.git
synced 2025-08-24 03:44:06 +02:00
gcode_move: Internally track an axis_map to map gcode axis names
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
2082300309
commit
4c21e1d00f
@ -1,6 +1,6 @@
|
|||||||
# G-Code G1 movement commands (and associated coordinate manipulation)
|
# 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.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
import logging
|
import logging
|
||||||
@ -42,6 +42,7 @@ class GCodeMove:
|
|||||||
self.base_position = [0.0, 0.0, 0.0, 0.0]
|
self.base_position = [0.0, 0.0, 0.0, 0.0]
|
||||||
self.last_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.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 = 25.
|
||||||
self.speed_factor = 1. / 60.
|
self.speed_factor = 1. / 60.
|
||||||
self.extrude_factor = 1.
|
self.extrude_factor = 1.
|
||||||
@ -114,23 +115,20 @@ class GCodeMove:
|
|||||||
# Move
|
# Move
|
||||||
params = gcmd.get_command_parameters()
|
params = gcmd.get_command_parameters()
|
||||||
try:
|
try:
|
||||||
for pos, axis in enumerate('XYZ'):
|
for axis, pos in self.axis_map.items():
|
||||||
if axis in params:
|
if axis in params:
|
||||||
v = float(params[axis])
|
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
|
# value relative to position of last move
|
||||||
self.last_position[pos] += v
|
self.last_position[pos] += v
|
||||||
else:
|
else:
|
||||||
# value relative to base coordinate position
|
# value relative to base coordinate position
|
||||||
self.last_position[pos] = v + self.base_position[pos]
|
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:
|
if 'F' in params:
|
||||||
gcode_speed = float(params['F'])
|
gcode_speed = float(params['F'])
|
||||||
if gcode_speed <= 0.:
|
if gcode_speed <= 0.:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user