Have M420 report a changed position

This commit is contained in:
Scott Lahteine 2017-12-10 21:26:11 -06:00
parent 03ba79f144
commit 7d2e850577

View file

@ -45,6 +45,11 @@
*/
void GcodeSuite::M420() {
const float oldpos[XYZE] = {
current_position[X_AXIS], current_position[Y_AXIS],
current_position[Z_AXIS], current_position[E_AXIS]
};
#if ENABLED(AUTO_BED_LEVELING_UBL)
// L to load a mesh from the EEPROM
@ -104,13 +109,16 @@ void GcodeSuite::M420() {
#endif
}
const bool to_enable = parser.boolval('S');
if (parser.seen('S')) set_bed_leveling_enabled(to_enable);
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units(), false);
#endif
bool to_enable = false;
if (parser.seen('S')) {
to_enable = parser.value_bool();
set_bed_leveling_enabled(to_enable);
}
const bool new_status = planner.leveling_active;
if (to_enable && !new_status) {
@ -129,6 +137,10 @@ void GcodeSuite::M420() {
else
SERIAL_ECHOLNPGM(MSG_OFF);
#endif
// Report change in position
if (memcmp(oldpos, current_position, sizeof(oldpos)))
report_current_position();
}
#endif // HAS_LEVELING