diff --git a/src/py/bbctrl/Ctrl.py b/src/py/bbctrl/Ctrl.py index fae382c..f66f39d 100644 --- a/src/py/bbctrl/Ctrl.py +++ b/src/py/bbctrl/Ctrl.py @@ -71,6 +71,7 @@ class Ctrl(object): def configure(self): # Indirectly configures state via calls to config() and the AVR self.config.reload() + self.state.init() def ready(self): # This is used to synchronize the start of the preplanner diff --git a/src/py/bbctrl/State.py b/src/py/bbctrl/State.py index 61b163b..d60de7b 100644 --- a/src/py/bbctrl/State.py +++ b/src/py/bbctrl/State.py @@ -419,3 +419,12 @@ class State(object): if switch[1:] == '-max': return self.get_axis_switch(switch[0], 'max') raise Exception('Unsupported switch "%s"' % switch) + + def init(self): + # Init machine units + metric = self.ctrl.config.get('units', 'METRIC').upper() == 'METRIC' + self.log.info('INIT Metric %d' % metric) + if not 'metric' in self.vars: + self.set('metric', metric) + if not 'imperial' in self.vars: + self.set('imperial', not metric)