diff --git a/ks_includes/KlippyGcodes.py b/ks_includes/KlippyGcodes.py index 2c9f17d1..aa667f53 100644 --- a/ks_includes/KlippyGcodes.py +++ b/ks_includes/KlippyGcodes.py @@ -1,36 +1,16 @@ class KlippyGcodes: - HOME = "G28" - HOME_XY = "G28 X Y" - Z_TILT = "Z_TILT_ADJUST" - QUAD_GANTRY_LEVEL = "QUAD_GANTRY_LEVEL" - - MOVE = "G1" MOVE_ABSOLUTE = "G90" MOVE_RELATIVE = "G91" - EXTRUDE_ABS = "M82" EXTRUDE_REL = "M83" - SET_EXT_TEMP = "M104" - SET_BED_TEMP = "M140" - - SET_EXT_FACTOR = "M221" - SET_FAN_SPEED = "M106" - SET_SPD_FACTOR = "M220" - - PROBE_CALIBRATE = "PROBE_CALIBRATE" - Z_ENDSTOP_CALIBRATE = "Z_ENDSTOP_CALIBRATE" - TESTZ = "TESTZ Z=" - ABORT = "ABORT" - ACCEPT = "ACCEPT" - @staticmethod def set_bed_temp(temp): - return f"{KlippyGcodes.SET_BED_TEMP} S{temp}" + return f"M140 S{temp}" @staticmethod def set_ext_temp(temp, tool=0): - return f"{KlippyGcodes.SET_EXT_TEMP} T{tool} S{temp}" + return f"M104 T{tool} S{temp}" @staticmethod def set_heater_temp(heater, temp): @@ -40,25 +20,13 @@ class KlippyGcodes: def set_temp_fan_temp(temp_fan, temp): return f'SET_TEMPERATURE_FAN_TARGET temperature_fan="{temp_fan}" target={temp}' - @staticmethod - def set_fan_speed(speed): - return f"{KlippyGcodes.SET_FAN_SPEED} S{speed * 2.55:.0f}" - @staticmethod def set_extrusion_rate(rate): - return f"{KlippyGcodes.SET_EXT_FACTOR} S{rate}" + return f"M221 S{rate}" @staticmethod def set_speed_rate(rate): - return f"{KlippyGcodes.SET_SPD_FACTOR} S{rate}" - - @staticmethod - def testz_move(dist): - return KlippyGcodes.TESTZ + dist - - @staticmethod - def extrude(dist, speed=500): - return f"{KlippyGcodes.MOVE} E{dist} F{speed}" + return f"M220 S{rate}" @staticmethod def bed_mesh_load(profile): diff --git a/panels/bed_level.py b/panels/bed_level.py index f712015a..5148a3b0 100644 --- a/panels/bed_level.py +++ b/panels/bed_level.py @@ -300,10 +300,10 @@ class Panel(ScreenPanel): def home(self): # Test if all axes have been homed. Home if necessary. if self._printer.get_stat("toolhead", "homed_axes") != "xyz": - self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME) + self._screen._ws.klippy.gcode_script("G28") # do Z_TILT_CALIBRATE if applicable. if self._printer.config_section_exists("z_tilt"): - self._screen._ws.klippy.gcode_script(KlippyGcodes.Z_TILT) + self._screen._ws.klippy.gcode_script("Z_TILT_ADJUST") def go_to_position(self, widget, position): self.home() diff --git a/panels/bed_mesh.py b/panels/bed_mesh.py index 219adc3f..f9093b31 100644 --- a/panels/bed_mesh.py +++ b/panels/bed_mesh.py @@ -263,7 +263,7 @@ class Panel(ScreenPanel): def calibrate_mesh(self, widget): self._screen.show_popup_message(_("Calibrating"), level=1) if self._printer.get_stat("toolhead", "homed_axes") != "xyz": - self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME) + self._screen._ws.klippy.gcode_script("G28") self._screen._ws.klippy.gcode_script("BED_MESH_CALIBRATE") diff --git a/panels/extrude.py b/panels/extrude.py index 79a8bf5e..5ea99a15 100644 --- a/panels/extrude.py +++ b/panels/extrude.py @@ -227,7 +227,7 @@ class Panel(ScreenPanel): def extrude(self, widget, direction): self._screen._ws.klippy.gcode_script(KlippyGcodes.EXTRUDE_REL) - self._screen._ws.klippy.gcode_script(KlippyGcodes.extrude(f"{direction}{self.distance}", f"{self.speed * 60}")) + self._screen._ws.klippy.gcode_script(f"G1 E{direction}{self.distance} F{self.speed * 60}") def load_unload(self, widget, direction): if direction == "-": diff --git a/panels/fan.py b/panels/fan.py index 9768499f..28c4b10f 100644 --- a/panels/fan.py +++ b/panels/fan.py @@ -3,7 +3,6 @@ import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk, GLib, Pango -from ks_includes.KlippyGcodes import KlippyGcodes from ks_includes.screen_panel import ScreenPanel @@ -129,7 +128,7 @@ class Panel(ScreenPanel): value = self.devices[fan]['scale'].get_value() if fan == "fan": - self._screen._ws.klippy.gcode_script(KlippyGcodes.set_fan_speed(value)) + self._screen._ws.klippy.gcode_script(f"M106 S{value * 2.55:.0f}") else: self._screen._ws.klippy.gcode_script(f"SET_FAN_SPEED FAN={fan.split()[1]} SPEED={float(value) / 100}") # Check the speed in case it wasn't applied diff --git a/panels/input_shaper.py b/panels/input_shaper.py index 5efb6b69..63c95dd3 100644 --- a/panels/input_shaper.py +++ b/panels/input_shaper.py @@ -3,7 +3,6 @@ import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk, Pango -from ks_includes.KlippyGcodes import KlippyGcodes from ks_includes.screen_panel import ScreenPanel @@ -108,7 +107,7 @@ class Panel(ScreenPanel): def start_calibration(self, widget, method): self.labels['popover'].popdown() if self._printer.get_stat("toolhead", "homed_axes") != "xyz": - self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME) + self._screen._ws.klippy.gcode_script("G28") self.calibrating_axis = method if method == "x": self._screen._ws.klippy.gcode_script('SHAPER_CALIBRATE AXIS=X') diff --git a/panels/move.py b/panels/move.py index 351fdb5a..23ebf42a 100644 --- a/panels/move.py +++ b/panels/move.py @@ -187,7 +187,7 @@ class Panel(ScreenPanel): speed = self._config.get_config()['main'].getint(config_key, 20) speed = 60 * max(1, speed) - self._screen._ws.klippy.gcode_script(f"{KlippyGcodes.MOVE_RELATIVE}\n{KlippyGcodes.MOVE} {axis}{dist} F{speed}") + self._screen._ws.klippy.gcode_script(f"{KlippyGcodes.MOVE_RELATIVE}\nG0 {axis}{dist} F{speed}") if self._printer.get_stat("gcode_move", "absolute_coordinates"): self._screen._ws.klippy.gcode_script("G90") @@ -250,7 +250,7 @@ class Panel(ScreenPanel): def home(self, widget): if "delta" in self._printer.get_config_section("printer")['kinematics']: - self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME) + self._screen._ws.klippy.gcode_script("G28") return name = "homing" disname = self._screen._config.get_menu_name("move", name) diff --git a/panels/zcalibrate.py b/panels/zcalibrate.py index a4086b11..22598a48 100644 --- a/panels/zcalibrate.py +++ b/panels/zcalibrate.py @@ -3,7 +3,6 @@ import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk -from ks_includes.KlippyGcodes import KlippyGcodes from ks_includes.screen_panel import ScreenPanel @@ -127,11 +126,11 @@ class Panel(ScreenPanel): def start_calibration(self, widget, method): self.labels['popover'].popdown() if self._printer.get_stat("toolhead", "homed_axes") != "xyz": - self._screen._ws.klippy.gcode_script(KlippyGcodes.HOME) + self._screen._ws.klippy.gcode_script("G28") if method == "probe": self._move_to_position() - self._screen._ws.klippy.gcode_script(KlippyGcodes.PROBE_CALIBRATE) + self._screen._ws.klippy.gcode_script("PROBE_CALIBRATE") elif method == "mesh": self._screen._ws.klippy.gcode_script("BED_MESH_CALIBRATE") elif method == "delta": @@ -139,7 +138,7 @@ class Panel(ScreenPanel): elif method == "delta_manual": self._screen._ws.klippy.gcode_script("DELTA_CALIBRATE METHOD=manual") elif method == "endstop": - self._screen._ws.klippy.gcode_script(KlippyGcodes.Z_ENDSTOP_CALIBRATE) + self._screen._ws.klippy.gcode_script("Z_ENDSTOP_CALIBRATE") def _move_to_position(self): x_position = y_position = None @@ -262,17 +261,17 @@ class Panel(ScreenPanel): self.distance = distance def move(self, widget, direction): - self._screen._ws.klippy.gcode_script(KlippyGcodes.testz_move(f"{direction}{self.distance}")) + self._screen._ws.klippy.gcode_script(f"TESTZ Z={direction}{self.distance}") def abort(self, widget): logging.info("Aborting calibration") - self._screen._ws.klippy.gcode_script(KlippyGcodes.ABORT) + self._screen._ws.klippy.gcode_script("ABORT") self.buttons_not_calibrating() self._screen._menu_go_back() def accept(self, widget): logging.info("Accepting Z position") - self._screen._ws.klippy.gcode_script(KlippyGcodes.ACCEPT) + self._screen._ws.klippy.gcode_script("ACCEPT") def buttons_calibrating(self): self.buttons['start'].get_style_context().remove_class('color3')