Browse Source

Extend `M420` to print state and, with `V`, the matrix / mesh

Scott Lahteine 8 years ago
parent
commit
32e65dc429
1 changed files with 44 additions and 15 deletions
  1. 44
    15
      Marlin/Marlin_main.cpp

+ 44
- 15
Marlin/Marlin_main.cpp View File

2423
   /**
2423
   /**
2424
    * Print calibration results for plotting or manual frame adjustment.
2424
    * Print calibration results for plotting or manual frame adjustment.
2425
    */
2425
    */
2426
-  static void print_bed_level() {
2426
+  static void print_bilinear_leveling_grid() {
2427
     SERIAL_ECHOPGM("Bilinear Leveling Grid:\n ");
2427
     SERIAL_ECHOPGM("Bilinear Leveling Grid:\n ");
2428
     for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++) {
2428
     for (uint8_t x = 0; x < ABL_GRID_MAX_POINTS_X; x++) {
2429
       SERIAL_PROTOCOLPGM("    ");
2429
       SERIAL_PROTOCOLPGM("    ");
3701
   // Save 130 bytes with non-duplication of PSTR
3701
   // Save 130 bytes with non-duplication of PSTR
3702
   void say_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
3702
   void say_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
3703
 
3703
 
3704
+  void mbl_mesh_report() {
3705
+    SERIAL_PROTOCOLLNPGM("Num X,Y: " STRINGIFY(MESH_NUM_X_POINTS) "," STRINGIFY(MESH_NUM_Y_POINTS));
3706
+    SERIAL_PROTOCOLLNPGM("Z search height: " STRINGIFY(MESH_HOME_SEARCH_Z));
3707
+    SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(mbl.z_offset, 5);
3708
+    SERIAL_PROTOCOLLNPGM("\nMeasured points:");
3709
+    for (uint8_t py = 0; py < MESH_NUM_Y_POINTS; py++) {
3710
+      for (uint8_t px = 0; px < MESH_NUM_X_POINTS; px++) {
3711
+        SERIAL_PROTOCOLPGM("  ");
3712
+        SERIAL_PROTOCOL_F(mbl.z_values[py][px], 5);
3713
+      }
3714
+      SERIAL_EOL;
3715
+    }
3716
+  }
3717
+
3704
   /**
3718
   /**
3705
    * G29: Mesh-based Z probe, probes a grid and produces a
3719
    * G29: Mesh-based Z probe, probes a grid and produces a
3706
    *      mesh to compensate for variable bed height
3720
    *      mesh to compensate for variable bed height
3736
     switch (state) {
3750
     switch (state) {
3737
       case MeshReport:
3751
       case MeshReport:
3738
         if (mbl.has_mesh()) {
3752
         if (mbl.has_mesh()) {
3739
-          SERIAL_PROTOCOLPAIR("State: ", mbl.active() ? MSG_ON : MSG_OFF);
3740
-          SERIAL_PROTOCOLLNPGM("\nNum X,Y: " STRINGIFY(MESH_NUM_X_POINTS) "," STRINGIFY(MESH_NUM_Y_POINTS));
3741
-          SERIAL_PROTOCOLLNPGM("Z search height: " STRINGIFY(MESH_HOME_SEARCH_Z));
3742
-          SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(mbl.z_offset, 5);
3743
-          SERIAL_PROTOCOLLNPGM("\nMeasured points:");
3744
-          for (py = 0; py < MESH_NUM_Y_POINTS; py++) {
3745
-            for (px = 0; px < MESH_NUM_X_POINTS; px++) {
3746
-              SERIAL_PROTOCOLPGM("  ");
3747
-              SERIAL_PROTOCOL_F(mbl.z_values[py][px], 5);
3748
-            }
3749
-            SERIAL_EOL;
3750
-          }
3753
+          SERIAL_PROTOCOLLNPAIR("State: ", mbl.active() ? MSG_ON : MSG_OFF);
3754
+          mbl_mesh_report();
3751
         }
3755
         }
3752
         else
3756
         else
3753
-          SERIAL_PROTOCOLLNPGM("Mesh bed leveling not active.");
3757
+          SERIAL_PROTOCOLLNPGM("Mesh bed leveling has no data.");
3754
         break;
3758
         break;
3755
 
3759
 
3756
       case MeshStart:
3760
       case MeshStart:
4220
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
4224
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
4221
 
4225
 
4222
       if (!dryrun) extrapolate_unprobed_bed_level();
4226
       if (!dryrun) extrapolate_unprobed_bed_level();
4223
-      print_bed_level();
4227
+      print_bilinear_leveling_grid();
4224
 
4228
 
4225
       #if ENABLED(ABL_BILINEAR_SUBDIVISION)
4229
       #if ENABLED(ABL_BILINEAR_SUBDIVISION)
4226
         bed_level_virt_prepare();
4230
         bed_level_virt_prepare();
7012
    *
7016
    *
7013
    *       S[bool]   Turns leveling on or off
7017
    *       S[bool]   Turns leveling on or off
7014
    *       Z[height] Sets the Z fade height (0 or none to disable)
7018
    *       Z[height] Sets the Z fade height (0 or none to disable)
7019
+   *       V[bool]   Verbose - Print the levelng grid
7015
    */
7020
    */
7016
   inline void gcode_M420() {
7021
   inline void gcode_M420() {
7017
     bool to_enable = false;
7022
     bool to_enable = false;
7032
         planner.abl_enabled
7037
         planner.abl_enabled
7033
       #endif
7038
       #endif
7034
     ) ) {
7039
     ) ) {
7040
+      to_enable = false;
7035
       SERIAL_ERROR_START;
7041
       SERIAL_ERROR_START;
7036
       SERIAL_ERRORLNPGM(MSG_ERR_M420_FAILED);
7042
       SERIAL_ERRORLNPGM(MSG_ERR_M420_FAILED);
7037
     }
7043
     }
7044
+
7045
+    SERIAL_ECHO_START;
7046
+    SERIAL_ECHOLNPAIR("Bed Leveling ", to_enable ? MSG_ON : MSG_OFF);
7047
+
7048
+    // V to print the matrix or mesh
7049
+    if (code_seen('V')) {
7050
+      #if ABL_PLANAR
7051
+        planner.bed_level_matrix.debug("Bed Level Correction Matrix:");
7052
+      #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
7053
+        if (bilinear_grid_spacing[X_AXIS]) {
7054
+          print_bilinear_leveling_grid();
7055
+          #if ENABLED(ABL_BILINEAR_SUBDIVISION)
7056
+            bed_level_virt_print();
7057
+          #endif
7058
+        }
7059
+      #elif ENABLED(MESH_BED_LEVELING)
7060
+        if (mbl.has_mesh()) {
7061
+          SERIAL_ECHOLNPGM("Mesh Bed Level data:");
7062
+          mbl_mesh_report();
7063
+        }
7064
+      #endif
7065
+    }
7066
+
7038
   }
7067
   }
7039
 #endif
7068
 #endif
7040
 
7069
 

Loading…
Cancel
Save