Make mbl.has_mesh() a method
This commit is contained in:
parent
be555e3578
commit
ffeb4495fe
@ -2374,7 +2374,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
|||||||
bool leveling_is_valid() {
|
bool leveling_is_valid() {
|
||||||
return
|
return
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
mbl.has_mesh
|
mbl.has_mesh()
|
||||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||||
!!bilinear_grid_spacing[X_AXIS]
|
!!bilinear_grid_spacing[X_AXIS]
|
||||||
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
||||||
@ -2503,10 +2503,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
|||||||
#endif
|
#endif
|
||||||
set_bed_leveling_enabled(false);
|
set_bed_leveling_enabled(false);
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
if (leveling_is_valid()) {
|
mbl.reset();
|
||||||
mbl.reset();
|
|
||||||
mbl.has_mesh = false;
|
|
||||||
}
|
|
||||||
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
||||||
ubl.reset();
|
ubl.reset();
|
||||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||||
@ -4184,7 +4181,6 @@ void home_all_axes() { gcode_G28(true); }
|
|||||||
SERIAL_PROTOCOLLNPGM("Mesh probing done.");
|
SERIAL_PROTOCOLLNPGM("Mesh probing done.");
|
||||||
BUZZ(100, 659);
|
BUZZ(100, 659);
|
||||||
BUZZ(100, 698);
|
BUZZ(100, 698);
|
||||||
mbl.has_mesh = true;
|
|
||||||
|
|
||||||
home_all_axes();
|
home_all_axes();
|
||||||
set_bed_leveling_enabled(true);
|
set_bed_leveling_enabled(true);
|
||||||
@ -4233,7 +4229,6 @@ void home_all_axes() { gcode_G28(true); }
|
|||||||
SERIAL_CHAR('Z'); echo_not_entered();
|
SERIAL_CHAR('Z'); echo_not_entered();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mbl.has_mesh = true; // set since user manually entered a mesh point
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MeshSetZOffset:
|
case MeshSetZOffset:
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Change EEPROM version if the structure changes
|
// Change EEPROM version if the structure changes
|
||||||
#define EEPROM_VERSION "V48"
|
#define EEPROM_VERSION "V49"
|
||||||
#define EEPROM_OFFSET 100
|
#define EEPROM_OFFSET 100
|
||||||
|
|
||||||
// Check the integrity of data offsets.
|
// Check the integrity of data offsets.
|
||||||
@ -114,7 +114,6 @@ typedef struct SettingsDataStruct {
|
|||||||
//
|
//
|
||||||
// MESH_BED_LEVELING
|
// MESH_BED_LEVELING
|
||||||
//
|
//
|
||||||
bool mbl_has_mesh; // mbl.has_mesh
|
|
||||||
float mbl_z_offset; // mbl.z_offset
|
float mbl_z_offset; // mbl.z_offset
|
||||||
uint8_t mesh_num_x, mesh_num_y; // GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y
|
uint8_t mesh_num_x, mesh_num_y; // GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
@ -453,16 +452,13 @@ void MarlinSettings::postprocess() {
|
|||||||
"MBL Z array is the wrong size."
|
"MBL Z array is the wrong size."
|
||||||
);
|
);
|
||||||
const uint8_t mesh_num_x = GRID_MAX_POINTS_X, mesh_num_y = GRID_MAX_POINTS_Y;
|
const uint8_t mesh_num_x = GRID_MAX_POINTS_X, mesh_num_y = GRID_MAX_POINTS_Y;
|
||||||
EEPROM_WRITE(mbl.has_mesh);
|
|
||||||
EEPROM_WRITE(mbl.z_offset);
|
EEPROM_WRITE(mbl.z_offset);
|
||||||
EEPROM_WRITE(mesh_num_x);
|
EEPROM_WRITE(mesh_num_x);
|
||||||
EEPROM_WRITE(mesh_num_y);
|
EEPROM_WRITE(mesh_num_y);
|
||||||
EEPROM_WRITE(mbl.z_values);
|
EEPROM_WRITE(mbl.z_values);
|
||||||
#else // For disabled MBL write a default mesh
|
#else // For disabled MBL write a default mesh
|
||||||
const bool leveling_is_on = false;
|
|
||||||
dummy = 0.0f;
|
dummy = 0.0f;
|
||||||
const uint8_t mesh_num_x = 3, mesh_num_y = 3;
|
const uint8_t mesh_num_x = 3, mesh_num_y = 3;
|
||||||
EEPROM_WRITE(leveling_is_on);
|
|
||||||
EEPROM_WRITE(dummy); // z_offset
|
EEPROM_WRITE(dummy); // z_offset
|
||||||
EEPROM_WRITE(mesh_num_x);
|
EEPROM_WRITE(mesh_num_x);
|
||||||
EEPROM_WRITE(mesh_num_y);
|
EEPROM_WRITE(mesh_num_y);
|
||||||
@ -960,10 +956,7 @@ void MarlinSettings::postprocess() {
|
|||||||
EEPROM_READ_ALWAYS(mesh_num_y);
|
EEPROM_READ_ALWAYS(mesh_num_y);
|
||||||
|
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
if (!validating) {
|
if (!validating) mbl.z_offset = dummy;
|
||||||
mbl.has_mesh = leveling_is_on;
|
|
||||||
mbl.z_offset = dummy;
|
|
||||||
}
|
|
||||||
if (mesh_num_x == GRID_MAX_POINTS_X && mesh_num_y == GRID_MAX_POINTS_Y) {
|
if (mesh_num_x == GRID_MAX_POINTS_X && mesh_num_y == GRID_MAX_POINTS_Y) {
|
||||||
// EEPROM data fits the current mesh
|
// EEPROM data fits the current mesh
|
||||||
EEPROM_READ(mbl.z_values);
|
EEPROM_READ(mbl.z_values);
|
||||||
|
@ -30,8 +30,6 @@
|
|||||||
|
|
||||||
mesh_bed_leveling mbl;
|
mesh_bed_leveling mbl;
|
||||||
|
|
||||||
bool mesh_bed_leveling::has_mesh;
|
|
||||||
|
|
||||||
float mesh_bed_leveling::z_offset,
|
float mesh_bed_leveling::z_offset,
|
||||||
mesh_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
|
mesh_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
|
||||||
mesh_bed_leveling::index_to_xpos[GRID_MAX_POINTS_X],
|
mesh_bed_leveling::index_to_xpos[GRID_MAX_POINTS_X],
|
||||||
@ -46,7 +44,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
void mesh_bed_leveling::reset() {
|
void mesh_bed_leveling::reset() {
|
||||||
has_mesh = false;
|
|
||||||
z_offset = 0;
|
z_offset = 0;
|
||||||
ZERO(z_values);
|
ZERO(z_values);
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,12 @@ public:
|
|||||||
|
|
||||||
static void reset();
|
static void reset();
|
||||||
|
|
||||||
|
FORCE_INLINE static bool has_mesh() {
|
||||||
|
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||||
|
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||||
|
if (z_values[x][y]) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
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; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user