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

[gcode_macro EXCITATE_AXIS_AT_FREQ]
description: Maintain a specified excitation frequency for a period of time to diagnose and locate a source of vibration
gcode:
    {% set frequency = params.FREQUENCY|default(25)|int %}
    {% set time = params.TIME|default(10)|int %}
    {% set axis = params.AXIS|default("x")|string|lower %}

    {% if axis not in ["x", "y", "a", "b"] %}
        { action_raise_error("AXIS selection invalid. Should be either x, y, a or b!") }
    {% endif %}

    {% if axis == "a" %}
        {% set axis = "1,-1" %}
    {% elif axis == "b" %}
        {% set axis = "1,1" %}
    {% endif %}

    TEST_RESONANCES OUTPUT=raw_data AXIS={axis} FREQ_START={frequency-1} FREQ_END={frequency+1} HZ_PER_SEC={1/(time/3)}
    M400
