Adjust resonance avoidance speed calculation (#11462)

* Adjust resonance avoidance speed calculation

 * Only adjust if it's strictly below max
 * If the speed is over half of the set speed range,
   use the max speed to prevent slowdowns

Signed-off-by: Kuran Kaname <celtare21@gmail.com>

* update comment

---------

Signed-off-by: Kuran Kaname <celtare21@gmail.com>
Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
Kuran Kaname
2025-12-23 06:55:55 +02:00
committed by GitHub
parent 7fa6175b4f
commit f08cae6c5a

View File

@@ -6186,10 +6186,15 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
);
}
// if still in avoidance mode and under max, clamp to “min”
if (m_resonance_avoidance
&& speed <= m_config.max_resonance_avoidance_speed.value) {
speed = std::min(speed, m_config.min_resonance_avoidance_speed.value);
// if still in avoidance mode and under "max", adjust speed:
// - speeds in lower half of range: clamp down to "min"
// - speeds in upper half of range: boost up to "max" if (m_resonance_avoidance && speed < m_config.max_resonance_avoidance_speed.value) {
if (speed < m_config.min_resonance_avoidance_speed.value +
((m_config.max_resonance_avoidance_speed.value - m_config.min_resonance_avoidance_speed.value) / 2)) {
speed = std::min(speed, m_config.min_resonance_avoidance_speed.value);
} else {
speed = m_config.max_resonance_avoidance_speed.value;
}
}
// reset flag for next segment