This commit is contained in:
alfrix 2022-11-20 21:26:36 -03:00
parent f1754f1014
commit bdd3e0ba1b
8 changed files with 11 additions and 40 deletions

View File

@ -1,8 +1,5 @@
class KlippyGcodes: class KlippyGcodes:
HOME = "G28" HOME = "G28"
HOME_X = "G28 X"
HOME_Y = "G28 Y"
HOME_Z = "G28 Z"
HOME_XY = "G28 X Y" HOME_XY = "G28 X Y"
Z_TILT = "Z_TILT_ADJUST" Z_TILT = "Z_TILT_ADJUST"
QUAD_GANTRY_LEVEL = "QUAD_GANTRY_LEVEL" QUAD_GANTRY_LEVEL = "QUAD_GANTRY_LEVEL"
@ -15,7 +12,6 @@ class KlippyGcodes:
EXTRUDE_REL = "M83" EXTRUDE_REL = "M83"
SET_EXT_TEMP = "M104" SET_EXT_TEMP = "M104"
SET_BED_TEMP = "M140" SET_BED_TEMP = "M140"
SET_EXT_FACTOR = "M221" SET_EXT_FACTOR = "M221"
@ -28,10 +24,6 @@ class KlippyGcodes:
ABORT = "ABORT" ABORT = "ABORT"
ACCEPT = "ACCEPT" ACCEPT = "ACCEPT"
SAVE_CONFIG = "SAVE_CONFIG"
RESTART = "RESTART"
FIRMWARE_RESTART = "FIRMWARE_RESTART"
@staticmethod @staticmethod
def set_bed_temp(temp): def set_bed_temp(temp):
return f"{KlippyGcodes.SET_BED_TEMP} S{temp}" return f"{KlippyGcodes.SET_BED_TEMP} S{temp}"

View File

@ -170,13 +170,12 @@ class KlippyGtk:
if label is not None: if label is not None:
try: try:
# Get the label object # Get the label object
if image_name is not None: if image_name is 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:
child = b.get_children()[0] 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_mode(Pango.WrapMode.WORD_CHAR)
child.set_line_wrap(True) child.set_line_wrap(True)
child.set_ellipsize(True) child.set_ellipsize(True)

View File

@ -21,7 +21,7 @@ class KlippyRest:
def get_oneshot_token(self): def get_oneshot_token(self):
r = self.send_request("access/oneshot_token") r = self.send_request("access/oneshot_token")
if r is False: if r is False or 'result' not in r:
return False return False
return r['result'] return r['result']

View File

@ -11,21 +11,6 @@ gi.require_version("Gtk", "3.0")
from gi.repository import GLib from gi.repository import GLib
from ks_includes.KlippyGcodes import KlippyGcodes 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): class KlippyWebsocket(threading.Thread):
_req_id = 0 _req_id = 0
@ -42,7 +27,6 @@ class KlippyWebsocket(threading.Thread):
self._screen = screen self._screen = screen
self._callback = callback self._callback = callback
self.klippy = MoonrakerApi(self) self.klippy = MoonrakerApi(self)
self.closing = False
self.ws = None self.ws = None
self.host = host self.host = host
@ -103,7 +87,6 @@ class KlippyWebsocket(threading.Thread):
logging.debug("Error starting web socket") logging.debug("Error starting web socket")
def close(self): def close(self):
self.closing = True
self.connecting = False self.connecting = False
if self.ws is not None: if self.ws is not None:
logging.debug("Closing websocket") logging.debug("Closing websocket")

View File

@ -240,11 +240,12 @@ class Printer:
return self.devices[dev][stat] return self.devices[dev][stat]
return None 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: if fan not in self.config or fan not in self.data:
logging.debug(f"Error getting {fan} config") logging.debug(f"Error getting {fan} config")
return speed if speed is not None else 0 return speed
if speed is None and "speed" in self.data[fan]: if "speed" in self.data[fan]:
speed = self.data[fan]["speed"] speed = self.data[fan]["speed"]
if 'max_power' in self.config[fan]: if 'max_power' in self.config[fan]:
max_power = float(self.config[fan]['max_power']) max_power = float(self.config[fan]['max_power'])

View File

@ -38,7 +38,7 @@ class FanPanel(ScreenPanel):
for fan in self.devices: for fan in self.devices:
if fan in data and "speed" in data[fan]: 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): def update_fan_speed(self, widget, fan, speed):
if fan not in self.devices: if fan not in self.devices:

View File

@ -134,7 +134,6 @@ class JobStatusPanel(ScreenPanel):
self.current_extruder = self._printer.get_stat("toolhead", "extruder") self.current_extruder = self._printer.get_stat("toolhead", "extruder")
diameter = float(self._printer.get_config_section(self.current_extruder)['filament_diameter']) diameter = float(self._printer.get_config_section(self.current_extruder)['filament_diameter'])
self.fila_section = pi * ((diameter / 2) ** 2) self.fila_section = pi * ((diameter / 2) ** 2)
self.create_status_grid()
self.grid.attach(overlay, 0, 0, 1, 1) self.grid.attach(overlay, 0, 0, 1, 1)
self.grid.attach(fi_box, 1, 0, 3, 1) self.grid.attach(fi_box, 1, 0, 3, 1)

View File

@ -1,5 +1,3 @@
import logging
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
@ -35,7 +33,6 @@ class SettingsPanel(ScreenPanel):
self.labels['printers'] = Gtk.Grid() self.labels['printers'] = Gtk.Grid()
self.labels['printers_menu'].add(self.labels['printers']) self.labels['printers_menu'].add(self.labels['printers'])
for printer in self._config.get_printers(): for printer in self._config.get_printers():
logging.debug(f"Printer: {printer}")
pname = list(printer)[0] pname = list(printer)[0]
self.printers[pname] = { self.printers[pname] = {
"name": pname, "name": pname,