diff --git a/ks_includes/KlippyGcodes.py b/ks_includes/KlippyGcodes.py index c0aa0bf5..2c9f17d1 100644 --- a/ks_includes/KlippyGcodes.py +++ b/ks_includes/KlippyGcodes.py @@ -1,8 +1,5 @@ class KlippyGcodes: HOME = "G28" - HOME_X = "G28 X" - HOME_Y = "G28 Y" - HOME_Z = "G28 Z" HOME_XY = "G28 X Y" Z_TILT = "Z_TILT_ADJUST" QUAD_GANTRY_LEVEL = "QUAD_GANTRY_LEVEL" @@ -15,7 +12,6 @@ class KlippyGcodes: EXTRUDE_REL = "M83" SET_EXT_TEMP = "M104" - SET_BED_TEMP = "M140" SET_EXT_FACTOR = "M221" @@ -28,10 +24,6 @@ class KlippyGcodes: ABORT = "ABORT" ACCEPT = "ACCEPT" - SAVE_CONFIG = "SAVE_CONFIG" - RESTART = "RESTART" - FIRMWARE_RESTART = "FIRMWARE_RESTART" - @staticmethod def set_bed_temp(temp): return f"{KlippyGcodes.SET_BED_TEMP} S{temp}" diff --git a/ks_includes/KlippyGtk.py b/ks_includes/KlippyGtk.py index cdf7dd41..a762e2d3 100644 --- a/ks_includes/KlippyGtk.py +++ b/ks_includes/KlippyGtk.py @@ -170,13 +170,12 @@ class KlippyGtk: if label is not None: try: # Get the label object - if image_name is not None: - if position == Gtk.PositionType.RIGHT: - child = b.get_children()[0].get_children()[0].get_children()[0] - else: - child = b.get_children()[0].get_children()[0].get_children()[1] - else: + if image_name is None: child = b.get_children()[0] + elif position == Gtk.PositionType.RIGHT: + child = b.get_children()[0].get_children()[0].get_children()[0] + else: + child = b.get_children()[0].get_children()[0].get_children()[1] child.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR) child.set_line_wrap(True) child.set_ellipsize(True) diff --git a/ks_includes/KlippyRest.py b/ks_includes/KlippyRest.py index 5050e559..b7b8a481 100644 --- a/ks_includes/KlippyRest.py +++ b/ks_includes/KlippyRest.py @@ -21,7 +21,7 @@ class KlippyRest: def get_oneshot_token(self): r = self.send_request("access/oneshot_token") - if r is False: + if r is False or 'result' not in r: return False return r['result'] diff --git a/ks_includes/KlippyWebsocket.py b/ks_includes/KlippyWebsocket.py index be5cb8f7..0571a103 100644 --- a/ks_includes/KlippyWebsocket.py +++ b/ks_includes/KlippyWebsocket.py @@ -11,21 +11,6 @@ gi.require_version("Gtk", "3.0") from gi.repository import GLib from ks_includes.KlippyGcodes import KlippyGcodes -api_key = "" - -api = { - "printer_info": { - "url": "/printer/info", - "method": "get_printer_info" - }, - "apikey": { - "url": "/access/api_key" - }, - "oneshot_token": { - "url": "/access/oneshot_token" - } -} - class KlippyWebsocket(threading.Thread): _req_id = 0 @@ -42,7 +27,6 @@ class KlippyWebsocket(threading.Thread): self._screen = screen self._callback = callback self.klippy = MoonrakerApi(self) - self.closing = False self.ws = None self.host = host @@ -103,7 +87,6 @@ class KlippyWebsocket(threading.Thread): logging.debug("Error starting web socket") def close(self): - self.closing = True self.connecting = False if self.ws is not None: logging.debug("Closing websocket") diff --git a/ks_includes/printer.py b/ks_includes/printer.py index 3e04f0e4..03ff10b0 100644 --- a/ks_includes/printer.py +++ b/ks_includes/printer.py @@ -240,11 +240,12 @@ class Printer: return self.devices[dev][stat] return None - def get_fan_speed(self, fan="fan", speed=None): + def get_fan_speed(self, fan="fan"): + speed = 0 if fan not in self.config or fan not in self.data: logging.debug(f"Error getting {fan} config") - return speed if speed is not None else 0 - if speed is None and "speed" in self.data[fan]: + return speed + if "speed" in self.data[fan]: speed = self.data[fan]["speed"] if 'max_power' in self.config[fan]: max_power = float(self.config[fan]['max_power']) diff --git a/panels/fan.py b/panels/fan.py index 46ee610e..e48f4ef4 100644 --- a/panels/fan.py +++ b/panels/fan.py @@ -38,7 +38,7 @@ class FanPanel(ScreenPanel): for fan in self.devices: if fan in data and "speed" in data[fan]: - self.update_fan_speed(None, fan, self._printer.get_fan_speed(fan, data[fan]["speed"])) + self.update_fan_speed(None, fan, self._printer.get_fan_speed(fan)) def update_fan_speed(self, widget, fan, speed): if fan not in self.devices: diff --git a/panels/job_status.py b/panels/job_status.py index 965a287f..01fd5dbd 100644 --- a/panels/job_status.py +++ b/panels/job_status.py @@ -134,7 +134,6 @@ class JobStatusPanel(ScreenPanel): self.current_extruder = self._printer.get_stat("toolhead", "extruder") diameter = float(self._printer.get_config_section(self.current_extruder)['filament_diameter']) self.fila_section = pi * ((diameter / 2) ** 2) - self.create_status_grid() self.grid.attach(overlay, 0, 0, 1, 1) self.grid.attach(fi_box, 1, 0, 3, 1) diff --git a/panels/settings.py b/panels/settings.py index d46d5066..e3bd05c5 100644 --- a/panels/settings.py +++ b/panels/settings.py @@ -1,5 +1,3 @@ -import logging - import gi gi.require_version("Gtk", "3.0") @@ -35,7 +33,6 @@ class SettingsPanel(ScreenPanel): self.labels['printers'] = Gtk.Grid() self.labels['printers_menu'].add(self.labels['printers']) for printer in self._config.get_printers(): - logging.debug(f"Printer: {printer}") pname = list(printer)[0] self.printers[pname] = { "name": pname,