소스 검색

Improve M48 output; Add min, max, range, etc.

Brian 8 년 전
부모
커밋
48cf19151a
1개의 변경된 파일29개의 추가작업 그리고 8개의 파일을 삭제
  1. 29
    8
      Marlin/Marlin_main.cpp

+ 29
- 8
Marlin/Marlin_main.cpp 파일 보기

@@ -4681,7 +4681,7 @@ inline void gcode_M42() {
4681 4681
     }
4682 4682
 
4683 4683
     if (verbose_level > 0)
4684
-      SERIAL_PROTOCOLLNPGM("M48 Z-Probe Repeatability test");
4684
+      SERIAL_PROTOCOLLNPGM("M48 Z-Probe Repeatability Test");
4685 4685
 
4686 4686
     int8_t n_samples = code_seen('P') ? code_value_byte() : 10;
4687 4687
     if (n_samples < 4 || n_samples > 50) {
@@ -4747,7 +4747,8 @@ inline void gcode_M42() {
4747 4747
 
4748 4748
     randomSeed(millis());
4749 4749
 
4750
-    double mean = 0, sigma = 0, sample_set[n_samples];
4750
+    double mean = 0, sigma = 0, sample_set[n_samples], min = 99999, max = 0;
4751
+
4751 4752
     for (uint8_t n = 0; n < n_samples; n++) {
4752 4753
       if (n_legs) {
4753 4754
         int dir = (random(0, 10) > 5.0) ? -1 : 1;  // clockwise or counter clockwise
@@ -4817,7 +4818,7 @@ inline void gcode_M42() {
4817 4818
       } // n_legs
4818 4819
 
4819 4820
       // Probe a single point
4820
-      sample_set[n] = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level);
4821
+      sample_set[n] = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, 0);
4821 4822
 
4822 4823
       /**
4823 4824
        * Get the current mean for the data points we have so far
@@ -4826,6 +4827,9 @@ inline void gcode_M42() {
4826 4827
       for (uint8_t j = 0; j <= n; j++) sum += sample_set[j];
4827 4828
       mean = sum / (n + 1);
4828 4829
 
4830
+      if(sample_set[n] < min) min = sample_set[n];
4831
+      if(sample_set[n] > max) max = sample_set[n];
4832
+
4829 4833
       /**
4830 4834
        * Now, use that mean to calculate the standard deviation for the
4831 4835
        * data points we have so far
@@ -4840,13 +4844,19 @@ inline void gcode_M42() {
4840 4844
           SERIAL_PROTOCOL(n + 1);
4841 4845
           SERIAL_PROTOCOLPGM(" of ");
4842 4846
           SERIAL_PROTOCOL((int)n_samples);
4843
-          SERIAL_PROTOCOLPGM("   z: ");
4844
-          SERIAL_PROTOCOL_F(current_position[Z_AXIS], 6);
4847
+          SERIAL_PROTOCOLPGM(": z: ");
4848
+          SERIAL_PROTOCOL_F(sample_set[n], 3);
4845 4849
           if (verbose_level > 2) {
4846 4850
             SERIAL_PROTOCOLPGM(" mean: ");
4847
-            SERIAL_PROTOCOL_F(mean, 6);
4848
-            SERIAL_PROTOCOLPGM("   sigma: ");
4851
+            SERIAL_PROTOCOL_F(mean, 4);
4852
+            SERIAL_PROTOCOLPGM(" sigma: ");
4849 4853
             SERIAL_PROTOCOL_F(sigma, 6);
4854
+            SERIAL_PROTOCOLPGM(" min: ");
4855
+            SERIAL_PROTOCOL_F(min, 3);
4856
+            SERIAL_PROTOCOLPGM(" max: ");
4857
+            SERIAL_PROTOCOL_F(max, 3);
4858
+            SERIAL_PROTOCOLPGM(" range: ");
4859
+            SERIAL_PROTOCOL_F(max-min, 3);
4850 4860
           }
4851 4861
         }
4852 4862
         SERIAL_EOL;
@@ -4856,15 +4866,26 @@ inline void gcode_M42() {
4856 4866
 
4857 4867
     if (STOW_PROBE()) return;
4858 4868
 
4869
+    SERIAL_PROTOCOLPGM("Finished!");
4870
+    SERIAL_EOL;
4871
+
4859 4872
     if (verbose_level > 0) {
4860 4873
       SERIAL_PROTOCOLPGM("Mean: ");
4861 4874
       SERIAL_PROTOCOL_F(mean, 6);
4875
+      SERIAL_PROTOCOLPGM(" Min: ");
4876
+      SERIAL_PROTOCOL_F(min, 3);
4877
+      SERIAL_PROTOCOLPGM(" Max: ");
4878
+      SERIAL_PROTOCOL_F(max, 3);
4879
+      SERIAL_PROTOCOLPGM(" Range: ");
4880
+      SERIAL_PROTOCOL_F(max-min, 3);
4862 4881
       SERIAL_EOL;
4863 4882
     }
4864 4883
 
4865 4884
     SERIAL_PROTOCOLPGM("Standard Deviation: ");
4866 4885
     SERIAL_PROTOCOL_F(sigma, 6);
4867
-    SERIAL_EOL; SERIAL_EOL;
4886
+    SERIAL_EOL;
4887
+
4888
+    SERIAL_EOL;
4868 4889
 
4869 4890
     clean_up_after_endstop_or_probe_move();
4870 4891
 

Loading…
취소
저장