diff --git a/docs/Configuration.md b/docs/Configuration.md index b976c818..bb053f86 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -45,6 +45,9 @@ moonraker_host: 127.0.0.1 moonraker_port: 7125 # Moonraker API key if this is not connecting from a trusted client IP moonraker_api_key: False + +# Define the z_babystep intervals in a CSV list. Currently only 2 are supported +z_babystep_values: 0.01, 0.05 ``` diff --git a/docs/changelog.md b/docs/changelog.md index e91f2719..9b7748fe 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,6 +1,7 @@ ## Changelog #### 2021 02 22 +* Add configurable z_babystep intervals * Fixed cursor issue on startup * Fixed font ratio for large, but short screens * Re-vamped logging system diff --git a/ks_includes/config.py b/ks_includes/config.py index 78201866..10297859 100644 --- a/ks_includes/config.py +++ b/ks_includes/config.py @@ -188,6 +188,14 @@ class KlipperScreenConfig: return preheat_options + def get_printer_config(self, name): + if not name.startswith("printer "): + name = "printer %s" % name + + if name not in self.config: + return None + return self.config[name] + def get_printer_power_name(self): return self.config['settings'].get("printer_power_name", "printer") diff --git a/panels/fine_tune.py b/panels/fine_tune.py index cca6d27e..f9c1e1d3 100644 --- a/panels/fine_tune.py +++ b/panels/fine_tune.py @@ -1,5 +1,6 @@ import gi import logging +import re gi.require_version("Gtk", "3.0") from gi.repository import Gtk, Gdk, GLib @@ -30,6 +31,17 @@ class FineTunePanel(ScreenPanel): grid.set_row_homogeneous(False) logging.debug("FineTunePanel") + print_cfg = self._config.get_printer_config(self._screen.connected_printer) + if print_cfg is not None: + bs = print_cfg.get("z_babystep_values","0.01, 0.05") + if re.match(r'^[0-9,\.\s]+$', bs): + bs = [str(i.strip()) for i in bs.split(',')] + if len(bs) <= 2: + self.bs_deltas = bs + else: + self.bs_deltas = [bs[0], bs[-1]] + self.bs_delta = self.bs_deltas[0] + self.labels['z+'] = self._gtk.ButtonImage("move-z-", _("Z+"), "color1") self.labels['z+'].connect("clicked", self.change_babystepping, "+") diff --git a/screen.py b/screen.py index deae6ba9..2d0e3360 100644 --- a/screen.py +++ b/screen.py @@ -126,6 +126,7 @@ class KlipperScreen(Gtk.Window): if self.files is not None: self.files.stop() + logging.info("Connecting to printer: %s" % name) self.apiclient = KlippyRest(self._config.get_main_config_option("moonraker_host"), self._config.get_main_config_option("moonraker_port"), self._config.get_main_config_option("moonraker_api_key", False))