Selaa lähdekoodia

Merge pull request #3242 from thinkyhead/rc_epatel_mesh_fixes

Updated Mesh Bed Leveling
Scott Lahteine 8 vuotta sitten
vanhempi
commit
18de9f55ac

+ 27
- 14
Marlin/Marlin_main.cpp Näytä tiedosto

@@ -2381,7 +2381,7 @@ inline void gcode_G28() {
2381 2381
     #endif
2382 2382
   #endif
2383 2383
 
2384
-  // For manual bed leveling deactivate the matrix temporarily
2384
+  // For mesh bed leveling deactivate the mesh calculations, will be turned on again when homing all axis
2385 2385
   #if ENABLED(MESH_BED_LEVELING)
2386 2386
     uint8_t mbl_was_active = mbl.active;
2387 2387
     mbl.active = 0;
@@ -2680,18 +2680,17 @@ inline void gcode_G28() {
2680 2680
     enable_endstops(false);
2681 2681
   #endif
2682 2682
 
2683
-  // For manual leveling move back to 0,0
2683
+  // For mesh leveling move back to Z=0
2684 2684
   #if ENABLED(MESH_BED_LEVELING)
2685
-    if (mbl_was_active) {
2686
-      current_position[X_AXIS] = mbl.get_x(0);
2687
-      current_position[Y_AXIS] = mbl.get_y(0);
2688
-      set_destination_to_current();
2689
-      feedrate = homing_feedrate[X_AXIS];
2690
-      line_to_destination();
2691
-      st_synchronize();
2685
+    if (mbl_was_active && home_all_axis) {
2692 2686
       current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2693 2687
       sync_plan_position();
2694 2688
       mbl.active = 1;
2689
+      current_position[Z_AXIS] = 0.0;
2690
+      set_destination_to_current();
2691
+      feedrate = homing_feedrate[Z_AXIS];
2692
+      line_to_destination();
2693
+      st_synchronize();
2695 2694
       #if ENABLED(DEBUG_LEVELING_FEATURE)
2696 2695
         if (marlin_debug_flags & DEBUG_LEVELING) {
2697 2696
           print_xyz("mbl_was_active > current_position", current_position);
@@ -2717,7 +2716,7 @@ inline void gcode_G28() {
2717 2716
 
2718 2717
 #if ENABLED(MESH_BED_LEVELING)
2719 2718
 
2720
-  enum MeshLevelingState { MeshReport, MeshStart, MeshNext, MeshSet };
2719
+  enum MeshLevelingState { MeshReport, MeshStart, MeshNext, MeshSet, MeshSetZOffset };
2721 2720
 
2722 2721
   /**
2723 2722
    * G29: Mesh-based Z probe, probes a grid and produces a
@@ -2729,21 +2728,22 @@ inline void gcode_G28() {
2729 2728
    *  S1              Start probing mesh points
2730 2729
    *  S2              Probe the next mesh point
2731 2730
    *  S3 Xn Yn Zn.nn  Manually modify a single point
2731
+   *  S4 Zn.nn        Set z offset. Positive away from bed, negative closer to bed.
2732 2732
    *
2733 2733
    * The S0 report the points as below
2734 2734
    *
2735
-   *  +----> X-axis
2735
+   *  +----> X-axis  1-n
2736 2736
    *  |
2737 2737
    *  |
2738
-   *  v Y-axis
2738
+   *  v Y-axis  1-n
2739 2739
    *
2740 2740
    */
2741 2741
   inline void gcode_G29() {
2742 2742
 
2743 2743
     static int probe_point = -1;
2744 2744
     MeshLevelingState state = code_seen('S') ? (MeshLevelingState)code_value_short() : MeshReport;
2745
-    if (state < 0 || state > 3) {
2746
-      SERIAL_PROTOCOLLNPGM("S out of range (0-3).");
2745
+    if (state < 0 || state > 4) {
2746
+      SERIAL_PROTOCOLLNPGM("S out of range (0-4).");
2747 2747
       return;
2748 2748
     }
2749 2749
 
@@ -2759,6 +2759,8 @@ inline void gcode_G28() {
2759 2759
           SERIAL_PROTOCOL(MESH_NUM_Y_POINTS);
2760 2760
           SERIAL_PROTOCOLPGM("\nZ search height: ");
2761 2761
           SERIAL_PROTOCOL(MESH_HOME_SEARCH_Z);
2762
+          SERIAL_PROTOCOLPGM("\nZ offset: ");
2763
+          SERIAL_PROTOCOL_F(mbl.z_offset, 5);
2762 2764
           SERIAL_PROTOCOLLNPGM("\nMeasured points:");
2763 2765
           for (int y = 0; y < MESH_NUM_Y_POINTS; y++) {
2764 2766
             for (int x = 0; x < MESH_NUM_X_POINTS; x++) {
@@ -2849,6 +2851,17 @@ inline void gcode_G28() {
2849 2851
           return;
2850 2852
         }
2851 2853
         mbl.z_values[iy][ix] = z;
2854
+        break;
2855
+
2856
+      case MeshSetZOffset:
2857
+        if (code_seen('Z')) {
2858
+          z = code_value();
2859
+        } 
2860
+        else {
2861
+          SERIAL_PROTOCOLPGM("Z not entered.\n");
2862
+          return;
2863
+        }
2864
+        mbl.z_offset = z;
2852 2865
 
2853 2866
     } // switch(state)
2854 2867
   }

+ 47
- 40
Marlin/configuration_store.cpp Näytä tiedosto

@@ -36,10 +36,10 @@
36 36
  *
37 37
  */
38 38
 
39
-#define EEPROM_VERSION "V22"
39
+#define EEPROM_VERSION "V23"
40 40
 
41 41
 /**
42
- * V21 EEPROM Layout:
42
+ * V23 EEPROM Layout:
43 43
  *
44 44
  *  100  Version (char x4)
45 45
  *
@@ -59,62 +59,65 @@
59 59
  *
60 60
  * Mesh bed leveling:
61 61
  *  200  M420 S    active (bool)
62
- *  201            mesh_num_x (uint8 as set in firmware)
63
- *  202            mesh_num_y (uint8 as set in firmware)
64
- *  203  M421 XYZ  z_values[][] (float x9, by default)
65
- *  239  M851      zprobe_zoffset (float)
62
+ *  201            z_offset (float) (added in V23)
63
+ *  205            mesh_num_x (uint8 as set in firmware)
64
+ *  206            mesh_num_y (uint8 as set in firmware)
65
+ *  207  M421 XYZ  z_values[][] (float x9, by default)
66
+ *
67
+ * AUTO BED LEVELING
68
+ *  243  M851      zprobe_zoffset (float)
66 69
  *
67 70
  * DELTA:
68
- *  243  M666 XYZ  endstop_adj (float x3)
69
- *  255  M665 R    delta_radius (float)
70
- *  259  M665 L    delta_diagonal_rod (float)
71
- *  263  M665 S    delta_segments_per_second (float)
72
- *  267  M665 A    delta_diagonal_rod_trim_tower_1 (float)
73
- *  271  M665 B    delta_diagonal_rod_trim_tower_2 (float)
74
- *  275  M665 C    delta_diagonal_rod_trim_tower_3 (float)
71
+ *  247  M666 XYZ  endstop_adj (float x3)
72
+ *  259  M665 R    delta_radius (float)
73
+ *  263  M665 L    delta_diagonal_rod (float)
74
+ *  267  M665 S    delta_segments_per_second (float)
75
+ *  271  M665 A    delta_diagonal_rod_trim_tower_1 (float)
76
+ *  275  M665 B    delta_diagonal_rod_trim_tower_2 (float)
77
+ *  279  M665 C    delta_diagonal_rod_trim_tower_3 (float)
75 78
  *
76 79
  * Z_DUAL_ENDSTOPS:
77
- *  279  M666 Z    z_endstop_adj (float)
80
+ *  283  M666 Z    z_endstop_adj (float)
78 81
  *
79 82
  * ULTIPANEL:
80
- *  283  M145 S0 H plaPreheatHotendTemp (int)
81
- *  285  M145 S0 B plaPreheatHPBTemp (int)
82
- *  287  M145 S0 F plaPreheatFanSpeed (int)
83
- *  289  M145 S1 H absPreheatHotendTemp (int)
84
- *  291  M145 S1 B absPreheatHPBTemp (int)
85
- *  293  M145 S1 F absPreheatFanSpeed (int)
83
+ *  287  M145 S0 H plaPreheatHotendTemp (int)
84
+ *  289  M145 S0 B plaPreheatHPBTemp (int)
85
+ *  291  M145 S0 F plaPreheatFanSpeed (int)
86
+ *  293  M145 S1 H absPreheatHotendTemp (int)
87
+ *  295  M145 S1 B absPreheatHPBTemp (int)
88
+ *  297  M145 S1 F absPreheatFanSpeed (int)
86 89
  *
87 90
  * PIDTEMP:
88
- *  295  M301 E0 PIDC  Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
89
- *  311  M301 E1 PIDC  Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
90
- *  327  M301 E2 PIDC  Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
91
- *  343  M301 E3 PIDC  Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
92
- *  359  M301 L        lpq_len (int)
91
+ *  299  M301 E0 PIDC  Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
92
+ *  315  M301 E1 PIDC  Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
93
+ *  331  M301 E2 PIDC  Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
94
+ *  347  M301 E3 PIDC  Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
95
+ *  363  M301 L        lpq_len (int)
93 96
  *
94 97
  * PIDTEMPBED:
95
- *  361  M304 PID  bedKp, bedKi, bedKd (float x3)
98
+ *  365  M304 PID  bedKp, bedKi, bedKd (float x3)
96 99
  *
97 100
  * DOGLCD:
98
- *  373  M250 C    lcd_contrast (int)
101
+ *  377  M250 C    lcd_contrast (int)
99 102
  *
100 103
  * SCARA:
101
- *  375  M365 XYZ  axis_scaling (float x3)
104
+ *  379  M365 XYZ  axis_scaling (float x3)
102 105
  *
103 106
  * FWRETRACT:
104
- *  387  M209 S    autoretract_enabled (bool)
105
- *  388  M207 S    retract_length (float)
106
- *  392  M207 W    retract_length_swap (float)
107
- *  396  M207 F    retract_feedrate (float)
108
- *  400  M207 Z    retract_zlift (float)
109
- *  404  M208 S    retract_recover_length (float)
110
- *  408  M208 W    retract_recover_length_swap (float)
111
- *  412  M208 F    retract_recover_feedrate (float)
107
+ *  391  M209 S    autoretract_enabled (bool)
108
+ *  392  M207 S    retract_length (float)
109
+ *  396  M207 W    retract_length_swap (float)
110
+ *  400  M207 F    retract_feedrate (float)
111
+ *  404  M207 Z    retract_zlift (float)
112
+ *  408  M208 S    retract_recover_length (float)
113
+ *  412  M208 W    retract_recover_length_swap (float)
114
+ *  416  M208 F    retract_recover_feedrate (float)
112 115
  *
113 116
  * Volumetric Extrusion:
114
- *  416  M200 D    volumetric_enabled (bool)
115
- *  417  M200 T D  filament_size (float x4) (T0..3)
117
+ *  420  M200 D    volumetric_enabled (bool)
118
+ *  421  M200 T D  filament_size (float x4) (T0..3)
116 119
  *
117
- *  433  This Slot is Available!
120
+ *  437  This Slot is Available!
118 121
  *
119 122
  */
120 123
 #include "Marlin.h"
@@ -192,15 +195,17 @@ void Config_StoreSettings()  {
192 195
     mesh_num_x = MESH_NUM_X_POINTS;
193 196
     mesh_num_y = MESH_NUM_Y_POINTS;
194 197
     EEPROM_WRITE_VAR(i, mbl.active);
198
+    EEPROM_WRITE_VAR(i, mbl.z_offset);
195 199
     EEPROM_WRITE_VAR(i, mesh_num_x);
196 200
     EEPROM_WRITE_VAR(i, mesh_num_y);
197 201
     EEPROM_WRITE_VAR(i, mbl.z_values);
198 202
   #else
199 203
     uint8_t dummy_uint8 = 0;
204
+    dummy = 0.0f;
200 205
     EEPROM_WRITE_VAR(i, dummy_uint8);
206
+    EEPROM_WRITE_VAR(i, dummy);
201 207
     EEPROM_WRITE_VAR(i, mesh_num_x);
202 208
     EEPROM_WRITE_VAR(i, mesh_num_y);
203
-    dummy = 0.0f;
204 209
     for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_WRITE_VAR(i, dummy);
205 210
   #endif // MESH_BED_LEVELING
206 211
 
@@ -366,10 +371,12 @@ void Config_RetrieveSettings() {
366 371
 
367 372
     uint8_t dummy_uint8 = 0, mesh_num_x = 0, mesh_num_y = 0;
368 373
     EEPROM_READ_VAR(i, dummy_uint8);
374
+    EEPROM_READ_VAR(i, dummy);
369 375
     EEPROM_READ_VAR(i, mesh_num_x);
370 376
     EEPROM_READ_VAR(i, mesh_num_y);
371 377
     #if ENABLED(MESH_BED_LEVELING)
372 378
       mbl.active = dummy_uint8;
379
+      mbl.z_offset = dummy;
373 380
       if (mesh_num_x == MESH_NUM_X_POINTS && mesh_num_y == MESH_NUM_Y_POINTS) {
374 381
         EEPROM_READ_VAR(i, mbl.z_values);
375 382
       } else {

+ 3
- 0
Marlin/language_en.h Näytä tiedosto

@@ -169,6 +169,9 @@
169 169
 #ifndef MSG_SPEED
170 170
   #define MSG_SPEED                           "Speed"
171 171
 #endif
172
+#ifndef MSG_BED_Z
173
+  #define MSG_BED_Z                           "Bed Z"
174
+#endif
172 175
 #ifndef MSG_NOZZLE
173 176
   #define MSG_NOZZLE                          "Nozzle"
174 177
 #endif

+ 1
- 0
Marlin/mesh_bed_leveling.cpp Näytä tiedosto

@@ -30,6 +30,7 @@
30 30
 
31 31
   void mesh_bed_leveling::reset() {
32 32
     active = 0;
33
+    z_offset = 0;
33 34
     for (int y = 0; y < MESH_NUM_Y_POINTS; y++)
34 35
       for (int x = 0; x < MESH_NUM_X_POINTS; x++)
35 36
         z_values[y][x] = 0;

+ 2
- 1
Marlin/mesh_bed_leveling.h Näytä tiedosto

@@ -30,6 +30,7 @@
30 30
   class mesh_bed_leveling {
31 31
   public:
32 32
     uint8_t active;
33
+    float z_offset;
33 34
     float z_values[MESH_NUM_Y_POINTS][MESH_NUM_X_POINTS];
34 35
 
35 36
     mesh_bed_leveling();
@@ -70,7 +71,7 @@
70 71
       float z0 = calc_z0(y0,
71 72
                          get_y(y_index), z1,
72 73
                          get_y(y_index + 1), z2);
73
-      return z0;
74
+      return z0 + z_offset;
74 75
     }
75 76
   };
76 77
 

+ 10
- 0
Marlin/ultralcd.cpp Näytä tiedosto

@@ -599,6 +599,11 @@ static void lcd_tune_menu() {
599 599
   //
600 600
   MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999);
601 601
 
602
+  // Manual bed leveling, Bed Z:
603
+  #if ENABLED(MANUAL_BED_LEVELING)
604
+    MENU_ITEM_EDIT(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
605
+  #endif
606
+
602 607
   //
603 608
   // Nozzle:
604 609
   // Nozzle [1-4]:
@@ -1333,6 +1338,10 @@ static void lcd_control_motion_menu() {
1333 1338
   #if ENABLED(AUTO_BED_LEVELING_FEATURE)
1334 1339
     MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
1335 1340
   #endif
1341
+  // Manual bed leveling, Bed Z:
1342
+  #if ENABLED(MANUAL_BED_LEVELING)
1343
+    MENU_ITEM_EDIT(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
1344
+  #endif
1336 1345
   MENU_ITEM_EDIT(float5, MSG_ACC, &acceleration, 10, 99000);
1337 1346
   MENU_ITEM_EDIT(float3, MSG_VXY_JERK, &max_xy_jerk, 1, 990);
1338 1347
   #if ENABLED(DELTA)
@@ -2425,6 +2434,7 @@ char* ftostr52(const float& x) {
2425 2434
         if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
2426 2435
           current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2427 2436
           line_to_current(Z_AXIS);
2437
+          st_synchronize();
2428 2438
           mbl.active = 1;
2429 2439
           enqueue_and_echo_commands_P(PSTR("G28"));
2430 2440
           lcd_return_to_status();

Loading…
Peruuta
Tallenna