From c5494a3ed3b1322c370362cfd393ff3acb6064ae Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Tue, 16 Apr 2019 16:51:21 -0700 Subject: [PATCH] Fixed zeroing with non-zero offset when unhomed. #211 --- CHANGELOG.md | 1 + src/py/bbctrl/Mach.py | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 162e217..c3d7367 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Buildbotics CNC Controller Firmware Changelog - Added warning about reliability in a noisy environment on WiFi config page. - EStop on motor fault. - Fixed ETA line wrapping on Web interface. + - Fixed zeroing with non-zero offset when unhomed. #211 ## v0.4.6 - Fixed a rare ``Negative s-curve time`` error. diff --git a/src/py/bbctrl/Mach.py b/src/py/bbctrl/Mach.py index dfbd9c9..347ad8e 100644 --- a/src/py/bbctrl/Mach.py +++ b/src/py/bbctrl/Mach.py @@ -320,19 +320,21 @@ class Mach(Comm): def set_position(self, axis, position): axis = axis.lower() + state = self.ctrl.state - if self.ctrl.state.is_axis_homed(axis): + if state.is_axis_homed(axis): # If homed, change the offset rather than the absolute position self.mdi('G92%s%f' % (axis, position)) - elif self.ctrl.state.is_axis_enabled(axis): + elif state.is_axis_enabled(axis): if self._get_cycle() != 'idle' and not self._is_paused(): raise Exception('Cannot set position during ' + self._get_cycle()) # Set the absolute position both locally and via the AVR - self.ctrl.state.set(axis + 'p', position) - super().queue_command(Cmd.set_axis(axis, position)) + target = position - state.get('offset_' + axis) + state.set(axis + 'p', target) + super().queue_command(Cmd.set_axis(axis, target)) def override_feed(self, override): -- 2.27.0