From b6ec4d0229f8384e053c783f7ffb6ff0eb74eebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Fri, 24 May 2024 21:17:58 +0200 Subject: [PATCH] fixed vibration accelermeter chip selection logic --- shaketune/measurement/vibrations_profile.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/shaketune/measurement/vibrations_profile.py b/shaketune/measurement/vibrations_profile.py index 6f7a846..fcf40ff 100644 --- a/shaketune/measurement/vibrations_profile.py +++ b/shaketune/measurement/vibrations_profile.py @@ -34,13 +34,10 @@ def create_vibrations_profile(gcmd, config, st_thread: ShakeTuneThread) -> None: gcmd.error('Input shaper is not configured! Please run the shaper calibration macro first.') motors_config_parser = MotorsConfigParser(config, motors=['stepper_x', 'stepper_y']) - if motors_config_parser.kinematics == 'cartesian' or motors_config_parser.kinematics == 'corexz': - # Cartesian motors are on X and Y axis directly, same for CoreXZ - main_angles = [0, 90] + main_angles = [0, 90] # Cartesian motors are on X and Y axis directly, same for CoreXZ elif motors_config_parser.kinematics == 'corexy': - # CoreXY motors are on A and B axis (45 and 135 degrees) - main_angles = [45, 135] + main_angles = [45, 135] # CoreXY motors are on A and B axis (45 and 135 degrees) else: gcmd.error( 'Only Cartesian, CoreXY and CoreXZ kinematics are supported at the moment for the vibrations measurement tool!' @@ -74,13 +71,14 @@ def create_vibrations_profile(gcmd, config, st_thread: ShakeTuneThread) -> None: # and then find the best accelerometer chip for the current angle if not manually specified angle_to_axis = {0: 'x', 90: 'y'} accel_axis = angle_to_axis.get(curr_angle, 'xy') - if accel_chip is None: - accel_chip = Accelerometer.find_axis_accelerometer(printer, accel_axis) - k_accelerometer = printer.lookup_object(accel_chip, None) + current_accel_chip = accel_chip # to retain the manually specified chip + if current_accel_chip is None: + current_accel_chip = Accelerometer.find_axis_accelerometer(printer, accel_axis) + k_accelerometer = printer.lookup_object(current_accel_chip, None) if k_accelerometer is None: - gcmd.error(f'Error: accelerometer "{accel_chip}" not found!') + gcmd.error(f'Error: accelerometer [{current_accel_chip}] not found!') accelerometer = Accelerometer(k_accelerometer) - ConsoleOutput.print(f'Accelerometer chip for {curr_angle} degree angle: {accel_chip}') + ConsoleOutput.print(f'Accelerometer chip used for this angle: [{current_accel_chip}]') # Sweep the speed range to record the vibrations at different speeds for curr_speed_sample in range(nb_speed_samples):