diff --git a/docs/Configuration.md b/docs/Configuration.md index 0ffd94a4..01b9e3fc 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -1,7 +1,22 @@ # Configuration -In the KlipperScreen folder, a file _KlipperScreen.conf_ allows for configuration of the screen. This document will -detail how to configure KlipperScreen. A default config is included here: [ks_includes/KlipperScreen.conf](../ks_includes/KlipperScreen.conf) +KlipperScreen has some configuration options which are outlined below. KlipperScreen will search for a configuration +file in the following order: +_${HOME}/KlipperScreen.conf_ +_${KlipperScreen_Directory}/KlipperScreen.conf_ + +If one of those files are found, it will be used over the default configuration. The default configuration will be +merged with the custom configuration, so if you do not define any menus the default menus will be used.The default +config is included here: [ks_includes/KlipperScreen.conf](../ks_includes/KlipperScreen.conf) + +## Main Options +``` +[main] +# Invert axis in move panel. Default is False. Change to true to invert +invert_x: False +invert_y: False +invert_z: False +``` ## Preheat Options diff --git a/docs/changelog.md b/docs/changelog.md index 1a8399df..aa71af7d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,9 @@ ## Changelog +#### 2020 12 05 +* Added ability to invert Z axis in move panel +* Fixed problem with metadata being retreived constantly + #### 2020 12 04 * Removed fan options from fine tuning * Add bed mesh panel diff --git a/ks_includes/KlipperScreen.conf b/ks_includes/KlipperScreen.conf index 20978f31..a0dc7179 100644 --- a/ks_includes/KlipperScreen.conf +++ b/ks_includes/KlipperScreen.conf @@ -1,3 +1,5 @@ +[main] + [preheat PLA] bed = 40 extruder = 195 diff --git a/ks_includes/config.py b/ks_includes/config.py index 772cc424..933159d6 100644 --- a/ks_includes/config.py +++ b/ks_includes/config.py @@ -14,34 +14,37 @@ class ConfigError(Exception): class KlipperScreenConfig: config = None + configfile_name = "KlipperScreen.conf" def __init__(self): + self.default_config_path = "%s/ks_includes/%s" % (os.getcwd(), self.configfile_name) self.config = configparser.ConfigParser() self.config_path = self.get_config_file_location() try: - self.config.read(self.config_path) + self.config.read(self.default_config_path) + if self.config_path != self.default_config_path: + self.config.read(self.config_path) except KeyError: raise ConfigError(f"Error reading config: {self.config_path}") self.log_config(self.config) - self.get_menu_items("__main") #self.build_main_menu(self.config) - def get_config_file_location(self): - conf_name = "KlipperScreen.conf" - - file = "%s/%s" % (os.getenv("HOME"), conf_name) + file = "%s/%s" % (os.getenv("HOME"), self.configfile_name) if not path.exists(file): - file = "%s/%s" % (os.getcwd(), conf_name) + file = "%s/%s" % (os.getcwd(), self.configfile_name) if not path.exists(file): - file = "%s/ks_includes/%s" % (os.getcwd(), conf_name) + file = self.default_config_path logger.info("Found configuration file at: %s" % file) return file + def get_main_config_option(self, option, default=None): + return self.config['main'].get(option, default) + def get_menu_items(self, menu="__main", subsection=""): if subsection != "": subsection = subsection + " " @@ -94,8 +97,6 @@ class KlipperScreenConfig: sfile.seek(0) return sfile.read().strip() - - def _build_menu_item(self, menu, name): if name not in self.config: return False diff --git a/ks_includes/screen_panel.py b/ks_includes/screen_panel.py index b50f2ab9..430b2098 100644 --- a/ks_includes/screen_panel.py +++ b/ks_includes/screen_panel.py @@ -14,6 +14,7 @@ class ScreenPanel: def __init__(self, screen, title, back=True): self._screen = screen + self._config = screen._config self.lang = self._screen.lang self._printer = screen.printer self.labels = {} diff --git a/panels/move.py b/panels/move.py index 1dc995ac..8161bf16 100644 --- a/panels/move.py +++ b/panels/move.py @@ -123,6 +123,9 @@ class MovePanel(ScreenPanel): self.labels[str(i)].set_active(False) def move(self, widget, axis, dir): + if self._config.get_main_config_option("invert_%s" % axis.lower(), False): + dir = "-" if dir == "+" else "+" + dist = str(self.distance) if dir == "+" else "-" + str(self.distance) logging.info("# Moving " + axis + " " + dist + "mm")