Signal an invalid mesh for M420 enable / load

This commit is contained in:
Scott Lahteine 2018-12-07 16:14:11 -06:00
parent 50b2fbd031
commit b7e38ea249

View file

@ -126,10 +126,14 @@ void GcodeSuite::M420() {
#endif // AUTO_BED_LEVELING_UBL #endif // AUTO_BED_LEVELING_UBL
const bool seenV = parser.seen('V');
#if HAS_MESH #if HAS_MESH
if (leveling_is_valid()) {
// Subtract the given value or the mean from all mesh values // Subtract the given value or the mean from all mesh values
if (leveling_is_valid() && parser.seen('C')) { if (parser.seen('C')) {
const float cval = parser.value_float(); const float cval = parser.value_float();
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
@ -177,10 +181,16 @@ void GcodeSuite::M420() {
#endif #endif
} }
}
else if (to_enable || seenV) {
SERIAL_ERROR_MSG("Invalid mesh.");
goto EXIT_M420;
}
#endif // HAS_MESH #endif // HAS_MESH
// V to print the matrix or mesh // V to print the matrix or mesh
if (parser.seen('V')) { if (seenV) {
#if ABL_PLANAR #if ABL_PLANAR
planner.bed_level_matrix.debug(PSTR("Bed Level Correction Matrix:")); planner.bed_level_matrix.debug(PSTR("Bed Level Correction Matrix:"));
#else #else
@ -205,6 +215,8 @@ void GcodeSuite::M420() {
// Enable leveling if specified, or if previously active // Enable leveling if specified, or if previously active
set_bed_leveling_enabled(to_enable); set_bed_leveling_enabled(to_enable);
EXIT_M420:
// Error if leveling failed to enable or reenable // Error if leveling failed to enable or reenable
if (to_enable && !planner.leveling_active) if (to_enable && !planner.leveling_active)
SERIAL_ERROR_MSG(MSG_ERR_M420_FAILED); SERIAL_ERROR_MSG(MSG_ERR_M420_FAILED);