Quellcode durchsuchen

Throw an error in M420 if can't enable

Scott Lahteine vor 8 Jahren
Ursprung
Commit
2643404ac8
2 geänderte Dateien mit 26 neuen und 2 gelöschten Zeilen
  1. 25
    2
      Marlin/Marlin_main.cpp
  2. 1
    0
      Marlin/language.h

+ 25
- 2
Marlin/Marlin_main.cpp Datei anzeigen

2243
 
2243
 
2244
     #elif HAS_ABL
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
         planner.abl_enabled = enable;
2253
         planner.abl_enabled = enable;
2248
         if (!enable)
2254
         if (!enable)
2249
           set_current_from_steppers_for_axis(
2255
           set_current_from_steppers_for_axis(
7007
    *       Z[height] Sets the Z fade height (0 or none to disable)
7013
    *       Z[height] Sets the Z fade height (0 or none to disable)
7008
    */
7014
    */
7009
   inline void gcode_M420() {
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
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
7023
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
7012
       if (code_seen('Z')) set_z_fade_height(code_value_linear_units());
7024
       if (code_seen('Z')) set_z_fade_height(code_value_linear_units());
7013
     #endif
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
 #endif
7038
 #endif
7016
 
7039
 

+ 1
- 0
Marlin/language.h Datei anzeigen

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

Laden…
Abbrechen
Speichern