printer: save and use available commands
This commit is contained in:
parent
dd497d592d
commit
9ba8d04861
@ -29,6 +29,9 @@ class KlippyRest:
|
||||
def get_printer_info(self):
|
||||
return self.send_request("printer/info")
|
||||
|
||||
def get_gcode_help(self):
|
||||
return self.send_request("printer/gcode/help")
|
||||
|
||||
def get_thumbnail_stream(self, thumbnail):
|
||||
return self.send_request(f"server/files/gcodes/{thumbnail}", json=False)
|
||||
|
||||
|
@ -25,6 +25,7 @@ class Printer:
|
||||
self.busy = False
|
||||
self.tempstore_size = 1200
|
||||
self.cameras = []
|
||||
self.available_commands = {}
|
||||
|
||||
def reinit(self, printer_info, data):
|
||||
self.config = data['configfile']['config']
|
||||
@ -40,6 +41,7 @@ class Printer:
|
||||
if not self.store_timeout:
|
||||
self.store_timeout = GLib.timeout_add_seconds(1, self._update_temp_store)
|
||||
self.tempstore_size = 1200
|
||||
self.available_commands = {}
|
||||
|
||||
for x in self.config.keys():
|
||||
if x[:8] == "extruder":
|
||||
|
@ -740,18 +740,11 @@ class Panel(ScreenPanel):
|
||||
offset = self._printer.get_stat("gcode_move", "homing_origin")
|
||||
self.zoffset = float(offset[2]) if offset else 0
|
||||
if self.zoffset != 0:
|
||||
endstop = (
|
||||
(
|
||||
self._printer.config_section_exists("stepper_z")
|
||||
and not self._printer.get_config_section("stepper_z")['endstop_pin'].startswith("probe")
|
||||
)
|
||||
or "delta" in self._printer.get_config_section("printer")['kinematics']
|
||||
)
|
||||
if endstop:
|
||||
if "Z_OFFSET_APPLY_ENDSTOP" in self._printer.available_commands:
|
||||
self.buttons['button_grid'].attach(self.buttons["save_offset_endstop"], 0, 0, 1, 1)
|
||||
else:
|
||||
self.buttons['button_grid'].attach(Gtk.Label(), 0, 0, 1, 1)
|
||||
if self._printer.get_probe():
|
||||
if "Z_OFFSET_APPLY_PROBE" in self._printer.available_commands:
|
||||
self.buttons['button_grid'].attach(self.buttons["save_offset_probe"], 1, 0, 1, 1)
|
||||
else:
|
||||
self.buttons['button_grid'].attach(Gtk.Label(), 1, 0, 1, 1)
|
||||
|
@ -44,18 +44,18 @@ class Panel(ScreenPanel):
|
||||
|
||||
functions = []
|
||||
pobox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
if self._printer.config_section_exists("stepper_z") \
|
||||
and not self._printer.get_config_section("stepper_z")['endstop_pin'].startswith("probe"):
|
||||
|
||||
if "Z_ENDSTOP_CALIBRATE" in self._printer.available_commands:
|
||||
self._add_button("Endstop", "endstop", pobox)
|
||||
functions.append("endstop")
|
||||
if self.probe:
|
||||
if "PROBE_CALIBRATE" in self._printer.available_commands:
|
||||
self._add_button("Probe", "probe", pobox)
|
||||
functions.append("probe")
|
||||
if self._printer.config_section_exists("bed_mesh") and "probe" not in functions:
|
||||
if "BED_MESH_CALIBRATE" in self._printer.available_commands and "probe" not in functions:
|
||||
# This is used to do a manual bed mesh if there is no probe
|
||||
self._add_button("Bed mesh", "mesh", pobox)
|
||||
functions.append("mesh")
|
||||
if "delta" in self._printer.get_config_section("printer")['kinematics']:
|
||||
if "DELTA_CALIBRATE" in self._printer.available_commands:
|
||||
if "probe" in functions:
|
||||
self._add_button("Delta Automatic", "delta", pobox)
|
||||
functions.append("delta")
|
||||
|
@ -869,6 +869,7 @@ class KlipperScreen(Gtk.Window):
|
||||
return self._init_printer("Error getting printer configuration")
|
||||
# Reinitialize printer, in case the printer was shut down and anything has changed.
|
||||
self.printer.reinit(printer_info['result'], config['result']['status'])
|
||||
self.printer.available_commands = self.apiclient.get_gcode_help()['result']
|
||||
|
||||
self.ws_subscribe()
|
||||
extra_items = (self.printer.get_tools()
|
||||
|
Loading…
x
Reference in New Issue
Block a user