Add M420 C to center the mesh on a value (#10521)

This commit is contained in:
Scott Lahteine 2018-04-25 06:43:59 -05:00 committed by GitHub
parent 21f5ca6ad4
commit d429d5a4ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 89 additions and 18 deletions

View file

@ -539,7 +539,7 @@
#endif
break;
case 5: find_mean_mesh_height(); break;
case 5: adjust_mesh_to_mean(g29_constant); break;
case 6: shift_mesh_height(); break;
}
@ -629,7 +629,7 @@
return;
}
void unified_bed_leveling::find_mean_mesh_height() {
void unified_bed_leveling::adjust_mesh_to_mean(const float value) {
float sum = 0.0;
int n = 0;
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
@ -664,7 +664,7 @@
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]))
z_values[x][y] -= mean + g29_constant;
z_values[x][y] -= mean + value;
}
void unified_bed_leveling::shift_mesh_height() {
@ -1076,7 +1076,7 @@
SERIAL_EOL();
#endif
find_mean_mesh_height();
adjust_mesh_to_mean(g29_constant);
#if HAS_BED_PROBE
SERIAL_PROTOCOLPGM("zprobe_zoffset: ");