fixed vibration accelermeter chip selection logic

This commit is contained in:
Félix Boisselier
2024-05-24 21:17:58 +02:00
parent d15e06b0c8
commit b6ec4d0229

View File

@@ -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.') gcmd.error('Input shaper is not configured! Please run the shaper calibration macro first.')
motors_config_parser = MotorsConfigParser(config, motors=['stepper_x', 'stepper_y']) motors_config_parser = MotorsConfigParser(config, motors=['stepper_x', 'stepper_y'])
if motors_config_parser.kinematics == 'cartesian' or motors_config_parser.kinematics == 'corexz': 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] # Cartesian motors are on X and Y axis directly, same for CoreXZ
main_angles = [0, 90]
elif motors_config_parser.kinematics == 'corexy': elif motors_config_parser.kinematics == 'corexy':
# CoreXY motors are on A and B axis (45 and 135 degrees) main_angles = [45, 135] # CoreXY motors are on A and B axis (45 and 135 degrees)
main_angles = [45, 135]
else: else:
gcmd.error( gcmd.error(
'Only Cartesian, CoreXY and CoreXZ kinematics are supported at the moment for the vibrations measurement tool!' '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 # and then find the best accelerometer chip for the current angle if not manually specified
angle_to_axis = {0: 'x', 90: 'y'} angle_to_axis = {0: 'x', 90: 'y'}
accel_axis = angle_to_axis.get(curr_angle, 'xy') accel_axis = angle_to_axis.get(curr_angle, 'xy')
if accel_chip is None: current_accel_chip = accel_chip # to retain the manually specified chip
accel_chip = Accelerometer.find_axis_accelerometer(printer, accel_axis) if current_accel_chip is None:
k_accelerometer = printer.lookup_object(accel_chip, 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: 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) 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 # Sweep the speed range to record the vibrations at different speeds
for curr_speed_sample in range(nb_speed_samples): for curr_speed_sample in range(nb_speed_samples):