Browse Source

Have M420 report a changed position

Scott Lahteine 7 years ago
parent
commit
aa1b4eded6
1 changed files with 14 additions and 14 deletions
  1. 14
    14
      Marlin/Marlin_main.cpp

+ 14
- 14
Marlin/Marlin_main.cpp View File

340
   #include "ubl.h"
340
   #include "ubl.h"
341
   extern bool defer_return_to_status;
341
   extern bool defer_return_to_status;
342
   unified_bed_leveling ubl;
342
   unified_bed_leveling ubl;
343
-  #define UBL_MESH_VALID !( ( ubl.z_values[0][0] == ubl.z_values[0][1] && ubl.z_values[0][1] == ubl.z_values[0][2] \
344
-                           && ubl.z_values[1][0] == ubl.z_values[1][1] && ubl.z_values[1][1] == ubl.z_values[1][2] \
345
-                           && ubl.z_values[2][0] == ubl.z_values[2][1] && ubl.z_values[2][1] == ubl.z_values[2][2] \
346
-                           && ubl.z_values[0][0] == 0 && ubl.z_values[1][0] == 0 && ubl.z_values[2][0] == 0 )  \
347
-                           || isnan(ubl.z_values[0][0]))
348
 #endif
343
 #endif
349
 
344
 
350
 #if ENABLED(CNC_COORDINATE_SYSTEMS)
345
 #if ENABLED(CNC_COORDINATE_SYSTEMS)
2490
       planner.set_z_fade_height(zfh);
2485
       planner.set_z_fade_height(zfh);
2491
 
2486
 
2492
       if (level_active) {
2487
       if (level_active) {
2493
-        const float oldpos[XYZE] = {
2494
-          current_position[X_AXIS], current_position[Y_AXIS],
2495
-          current_position[Z_AXIS], current_position[E_AXIS]
2496
-        };
2488
+        const float oldpos[] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
2497
         #if ENABLED(AUTO_BED_LEVELING_UBL)
2489
         #if ENABLED(AUTO_BED_LEVELING_UBL)
2498
           set_bed_leveling_enabled(true);  // turn back on after changing fade height
2490
           set_bed_leveling_enabled(true);  // turn back on after changing fade height
2499
         #else
2491
         #else
9616
    */
9608
    */
9617
   inline void gcode_M420() {
9609
   inline void gcode_M420() {
9618
 
9610
 
9611
+    const float oldpos[] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
9612
+
9619
     #if ENABLED(AUTO_BED_LEVELING_UBL)
9613
     #if ENABLED(AUTO_BED_LEVELING_UBL)
9620
 
9614
 
9621
       // L to load a mesh from the EEPROM
9615
       // L to load a mesh from the EEPROM
9650
       // L to load a mesh from the EEPROM
9644
       // L to load a mesh from the EEPROM
9651
       if (parser.seen('L') || parser.seen('V')) {
9645
       if (parser.seen('L') || parser.seen('V')) {
9652
         ubl.display_map(0);  // Currently only supports one map type
9646
         ubl.display_map(0);  // Currently only supports one map type
9653
-        SERIAL_ECHOLNPAIR("UBL_MESH_VALID = ", UBL_MESH_VALID);
9647
+        SERIAL_ECHOLNPAIR("ubl.mesh_is_valid = ", ubl.mesh_is_valid());
9654
         SERIAL_ECHOLNPAIR("ubl.storage_slot = ", ubl.storage_slot);
9648
         SERIAL_ECHOLNPAIR("ubl.storage_slot = ", ubl.storage_slot);
9655
       }
9649
       }
9656
 
9650
 
9675
       #endif
9669
       #endif
9676
     }
9670
     }
9677
 
9671
 
9678
-    const bool to_enable = parser.boolval('S');
9679
-    if (parser.seen('S'))
9680
-      set_bed_leveling_enabled(to_enable);
9681
-
9682
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
9672
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
9683
       if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units(), false);
9673
       if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units(), false);
9684
     #endif
9674
     #endif
9685
 
9675
 
9676
+    bool to_enable = false;
9677
+    if (parser.seen('S')) {
9678
+      to_enable = parser.value_bool();
9679
+      set_bed_leveling_enabled(to_enable);
9680
+    }
9681
+
9686
     const bool new_status = planner.leveling_active;
9682
     const bool new_status = planner.leveling_active;
9687
 
9683
 
9688
     if (to_enable && !new_status) {
9684
     if (to_enable && !new_status) {
9701
       else
9697
       else
9702
         SERIAL_ECHOLNPGM(MSG_OFF);
9698
         SERIAL_ECHOLNPGM(MSG_OFF);
9703
     #endif
9699
     #endif
9700
+
9701
+    // Report change in position
9702
+    if (memcmp(oldpos, current_position, sizeof(oldpos)))
9703
+      report_current_position();
9704
   }
9704
   }
9705
 #endif
9705
 #endif
9706
 
9706
 

Loading…
Cancel
Save