|
@@ -7968,46 +7968,53 @@ inline void gcode_M503() {
|
7968
|
7968
|
|
7969
|
7969
|
#if HAS_BED_PROBE
|
7970
|
7970
|
|
7971
|
|
- inline void gcode_M851() {
|
|
7971
|
+ void refresh_zprobe_zoffset(const bool no_babystep/*=false*/) {
|
|
7972
|
+ static float last_zoffset = NAN;
|
7972
|
7973
|
|
7973
|
|
- SERIAL_ECHO_START;
|
7974
|
|
- SERIAL_ECHOPGM(MSG_ZPROBE_ZOFFSET);
|
7975
|
|
- SERIAL_CHAR(' ');
|
|
7974
|
+ if (!isnan(last_zoffset)) {
|
7976
|
7975
|
|
7977
|
|
- if (code_seen('Z')) {
|
7978
|
|
- float value = code_value_axis_units(Z_AXIS);
|
7979
|
|
- if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
|
|
7976
|
+ #if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(BABYSTEPPING)
|
|
7977
|
+ const float diff = zprobe_zoffset - last_zoffset;
|
|
7978
|
+ #endif
|
7980
|
7979
|
|
7981
|
|
- #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
7982
|
|
- // Correct bilinear grid for new probe offset
|
7983
|
|
- const float diff = value - zprobe_zoffset;
|
7984
|
|
- if (diff) {
|
7985
|
|
- for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
7986
|
|
- for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
7987
|
|
- bed_level_grid[x][y] -= diff;
|
7988
|
|
- }
|
7989
|
|
- #if ENABLED(ABL_BILINEAR_SUBDIVISION)
|
7990
|
|
- bed_level_virt_interpolate();
|
7991
|
|
- #endif
|
|
7980
|
+ #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
|
7981
|
+ // Correct bilinear grid for new probe offset
|
|
7982
|
+ if (diff) {
|
|
7983
|
+ for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
|
7984
|
+ for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
|
7985
|
+ bed_level_grid[x][y] -= diff;
|
|
7986
|
+ }
|
|
7987
|
+ #if ENABLED(ABL_BILINEAR_SUBDIVISION)
|
|
7988
|
+ bed_level_virt_interpolate();
|
7992
|
7989
|
#endif
|
|
7990
|
+ #endif
|
7993
|
7991
|
|
7994
|
|
- #if ENABLED(BABYSTEPPING)
|
7995
|
|
- if (planner.abl_enabled)
|
7996
|
|
- thermalManager.babystep_axis(Z_AXIS, lround(-(value - zprobe_zoffset) * planner.axis_steps_per_mm[Z_AXIS]));
|
7997
|
|
- #endif
|
|
7992
|
+ #if ENABLED(BABYSTEPPING)
|
|
7993
|
+ if (!no_babystep && planner.abl_enabled)
|
|
7994
|
+ thermalManager.babystep_axis(Z_AXIS, -lround(diff * planner.axis_steps_per_mm[Z_AXIS]));
|
|
7995
|
+ #else
|
|
7996
|
+ UNUSED(no_babystep);
|
|
7997
|
+ #endif
|
|
7998
|
+ }
|
|
7999
|
+
|
|
8000
|
+ last_zoffset = zprobe_zoffset;
|
|
8001
|
+ }
|
7998
|
8002
|
|
|
8003
|
+ inline void gcode_M851() {
|
|
8004
|
+ SERIAL_ECHO_START;
|
|
8005
|
+ SERIAL_ECHOPGM(MSG_ZPROBE_ZOFFSET " ");
|
|
8006
|
+ if (code_seen('Z')) {
|
|
8007
|
+ const float value = code_value_axis_units(Z_AXIS);
|
|
8008
|
+ if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
|
7999
|
8009
|
zprobe_zoffset = value;
|
|
8010
|
+ refresh_zprobe_zoffset();
|
8000
|
8011
|
SERIAL_ECHO(zprobe_zoffset);
|
8001
|
8012
|
}
|
8002
|
|
- else {
|
8003
|
|
- SERIAL_ECHOPAIR(MSG_Z_MIN, Z_PROBE_OFFSET_RANGE_MIN);
|
8004
|
|
- SERIAL_CHAR(' ');
|
8005
|
|
- SERIAL_ECHOPAIR(MSG_Z_MAX, Z_PROBE_OFFSET_RANGE_MAX);
|
8006
|
|
- }
|
|
8013
|
+ else
|
|
8014
|
+ SERIAL_ECHOPGM(MSG_Z_MIN " " STRINGIFY(Z_PROBE_OFFSET_RANGE_MIN) " " MSG_Z_MAX " " STRINGIFY(Z_PROBE_OFFSET_RANGE_MAX));
|
8007
|
8015
|
}
|
8008
|
|
- else {
|
|
8016
|
+ else
|
8009
|
8017
|
SERIAL_ECHOPAIR(": ", zprobe_zoffset);
|
8010
|
|
- }
|
8011
|
8018
|
|
8012
|
8019
|
SERIAL_EOL;
|
8013
|
8020
|
}
|