5 #define BED_ZERO_REF_X (- 22.f + X_PROBE_OFFSET_FROM_EXTRUDER)
6 #define BED_ZERO_REF_Y (- 0.6f + Y_PROBE_OFFSET_FROM_EXTRUDER + 4.f)
10 #define BED_X0 (2.f - BED_ZERO_REF_X)
11 #define BED_Y0 (9.4f - BED_ZERO_REF_Y)
12 #define BED_Xn (206.f - BED_ZERO_REF_X)
13 #define BED_Yn (213.4f - BED_ZERO_REF_Y)
17 #define BED_X0 (13.f - BED_ZERO_REF_X)
18 #define BED_Y0 (8.4f - BED_ZERO_REF_Y)
19 #define BED_Xn (216.f - BED_ZERO_REF_X)
20 #define BED_Yn (202.4f - BED_ZERO_REF_Y)
24 constexpr
float x_mesh_density = (BED_Xn - BED_X0) / (MESH_NUM_X_POINTS - 1);
25 constexpr
float y_mesh_density = (BED_Yn - BED_Y0) / (MESH_NUM_Y_POINTS - 1);
30 extern const float bed_ref_points_4[] PROGMEM;
32 extern const float bed_skew_angle_mild;
33 extern const float bed_skew_angle_extreme;
36 enum World2MachineCorrectionMode
38 WORLD2MACHINE_CORRECTION_NONE = 0,
39 WORLD2MACHINE_CORRECTION_SHIFT = 1,
40 WORLD2MACHINE_CORRECTION_SKEW = 2,
42 extern uint8_t world2machine_correction_mode;
46 extern float world2machine_rotation_and_skew[2][2];
47 extern float world2machine_rotation_and_skew_inv[2][2];
49 extern float world2machine_shift[2];
51 extern void world2machine_reset();
54 extern void world2machine_read_valid(
float vec_x[2],
float vec_y[2],
float cntr[2]);
57 inline void world2machine(
float &x,
float &y)
59 if (world2machine_correction_mode == WORLD2MACHINE_CORRECTION_NONE) {
62 if (world2machine_correction_mode & WORLD2MACHINE_CORRECTION_SKEW) {
64 float out_x = world2machine_rotation_and_skew[0][0] * x + world2machine_rotation_and_skew[0][1] * y;
65 float out_y = world2machine_rotation_and_skew[1][0] * x + world2machine_rotation_and_skew[1][1] * y;
69 if (world2machine_correction_mode & WORLD2MACHINE_CORRECTION_SHIFT) {
71 x += world2machine_shift[0];
72 y += world2machine_shift[1];
77 inline void world2machine(
const float &x,
const float &y,
float &out_x,
float &out_y)
81 world2machine(out_x, out_y);
84 inline void machine2world(
float x,
float y,
float &out_x,
float &out_y)
86 if (world2machine_correction_mode == WORLD2MACHINE_CORRECTION_NONE) {
91 if (world2machine_correction_mode & WORLD2MACHINE_CORRECTION_SHIFT) {
93 x -= world2machine_shift[0];
94 y -= world2machine_shift[1];
96 if (world2machine_correction_mode & WORLD2MACHINE_CORRECTION_SKEW) {
98 out_x = world2machine_rotation_and_skew_inv[0][0] * x + world2machine_rotation_and_skew_inv[0][1] * y;
99 out_y = world2machine_rotation_and_skew_inv[1][0] * x + world2machine_rotation_and_skew_inv[1][1] * y;
104 inline void machine2world(
float &x,
float &y)
106 if (world2machine_correction_mode == WORLD2MACHINE_CORRECTION_NONE) {
109 if (world2machine_correction_mode & WORLD2MACHINE_CORRECTION_SHIFT) {
111 x -= world2machine_shift[0];
112 y -= world2machine_shift[1];
114 if (world2machine_correction_mode & WORLD2MACHINE_CORRECTION_SKEW) {
116 float out_x = world2machine_rotation_and_skew_inv[0][0] * x + world2machine_rotation_and_skew_inv[0][1] * y;
117 float out_y = world2machine_rotation_and_skew_inv[1][0] * x + world2machine_rotation_and_skew_inv[1][1] * y;
124 inline bool world2machine_clamp(
float &x,
float &y)
126 bool clamped =
false;
128 world2machine(x, y, tmpx, tmpy);
129 if (tmpx < X_MIN_POS) {
132 }
else if (tmpx > X_MAX_POS) {
137 if (tmpy < Y_MIN_POS) {
140 }
else if (tmpy > Y_MAX_POS) {
145 machine2world(tmpx, tmpy, x, y);
152 float BED_X(
const uint8_t col);
157 float BED_Y(
const uint8_t row);
166 enum BedSkewOffsetDetectionResultType {
168 BED_SKEW_OFFSET_DETECTION_POINT_FOUND = 0,
169 BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND = -1,
170 BED_SKEW_OFFSET_DETECTION_FITTING_FAILED = -2,
171 BED_SKEW_OFFSET_DETECTION_POINT_SCAN_FAILED = -3,
174 BED_SKEW_OFFSET_DETECTION_PERFECT = 0,
175 BED_SKEW_OFFSET_DETECTION_SKEW_MILD = 1,
176 BED_SKEW_OFFSET_DETECTION_SKEW_EXTREME = 2
179 bool find_bed_induction_sensor_point_z(
float minimum_z = -10.f, uint8_t n_iter = 3,
int verbosity_level = 0);
180 BedSkewOffsetDetectionResultType find_bed_induction_sensor_point_xy(
int verbosity_level = 0);
181 void go_home_with_z_lift();
183 extern BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level, uint8_t &too_far_mask);
185 extern BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8_t verbosity_level, uint8_t &too_far_mask);
188 extern bool sample_mesh_and_store_reference();
190 extern void reset_bed_offset_and_skew();
191 extern bool is_bed_z_jitter_data_valid();
196 extern bool scan_bed_induction_points(int8_t verbosity_level);
201 extern void babystep_load();
204 extern void babystep_apply();
207 extern void babystep_undo();
210 extern void babystep_reset();
213 extern void count_xyz_details(
float (&distanceMin)[2]);
214 extern bool sample_z();
216 extern void mbl_settings_init();
217 extern bool mbl_point_measurement_valid(uint8_t ix, uint8_t iy);
218 extern void mbl_magnet_elimination();
world2machine_initialize()
Read and apply validated calibration data from EEPROM.
Definition: mesh_bed_calibration.cpp:867
world2machine_revert_to_uncorrected()
Set calibration matrix to identity and update current position with absolute position.
Definition: mesh_bed_calibration.cpp:766
world2machine_update_current()
Update current position after switching to corrected coordinates.
Definition: mesh_bed_calibration.cpp:902