AXES_MAP detection reworked (#110)
This commit is contained in:
@@ -5,6 +5,8 @@ from ..helpers.console_output import ConsoleOutput
|
||||
from ..shaketune_process import ShakeTuneProcess
|
||||
from .accelerometer import Accelerometer
|
||||
|
||||
SEGMENT_LENGTH = 30 # mm
|
||||
|
||||
|
||||
def axes_map_calibration(gcmd, config, st_process: ShakeTuneProcess) -> None:
|
||||
z_height = gcmd.get_float('Z_HEIGHT', default=20.0)
|
||||
@@ -21,6 +23,12 @@ def axes_map_calibration(gcmd, config, st_process: ShakeTuneProcess) -> None:
|
||||
k_accelerometer = printer.lookup_object(accel_chip, None)
|
||||
if k_accelerometer is None:
|
||||
gcmd.error('Error: multi-accelerometer configurations are not supported for this macro!')
|
||||
pconfig = printer.lookup_object('configfile')
|
||||
current_axes_map = pconfig.status_raw_config[accel_chip]['axes_map']
|
||||
if current_axes_map.strip().replace(' ', '') != 'x,y,z':
|
||||
gcmd.error(
|
||||
f'Error: The parameter axes_map is already set in your {accel_chip} configuration! Please remove it (or set it to "x,y,z")!'
|
||||
)
|
||||
accelerometer = Accelerometer(k_accelerometer)
|
||||
|
||||
toolhead_info = toolhead.get_status(systime)
|
||||
@@ -44,19 +52,27 @@ def axes_map_calibration(gcmd, config, st_process: ShakeTuneProcess) -> None:
|
||||
_, _, _, E = toolhead.get_position()
|
||||
|
||||
# Going to the start position
|
||||
toolhead.move([mid_x - 15, mid_y - 15, z_height, E], feedrate_travel)
|
||||
toolhead.move([mid_x - SEGMENT_LENGTH / 2, mid_y - SEGMENT_LENGTH / 2, z_height, E], feedrate_travel)
|
||||
toolhead.dwell(0.5)
|
||||
|
||||
# Start the measurements and do the movements (+X, +Y and then +Z)
|
||||
accelerometer.start_measurement()
|
||||
toolhead.dwell(1)
|
||||
toolhead.move([mid_x + 15, mid_y - 15, z_height, E], speed)
|
||||
toolhead.dwell(1)
|
||||
toolhead.move([mid_x + 15, mid_y + 15, z_height, E], speed)
|
||||
toolhead.dwell(1)
|
||||
toolhead.move([mid_x + 15, mid_y + 15, z_height + 15, E], speed)
|
||||
toolhead.dwell(1)
|
||||
accelerometer.stop_measurement('axemap')
|
||||
toolhead.dwell(0.5)
|
||||
toolhead.move([mid_x + SEGMENT_LENGTH / 2, mid_y - SEGMENT_LENGTH / 2, z_height, E], speed)
|
||||
toolhead.dwell(0.5)
|
||||
accelerometer.stop_measurement('axesmap_X', append_time=True)
|
||||
toolhead.dwell(0.5)
|
||||
accelerometer.start_measurement()
|
||||
toolhead.dwell(0.5)
|
||||
toolhead.move([mid_x + SEGMENT_LENGTH / 2, mid_y + SEGMENT_LENGTH / 2, z_height, E], speed)
|
||||
toolhead.dwell(0.5)
|
||||
accelerometer.stop_measurement('axesmap_Y', append_time=True)
|
||||
toolhead.dwell(0.5)
|
||||
accelerometer.start_measurement()
|
||||
toolhead.dwell(0.5)
|
||||
toolhead.move([mid_x + SEGMENT_LENGTH / 2, mid_y + SEGMENT_LENGTH / 2, z_height + SEGMENT_LENGTH, E], speed)
|
||||
toolhead.dwell(0.5)
|
||||
accelerometer.stop_measurement('axesmap_Z', append_time=True)
|
||||
|
||||
# Re-enable the input shaper if it was active
|
||||
if input_shaper is not None:
|
||||
@@ -71,5 +87,5 @@ def axes_map_calibration(gcmd, config, st_process: ShakeTuneProcess) -> None:
|
||||
# Run post-processing
|
||||
ConsoleOutput.print('Analysis of the movements...')
|
||||
creator = st_process.get_graph_creator()
|
||||
creator.configure(accel)
|
||||
creator.configure(accel, SEGMENT_LENGTH)
|
||||
st_process.run()
|
||||
|
||||
Reference in New Issue
Block a user