From d58497bc8ee72ee44891a3f6f9c1735ca6b43e9e Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sat, 23 Apr 2022 21:16:15 +1200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20BACKLASH=5FCOMPENSATION=20?= =?UTF-8?q?compile=20(#24072)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #23826 --- Marlin/src/feature/backlash.cpp | 47 ++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/Marlin/src/feature/backlash.cpp b/Marlin/src/feature/backlash.cpp index 876d28a8fe..13e2cd99ec 100644 --- a/Marlin/src/feature/backlash.cpp +++ b/Marlin/src/feature/backlash.cpp @@ -162,32 +162,37 @@ int32_t Backlash::get_applied_steps(const AxisEnum axis) { } class Backlash::StepAdjuster { - xyz_long_t applied_steps; -public: - StepAdjuster() { - LOOP_NUM_AXES(axis) applied_steps[axis] = backlash.get_applied_steps((AxisEnum)axis); - } - ~StepAdjuster() { - // after backlash compensation parameter changes, ensure applied step count does not change - LOOP_NUM_AXES(axis) residual_error[axis] += backlash.get_applied_steps((AxisEnum)axis) - applied_steps[axis]; - } + private: + xyz_long_t applied_steps; + public: + StepAdjuster() { + LOOP_NUM_AXES(axis) applied_steps[axis] = backlash.get_applied_steps((AxisEnum)axis); + } + ~StepAdjuster() { + // after backlash compensation parameter changes, ensure applied step count does not change + LOOP_NUM_AXES(axis) residual_error[axis] += backlash.get_applied_steps((AxisEnum)axis) - applied_steps[axis]; + } }; -void Backlash::set_correction_uint8(const uint8_t v) { - StepAdjuster adjuster; - correction = v; -} +#if ENABLED(BACKLASH_GCODE) -void Backlash::set_distance_mm(const AxisEnum axis, const float v) { - StepAdjuster adjuster; - distance_mm[axis] = v; -} - -#ifdef BACKLASH_SMOOTHING_MM - void Backlash::set_smoothing_mm(const float v) { + void Backlash::set_correction_uint8(const uint8_t v) { StepAdjuster adjuster; - smoothing_mm = v; + correction = v; } + + void Backlash::set_distance_mm(const AxisEnum axis, const float v) { + StepAdjuster adjuster; + distance_mm[axis] = v; + } + + #ifdef BACKLASH_SMOOTHING_MM + void Backlash::set_smoothing_mm(const float v) { + StepAdjuster adjuster; + smoothing_mm = v; + } + #endif + #endif #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)