diff options
author | Robert Konklewski <nythil@gmail.com> | 2019-03-21 15:37:28 +0100 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2019-03-21 10:37:28 -0400 |
commit | 6f91574cd9c6c84cd3dee3633cf9664d3f2026cf (patch) | |
tree | 91dabaa85af6254153b64957e4c777467216f307 /klippy/gcode.py | |
parent | d76658756ebbd1808774b475ca6e4367ec70b17e (diff) | |
download | kutter-6f91574cd9c6c84cd3dee3633cf9664d3f2026cf.tar.gz kutter-6f91574cd9c6c84cd3dee3633cf9664d3f2026cf.tar.xz kutter-6f91574cd9c6c84cd3dee3633cf9664d3f2026cf.zip |
menu: Show current positions based on gcode positions (#1389)
menu: Show current positions based on gcode positions
Added "move_[xyze]pos" properties to the "gcode" object for use in menus.
The new properties track the toolhead's position in gcode coordinates,
taking gcode and bed leveling offsets into account.
This position is equal to the value returned by M114 gcode.
Changes the move menus to show current position based on gcode
position. This allows gcode offsets and bed leveling offsets
to be taken into account, and prevents unexpected toolhead
movements when moving it using the menu.
Signed-off-by: Robert Konklewski <nythil@gmail.com>
Diffstat (limited to 'klippy/gcode.py')
-rw-r--r-- | klippy/gcode.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py index 8cddde9f..8dc235d0 100644 --- a/klippy/gcode.py +++ b/klippy/gcode.py @@ -102,7 +102,12 @@ class GCodeParser: self.position_with_transform = transform.get_position def stats(self, eventtime): return False, "gcodein=%d" % (self.bytes_read,) + def get_current_position(self): + p = [lp - bp for lp, bp in zip(self.last_position, self.base_position)] + p[3] /= self.extrude_factor + return p def get_status(self, eventtime): + move_position = self.get_current_position() busy = self.is_processing_data return { 'speed_factor': self.speed_factor * 60., @@ -110,6 +115,10 @@ class GCodeParser: 'extrude_factor': self.extrude_factor, 'abs_extrude': self.absoluteextrude, 'busy': busy, + 'move_xpos': move_position[0], + 'move_ypos': move_position[1], + 'move_zpos': move_position[2], + 'move_epos': move_position[3], 'last_xpos': self.last_position[0], 'last_ypos': self.last_position[1], 'last_zpos': self.last_position[2], @@ -573,8 +582,7 @@ class GCodeParser: cmd_M114_when_not_ready = True def cmd_M114(self, params): # Get Current Position - p = [lp - bp for lp, bp in zip(self.last_position, self.base_position)] - p[3] /= self.extrude_factor + p = self.get_current_position() self.respond("X:%.3f Y:%.3f Z:%.3f E:%.3f" % tuple(p)) def cmd_M220(self, params): # Set speed factor override percentage |