From 027a2b0c3b47dc0212956a8881384866b6c05cb6 Mon Sep 17 00:00:00 2001 From: sanjayk03-dev Date: Tue, 30 Jul 2024 17:40:31 +0530 Subject: [PATCH] loading the origin back after homing --- src/py/bbctrl/State.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/py/bbctrl/State.py b/src/py/bbctrl/State.py index 373b94f..476a1aa 100644 --- a/src/py/bbctrl/State.py +++ b/src/py/bbctrl/State.py @@ -243,12 +243,19 @@ class State(object): if self.timeout is None: self.timeout = self.ctrl.ioloop.call_later(0.25, self._notify) - if name in ['offset_x', 'offset_y', 'offset_z'] and 'cycle' in self.vars.get('cycle') == 'mdi': + # Storing origin to config + if name in ['offset_x', 'offset_y', 'offset_z'] and self.vars.get('cycle') == 'mdi': self.ctrl.config.set('axes', {name: value}) self.set('cycle', 'idle') + # Loading origin from config after homing if load_position and self.vars.get('cycle') == 'idle': - self.log.info('set the position value') + for axis in 'xyz': + offset = self.ctrl.config.get('offset_' + axis) + if offset is not None: + origin = offset if self.get('metric') == True else offset / 25.4 + self.log.info('axis: {} offset: {} origin: {}'.format(axis, offset, origin)) + self.ctrl.mach.set_position(axis,-origin) def update(self, update):