🚸 Universal X_AXIS_TWIST_COMPENSATION (#23828)
This commit is contained in:
committed by
Scott Lahteine
parent
43d4e30668
commit
575c3150f9
@ -63,9 +63,6 @@ class TemporaryBedLevelingState {
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
#include "abl/abl.h"
|
||||
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
|
||||
#include "abl/x_twist.h"
|
||||
#endif
|
||||
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
#include "ubl/ubl.h"
|
||||
#elif ENABLED(MESH_BED_LEVELING)
|
||||
|
@ -19,16 +19,24 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
#include "../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
|
||||
|
||||
#include "../bedlevel.h"
|
||||
#include "x_twist.h"
|
||||
|
||||
XATC xatc;
|
||||
|
||||
bool XATC::enabled = true;
|
||||
float XATC::spacing, XATC::start;
|
||||
xatc_array_t XATC::z_offset;
|
||||
xatc_array_t XATC::z_offset; // Initialized by settings.load()
|
||||
|
||||
void XATC::reset() {
|
||||
constexpr float xzo[] = XATC_Z_OFFSETS;
|
||||
static_assert(COUNT(xzo) == XATC_MAX_POINTS, "XATC_Z_OFFSETS is the wrong size.");
|
||||
enabled = false;
|
||||
COPY(z_offset, xzo);
|
||||
}
|
||||
|
||||
void XATC::print_points() {
|
||||
SERIAL_ECHOLNPGM(" X-Twist Correction:");
|
||||
@ -49,6 +57,7 @@ void XATC::print_points() {
|
||||
float lerp(const_float_t t, const_float_t a, const_float_t b) { return a + t * (b - a); }
|
||||
|
||||
float XATC::compensation(const xy_pos_t &raw) {
|
||||
if (!enabled) return 0;
|
||||
if (NEAR_ZERO(spacing)) return 0;
|
||||
float t = (raw.x - start) / spacing;
|
||||
int i = FLOOR(t);
|
@ -21,15 +21,18 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
#include "../inc/MarlinConfigPre.h"
|
||||
|
||||
typedef float xatc_array_t[XATC_MAX_POINTS];
|
||||
|
||||
class XATC {
|
||||
static bool enabled;
|
||||
public:
|
||||
static float spacing, start;
|
||||
static xatc_array_t z_offset;
|
||||
|
||||
static void reset();
|
||||
static void set_enabled(const bool ena) { enabled = ena; }
|
||||
static float compensation(const xy_pos_t &raw);
|
||||
static void print_points();
|
||||
};
|
Reference in New Issue
Block a user