Kaynağa Gözat

Merge pull request #7961 from thinkyhead/bf1_ubl_remove_z_offset

[1.1.x] Remove obsolete UBL z_offset
Scott Lahteine 7 yıl önce
ebeveyn
işleme
fcd3b326e9
6 değiştirilmiş dosya ile 25 ekleme ve 103 silme
  1. 3
    15
      Marlin/configuration_store.cpp
  2. 11
    11
      Marlin/planner.cpp
  3. 1
    3
      Marlin/ubl.cpp
  4. 3
    4
      Marlin/ubl.h
  5. 0
    59
      Marlin/ubl_G29.cpp
  6. 7
    11
      Marlin/ubl_motion.cpp

+ 3
- 15
Marlin/configuration_store.cpp Dosyayı Görüntüle

@@ -36,13 +36,13 @@
36 36
  *
37 37
  */
38 38
 
39
-#define EEPROM_VERSION "V41"
39
+#define EEPROM_VERSION "V42"
40 40
 
41 41
 // Change EEPROM version if these are changed:
42 42
 #define EEPROM_OFFSET 100
43 43
 
44 44
 /**
45
- * V41 EEPROM Layout:
45
+ * V42 EEPROM Layout:
46 46
  *
47 47
  *  100  Version                                    (char x4)
48 48
  *  104  EEPROM CRC16                               (uint16_t)
@@ -89,8 +89,7 @@
89 89
  *
90 90
  * AUTO_BED_LEVELING_UBL:                           6 bytes
91 91
  *  324  G29 A     ubl.state.active                 (bool)
92
- *  325  G29 Z     ubl.state.z_offset               (float)
93
- *  329  G29 S     ubl.state.storage_slot           (int8_t)
92
+ *  325  G29 S     ubl.state.storage_slot           (int8_t)
94 93
  *
95 94
  * DELTA:                                           48 bytes
96 95
  *  348  M666 XYZ  endstop_adj                      (float x3)
@@ -437,14 +436,11 @@ void MarlinSettings::postprocess() {
437 436
 
438 437
     #if ENABLED(AUTO_BED_LEVELING_UBL)
439 438
       EEPROM_WRITE(ubl.state.active);
440
-      EEPROM_WRITE(ubl.state.z_offset);
441 439
       EEPROM_WRITE(ubl.state.storage_slot);
442 440
     #else
443 441
       const bool ubl_active = false;
444
-      dummy = 0.0f;
445 442
       const int8_t storage_slot = -1;
446 443
       EEPROM_WRITE(ubl_active);
447
-      EEPROM_WRITE(dummy);
448 444
       EEPROM_WRITE(storage_slot);
449 445
     #endif // AUTO_BED_LEVELING_UBL
450 446
 
@@ -829,12 +825,10 @@ void MarlinSettings::postprocess() {
829 825
 
830 826
       #if ENABLED(AUTO_BED_LEVELING_UBL)
831 827
         EEPROM_READ(ubl.state.active);
832
-        EEPROM_READ(ubl.state.z_offset);
833 828
         EEPROM_READ(ubl.state.storage_slot);
834 829
       #else
835 830
         uint8_t dummyui8;
836 831
         EEPROM_READ(dummyb);
837
-        EEPROM_READ(dummy);
838 832
         EEPROM_READ(dummyui8);
839 833
       #endif // AUTO_BED_LEVELING_UBL
840 834
 
@@ -1609,13 +1603,7 @@ void MarlinSettings::reset() {
1609 1603
       if (!forReplay) {
1610 1604
         SERIAL_EOL();
1611 1605
         ubl.report_state();
1612
-
1613 1606
         SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.state.storage_slot);
1614
-
1615
-        SERIAL_ECHOPGM("z_offset: ");
1616
-        SERIAL_ECHO_F(ubl.state.z_offset, 6);
1617
-        SERIAL_EOL();
1618
-
1619 1607
         SERIAL_ECHOPAIR("EEPROM can hold ", calc_num_meshes());
1620 1608
         SERIAL_ECHOLNPGM(" meshes.\n");
1621 1609
       }

+ 11
- 11
Marlin/planner.cpp Dosyayı Görüntüle

@@ -533,9 +533,9 @@ void Planner::check_axes_activity() {
533 533
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
534 534
         // if z_fade_height enabled (nonzero) and raw_z above it, no leveling required
535 535
         if (planner.z_fade_height && planner.z_fade_height <= RAW_Z_POSITION(lz)) return;
536
-        lz += ubl.state.z_offset + ubl.get_z_correction(lx, ly) * ubl.fade_scaling_factor_for_z(lz);
536
+        lz += ubl.get_z_correction(lx, ly) * ubl.fade_scaling_factor_for_z(lz);
537 537
       #else // no fade
538
-        lz += ubl.state.z_offset + ubl.get_z_correction(lx, ly);
538
+        lz += ubl.get_z_correction(lx, ly);
539 539
       #endif // FADE
540 540
     #endif // UBL
541 541
 
@@ -598,22 +598,22 @@ void Planner::check_axes_activity() {
598 598
 
599 599
         const float z_physical = RAW_Z_POSITION(logical[Z_AXIS]),
600 600
                     z_correct = ubl.get_z_correction(logical[X_AXIS], logical[Y_AXIS]),
601
-                    z_virtual = z_physical - ubl.state.z_offset - z_correct;
601
+                    z_virtual = z_physical - z_correct;
602 602
               float z_logical = LOGICAL_Z_POSITION(z_virtual);
603 603
 
604 604
         #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
605 605
 
606
-          // for P=physical_z, L=logical_z, M=mesh_z, O=z_offset, H=fade_height,
607
-          // Given P=L+O+M(1-L/H) (faded mesh correction formula for L<H)
608
-          //  then L=P-O-M(1-L/H)
609
-          //    so L=P-O-M+ML/H
610
-          //    so L-ML/H=P-O-M
611
-          //    so L(1-M/H)=P-O-M
612
-          //    so L=(P-O-M)/(1-M/H) for L<H
606
+          // for P=physical_z, L=logical_z, M=mesh_z, H=fade_height,
607
+          // Given P=L+M(1-L/H) (faded mesh correction formula for L<H)
608
+          //  then L=P-M(1-L/H)
609
+          //    so L=P-M+ML/H
610
+          //    so L-ML/H=P-M
611
+          //    so L(1-M/H)=P-M
612
+          //    so L=(P-M)/(1-M/H) for L<H
613 613
 
614 614
           if (planner.z_fade_height) {
615 615
             if (z_logical >= planner.z_fade_height)
616
-              z_logical = LOGICAL_Z_POSITION(z_physical - ubl.state.z_offset);
616
+              z_logical = LOGICAL_Z_POSITION(z_physical);
617 617
             else
618 618
               z_logical /= 1.0 - z_correct * planner.inverse_z_fade_height;
619 619
           }

+ 1
- 3
Marlin/ubl.cpp Dosyayı Görüntüle

@@ -84,7 +84,6 @@
84 84
 
85 85
   void unified_bed_leveling::reset() {
86 86
     set_bed_leveling_enabled(false);
87
-    state.z_offset = 0;
88 87
     state.storage_slot = -1;
89 88
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
90 89
       planner.z_fade_height = 10.0;
@@ -95,11 +94,10 @@
95 94
 
96 95
   void unified_bed_leveling::invalidate() {
97 96
     set_bed_leveling_enabled(false);
98
-    state.z_offset = 0;
99 97
     set_all_mesh_points_to_value(NAN);
100 98
   }
101 99
 
102
-  void unified_bed_leveling::set_all_mesh_points_to_value(float value) {
100
+  void unified_bed_leveling::set_all_mesh_points_to_value(const float value) {
103 101
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {
104 102
       for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
105 103
         z_values[x][y] = value;

+ 3
- 4
Marlin/ubl.h Dosyayı Görüntüle

@@ -78,7 +78,6 @@
78 78
 
79 79
   typedef struct {
80 80
     bool active = false;
81
-    float z_offset = 0.0;
82 81
     int8_t storage_slot = -1;
83 82
   } ubl_state;
84 83
 
@@ -158,7 +157,7 @@
158 157
       static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, uint16_t[16], bool);
159 158
       static void reset();
160 159
       static void invalidate();
161
-      static void set_all_mesh_points_to_value(float);
160
+      static void set_all_mesh_points_to_value(const float);
162 161
       static bool sanity_check();
163 162
 
164 163
       static void G29() _O0;                          // O0 for no optimization
@@ -310,7 +309,7 @@
310 309
             strcpy(lcd_status_message, "get_z_correction() indexes out of range.");
311 310
             lcd_quick_feedback();
312 311
           #endif
313
-          return NAN; // this used to return state.z_offset
312
+          return NAN;
314 313
         }
315 314
 
316 315
         const float z1 = calc_z0(RAW_X_POSITION(lx0),
@@ -359,7 +358,7 @@
359 358
             }
360 359
           #endif
361 360
         }
362
-        return z0; // there used to be a +state.z_offset on this line
361
+        return z0;
363 362
       }
364 363
 
365 364
       /**

+ 0
- 59
Marlin/ubl_G29.cpp Dosyayı Görüntüle

@@ -669,65 +669,6 @@
669 669
     if (parser.seen('T'))
670 670
       display_map(parser.has_value() ? parser.value_int() : 0);
671 671
 
672
-    /**
673
-     * This code may not be needed...  Prepare for its removal...
674
-     *
675
-     */
676
-    #if 0
677
-    if (parser.seen('Z')) {
678
-      if (parser.has_value())
679
-        state.z_offset = parser.value_float();   // do the simple case. Just lock in the specified value
680
-      else {
681
-        save_ubl_active_state_and_disable();
682
-        //float measured_z = probe_pt(g29_x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, g29_y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER, ProbeDeployAndStow, g29_verbose_level);
683
-
684
-        has_control_of_lcd_panel = true;     // Grab the LCD Hardware
685
-        float measured_z = 1.5;
686
-        do_blocking_move_to_z(measured_z);  // Get close to the bed, but leave some space so we don't damage anything
687
-                                            // The user is not going to be locking in a new Z-Offset very often so
688
-                                            // it won't be that painful to spin the Encoder Wheel for 1.5mm
689
-        lcd_refresh();
690
-        lcd_z_offset_edit_setup(measured_z);
691
-
692
-        KEEPALIVE_STATE(PAUSED_FOR_USER);
693
-
694
-        do {
695
-          measured_z = lcd_z_offset_edit();
696
-          idle();
697
-          do_blocking_move_to_z(measured_z);
698
-        } while (!ubl_lcd_clicked());
699
-
700
-        has_control_of_lcd_panel = true;   // There is a race condition for the encoder click.
701
-                                               // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune)
702
-                                               // or here. So, until we are done looking for a long encoder press,
703
-                                               // we need to take control of the panel
704
-
705
-        KEEPALIVE_STATE(IN_HANDLER);
706
-
707
-        lcd_return_to_status();
708
-
709
-        const millis_t nxt = millis() + 1500UL;
710
-        while (ubl_lcd_clicked()) { // debounce and watch for abort
711
-          idle();
712
-          if (ELAPSED(millis(), nxt)) {
713
-            SERIAL_PROTOCOLLNPGM("\nZ-Offset Adjustment Stopped.");
714
-            do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
715
-            LCD_MESSAGEPGM(MSG_UBL_Z_OFFSET_STOPPED);
716
-            restore_ubl_active_state_and_leave();
717
-            goto LEAVE;
718
-          }
719
-        }
720
-        has_control_of_lcd_panel = false;
721
-        safe_delay(20); // We don't want any switch noise.
722
-
723
-        state.z_offset = measured_z;
724
-
725
-        lcd_refresh();
726
-        restore_ubl_active_state_and_leave();
727
-      }
728
-    }
729
-    #endif
730
-
731 672
     LEAVE:
732 673
 
733 674
     #if ENABLED(NEWPANEL)

+ 7
- 11
Marlin/ubl_motion.cpp Dosyayı Görüntüle

@@ -153,7 +153,7 @@
153 153
         // Note: There is no Z Correction in this case. We are off the grid and don't know what
154 154
         // a reasonable correction would be.
155 155
 
156
-        planner._buffer_line(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + state.z_offset, end[E_AXIS], feed_rate, extruder);
156
+        planner._buffer_line(end[X_AXIS], end[Y_AXIS], end[Z_AXIS], end[E_AXIS], feed_rate, extruder);
157 157
         set_current_to_destination();
158 158
 
159 159
         if (g26_debug_flag)
@@ -197,7 +197,7 @@
197 197
        */
198 198
       if (isnan(z0)) z0 = 0.0;
199 199
 
200
-      planner._buffer_line(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + z0 + state.z_offset, end[E_AXIS], feed_rate, extruder);
200
+      planner._buffer_line(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + z0, end[E_AXIS], feed_rate, extruder);
201 201
 
202 202
       if (g26_debug_flag)
203 203
         debug_current_and_destination(PSTR("FINAL_MOVE in ubl.line_to_destination()"));
@@ -302,7 +302,7 @@
302 302
             z_position = end[Z_AXIS];
303 303
           }
304 304
 
305
-          planner._buffer_line(x, y, z_position + z0 + state.z_offset, e_position, feed_rate, extruder);
305
+          planner._buffer_line(x, y, z_position + z0, e_position, feed_rate, extruder);
306 306
         } //else printf("FIRST MOVE PRUNED  ");
307 307
       }
308 308
 
@@ -367,7 +367,7 @@
367 367
             z_position = end[Z_AXIS];
368 368
           }
369 369
 
370
-          planner._buffer_line(x, y, z_position + z0 + state.z_offset, e_position, feed_rate, extruder);
370
+          planner._buffer_line(x, y, z_position + z0, e_position, feed_rate, extruder);
371 371
         } //else printf("FIRST MOVE PRUNED  ");
372 372
       }
373 373
 
@@ -430,7 +430,7 @@
430 430
           e_position = end[E_AXIS];
431 431
           z_position = end[Z_AXIS];
432 432
         }
433
-        planner._buffer_line(x, next_mesh_line_y, z_position + z0 + state.z_offset, e_position, feed_rate, extruder);
433
+        planner._buffer_line(x, next_mesh_line_y, z_position + z0, e_position, feed_rate, extruder);
434 434
         current_yi += dyi;
435 435
         yi_cnt--;
436 436
       }
@@ -459,7 +459,7 @@
459 459
           z_position = end[Z_AXIS];
460 460
         }
461 461
 
462
-        planner._buffer_line(next_mesh_line_x, y, z_position + z0 + state.z_offset, e_position, feed_rate, extruder);
462
+        planner._buffer_line(next_mesh_line_x, y, z_position + z0, e_position, feed_rate, extruder);
463 463
         current_xi += dxi;
464 464
         xi_cnt--;
465 465
       }
@@ -605,8 +605,6 @@
605 605
 
606 606
       if (!state.active || above_fade_height) {   // no mesh leveling
607 607
 
608
-        const float z_offset = state.active ? state.z_offset : 0.0;
609
-
610 608
         do {
611 609
 
612 610
           if (--segments) {     // not the last segment
@@ -621,7 +619,7 @@
621 619
             seg_le = ltarget[E_AXIS];
622 620
           }
623 621
 
624
-          ubl_buffer_segment_raw( seg_rx, seg_ry, seg_rz + z_offset, seg_le, feedrate );
622
+          ubl_buffer_segment_raw( seg_rx, seg_ry, seg_rz, seg_le, feedrate );
625 623
 
626 624
         } while (segments);
627 625
 
@@ -698,8 +696,6 @@
698 696
             z_cxcy *= fade_scaling_factor;          // apply fade factor to interpolated mesh height
699 697
           #endif
700 698
 
701
-          z_cxcy += state.z_offset;                 // add fixed mesh offset from G29 Z
702
-
703 699
           if (--segments == 0) {                    // if this is last segment, use ltarget for exact
704 700
             seg_rx = RAW_X_POSITION(ltarget[X_AXIS]);
705 701
             seg_ry = RAW_Y_POSITION(ltarget[Y_AXIS]);

Loading…
İptal
Kaydet