Add code to handle changes to zprobe_zoffset
This commit is contained in:
parent
8fa4209916
commit
60ac41a32c
@ -317,6 +317,7 @@ float code_value_temp_diff();
|
|||||||
|
|
||||||
#if HAS_BED_PROBE
|
#if HAS_BED_PROBE
|
||||||
extern float zprobe_zoffset;
|
extern float zprobe_zoffset;
|
||||||
|
void refresh_zprobe_zoffset(const bool no_babystep=false);
|
||||||
#define DEPLOY_PROBE() set_probe_deployed(true)
|
#define DEPLOY_PROBE() set_probe_deployed(true)
|
||||||
#define STOW_PROBE() set_probe_deployed(false)
|
#define STOW_PROBE() set_probe_deployed(false)
|
||||||
#endif
|
#endif
|
||||||
|
@ -7968,46 +7968,53 @@ inline void gcode_M503() {
|
|||||||
|
|
||||||
#if HAS_BED_PROBE
|
#if HAS_BED_PROBE
|
||||||
|
|
||||||
|
void refresh_zprobe_zoffset(const bool no_babystep/*=false*/) {
|
||||||
|
static float last_zoffset = NAN;
|
||||||
|
|
||||||
|
if (!isnan(last_zoffset)) {
|
||||||
|
|
||||||
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(BABYSTEPPING)
|
||||||
|
const float diff = zprobe_zoffset - last_zoffset;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||||
|
// Correct bilinear grid for new probe offset
|
||||||
|
if (diff) {
|
||||||
|
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
||||||
|
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||||
|
bed_level_grid[x][y] -= diff;
|
||||||
|
}
|
||||||
|
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
|
||||||
|
bed_level_virt_interpolate();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(BABYSTEPPING)
|
||||||
|
if (!no_babystep && planner.abl_enabled)
|
||||||
|
thermalManager.babystep_axis(Z_AXIS, -lround(diff * planner.axis_steps_per_mm[Z_AXIS]));
|
||||||
|
#else
|
||||||
|
UNUSED(no_babystep);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
last_zoffset = zprobe_zoffset;
|
||||||
|
}
|
||||||
|
|
||||||
inline void gcode_M851() {
|
inline void gcode_M851() {
|
||||||
|
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
SERIAL_ECHOPGM(MSG_ZPROBE_ZOFFSET);
|
SERIAL_ECHOPGM(MSG_ZPROBE_ZOFFSET " ");
|
||||||
SERIAL_CHAR(' ');
|
|
||||||
|
|
||||||
if (code_seen('Z')) {
|
if (code_seen('Z')) {
|
||||||
float value = code_value_axis_units(Z_AXIS);
|
const float value = code_value_axis_units(Z_AXIS);
|
||||||
if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
|
if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
|
||||||
|
|
||||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
|
||||||
// Correct bilinear grid for new probe offset
|
|
||||||
const float diff = value - zprobe_zoffset;
|
|
||||||
if (diff) {
|
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
|
||||||
bed_level_grid[x][y] -= diff;
|
|
||||||
}
|
|
||||||
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
|
|
||||||
bed_level_virt_interpolate();
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(BABYSTEPPING)
|
|
||||||
if (planner.abl_enabled)
|
|
||||||
thermalManager.babystep_axis(Z_AXIS, lround(-(value - zprobe_zoffset) * planner.axis_steps_per_mm[Z_AXIS]));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
zprobe_zoffset = value;
|
zprobe_zoffset = value;
|
||||||
|
refresh_zprobe_zoffset();
|
||||||
SERIAL_ECHO(zprobe_zoffset);
|
SERIAL_ECHO(zprobe_zoffset);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
SERIAL_ECHOPAIR(MSG_Z_MIN, Z_PROBE_OFFSET_RANGE_MIN);
|
SERIAL_ECHOPGM(MSG_Z_MIN " " STRINGIFY(Z_PROBE_OFFSET_RANGE_MIN) " " MSG_Z_MAX " " STRINGIFY(Z_PROBE_OFFSET_RANGE_MAX));
|
||||||
SERIAL_CHAR(' ');
|
|
||||||
SERIAL_ECHOPAIR(MSG_Z_MAX, Z_PROBE_OFFSET_RANGE_MAX);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
SERIAL_ECHOPAIR(": ", zprobe_zoffset);
|
SERIAL_ECHOPAIR(": ", zprobe_zoffset);
|
||||||
}
|
|
||||||
|
|
||||||
SERIAL_EOL;
|
SERIAL_EOL;
|
||||||
}
|
}
|
||||||
|
@ -216,6 +216,10 @@ void MarlinSettings::postprocess() {
|
|||||||
//#endif
|
//#endif
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAS_BED_PROBE
|
||||||
|
refresh_zprobe_zoffset();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(EEPROM_SETTINGS)
|
#if ENABLED(EEPROM_SETTINGS)
|
||||||
@ -344,7 +348,7 @@ void MarlinSettings::postprocess() {
|
|||||||
#endif // MESH_BED_LEVELING
|
#endif // MESH_BED_LEVELING
|
||||||
|
|
||||||
#if !HAS_BED_PROBE
|
#if !HAS_BED_PROBE
|
||||||
float zprobe_zoffset = 0;
|
const float zprobe_zoffset = 0;
|
||||||
#endif
|
#endif
|
||||||
EEPROM_WRITE(zprobe_zoffset);
|
EEPROM_WRITE(zprobe_zoffset);
|
||||||
|
|
||||||
@ -685,7 +689,7 @@ void MarlinSettings::postprocess() {
|
|||||||
#endif // MESH_BED_LEVELING
|
#endif // MESH_BED_LEVELING
|
||||||
|
|
||||||
#if !HAS_BED_PROBE
|
#if !HAS_BED_PROBE
|
||||||
float zprobe_zoffset = 0;
|
float zprobe_zoffset;
|
||||||
#endif
|
#endif
|
||||||
EEPROM_READ(zprobe_zoffset);
|
EEPROM_READ(zprobe_zoffset);
|
||||||
|
|
||||||
|
@ -863,11 +863,12 @@ void kill_screen(const char* lcd_msg) {
|
|||||||
|
|
||||||
const float new_zoffset = zprobe_zoffset + steps_to_mm[Z_AXIS] * babystep_increment;
|
const float new_zoffset = zprobe_zoffset + steps_to_mm[Z_AXIS] * babystep_increment;
|
||||||
if (WITHIN(new_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
|
if (WITHIN(new_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
|
||||||
|
|
||||||
if (planner.abl_enabled)
|
if (planner.abl_enabled)
|
||||||
thermalManager.babystep_axis(Z_AXIS, babystep_increment);
|
thermalManager.babystep_axis(Z_AXIS, babystep_increment);
|
||||||
|
|
||||||
zprobe_zoffset = new_zoffset;
|
zprobe_zoffset = new_zoffset;
|
||||||
|
refresh_zprobe_zoffset(true);
|
||||||
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2412,7 +2413,7 @@ void kill_screen(const char* lcd_msg) {
|
|||||||
#if ENABLED(BABYSTEPPING)
|
#if ENABLED(BABYSTEPPING)
|
||||||
MENU_ITEM(submenu, MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
|
MENU_ITEM(submenu, MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
|
||||||
#else
|
#else
|
||||||
MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
|
MENU_ITEM_EDIT_CALLBACK(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX, refresh_zprobe_zoffset);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
// Manual bed leveling, Bed Z:
|
// Manual bed leveling, Bed Z:
|
||||||
|
Loading…
Reference in New Issue
Block a user