Update backlash code
This commit is contained in:
@ -20,11 +20,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../Marlin.h"
|
||||
#include "../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(BACKLASH_COMPENSATION)
|
||||
|
||||
#include "backlash.h"
|
||||
|
||||
#include "../module/motion.h"
|
||||
#include "../module/planner.h"
|
||||
|
||||
#if ENABLED(BACKLASH_GCODE)
|
||||
@ -75,10 +77,10 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
|
||||
// to segments where there is no direction change.
|
||||
static int32_t residual_error[XYZ] = { 0 };
|
||||
#else
|
||||
// No leftover residual error from segment to segment
|
||||
int32_t residual_error[XYZ] = { 0 };
|
||||
// No direction change, no correction.
|
||||
if (!changed_dir) return;
|
||||
// No leftover residual error from segment to segment
|
||||
int32_t residual_error[XYZ] = { 0 };
|
||||
#endif
|
||||
|
||||
const float f_corr = float(correction) / 255.0f;
|
||||
@ -100,7 +102,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
|
||||
if (reversing == (error_correction < 0)) {
|
||||
if (segment_proportion == 0)
|
||||
segment_proportion = MIN(1.0f, block->millimeters / smoothing_mm);
|
||||
error_correction = ceil(segment_proportion * error_correction);
|
||||
error_correction = CEIL(segment_proportion * error_correction);
|
||||
}
|
||||
else
|
||||
error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
#endif
|
||||
static inline void set_correction(const float &v) { correction = MAX(0, MIN(1.0, v)) * all_on; }
|
||||
static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
|
||||
#elif ENABLED(BACKLASH_COMPENSATION)
|
||||
#else
|
||||
static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF;
|
||||
#ifdef BACKLASH_DISTANCE_MM
|
||||
static constexpr float distance_mm[XYZ] = BACKLASH_DISTANCE_MM;
|
||||
@ -46,10 +46,6 @@ public:
|
||||
#endif
|
||||
static inline void set_correction(float) { }
|
||||
static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
|
||||
#else
|
||||
static constexpr uint8_t correction = 0;
|
||||
static inline void set_correction(float) { }
|
||||
static inline float get_correction() { return 0; }
|
||||
#endif
|
||||
|
||||
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
|
||||
|
Reference in New Issue
Block a user