diff --git a/docs/Config_Changes.md b/docs/Config_Changes.md index 0d1573910..030b99c93 100644 --- a/docs/Config_Changes.md +++ b/docs/Config_Changes.md @@ -22,6 +22,11 @@ deprecated. It will be removed in the near future. Use instead. The `printer[fan object].speed` status will be replaced by `printer[fan object].value` and `printer[fan object].power`. +20241223: The `CLEAR_RETRACTION` command does not reset parameters to +default config values anymore, a [`RESET_RETRACTION`](./G-Codes.md#reset_retraction) +command was added to achieve this. Automatic resetting behavior on +events was removed. + 20240430: The `adc_ignore_limits` parameter in the `[danger_options]` config section has been renamed to `temp_ignore_limits` and it now covers all possible temperature sensors. diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index 06a6c6d99..b88b4cdd6 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -1926,7 +1926,12 @@ allowing per-filament settings and runtime tuning. # The vertical height by which the nozzle is lifted from the print to # prevent collisions with the print during travel moves when retracted. # The minimum value is 0 mm, the default value is 0 mm, which disables -# zhop moves. +# zhop moves. The value will be reduced if the zhop move reaches +# maximum z. +#clear_zhop_on_z_moves: False +# If True, when a change in Z is sent while toolhead is retracted, +# z_hop is cancelled until next retraction. Otherwise, +# `z_hop_height` is applied as an offset to all movements. ``` ### [gcode_arcs] diff --git a/docs/G-Codes.md b/docs/G-Codes.md index cd4c81f4c..bcded597d 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -633,6 +633,8 @@ the filament unretract move to reduce blobbing at seams (the minimum value is Z_HOP_HEIGHT determines the vertical height by which the nozzle is lifted from the print to prevent collisions with the print during travel moves (the minimum value is 0 mm, the standard value is 0 mm, which disables Z-Hop moves). +If a parameter is set when retracted, the new value will be taken into +account only after G11 or CLEAR_RETRACTION event. SET_RETRACTION is commonly set as part of slicer per-filament configuration, as different filaments require different parameter settings. The command can be issued at runtime. @@ -640,29 +642,31 @@ issued at runtime. #### GET_RETRACTION `GET_RETRACTION`: Queries the current parameters used by the firmware retraction module as well as the retract state. RETRACT_LENGTH, RETRACT_SPEED, -UNRETRACT_EXTRA_LENGTH, UNRETRACT_SPEED, Z_HOP_HEIGHT and RETRACTED (True, if -retracted) are displayed on the terminal. +UNRETRACT_EXTRA_LENGTH, UNRETRACT_SPEED, Z_HOP_HEIGHT, RETRACT_STATE (True, if +retracted), ZHOP_STATE (True, if zhop offset currently applied) are displayed on +the terminal. #### CLEAR_RETRACTION `CLEAR_RETRACTION`: Clears the current retract state without extruder or motion system movement. All flags related to the retract state are reset to -False and all changes to retraction parameters made via previous SET_RETRACTION -commands are reset to config values. -NOTE: The Module contains a lot of redundancy for safety to prevent undesired -behavior. When printing from virtual SD Card, the printer state is monitored and -retraction state is cleared if a print is started, canceled or finished or if a -virtual SD card file is reset. When printing via GCode streaming (e.g. using -OctoPrint), the retract state is cleared when the steppers are disabled (M84, +False. + +NOTE: The zhop state is also reset to False when the steppers are disabled (M84, typically part of end gcode and standard behavior of OctoPrint if a print is canceled) or the printer is homed (G28, typically part of start gcode). Hence, upon ending or canceling a print as well as starting a new print via GCode -streaming or virtual SD card, the printer should always be in unretracted state. +streaming or virtual SD card, the toolhead will not apply `z_hop_height` until +next G11 if filament is retracted. Nevertheless, it is recommended to add `CLEAR_RETRACTION` to your start and end -gcode to make sure the retract state is reset before and after each print. If a -print is finished or canceled while retracted and the retract state is not -cleared, either via `CLEAR_RETRACTION` without filament or motion system -movement or G11, the nozzle will stay above the requested z coordinate by the -set z_hop_height. +gcode to make sure the retract state is reset before and after each print. + +#### RESET_RETRACTION +`RESET_RETRACTION`: All changes to retraction parameters made via previous +SET_RETRACTION commands are reset to config values. + +NOTE: It is recommended to add `RESET_RETRACTION` to your start and end gcode +(with a possible override in your filament start gcode to set filament-specific +overrides of firmware retraction defaults via `SET_RETRACTION`). ### [force_move] diff --git a/docs/Status_Reference.md b/docs/Status_Reference.md index df0cff188..321b3334b 100644 --- a/docs/Status_Reference.md +++ b/docs/Status_Reference.md @@ -199,6 +199,7 @@ The following information is available in the config file if a `SET_RETRACTION` command altered them. Additional information available is as follows. - `retract_state`: Returns 'True' if filament is retracted. +- `zhop_state`: Returns 'True' if a zhop is currently applied. ## gcode diff --git a/klippy/extras/firmware_retraction.py b/klippy/extras/firmware_retraction.py index ed6130133..4a6fae6ac 100644 --- a/klippy/extras/firmware_retraction.py +++ b/klippy/extras/firmware_retraction.py @@ -9,6 +9,7 @@ # Constants ZHOP_MOVE_SPEED_FRACTION = 0.8 +MAX_Z_MARGIN = 0.1 class FirmwareRetraction: @@ -16,23 +17,22 @@ class FirmwareRetraction: def __init__(self, config): self.config_ref = config self.printer = config.get_printer() - # Get retraction params from config, used also in clear retraction + + # Get retraction params from config, used also in RESET_RETRACTION + # and initiate params self._get_config_params() - # Initialize variables - self.unretract_length = ( - self.retract_length + self.unretract_extra_length - ) - self.currentPos = [] - self.currentZ = 0.0 - self.z_hop_Z = 0.0 # Z coordinate of zhop move + # Initialize variables self.is_retracted = False # Retract state flag - self.vsdcard_paused = False # VSDCard pause flag - self.G1_toggle_state = False # G1 toggle state flag + self.do_zhop = False # zhop state flag + self.current_z_hop_height = 0.0 + self.last_position = [0.0, 0.0, 0.0, 0.0] + self.next_transform = None - # Get maximum printer move velocity for zhop moves + # Get maximum printer z move velocity for zhop moves printer_config = config.getsection("printer") - self.max_vel = printer_config.getfloat("max_velocity") + max_velocity = printer_config.getfloat("max_velocity") + self.max_z_vel = printer_config.getfloat("max_z_velocity", max_velocity) self.printer.register_event_handler("klippy:ready", self._handle_ready) @@ -54,6 +54,11 @@ def __init__(self, config): self.cmd_CLEAR_RETRACTION, desc=self.cmd_CLEAR_RETRACTION_help, ) + self.gcode.register_command( + "RESET_RETRACTION", + self.cmd_RESET_RETRACTION, + desc=self.cmd_RESET_RETRACTION_help, + ) # Register new G-code commands for firmware retraction/unretraction self.gcode.register_command("G10", self.cmd_G10) @@ -73,59 +78,44 @@ def _get_config_params(self): self.unretract_speed = self.config_ref.getfloat( "unretract_speed", 10.0, minval=1 ) - # Zero min. and stand. zhop valueto ensure compatibility with macros self.z_hop_height = self.config_ref.getfloat( "z_hop_height", 0.0, minval=0.0 ) + self.clear_zhop = self.config_ref.getboolean( + "clear_zhop_on_z_moves", False + ) + self.unretract_length = ( + self.retract_length + self.unretract_extra_length + ) # Helper method to register commands and instantiate required objects def _handle_ready(self): self.gcode_move = self.printer.lookup_object("gcode_move") - self.toolhead = self.printer.lookup_object("toolhead") + self.exclude_objects = self.printer.lookup_object( + "exclude_object", None + ) + + # Register move transformation while printer ready + # important to track Z change request + self.next_transform = self.gcode_move.set_move_transform( + self, force=True + ) + + # Get maximum_z + toolhead = self.printer.lookup_object("toolhead") + kin = toolhead.get_kinematics() + self.maximum_z = kin.get_status(None)["axis_maximum"][2] # Register Events to clear retraction when a new print is started, an # ongoing print is canceled or a print is finished # GCode streaming mode (most commonly done via OctoPrint) self.printer.register_event_handler( - "homing:homing_move_begin", self._evaluate_retraction + "homing:homing_move_begin", self._execute_clear_z_hop ) self.printer.register_event_handler( - "stepper_enable:motor_off", self._evaluate_retraction + "stepper_enable:motor_off", self._execute_clear_z_hop ) - # Virtual SD card mode (Mainsail, Fluidd and DWC2-to-Klipper default) - # Only register events if Virtual SD Card enabled - if self.config_ref.has_section("virtual_sdcard"): - self.vsdcard = self.printer.lookup_object("virtual_sdcard") - self.printer.register_event_handler( - "virtual_sdcard:reset_file", self._reset_pause_flag - ) - self.printer.register_event_handler( - "print_stats:start_printing", self._evaluate_retraction - ) - self.printer.register_event_handler( - "print_stats:complete_printing", self._evaluate_retraction - ) - self.printer.register_event_handler( - "print_stats:cancelled_printing", - self._reset_pause_flag, - ) - self.printer.register_event_handler( - "print_stats:paused_printing", self._set_pause_flag - ) - - # Helper method to evaluate to clear retraction if certain events occur - # (must accept all arguments passed from event handlers) - def _evaluate_retraction(self, *args): - if self.is_retracted: # Check if retracted - if self.vsdcard_paused: # Check if VSDCard print paused - # Reset paused flag and hence do not clear retraction on - # resume command. - self.vsdcard_paused = False - else: - # If cancel command triggered pause event, clear retraction. - self._execute_clear_retraction() - # Helper method to return the current retraction parameters def get_status(self, eventtime): return { @@ -136,31 +126,13 @@ def get_status(self, eventtime): "z_hop_height": self.z_hop_height, "unretract_length": self.unretract_length, "retract_state": self.is_retracted, + "zhop_state": self.do_zhop, } - # Helper method to reset pause flags and force evaluate retraction - def _reset_pause_flag(self, *args): - self.vsdcard_paused = False - self._evaluate_retraction() - - # Helper method to set pause flag - def _set_pause_flag(self, *args): - self.vsdcard_paused = True - # Command to set the firmware retraction parameters cmd_SET_RETRACTION_help = "Set firmware retraction parameters" def cmd_SET_RETRACTION(self, gcmd): - if not self.is_retracted: # Only execute command when unretracted - self._execute_set_retraction(gcmd) # Execute command immediately - else: - self.gcode.respond_info( - "WARNING: Printer in retract state. SET_RETRACTION will not be\ - executed!" - ) - - # Helper to set retraction parameters if command is called - def _execute_set_retraction(self, gcmd): self.retract_length = gcmd.get_float( "RETRACT_LENGTH", self.retract_length, minval=0.0 ) @@ -168,7 +140,9 @@ def _execute_set_retraction(self, gcmd): "RETRACT_SPEED", self.retract_speed, minval=1.0 ) self.unretract_extra_length = gcmd.get_float( - "UNRETRACT_EXTRA_LENGTH", self.unretract_extra_length, minval=-1.0 + "UNRETRACT_EXTRA_LENGTH", + self.unretract_extra_length, + minval=-1.0, ) self.unretract_speed = gcmd.get_float( "UNRETRACT_SPEED", self.unretract_speed, minval=1.0 @@ -181,14 +155,15 @@ def _execute_set_retraction(self, gcmd): ) # Command to report the current firmware retraction parameters - cmd_GET_RETRACTION_help = "Report firmware retraction paramters" + cmd_GET_RETRACTION_help = "Report firmware retraction parameters and states" def cmd_GET_RETRACTION(self, gcmd): gcmd.respond_info( "RETRACT_LENGTH=%.5f RETRACT_SPEED=%.5f " "UNRETRACT_EXTRA_LENGTH=%.5f UNRETRACT_SPEED=%.5f " " Z_HOP_HEIGHT=%.5f " - " RETRACTED=%s " + " RETRACT_STATE=%s " + " ZHOP_STATE=%s" % ( self.retract_length, self.retract_speed, @@ -196,210 +171,155 @@ def cmd_GET_RETRACTION(self, gcmd): self.unretract_speed, self.z_hop_height, self.is_retracted, + self.do_zhop, ) ) # Command to clear FW retraction (add to CANCEL macros at the beginning) - cmd_CLEAR_RETRACTION_help = "Clear retraction state without retract move \ - or zhop, if enabled" + cmd_CLEAR_RETRACTION_help = ( + "Clear retraction state without retract move if enabled" + ) def cmd_CLEAR_RETRACTION(self, gcmd): - if self.is_retracted: - self._execute_clear_retraction() - gcmd.respond_info( - "Retraction was cleared and reset to config \ - values. zhop is undone on next move." - ) - else: - gcmd.respond_info( - "WARNING: Printer is not retracted. \ - Command has been ignored!" - ) - - # Helper to clear retraction - def _execute_clear_retraction(self): - if self.z_hop_height > 0.0: - # Re-establish regular G1 command if zhop enabled. - # zhop will be reversed on next move with z coordinate - self._re_register_G1() - self.G1_toggle_state = False # Prevent repeat re-register + self._execute_clear_z_hop() self.is_retracted = False # Reset retract flag to enable G10 command - self._get_config_params() # Reset retraction parameters to config values - - # Gcode Command G10 to perform firmware retraction - def cmd_G10(self, gcmd): - retract_gcode = "" # Reset retract string - zhop_gcode = "" # Reset zhop move string - - if self.retract_length == 0.0: # Check if FW retraction enabled - gcmd.respond_info( - "Retraction length zero. Firmware retraction \ - disabled. Command ignored!" - ) - elif not self.is_retracted: # If filament isn't retracted, build G-Code - # Incl move command if z_hop_height > 0 - if self.z_hop_height > 0.0: - # Determine z coordinate for zhop move - self._set_zhop_move_params() - # Set zhop gcode move - zhop_gcode = ("G1 Z{:.5f} F{}\n").format( - self.z_hop_Z, - int(ZHOP_MOVE_SPEED_FRACTION * self.max_vel * 60), - ) + gcmd.respond_info( + "Retraction was cleared. zhop is undone on next move." + ) - retract_gcode = ( - "SAVE_GCODE_STATE NAME=_retract_state\n" - "G91\n" - "G1 E-{:.5f} F{}\n" # Retract filament at retract speed - "G90\n" # Switch to absolute mode (just in case) - "{}" - "RESTORE_GCODE_STATE NAME=_retract_state" - ).format( - self.retract_length, int(self.retract_speed * 60), zhop_gcode - ) + # Command to reset retraction parameters + cmd_RESET_RETRACTION_help = "Reset retraction parameters to default values" - self.gcode.run_script_from_command(retract_gcode) - self.is_retracted = True + def cmd_RESET_RETRACTION(self, gcmd): + self._get_config_params() # Reset retraction parameters to config values - if self.z_hop_height > 0.0: - # Swap original G1 handlers if z_hop enabled to offset following - # moves in eiter absolute or relative mode - self._unregister_G1() - self.G1_toggle_state = ( - True # Prevent repeat unregister with flag - ) + # Helper to clear z_hop + def _execute_clear_z_hop(self, *args): + self.do_zhop = False + self.current_z_hop_height = 0.0 # prevent nozzle crash if G11 occurs + # Helper to skip command while in exclude object + def _test_in_excluded_region(self): + if self.exclude_objects is not None: + return self.exclude_objects._test_in_excluded_region() else: - gcmd.respond_info("Printer is already retracted. Command ignored!") - - # Helper to determine zhop coordinate - def _set_zhop_move_params(self): - self.currentPos = self._get_gcode_pos() - self.currentZ = self.currentPos[2] - self.z_hop_Z = self.currentZ + self.z_hop_height + return False - # Helper to get current gcode position - def _get_gcode_pos(self): - # Get current gcode position for z_hop move if enabled - gcodestatus = self.gcode_move.get_status() - currentPos = gcodestatus["gcode_position"] - return currentPos + # Gcode Command G10 to perform firmware retraction + def cmd_G10(self, gcmd): + extrude_factor, speed_factor = self._get_factors() + + if ( + not self.is_retracted and not self._test_in_excluded_region() + ): # If filament isn't retracted + # Check if FW retraction enabled + if self.retract_length == 0.0 and self.z_hop_height == 0.0: + gcmd.respond_info( + "Retraction length and z_hop zero. Firmware retraction " + "disabled. G10 Command ignored!" + ) + else: + # Store retract parameters for moves when retracted until next G11 + self.current_unretract_length = self.unretract_length + self.current_unretract_speed = self.unretract_speed + self._execute_clear_z_hop() + # get position (track of bed_mesh, z_thermal_adjust changes) + position = self.get_position() + # do retraction + if self.retract_length > 0.0: + position[3] -= self.retract_length * extrude_factor + self.move(position, self.retract_speed * speed_factor) + # do zhop + if self._limit_zhop(gcmd, position): + self.do_zhop = True + self.move( + position, + ZHOP_MOVE_SPEED_FRACTION + * self.max_z_vel + * speed_factor, + ) + # update toolhead position + self.gcode_move.reset_last_position() + self.is_retracted = True # GCode Command G11 to perform filament unretraction def cmd_G11(self, gcmd): - unretract_gcode = "" # Reset unretract string - unzhop_gcode = "" # Reset un-zhop move string - - if self.retract_length == 0.0: # Check if FW retraction enabled - gcmd.respond_info( - "Retraction length zero. Firmware retraction \ - disabled. Command ignored!" - ) - elif self.is_retracted: # Check if the filament is retracted - if self.z_hop_height > 0.0: - self._re_register_G1() # Restore G1 handlers if z_hop on - self.G1_toggle_state = False # Prevent repeat re-register - # Set unzhop gcode move - unzhop_gcode = ("G1 Z-{:.5f} F{}\n").format( - self.z_hop_height, - int(ZHOP_MOVE_SPEED_FRACTION * self.max_vel * 60), + extrude_factor, speed_factor = self._get_factors() + if ( + self.is_retracted and not self._test_in_excluded_region() + ): # Check if the filament is retracted + if ( + self.current_unretract_length == 0.0 + and self.current_z_hop_height == 0.0 + ): # Check if FW retraction enabled + gcmd.respond_info( + "Retraction length and z_hop zero. Firmware retraction " + "disabled. G11 Command ignored!" ) - - unretract_gcode = ( - "SAVE_GCODE_STATE NAME=_unretract_state\n" - "G91\n" - "{}" - "G1 E{:.5f} F{}\n" # Unretract filament - "RESTORE_GCODE_STATE NAME=_unretract_state" - ).format( - unzhop_gcode, - self.unretract_length, - int(self.unretract_speed * 60), + else: + # get position (track of bed_mesh, z_thermal_adjust changes) + position = self.get_position() + # undo zhop + self._execute_clear_z_hop() + self.move( + position, + ZHOP_MOVE_SPEED_FRACTION * self.max_z_vel * speed_factor, + ) + # un-retract + if self.current_unretract_length > 0.0: + position[3] += ( + self.current_unretract_length * extrude_factor + ) + self.move( + position, self.current_unretract_speed * speed_factor + ) + # update toolhead position + self.gcode_move.reset_last_position() + self.is_retracted = False + + # gcode_move transform position helper + def get_position(self): + position = self.next_transform.get_position() + position[2] -= self.current_z_hop_height + self.last_position[:] = position + return position + + # gcode_move transform move helper + def move(self, newpos, speed): + # cancel zhop on z moves + if ( + self.do_zhop + and self.clear_zhop + and newpos[2] != self.last_position[2] + ): + self._execute_clear_z_hop() + + adjusted_pos = [ + newpos[0], + newpos[1], + newpos[2] + self.current_z_hop_height, + newpos[3], + ] + self.next_transform.move(adjusted_pos, speed) + self.last_position[:] = newpos + + # Helper to limit z_hop while z_max is reached + def _limit_zhop(self, gcmd, pos): + z_margin = self.maximum_z - pos[2] - MAX_Z_MARGIN + if self.z_hop_height > z_margin: + self.current_z_hop_height = max(0, z_margin) + gcmd.respond_info( + "firmware_retraction : z_hop is limited to %.5f" + % self.current_z_hop_height ) - - self.gcode.run_script_from_command(unretract_gcode) - self.is_retracted = False # Set the flag to filament unretracted else: - gcmd.respond_info("Printer is not retracted. Command ignored!") - - # Register new G1 command handler - def _unregister_G1(self): - # Change handler only if G1 command has not been toggled before - if not self.G1_toggle_state: - self._toggle_gcode_comms( - "G1.20140114", - "G1", - self._G1_zhop, - "G1 command that accounts for z hop when retracted", - self.G1_toggle_state, - ) - self._toggle_gcode_comms( - "G0.20140114", - "G0", - self._G1_zhop, - "G0 command that accounts for z hop when retracted", - self.G1_toggle_state, - ) + self.current_z_hop_height = self.z_hop_height + return self.current_z_hop_height > 0.0 - # Helper to toggle/untoggle command handlers and methods - def _toggle_gcode_comms( - self, - new_cmd_name, - old_cmd_name, - new_cmd_func, - new_cmd_desc, - toggle_state, - ): - # Unregister current method from current handler and store in prev_cmd - prev_cmd = self.gcode.register_command(old_cmd_name, None) - pdesc = 'Renamed builtin of "%s"' % old_cmd_name - if not toggle_state: - # Register prev method to toggled handler, indicate built-in command - self.gcode.register_command(new_cmd_name, prev_cmd, desc=pdesc) - self.gcode.register_command( - old_cmd_name, new_cmd_func, desc=new_cmd_desc - ) # Register toggled method to command handler - else: - # Unregister toggled command from the untoggled handler - self.gcode.register_command(new_cmd_name, new_cmd_func) - self.gcode.register_command( - new_cmd_name, prev_cmd, desc=new_cmd_desc - ) # Register untoggled method to untog handler - - # G1 method that accounts for z-hop by altering the z-coordinates - # Offsets are not touched to prevent incompatibility issues with user macros - def _G1_zhop(self, gcmd): - params = gcmd.get_command_parameters() - is_relative = self._toolhead_is_relative() - - if "Z" in params and not is_relative: - # In absolute, adjust Z param to account for Z-hop offset - params["Z"] = str(float(params["Z"]) + self.z_hop_height) - # In relative, don't adjust as Z-hop offset considered before - - new_g1_command = "G1.20140114" - for key, value in params.items(): - new_g1_command += " {0}{1}".format(key, value) - - # Run originl G1 (renamed G1.20140114) with adjusted parameters - self.gcode.run_script_from_command(new_g1_command) - - # Helper to get absolute/relative mode - def _toolhead_is_relative(self): + # Helper to get extrude_factor & speed_factor + def _get_factors(self): gcodestatus = self.gcode_move.get_status() - movemode = gcodestatus["absolute_coordinates"] - return not movemode - - # Re-register old G1 command handler - def _re_register_G1(self): - # Change handler only if G1 command has been toggled before - if self.G1_toggle_state: - self._toggle_gcode_comms( - "G1", "G1.20140114", None, "cmd_G1_help", self.G1_toggle_state - ) - self._toggle_gcode_comms( - "G0", "G0.20140114", None, "cmd_G1_help", self.G1_toggle_state - ) + return [gcodestatus["extrude_factor"], gcodestatus["speed_factor"]] def load_config(config): diff --git a/test/klippy/firmware_retraction_with_VSDCard.cfg b/test/klippy/firmware_retraction.cfg similarity index 70% rename from test/klippy/firmware_retraction_with_VSDCard.cfg rename to test/klippy/firmware_retraction.cfg index 6bd527fa5..834507b71 100644 --- a/test/klippy/firmware_retraction_with_VSDCard.cfg +++ b/test/klippy/firmware_retraction.cfg @@ -1,7 +1,4 @@ -# Config for firmware_retraction testing with Virtual SD Card module enabled -[virtual_sdcard] -path: test/klippy/sdcard_loop - +# Config for firmware_retraction testing while reset_on_clear is False [display_status] [respond] @@ -13,6 +10,7 @@ retract_speed: 45.0 unretract_extra_length: 0.0 unretract_speed: 45.0 z_hop_height: 0.4 +clear_zhop_on_z_moves: True [stepper_x] step_pin: PF0 @@ -111,6 +109,23 @@ gcode: {% endif %} {% endif %} +[gcode_macro VERIFY_TOOLHEAD_POSITION] +gcode: + {% set axis_name = params.AXIS %} + {% set expected_position = params.EXPECTED|float %} + {% set axisstate_verbose = False %} + + {% set current_axis_position = printer.toolhead.position[axis_name] %} + + {% if current_axis_position != expected_position %} + {action_raise_error("Wrong toolhead position for %s. Expected %f, got %f" + % (axis_name, expected_position, current_axis_position))} + {% else %} + {% if axisstate_verbose %} + M118 TOOLHEAD POSITION {axis_name} OK! + {% endif %} + {% endif %} + [gcode_macro CHECK_RECTRACTION_CLEARED] gcode: {% set retract_state = False %} @@ -118,3 +133,11 @@ gcode: {% if retract_state == True %} {action_raise_error("Retraction should be cleared!")} {% endif%} + +[gcode_macro CHECK_ZHOP_CLEARED] +gcode: + {% set zhop_state = False %} + {% set zhop_state = printer.firmware_retraction.zhop_state %} + {% if zhop_state == True %} + {action_raise_error("ZHOP should be cleared!")} + {% endif%} diff --git a/test/klippy/firmware_retraction.test b/test/klippy/firmware_retraction.test new file mode 100644 index 000000000..9aea1bc36 --- /dev/null +++ b/test/klippy/firmware_retraction.test @@ -0,0 +1,98 @@ +# Tests Firmware retraction G10 and G11 + +DICTIONARY atmega2560.dict +CONFIG firmware_retraction.cfg + +CLEAR_RETRACTION +G90 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=0.0 +G28 + +####################################################### TESTING FIMWARE RETRACTION +G1 X90.0 Y90.0 Z20.0 + +SET_RETRACTION RETRACT_LENGTH=2.5 UNRETRACT_EXTRA_LENGTH=0 Z_HOP_HEIGHT=2.0 +# Test CLEAR_RETRACTION while unretracted +CLEAR_RETRACTION +CHECK_RECTRACTION_CLEARED + +# Test CLEAR_RETRACTION while retracted +G10 +VERIFY_AXIS_POSITION AXIS=z EXPECTED=20 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=22 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-2.5 +CLEAR_RETRACTION +CHECK_RECTRACTION_CLEARED +CHECK_ZHOP_CLEARED +VERIFY_AXIS_POSITION AXIS=z EXPECTED=20 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=22 +G1 X90.0 Y90.0 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=20 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-2.5 + +# Unretract after clearing retraction +G11 +VERIFY_AXIS_POSITION AXIS=z EXPECTED=20 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=20 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-2.5 + +# Test CLEAR_RETRACTION while retracted, 2nd go +SET_RETRACTION Z_HOP_HEIGHT=3.0 +G10 +VERIFY_AXIS_POSITION AXIS=z EXPECTED=20 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=23 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-5 +CLEAR_RETRACTION +CHECK_RECTRACTION_CLEARED +CHECK_ZHOP_CLEARED +VERIFY_AXIS_POSITION AXIS=z EXPECTED=20 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=23 +G1 X90.0 Y90.0 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=20 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-5.0 + +# Test Clear_zhop on home +G10 +VERIFY_AXIS_POSITION AXIS=z EXPECTED=20.0 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=23 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-7.5 +G28 +CHECK_ZHOP_CLEARED +G1 X90.0 Y90.0 Z20.0 +G11 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-5 + +# Test Clear_zhop on z moves +G10 +VERIFY_AXIS_POSITION AXIS=z EXPECTED=20.0 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=23 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-7.5 +G1 X100.0 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=23 +G1 Z30.0 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=30 +CHECK_ZHOP_CLEARED +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-7.5 +G11 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=30 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-5 +G1 Z20.0 + +# Test RESET_RETRACTION +G10 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-7.5 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=23 +RESET_RETRACTION +G1 X90.0 Y90.0 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-7.5 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=23 +G11 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-5 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=20 +G10 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-8 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=20.4 +G11 +VERIFY_AXIS_POSITION AXIS=e EXPECTED=-5 +VERIFY_TOOLHEAD_POSITION AXIS=z EXPECTED=20 +M118 Test successful! diff --git a/test/klippy/firmware_retraction_with_VSDCard.test b/test/klippy/firmware_retraction_with_VSDCard.test deleted file mode 100644 index 45100cde4..000000000 --- a/test/klippy/firmware_retraction_with_VSDCard.test +++ /dev/null @@ -1,212 +0,0 @@ -# Tests Firmware retraction G10 and G11 with Virtual SD Card ENABLED - -DICTIONARY atmega2560.dict -CONFIG firmware_retraction_with_VSDCard.cfg - -CLEAR_RETRACTION -G90 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=0.0 - -################################### CHECK DISABLED RETRACTION WITH ZHOP DISABLED -G28 -SET_RETRACTION RETRACT_LENGTH=0.0 UNRETRACT_EXTRA_LENGTH=0.0 Z_HOP_HEIGHT=0.0 -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=0.0 -G11 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=0.0 - -############# CHECK RETRACTION CLEAR ON STEPPER DISABLE EVENT WITH ZHOP DISABLED -SET_RETRACTION RETRACT_LENGTH=2.5 UNRETRACT_EXTRA_LENGTH=1.0 Z_HOP_HEIGHT=0.0 -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-2.5 -M84 -CHECK_RECTRACTION_CLEARED - -###################### CHECK RETRACTION CLEAR ON HOMING EVENT WITH ZHOP DISABLED -G28 -SET_RETRACTION RETRACT_LENGTH=2.5 UNRETRACT_EXTRA_LENGTH=1.0 Z_HOP_HEIGHT=0.0 -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-5.0 -G28 -CHECK_RECTRACTION_CLEARED - -############## CHECK RETRACTION CLEAR ON STEPPER DISABLE EVENT WITH ZHOP ENABLED -SET_RETRACTION RETRACT_LENGTH=2.5 UNRETRACT_EXTRA_LENGTH=1.0 Z_HOP_HEIGHT=2.0 -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-7.5 -M84 -CHECK_RECTRACTION_CLEARED - -####################### CHECK RETRACTION CLEAR ON HOMING EVENT WITH ZHOP ENABLED -G28 -SET_RETRACTION RETRACT_LENGTH=2.5 UNRETRACT_EXTRA_LENGTH=1.0 Z_HOP_HEIGHT=2.0 -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-10.0 -G28 -CHECK_RECTRACTION_CLEARED - -############################################## SET PRINTER UP FOR MOVEMENT TESTS -SET_RETRACTION RETRACT_LENGTH=2.5 UNRETRACT_EXTRA_LENGTH=1.0 Z_HOP_HEIGHT=0.0 -G1 X100.0 Y100.0 Z20.0 -G91 -G1 E10.0 -G90 - -####################################################### TESTING FW WITHOUT Z_HOP - -# Unretract in unretract state -G11 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=0.0 - -# Retract in unretract state -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-2.5 - -# Repeat Retract -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-2.5 - -# Unretract in retract state -G11 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=1.0 - -# Second round: Retract in unretract state -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Second round: Unretract in retract state -G11 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=2.0 -# Compensate for second round -G91 -G1 E-1.0 -G90 - -###################################################### TESTING FW Z_HOP STANDARD - -SET_RETRACTION UNRETRACT_EXTRA_LENGTH=0.0 -SET_RETRACTION Z_HOP_HEIGHT=2.0 - -# Retract with Standard zhop -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Repeat retract with Standard zhop -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Unretract with Standard zhop in retract state -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=20.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=1.0 - -# Second round: Retract with Standard zhop -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Second round: Unretract with Standard zhop in retract state -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=20.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=1.0 - -#################################### TESTING CHANGE Z_HOP_HEIGHT WHILE RETRACTED - -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 -SET_RETRACTION Z_HOP_HEIGHT=3.0 -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=20.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=1.0 - -################ TESTING MOVE Z WHILE RETRACTED WITH SWITCH TO RELATIVE AND BACK - -SET_RETRACTION Z_HOP_HEIGHT=2.0 -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Switch to relative mode while retracted -G91 -G1 Z-10.0 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=12.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Switch back to absolute mode -G90 -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=10.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=1.0 - -################################################ TESTING MOVE XY WHILE RETRACTED - -# Test XY Move in Standard -G1 Z20.0 -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -G1 X90.0 Y90.0 -VERIFY_AXIS_POSITION AXIS=x EXPECTED=90.0 -VERIFY_AXIS_POSITION AXIS=y EXPECTED=90.0 - -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=20.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=1.0 - -G1 X100.0 Y100.0 -VERIFY_AXIS_POSITION AXIS=x EXPECTED=100.0 -VERIFY_AXIS_POSITION AXIS=y EXPECTED=100.0 - -####################################################### TESTING CLEAR RETRACTION -G1 X90.0 Y90.0 Z20.0 - -# Test CLEAR_RETRACTION while unretracted -CLEAR_RETRACTION - -# Test CLEAR_RETRACTION while retracted -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 -CLEAR_RETRACTION -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Unretract after clearing retraction -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Test CLEAR_RETRACTION while retracted, 2nd go -SET_RETRACTION Z_HOP_HEIGHT=2.0 -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=24.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-4.5 -CLEAR_RETRACTION -VERIFY_AXIS_POSITION AXIS=z EXPECTED=24.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-4.5 - -# Unretract after clearing retraction and retracting -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=24.4 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-7.5 -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=24.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-4.5 -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=24.4 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-7.5 - -# Test first move with z coordinate after retraction was cleared -G1 X100.0 Y100.0 Z28.0 -VERIFY_AXIS_POSITION AXIS=x EXPECTED=100.0 -VERIFY_AXIS_POSITION AXIS=y EXPECTED=100.0 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=28.4 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-7.5 -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=28.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-4.5 -M118 Test successful! diff --git a/test/klippy/firmware_retraction_without_VSDCard.cfg b/test/klippy/firmware_retraction_without_VSDCard.cfg deleted file mode 100644 index 7364eec9b..000000000 --- a/test/klippy/firmware_retraction_without_VSDCard.cfg +++ /dev/null @@ -1,117 +0,0 @@ -# Config for firmware_retraction testing with Virtual SD Card module disabled -[display_status] - -[respond] -default_type: command - -[firmware_retraction] -retract_length: 3.0 -retract_speed: 45.0 -unretract_extra_length: 0.0 -unretract_speed: 45.0 -z_hop_height: 0.4 - -[stepper_x] -step_pin: PF0 -dir_pin: PF1 -enable_pin: !PD7 -microsteps: 16 -rotation_distance: 40 -endstop_pin: ^PE5 -position_endstop: 0 -position_max: 224 -homing_speed: 50 - -[stepper_y] -step_pin: PF6 -dir_pin: !PF7 -enable_pin: !PF2 -microsteps: 16 -rotation_distance: 40 -endstop_pin: ^PJ1 -position_endstop: 0 -position_max: 220 -homing_speed: 50 - -[stepper_z] -step_pin: PL3 -dir_pin: PL1 -enable_pin: !PK0 -microsteps: 16 -rotation_distance: 8 -endstop_pin: ^PD3 -position_endstop: 0 -position_max: 200 - -[extruder] -step_pin: PA4 -dir_pin: PA6 -enable_pin: !PA2 -microsteps: 16 -rotation_distance: 33.5 -nozzle_diameter: 0.400 -filament_diameter: 1.750 -heater_pin: PB4 -sensor_type: EPCOS 100K B57560G104F -sensor_pin: PK5 -control: pid -pid_Kp: 22.2 -pid_Ki: 1.08 -pid_Kd: 114 -min_temp: 0 -max_temp: 210 -min_extrude_temp: 0 - -[heater_bed] -heater_pin: PH5 -sensor_type: EPCOS 100K B57560G104F -sensor_pin: PK6 -control: watermark -min_temp: 0 -max_temp: 110 - -[mcu] -serial: /dev/ttyACM0 - -[printer] -kinematics: cartesian -max_velocity: 300 -max_accel: 3000 -max_z_velocity: 5 -max_z_accel: 100 - -[gcode_arcs] -resolution: 0.1 - -[homing_override] -gcode: - G28 X0 - G28 Y0 - G1 X112 Y110 - G28 Z0 - G1 X112 Y110 Z8 - -[gcode_macro VERIFY_AXIS_POSITION] -gcode: - {% set axis_name = params.AXIS %} - {% set expected_position = params.EXPECTED|float %} - {% set axisstate_verbose = False %} - - {% set current_axis_position = printer.gcode_move.position[axis_name] %} - - {% if current_axis_position != expected_position %} - {action_raise_error("Wrong axis position for %s. Expected %f, got %f" - % (axis_name, expected_position, current_axis_position))} - {% else %} - {% if axisstate_verbose %} - M118 Axis {axis_name} OK! - {% endif %} - {% endif %} - -[gcode_macro CHECK_RECTRACTION_CLEARED] -gcode: - {% set retract_state = False %} - {% set retract_state = printer.firmware_retraction.retract_state %} - {% if retract_state == True %} - {action_raise_error("Retraction should be cleared!")} - {% endif%} diff --git a/test/klippy/firmware_retraction_without_VSDCard.test b/test/klippy/firmware_retraction_without_VSDCard.test deleted file mode 100644 index bea144032..000000000 --- a/test/klippy/firmware_retraction_without_VSDCard.test +++ /dev/null @@ -1,212 +0,0 @@ -# Tests Firmware retraction G10 and G11 with Virtual SD Card DISABLED - -DICTIONARY atmega2560.dict -CONFIG firmware_retraction_without_VSDCard.cfg - -CLEAR_RETRACTION -G90 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=0.0 - -################################### CHECK DISABLED RETRACTION WITH ZHOP DISABLED -G28 -SET_RETRACTION RETRACT_LENGTH=0.0 UNRETRACT_EXTRA_LENGTH=0.0 Z_HOP_HEIGHT=0.0 -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=0.0 -G11 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=0.0 - -############# CHECK RETRACTION CLEAR ON STEPPER DISABLE EVENT WITH ZHOP DISABLED -SET_RETRACTION RETRACT_LENGTH=2.5 UNRETRACT_EXTRA_LENGTH=1.0 Z_HOP_HEIGHT=0.0 -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-2.5 -M84 -CHECK_RECTRACTION_CLEARED - -###################### CHECK RETRACTION CLEAR ON HOMING EVENT WITH ZHOP DISABLED -G28 -SET_RETRACTION RETRACT_LENGTH=2.5 UNRETRACT_EXTRA_LENGTH=1.0 Z_HOP_HEIGHT=0.0 -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-5.0 -G28 -CHECK_RECTRACTION_CLEARED - -############## CHECK RETRACTION CLEAR ON STEPPER DISABLE EVENT WITH ZHOP ENABLED -SET_RETRACTION RETRACT_LENGTH=2.5 UNRETRACT_EXTRA_LENGTH=1.0 Z_HOP_HEIGHT=2.0 -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-7.5 -M84 -CHECK_RECTRACTION_CLEARED - -####################### CHECK RETRACTION CLEAR ON HOMING EVENT WITH ZHOP ENABLED -G28 -SET_RETRACTION RETRACT_LENGTH=2.5 UNRETRACT_EXTRA_LENGTH=1.0 Z_HOP_HEIGHT=2.0 -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-10.0 -G28 -CHECK_RECTRACTION_CLEARED - -############################################## SET PRINTER UP FOR MOVEMENT TESTS -SET_RETRACTION RETRACT_LENGTH=2.5 UNRETRACT_EXTRA_LENGTH=1.0 Z_HOP_HEIGHT=0.0 -G1 X100.0 Y100.0 Z20.0 -G91 -G1 E10.0 -G90 - -####################################################### TESTING FW WITHOUT Z_HOP - -# Unretract in unretract state -G11 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=0.0 - -# Retract in unretract state -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-2.5 - -# Repeat Retract -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-2.5 - -# Unretract in retract state -G11 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=1.0 - -# Second round: Retract in unretract state -G10 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Second round: Unretract in retract state -G11 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=2.0 -# Compensate for second round -G91 -G1 E-1.0 -G90 - -###################################################### TESTING FW Z_HOP STANDARD - -SET_RETRACTION UNRETRACT_EXTRA_LENGTH=0.0 -SET_RETRACTION Z_HOP_HEIGHT=2.0 - -# Retract with Standard zhop -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Repeat retract with Standard zhop -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Unretract with Standard zhop in retract state -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=20.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=1.0 - -# Second round: Retract with Standard zhop -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Second round: Unretract with Standard zhop in retract state -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=20.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=1.0 - -#################################### TESTING CHANGE Z_HOP_HEIGHT WHILE RETRACTED - -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 -SET_RETRACTION Z_HOP_HEIGHT=3.0 -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=20.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=1.0 - -################ TESTING MOVE Z WHILE RETRACTED WITH SWITCH TO RELATIVE AND BACK - -SET_RETRACTION Z_HOP_HEIGHT=2.0 -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Switch to relative mode while retracted -G91 -G1 Z-10.0 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=12.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Switch back to absolute mode -G90 -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=10.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=1.0 - -################################################ TESTING MOVE XY WHILE RETRACTED - -# Test XY Move in Standard -G1 Z20.0 -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -G1 X90.0 Y90.0 -VERIFY_AXIS_POSITION AXIS=x EXPECTED=90.0 -VERIFY_AXIS_POSITION AXIS=y EXPECTED=90.0 - -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=20.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=1.0 - -G1 X100.0 Y100.0 -VERIFY_AXIS_POSITION AXIS=x EXPECTED=100.0 -VERIFY_AXIS_POSITION AXIS=y EXPECTED=100.0 - -####################################################### TESTING CLEAR RETRACTION -G1 X90.0 Y90.0 Z20.0 - -# Test CLEAR_RETRACTION while unretracted -CLEAR_RETRACTION - -# Test CLEAR_RETRACTION while retracted -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 -CLEAR_RETRACTION -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Unretract after clearing retraction -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=22.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-1.5 - -# Test CLEAR_RETRACTION while retracted, 2nd go -SET_RETRACTION Z_HOP_HEIGHT=2.0 -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=24.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-4.5 -CLEAR_RETRACTION -VERIFY_AXIS_POSITION AXIS=z EXPECTED=24.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-4.5 - -# Unretract after clearing retraction and retracting -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=24.4 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-7.5 -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=24.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-4.5 -G10 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=24.4 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-7.5 - -# Test first move with z coordinate after retraction was cleared -G1 X100.0 Y100.0 Z28.0 -VERIFY_AXIS_POSITION AXIS=x EXPECTED=100.0 -VERIFY_AXIS_POSITION AXIS=y EXPECTED=100.0 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=28.4 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-7.5 -G11 -VERIFY_AXIS_POSITION AXIS=z EXPECTED=28.0 -VERIFY_AXIS_POSITION AXIS=e EXPECTED=-4.5 -M118 Test successful!