Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions Marlin/configuration_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2061,14 +2061,16 @@ void MarlinSettings::reset() {

#if ENABLED(MESH_BED_LEVELING)

for (uint8_t py = 0; py < GRID_MAX_POINTS_Y; py++) {
for (uint8_t px = 0; px < GRID_MAX_POINTS_X; px++) {
CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" G29 S3 X", (int)px + 1);
SERIAL_ECHOPAIR(" Y", (int)py + 1);
SERIAL_ECHOPGM(" Z");
SERIAL_PROTOCOL_F(LINEAR_UNIT(mbl.z_values[px][py]), 5);
SERIAL_EOL();
if (leveling_is_valid()) {
for (uint8_t py = 0; py < GRID_MAX_POINTS_Y; py++) {
for (uint8_t px = 0; px < GRID_MAX_POINTS_X; px++) {
CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" G29 S3 X", (int)px + 1);
SERIAL_ECHOPAIR(" Y", (int)py + 1);
SERIAL_ECHOPGM(" Z");
SERIAL_PROTOCOL_F(LINEAR_UNIT(mbl.z_values[px][py]), 5);
SERIAL_EOL();
}
}
}

Expand All @@ -2082,6 +2084,23 @@ void MarlinSettings::reset() {
SERIAL_ECHOLNPGM(" meshes.\n");
}

ubl.report_current_mesh();

#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)

if (leveling_is_valid()) {
for (uint8_t py = 0; py < GRID_MAX_POINTS_Y; py++) {
for (uint8_t px = 0; px < GRID_MAX_POINTS_X; px++) {
CONFIG_ECHO_START;
SERIAL_ECHOPAIR(" G29 W I", (int)px + 1);
SERIAL_ECHOPAIR(" J", (int)py + 1);
SERIAL_ECHOPGM(" Z");
SERIAL_PROTOCOL_F(LINEAR_UNIT(z_values[px][py]), 5);
SERIAL_EOL();
}
}
}

#endif

#endif // HAS_LEVELING
Expand Down
18 changes: 18 additions & 0 deletions Marlin/ubl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@

void unified_bed_leveling::echo_name() { SERIAL_PROTOCOLPGM("Unified Bed Leveling"); }

void unified_bed_leveling::report_current_mesh() {
if (!leveling_is_valid()) return;
SERIAL_ECHO_START();
SERIAL_ECHOLNPGM(" G29 I 999");
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
if (!isnan(z_values[x][y])) {
SERIAL_ECHO_START();
SERIAL_ECHOPAIR(" M421 I ", x);
SERIAL_ECHOPAIR(" J ", y);
SERIAL_ECHOPGM(" Z ");
SERIAL_ECHO_F(z_values[x][y], 6);
SERIAL_ECHOPAIR(" ; X ", LOGICAL_X_POSITION(mesh_index_to_xpos(x)));
SERIAL_ECHOPAIR(", Y ", LOGICAL_Y_POSITION(mesh_index_to_ypos(y)));
SERIAL_EOL();
}
}

void unified_bed_leveling::report_state() {
echo_name();
SERIAL_PROTOCOLPGM(" System v" UBL_VERSION " ");
Expand Down
1 change: 1 addition & 0 deletions Marlin/ubl.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class unified_bed_leveling {
public:

static void echo_name();
static void report_current_mesh();
static void report_state();
static void save_ubl_active_state_and_disable();
static void restore_ubl_active_state_and_leave();
Expand Down
18 changes: 2 additions & 16 deletions Marlin/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,21 +596,8 @@
if (parser.seen('S')) { // Store (or Save) Current Mesh Data
g29_storage_slot = parser.has_value() ? parser.value_int() : storage_slot;

if (g29_storage_slot == -1) { // Special case, we are going to 'Export' the mesh to the
SERIAL_ECHOLNPGM("G29 I 999"); // host in a form it can be reconstructed on a different machine
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
if (!isnan(z_values[x][y])) {
SERIAL_ECHOPAIR("M421 I ", x);
SERIAL_ECHOPAIR(" J ", y);
SERIAL_ECHOPGM(" Z ");
SERIAL_ECHO_F(z_values[x][y], 6);
SERIAL_ECHOPAIR(" ; X ", LOGICAL_X_POSITION(mesh_index_to_xpos(x)));
SERIAL_ECHOPAIR(", Y ", LOGICAL_Y_POSITION(mesh_index_to_ypos(y)));
SERIAL_EOL();
}
return;
}
if (g29_storage_slot == -1) // Special case, we are going to 'Export' the mesh to the
return report_current_mesh();

int16_t a = settings.calc_num_meshes();

Expand Down Expand Up @@ -764,7 +751,6 @@
z_values[location.x_index][location.y_index] = measured_z;
}
SERIAL_FLUSH(); // Prevent host M105 buffer overrun.

} while (location.x_index >= 0 && --max_iterations);

STOW_PROBE();
Expand Down