move: Allow inverting of the axis

This commit is contained in:
Jordan Ruthe 2020-12-05 15:42:34 -05:00
parent cf3a924bb2
commit 0907c6a06a
6 changed files with 38 additions and 12 deletions

View File

@ -1,7 +1,22 @@
# Configuration # Configuration
In the KlipperScreen folder, a file _KlipperScreen.conf_ allows for configuration of the screen. This document will KlipperScreen has some configuration options which are outlined below. KlipperScreen will search for a configuration
detail how to configure KlipperScreen. A default config is included here: [ks_includes/KlipperScreen.conf](../ks_includes/KlipperScreen.conf) 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 ## Preheat Options

View File

@ -1,5 +1,9 @@
## Changelog ## Changelog
#### 2020 12 05
* Added ability to invert Z axis in move panel
* Fixed problem with metadata being retreived constantly
#### 2020 12 04 #### 2020 12 04
* Removed fan options from fine tuning * Removed fan options from fine tuning
* Add bed mesh panel * Add bed mesh panel

View File

@ -1,3 +1,5 @@
[main]
[preheat PLA] [preheat PLA]
bed = 40 bed = 40
extruder = 195 extruder = 195

View File

@ -14,34 +14,37 @@ class ConfigError(Exception):
class KlipperScreenConfig: class KlipperScreenConfig:
config = None config = None
configfile_name = "KlipperScreen.conf"
def __init__(self): def __init__(self):
self.default_config_path = "%s/ks_includes/%s" % (os.getcwd(), self.configfile_name)
self.config = configparser.ConfigParser() self.config = configparser.ConfigParser()
self.config_path = self.get_config_file_location() self.config_path = self.get_config_file_location()
try: try:
self.config.read(self.default_config_path)
if self.config_path != self.default_config_path:
self.config.read(self.config_path) self.config.read(self.config_path)
except KeyError: except KeyError:
raise ConfigError(f"Error reading config: {self.config_path}") raise ConfigError(f"Error reading config: {self.config_path}")
self.log_config(self.config) self.log_config(self.config)
self.get_menu_items("__main") self.get_menu_items("__main")
#self.build_main_menu(self.config) #self.build_main_menu(self.config)
def get_config_file_location(self): def get_config_file_location(self):
conf_name = "KlipperScreen.conf" file = "%s/%s" % (os.getenv("HOME"), self.configfile_name)
file = "%s/%s" % (os.getenv("HOME"), conf_name)
if not path.exists(file): 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): 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) logger.info("Found configuration file at: %s" % file)
return 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=""): def get_menu_items(self, menu="__main", subsection=""):
if subsection != "": if subsection != "":
subsection = subsection + " " subsection = subsection + " "
@ -94,8 +97,6 @@ class KlipperScreenConfig:
sfile.seek(0) sfile.seek(0)
return sfile.read().strip() return sfile.read().strip()
def _build_menu_item(self, menu, name): def _build_menu_item(self, menu, name):
if name not in self.config: if name not in self.config:
return False return False

View File

@ -14,6 +14,7 @@ class ScreenPanel:
def __init__(self, screen, title, back=True): def __init__(self, screen, title, back=True):
self._screen = screen self._screen = screen
self._config = screen._config
self.lang = self._screen.lang self.lang = self._screen.lang
self._printer = screen.printer self._printer = screen.printer
self.labels = {} self.labels = {}

View File

@ -123,6 +123,9 @@ class MovePanel(ScreenPanel):
self.labels[str(i)].set_active(False) self.labels[str(i)].set_active(False)
def move(self, widget, axis, dir): 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) dist = str(self.distance) if dir == "+" else "-" + str(self.distance)
logging.info("# Moving " + axis + " " + dist + "mm") logging.info("# Moving " + axis + " " + dist + "mm")