Move MBL functions into the class
This commit is contained in:
parent
eec97a5cf1
commit
be555e3578
@ -383,6 +383,11 @@ void report_current_position();
|
|||||||
float bilinear_z_offset(const float raw[XYZ]);
|
float bilinear_z_offset(const float raw[XYZ]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(MESH_BED_LEVELING)
|
||||||
|
typedef float (*element_2d_fn)(const uint8_t, const uint8_t);
|
||||||
|
void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, const element_2d_fn fn);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||||
typedef struct { double A, B, D; } linear_fit;
|
typedef struct { double A, B, D; } linear_fit;
|
||||||
linear_fit* lsf_linear_fit(double x[], double y[], double z[], const int);
|
linear_fit* lsf_linear_fit(double x[], double y[], double z[], const int);
|
||||||
|
@ -2537,7 +2537,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
|||||||
/**
|
/**
|
||||||
* Print calibration results for plotting or manual frame adjustment.
|
* Print calibration results for plotting or manual frame adjustment.
|
||||||
*/
|
*/
|
||||||
static void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, float (*fn)(const uint8_t, const uint8_t)) {
|
void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, const element_2d_fn fn) {
|
||||||
#ifndef SCAD_MESH_OUTPUT
|
#ifndef SCAD_MESH_OUTPUT
|
||||||
for (uint8_t x = 0; x < sx; x++) {
|
for (uint8_t x = 0; x < sx; x++) {
|
||||||
for (uint8_t i = 0; i < precision + 2 + (x < 10 ? 1 : 0); i++)
|
for (uint8_t i = 0; i < precision + 2 + (x < 10 ? 1 : 0); i++)
|
||||||
@ -4089,15 +4089,6 @@ void home_all_axes() { gcode_G28(true); }
|
|||||||
// Save 130 bytes with non-duplication of PSTR
|
// Save 130 bytes with non-duplication of PSTR
|
||||||
void echo_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
|
void echo_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
|
||||||
|
|
||||||
void mbl_mesh_report() {
|
|
||||||
SERIAL_PROTOCOLLNPGM("Num X,Y: " STRINGIFY(GRID_MAX_POINTS_X) "," STRINGIFY(GRID_MAX_POINTS_Y));
|
|
||||||
SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(mbl.z_offset, 5);
|
|
||||||
SERIAL_PROTOCOLLNPGM("\nMeasured points:");
|
|
||||||
print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 5,
|
|
||||||
[](const uint8_t ix, const uint8_t iy) { return mbl.z_values[ix][iy]; }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* G29: Mesh-based Z probe, probes a grid and produces a
|
* G29: Mesh-based Z probe, probes a grid and produces a
|
||||||
* mesh to compensate for variable bed height
|
* mesh to compensate for variable bed height
|
||||||
@ -4138,7 +4129,7 @@ void home_all_axes() { gcode_G28(true); }
|
|||||||
case MeshReport:
|
case MeshReport:
|
||||||
if (leveling_is_valid()) {
|
if (leveling_is_valid()) {
|
||||||
SERIAL_PROTOCOLLNPAIR("State: ", planner.leveling_active ? MSG_ON : MSG_OFF);
|
SERIAL_PROTOCOLLNPAIR("State: ", planner.leveling_active ? MSG_ON : MSG_OFF);
|
||||||
mbl_mesh_report();
|
mbl.report_mesh();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SERIAL_PROTOCOLLNPGM("Mesh bed leveling has no data.");
|
SERIAL_PROTOCOLLNPGM("Mesh bed leveling has no data.");
|
||||||
@ -9630,7 +9621,7 @@ void quickstop_stepper() {
|
|||||||
#endif
|
#endif
|
||||||
#elif ENABLED(MESH_BED_LEVELING)
|
#elif ENABLED(MESH_BED_LEVELING)
|
||||||
SERIAL_ECHOLNPGM("Mesh Bed Level data:");
|
SERIAL_ECHOLNPGM("Mesh Bed Level data:");
|
||||||
mbl_mesh_report();
|
mbl.report_mesh();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#if ENABLED(MESH_BED_LEVELING)
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
|
|
||||||
#include "mesh_bed_leveling.h"
|
#include "mesh_bed_leveling.h"
|
||||||
|
#include "Marlin.h"
|
||||||
|
#include "serial.h"
|
||||||
|
|
||||||
mesh_bed_leveling mbl;
|
mesh_bed_leveling mbl;
|
||||||
|
|
||||||
@ -49,4 +51,13 @@
|
|||||||
ZERO(z_values);
|
ZERO(z_values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mesh_bed_leveling::report_mesh() {
|
||||||
|
SERIAL_PROTOCOLLNPGM("Num X,Y: " STRINGIFY(GRID_MAX_POINTS_X) "," STRINGIFY(GRID_MAX_POINTS_Y));
|
||||||
|
SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(z_offset, 5);
|
||||||
|
SERIAL_PROTOCOLLNPGM("\nMeasured points:");
|
||||||
|
print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 5,
|
||||||
|
[](const uint8_t ix, const uint8_t iy) { return z_values[ix][iy]; }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // MESH_BED_LEVELING
|
#endif // MESH_BED_LEVELING
|
||||||
|
@ -39,7 +39,6 @@ enum MeshLevelingState {
|
|||||||
|
|
||||||
class mesh_bed_leveling {
|
class mesh_bed_leveling {
|
||||||
public:
|
public:
|
||||||
static bool has_mesh;
|
|
||||||
static float z_offset,
|
static float z_offset,
|
||||||
z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
|
z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
|
||||||
index_to_xpos[GRID_MAX_POINTS_X],
|
index_to_xpos[GRID_MAX_POINTS_X],
|
||||||
@ -47,8 +46,11 @@ public:
|
|||||||
|
|
||||||
mesh_bed_leveling();
|
mesh_bed_leveling();
|
||||||
|
|
||||||
|
static void report_mesh();
|
||||||
|
|
||||||
static void reset();
|
static void reset();
|
||||||
|
|
||||||
|
|
||||||
static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
|
static void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
|
||||||
|
|
||||||
static inline void zigzag(const int8_t index, int8_t &px, int8_t &py) {
|
static inline void zigzag(const int8_t index, int8_t &px, int8_t &py) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user