diff --git a/panels/zcalibrate.py b/panels/zcalibrate.py index 4affabf1..bd1c5a58 100644 --- a/panels/zcalibrate.py +++ b/panels/zcalibrate.py @@ -225,8 +225,13 @@ class ZCalibratePanel(ScreenPanel): self._screen._ws.klippy.gcode_script(f'G0 X{x_position} Y{y_position} F3000') def process_busy(self, busy): - for button in self.buttons: - self.buttons[button].set_sensitive(not busy) + if busy: + for button in self.buttons: + self.buttons[button].set_sensitive(False) + elif self._printer.get_stat("manual_probe", "is_active"): + self.buttons_calibrating() + else: + self.buttons_not_calibrating() def process_update(self, action, data): if action == "notify_busy": @@ -237,23 +242,18 @@ class ZCalibratePanel(ScreenPanel): self.widgets['zposition'].set_text("Z: ?") elif "gcode_move" in data and "gcode_position" in data['gcode_move']: self.update_position(data['gcode_move']['gcode_position']) + if "manual_probe" in data: + if data["manual_probe"]["is_active"]: + self.buttons_calibrating() + else: + self.buttons_not_calibrating() elif action == "notify_gcode_response": - data = data.lower() - if "unknown" in data: - self.buttons_not_calibrating() - logging.info(data) - elif "save_config" in data: - self.buttons_not_calibrating() - elif "out of range" in data: + if "out of range" in data.lower(): self._screen.show_popup_message(data) - self.buttons_not_calibrating() logging.info(data) - elif "fail" in data and "use testz" in data: + elif "fail" in data.lower() and "use testz" in data.lower(): self._screen.show_popup_message(_("Failed, adjust position first")) - self.buttons_not_calibrating() logging.info(data) - elif "use testz" in data or "use abort" in data or "z position" in data: - self.buttons_calibrating() return def update_position(self, position): @@ -305,7 +305,3 @@ class ZCalibratePanel(ScreenPanel): self.buttons['complete'].get_style_context().remove_class('color3') self.buttons['cancel'].set_sensitive(False) self.buttons['cancel'].get_style_context().remove_class('color2') - - def activate(self): - # This is only here because klipper doesn't provide a method to detect if it's calibrating - self._screen._ws.klippy.gcode_script(KlippyGcodes.testz_move("+0.001")) diff --git a/screen.py b/screen.py index d95ee936..0eebb025 100755 --- a/screen.py +++ b/screen.py @@ -46,6 +46,7 @@ PRINTER_BASE_STATUS_OBJECTS = [ 'motion_report', 'firmware_retraction', 'exclude_object', + 'manual_probe', ] klipperscreendir = pathlib.Path(__file__).parent.resolve() @@ -240,7 +241,8 @@ class KlipperScreen(Gtk.Window): "webhooks": ["state", "state_message"], "firmware_retraction": ["retract_length", "retract_speed", "unretract_extra_length", "unretract_speed"], "motion_report": ["live_position", "live_velocity", "live_extruder_velocity"], - "exclude_object": ["current_object", "objects", "excluded_objects"] + "exclude_object": ["current_object", "objects", "excluded_objects"], + "manual_probe": ['is_active'], } } for extruder in self.printer.get_tools(): @@ -724,6 +726,8 @@ class KlipperScreen(Gtk.Window): self.printer.process_update({'webhooks': {'state': "ready"}}) elif action == "notify_status_update" and self.printer.state != "shutdown": self.printer.process_update(data) + if 'manual_probe' in data and data['manual_probe']['is_active'] and 'zcalibrate' not in self._cur_panels: + self.show_panel('zoffset', "zcalibrate", None, 1, False) elif action == "notify_filelist_changed": if self.files is not None: self.files.process_update(data)