################################################
###### STANDARD INPUT_SHAPER CALIBRATIONS ######
################################################
# Written by Frix_x#0161 #

[gcode_macro BELTS_SHAPER_CALIBRATION]
description: Perform a custom half-axis test to analyze and compare the frequency profiles of individual belts on CoreXY printers
gcode:
    {% set min_freq = params.FREQ_START|default(5)|float %}
    {% set max_freq = params.FREQ_END|default(133.33)|float %}
    {% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
    {% set keep_results = params.KEEP_N_RESULTS|default(3)|int %}
    {% set keep_csv = params.KEEP_CSV|default(True) %}

    TEST_RESONANCES AXIS=1,1 OUTPUT=raw_data NAME=b FREQ_START={min_freq} FREQ_END={max_freq} HZ_PER_SEC={hz_per_sec}
    M400

    TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=a FREQ_START={min_freq} FREQ_END={max_freq} HZ_PER_SEC={hz_per_sec}
    M400

    RESPOND MSG="Belts comparative frequency profile generation..."
    RESPOND MSG="This may take some time (3-5min)"
    RUN_SHELL_COMMAND CMD=shaketune PARAMS="--type belts {% if keep_csv %}--keep_csv{% endif %}"
    M400
    RUN_SHELL_COMMAND CMD=shaketune PARAMS="--type clean --keep_results {keep_results}"
