Переглянути джерело

Throw an error in M420 if can't enable

Scott Lahteine 7 роки тому
джерело
коміт
2643404ac8
2 змінених файлів з 26 додано та 2 видалено
  1. 25
    2
      Marlin/Marlin_main.cpp
  2. 1
    0
      Marlin/language.h

+ 25
- 2
Marlin/Marlin_main.cpp Переглянути файл

@@ -2243,7 +2243,13 @@ static void clean_up_after_endstop_or_probe_move() {
2243 2243
 
2244 2244
     #elif HAS_ABL
2245 2245
 
2246
-      if (enable != planner.abl_enabled) {
2246
+      #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
2247
+        const bool can_change = (!enable || (bilinear_grid_spacing[0] && bilinear_grid_spacing[1]));
2248
+      #else
2249
+        constexpr bool can_change = true;
2250
+      #endif
2251
+
2252
+      if (can_change && enable != planner.abl_enabled) {
2247 2253
         planner.abl_enabled = enable;
2248 2254
         if (!enable)
2249 2255
           set_current_from_steppers_for_axis(
@@ -7007,10 +7013,27 @@ void quickstop_stepper() {
7007 7013
    *       Z[height] Sets the Z fade height (0 or none to disable)
7008 7014
    */
7009 7015
   inline void gcode_M420() {
7010
-    if (code_seen('S')) set_bed_leveling_enabled(code_value_bool());
7016
+    bool to_enable = false;
7017
+
7018
+    if (code_seen('S')) {
7019
+      to_enable = code_value_bool();
7020
+      set_bed_leveling_enabled(to_enable);
7021
+    }
7022
+
7011 7023
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
7012 7024
       if (code_seen('Z')) set_z_fade_height(code_value_linear_units());
7013 7025
     #endif
7026
+
7027
+    if (to_enable && !(
7028
+      #if ENABLED(MESH_BED_LEVELING)
7029
+        mbl.active()
7030
+      #else
7031
+        planner.abl_enabled
7032
+      #endif
7033
+    ) ) {
7034
+      SERIAL_ERROR_START;
7035
+      SERIAL_ERRORLNPGM(MSG_ERR_M420_FAILED);
7036
+    }
7014 7037
   }
7015 7038
 #endif
7016 7039
 

+ 1
- 0
Marlin/language.h Переглянути файл

@@ -157,6 +157,7 @@
157 157
 #define MSG_ERR_MESH_XY                     "Mesh XY or IJ cannot be resolved"
158 158
 #define MSG_ERR_ARC_ARGS                    "G2/G3 bad parameters"
159 159
 #define MSG_ERR_PROTECTED_PIN               "Protected Pin"
160
+#define MSG_ERR_M420_FAILED                 "Failed to enable Bed Leveling"
160 161
 #define MSG_ERR_M428_TOO_FAR                "Too far from reference point"
161 162
 #define MSG_ERR_M303_DISABLED               "PIDTEMP disabled"
162 163
 #define MSG_M119_REPORT                     "Reporting endstop status"

Завантаження…
Відмінити
Зберегти