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:
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}"

View File

@ -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)

View File

@ -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']

View File

@ -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")

View File

@ -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'])

View File

@ -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:

View File

@ -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)

View File

@ -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,