diff --git a/shaketune/commands/axes_map_calibration.py b/shaketune/commands/axes_map_calibration.py index 0b17ee3..b310949 100644 --- a/shaketune/commands/axes_map_calibration.py +++ b/shaketune/commands/axes_map_calibration.py @@ -41,11 +41,15 @@ def axes_map_calibration(gcmd, config, st_process: ShakeTuneProcess) -> None: toolhead_info = toolhead.get_status(systime) old_accel = toolhead_info['max_accel'] - old_mcr = toolhead_info['minimum_cruise_ratio'] old_sqv = toolhead_info['square_corner_velocity'] # set the wanted acceleration values - gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={accel} MINIMUM_CRUISE_RATIO=0 SQUARE_CORNER_VELOCITY=5.0') + if 'minimum_cruise_ratio' in toolhead_info: + old_mcr = toolhead_info['minimum_cruise_ratio'] # minimum_cruise_ratio found: Klipper >= v0.12.0-239 + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={accel} MINIMUM_CRUISE_RATIO=0 SQUARE_CORNER_VELOCITY=5.0') + else: # minimum_cruise_ratio not found: Klipper < v0.12.0-239 + old_mcr = None + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={accel} SQUARE_CORNER_VELOCITY=5.0') # Deactivate input shaper if it is active to get raw movements input_shaper = printer.lookup_object('input_shaper', None) @@ -89,9 +93,11 @@ def axes_map_calibration(gcmd, config, st_process: ShakeTuneProcess) -> None: input_shaper.enable_shaping() # Restore the previous acceleration values - gcode.run_script_from_command( - f'SET_VELOCITY_LIMIT ACCEL={old_accel} MINIMUM_CRUISE_RATIO={old_mcr} SQUARE_CORNER_VELOCITY={old_sqv}' - ) + if old_mcr is not None: # minimum_cruise_ratio found: Klipper >= v0.12.0-239 + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={old_accel} MINIMUM_CRUISE_RATIO={old_mcr} SQUARE_CORNER_VELOCITY={old_sqv}') + else: # minimum_cruise_ratio not found: Klipper < v0.12.0-239 + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={old_accel} SQUARE_CORNER_VELOCITY={old_sqv}') + toolhead.wait_moves() # Run post-processing diff --git a/shaketune/commands/axes_shaper_calibration.py b/shaketune/commands/axes_shaper_calibration.py index f616e11..051f71b 100644 --- a/shaketune/commands/axes_shaper_calibration.py +++ b/shaketune/commands/axes_shaper_calibration.py @@ -76,8 +76,12 @@ def axes_shaper_calibration(gcmd, config, st_process: ShakeTuneProcess) -> None: # set the needed acceleration values for the test toolhead_info = toolhead.get_status(systime) old_accel = toolhead_info['max_accel'] - old_mcr = toolhead_info['minimum_cruise_ratio'] - gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={max_accel} MINIMUM_CRUISE_RATIO=0') + if 'minimum_cruise_ratio' in toolhead_info: # minimum_cruise_ratio found: Klipper >= v0.12.0-239 + old_mcr = toolhead_info['minimum_cruise_ratio'] + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={max_accel} MINIMUM_CRUISE_RATIO=0') + else: # minimum_cruise_ratio not found: Klipper < v0.12.0-239 + old_mcr = None + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={max_accel}') # Deactivate input shaper if it is active to get raw movements input_shaper = printer.lookup_object('input_shaper', None) @@ -115,6 +119,9 @@ def axes_shaper_calibration(gcmd, config, st_process: ShakeTuneProcess) -> None: # Re-enable the input shaper if it was active if input_shaper is not None: input_shaper.enable_shaping() - + # Restore the previous acceleration values - gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={old_accel} MINIMUM_CRUISE_RATIO={old_mcr}') + if old_mcr is not None: # minimum_cruise_ratio found: Klipper >= v0.12.0-239 + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={old_accel} MINIMUM_CRUISE_RATIO={old_mcr}') + else: # minimum_cruise_ratio not found: Klipper < v0.12.0-239 + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={old_accel}') diff --git a/shaketune/commands/compare_belts_responses.py b/shaketune/commands/compare_belts_responses.py index 4342989..f5d578c 100644 --- a/shaketune/commands/compare_belts_responses.py +++ b/shaketune/commands/compare_belts_responses.py @@ -88,9 +88,13 @@ def compare_belts_responses(gcmd, config, st_process: ShakeTuneProcess) -> None: # set the needed acceleration values for the test toolhead_info = toolhead.get_status(systime) - old_accel = toolhead_info['max_accel'] - old_mcr = toolhead_info['minimum_cruise_ratio'] - gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={max_accel} MINIMUM_CRUISE_RATIO=0') + old_accel = toolhead_info['max_accel'] + if 'minimum_cruise_ratio' in toolhead_info: # minimum_cruise_ratio found: Klipper >= v0.12.0-239 + old_mcr = toolhead_info['minimum_cruise_ratio'] + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={max_accel} MINIMUM_CRUISE_RATIO=0') + else: # minimum_cruise_ratio not found: Klipper < v0.12.0-239 + old_mcr = None + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={max_accel}') # Deactivate input shaper if it is active to get raw movements input_shaper = printer.lookup_object('input_shaper', None) @@ -112,7 +116,10 @@ def compare_belts_responses(gcmd, config, st_process: ShakeTuneProcess) -> None: input_shaper.enable_shaping() # Restore the previous acceleration values - gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={old_accel} MINIMUM_CRUISE_RATIO={old_mcr}') + if old_mcr is not None: # minimum_cruise_ratio found: Klipper >= v0.12.0-239 + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={old_accel} MINIMUM_CRUISE_RATIO={old_mcr}') + else: # minimum_cruise_ratio not found: Klipper < v0.12.0-239 + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={old_accel}') # Run post-processing ConsoleOutput.print('Belts comparative frequency profile generation...') diff --git a/shaketune/commands/create_vibrations_profile.py b/shaketune/commands/create_vibrations_profile.py index efdc54a..06bd5a7 100644 --- a/shaketune/commands/create_vibrations_profile.py +++ b/shaketune/commands/create_vibrations_profile.py @@ -59,11 +59,15 @@ def create_vibrations_profile(gcmd, config, st_process: ShakeTuneProcess) -> Non toolhead_info = toolhead.get_status(systime) old_accel = toolhead_info['max_accel'] - old_mcr = toolhead_info['minimum_cruise_ratio'] old_sqv = toolhead_info['square_corner_velocity'] # set the wanted acceleration values - gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={accel} MINIMUM_CRUISE_RATIO=0 SQUARE_CORNER_VELOCITY=5.0') + if 'minimum_cruise_ratio' in toolhead_info: # minimum_cruise_ratio found: Klipper >= v0.12.0-239 + old_mcr = toolhead_info['minimum_cruise_ratio'] + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={accel} MINIMUM_CRUISE_RATIO=0 SQUARE_CORNER_VELOCITY=5.0') + else: # minimum_cruise_ratio not found: Klipper < v0.12.0-239 + old_mcr = None + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={accel} SQUARE_CORNER_VELOCITY=5.0') kin_info = toolhead.kin.get_status(systime) mid_x = (kin_info['axis_minimum'].x + kin_info['axis_maximum'].x) / 2 @@ -133,10 +137,11 @@ def create_vibrations_profile(gcmd, config, st_process: ShakeTuneProcess) -> Non accelerometer.wait_for_file_writes() - # Restore the previous acceleration values - gcode.run_script_from_command( - f'SET_VELOCITY_LIMIT ACCEL={old_accel} MINIMUM_CRUISE_RATIO={old_mcr} SQUARE_CORNER_VELOCITY={old_sqv}' - ) + # Restore the previous acceleration values + if old_mcr is not None: # minimum_cruise_ratio found: Klipper >= v0.12.0-239 + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={old_accel} MINIMUM_CRUISE_RATIO={old_mcr} SQUARE_CORNER_VELOCITY={old_sqv}') + else: # minimum_cruise_ratio not found: Klipper < v0.12.0-239 + gcode.run_script_from_command(f'SET_VELOCITY_LIMIT ACCEL={old_accel} SQUARE_CORNER_VELOCITY={old_sqv}') toolhead.wait_moves() # Run post-processing