Bläddra i källkod

Remove obsolete UBL z_offset

Scott Lahteine 7 år sedan
förälder
incheckning
1adb5a6a48

+ 1
- 3
Marlin/src/feature/bedlevel/ubl/ubl.cpp Visa fil

@@ -91,7 +91,6 @@
91 91
 
92 92
   void unified_bed_leveling::reset() {
93 93
     set_bed_leveling_enabled(false);
94
-    state.z_offset = 0;
95 94
     state.storage_slot = -1;
96 95
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
97 96
       planner.z_fade_height = 10.0;
@@ -102,11 +101,10 @@
102 101
 
103 102
   void unified_bed_leveling::invalidate() {
104 103
     set_bed_leveling_enabled(false);
105
-    state.z_offset = 0;
106 104
     set_all_mesh_points_to_value(NAN);
107 105
   }
108 106
 
109
-  void unified_bed_leveling::set_all_mesh_points_to_value(float value) {
107
+  void unified_bed_leveling::set_all_mesh_points_to_value(const float value) {
110 108
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {
111 109
       for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
112 110
         z_values[x][y] = value;

+ 3
- 4
Marlin/src/feature/bedlevel/ubl/ubl.h Visa fil

@@ -72,7 +72,6 @@ extern uint8_t ubl_cnt;
72 72
 
73 73
 typedef struct {
74 74
   bool active = false;
75
-  float z_offset = 0.0;
76 75
   int8_t storage_slot = -1;
77 76
 } ubl_state;
78 77
 
@@ -152,7 +151,7 @@ class unified_bed_leveling {
152 151
     static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, uint16_t[16], bool);
153 152
     static void reset();
154 153
     static void invalidate();
155
-    static void set_all_mesh_points_to_value(float);
154
+    static void set_all_mesh_points_to_value(const float);
156 155
     static bool sanity_check();
157 156
 
158 157
     static void G29() _O0;                          // O0 for no optimization
@@ -316,7 +315,7 @@ class unified_bed_leveling {
316 315
           strcpy(lcd_status_message, "get_z_correction() indexes out of range.");
317 316
           lcd_quick_feedback();
318 317
         #endif
319
-        return NAN; // this used to return state.z_offset
318
+        return NAN;
320 319
       }
321 320
 
322 321
       const float z1 = calc_z0(RAW_X_POSITION(lx0),
@@ -365,7 +364,7 @@ class unified_bed_leveling {
365 364
           }
366 365
         #endif
367 366
       }
368
-      return z0; // there used to be a +state.z_offset on this line
367
+      return z0;
369 368
     }
370 369
 
371 370
     /**

+ 0
- 59
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Visa fil

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

+ 7
- 11
Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp Visa fil

@@ -140,7 +140,7 @@
140 140
         // Note: There is no Z Correction in this case. We are off the grid and don't know what
141 141
         // a reasonable correction would be.
142 142
 
143
-        planner._buffer_line(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + state.z_offset, end[E_AXIS], feed_rate, extruder);
143
+        planner._buffer_line(end[X_AXIS], end[Y_AXIS], end[Z_AXIS], end[E_AXIS], feed_rate, extruder);
144 144
         set_current_to_destination();
145 145
 
146 146
         if (g26_debug_flag)
@@ -184,7 +184,7 @@
184 184
        */
185 185
       if (isnan(z0)) z0 = 0.0;
186 186
 
187
-      planner._buffer_line(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + z0 + state.z_offset, end[E_AXIS], feed_rate, extruder);
187
+      planner._buffer_line(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + z0, end[E_AXIS], feed_rate, extruder);
188 188
 
189 189
       if (g26_debug_flag)
190 190
         debug_current_and_destination(PSTR("FINAL_MOVE in ubl.line_to_destination()"));
@@ -289,7 +289,7 @@
289 289
             z_position = end[Z_AXIS];
290 290
           }
291 291
 
292
-          planner._buffer_line(x, y, z_position + z0 + state.z_offset, e_position, feed_rate, extruder);
292
+          planner._buffer_line(x, y, z_position + z0, e_position, feed_rate, extruder);
293 293
         } //else printf("FIRST MOVE PRUNED  ");
294 294
       }
295 295
 
@@ -354,7 +354,7 @@
354 354
             z_position = end[Z_AXIS];
355 355
           }
356 356
 
357
-          planner._buffer_line(x, y, z_position + z0 + state.z_offset, e_position, feed_rate, extruder);
357
+          planner._buffer_line(x, y, z_position + z0, e_position, feed_rate, extruder);
358 358
         } //else printf("FIRST MOVE PRUNED  ");
359 359
       }
360 360
 
@@ -417,7 +417,7 @@
417 417
           e_position = end[E_AXIS];
418 418
           z_position = end[Z_AXIS];
419 419
         }
420
-        planner._buffer_line(x, next_mesh_line_y, z_position + z0 + state.z_offset, e_position, feed_rate, extruder);
420
+        planner._buffer_line(x, next_mesh_line_y, z_position + z0, e_position, feed_rate, extruder);
421 421
         current_yi += dyi;
422 422
         yi_cnt--;
423 423
       }
@@ -446,7 +446,7 @@
446 446
           z_position = end[Z_AXIS];
447 447
         }
448 448
 
449
-        planner._buffer_line(next_mesh_line_x, y, z_position + z0 + state.z_offset, e_position, feed_rate, extruder);
449
+        planner._buffer_line(next_mesh_line_x, y, z_position + z0, e_position, feed_rate, extruder);
450 450
         current_xi += dxi;
451 451
         xi_cnt--;
452 452
       }
@@ -592,8 +592,6 @@
592 592
 
593 593
       if (!state.active || above_fade_height) {   // no mesh leveling
594 594
 
595
-        const float z_offset = state.active ? state.z_offset : 0.0;
596
-
597 595
         do {
598 596
 
599 597
           if (--segments) {     // not the last segment
@@ -608,7 +606,7 @@
608 606
             seg_le = ltarget[E_AXIS];
609 607
           }
610 608
 
611
-          ubl_buffer_segment_raw( seg_rx, seg_ry, seg_rz + z_offset, seg_le, feedrate );
609
+          ubl_buffer_segment_raw( seg_rx, seg_ry, seg_rz, seg_le, feedrate );
612 610
 
613 611
         } while (segments);
614 612
 
@@ -685,8 +683,6 @@
685 683
             z_cxcy *= fade_scaling_factor;          // apply fade factor to interpolated mesh height
686 684
           #endif
687 685
 
688
-          z_cxcy += state.z_offset;                 // add fixed mesh offset from G29 Z
689
-
690 686
           if (--segments == 0) {                    // if this is last segment, use ltarget for exact
691 687
             seg_rx = RAW_X_POSITION(ltarget[X_AXIS]);
692 688
             seg_ry = RAW_Y_POSITION(ltarget[Y_AXIS]);

+ 5
- 16
Marlin/src/module/configuration_store.cpp Visa fil

@@ -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)
@@ -87,13 +87,12 @@
87 87
  *  312  G29 L F   bilinear_start                   (int x2)
88 88
  *  316            z_values[][]                     (float x9, up to float x256) +988
89 89
  *
90
- * AUTO_BED_LEVELING_UBL:                           6 bytes
90
+ * AUTO_BED_LEVELING_UBL:                           2 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
- *  348  M666 XYZ  delta_endstop_adj                (float x3)
95
+ *  344  M666 XYZ  delta_endstop_adj                (float x3)
97 96
  *  360  M665 R    delta_radius                     (float)
98 97
  *  364  M665 L    delta_diagonal_rod               (float)
99 98
  *  368  M665 S    delta_segments_per_second        (float)
@@ -408,14 +407,11 @@ void MarlinSettings::postprocess() {
408 407
 
409 408
     #if ENABLED(AUTO_BED_LEVELING_UBL)
410 409
       EEPROM_WRITE(ubl.state.active);
411
-      EEPROM_WRITE(ubl.state.z_offset);
412 410
       EEPROM_WRITE(ubl.state.storage_slot);
413 411
     #else
414 412
       const bool ubl_active = false;
415
-      dummy = 0.0f;
416 413
       const int8_t storage_slot = -1;
417 414
       EEPROM_WRITE(ubl_active);
418
-      EEPROM_WRITE(dummy);
419 415
       EEPROM_WRITE(storage_slot);
420 416
     #endif // AUTO_BED_LEVELING_UBL
421 417
 
@@ -798,12 +794,10 @@ void MarlinSettings::postprocess() {
798 794
 
799 795
       #if ENABLED(AUTO_BED_LEVELING_UBL)
800 796
         EEPROM_READ(ubl.state.active);
801
-        EEPROM_READ(ubl.state.z_offset);
802 797
         EEPROM_READ(ubl.state.storage_slot);
803 798
       #else
804 799
         uint8_t dummyui8;
805 800
         EEPROM_READ(dummyb);
806
-        EEPROM_READ(dummy);
807 801
         EEPROM_READ(dummyui8);
808 802
       #endif // AUTO_BED_LEVELING_UBL
809 803
 
@@ -1573,11 +1567,6 @@ void MarlinSettings::reset() {
1573 1567
         ubl.report_state();
1574 1568
 
1575 1569
         SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.state.storage_slot);
1576
-
1577
-        SERIAL_ECHOPGM("z_offset: ");
1578
-        SERIAL_ECHO_F(ubl.state.z_offset, 6);
1579
-        SERIAL_EOL();
1580
-
1581 1570
         SERIAL_ECHOPAIR("EEPROM can hold ", calc_num_meshes());
1582 1571
         SERIAL_ECHOLNPGM(" meshes.\n");
1583 1572
       }

+ 11
- 11
Marlin/src/module/planner.cpp Visa fil

@@ -560,9 +560,9 @@ void Planner::calculate_volumetric_multipliers() {
560 560
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
561 561
         // if z_fade_height enabled (nonzero) and raw_z above it, no leveling required
562 562
         if (planner.z_fade_height && planner.z_fade_height <= RAW_Z_POSITION(lz)) return;
563
-        lz += ubl.state.z_offset + ubl.get_z_correction(lx, ly) * ubl.fade_scaling_factor_for_z(lz);
563
+        lz += ubl.get_z_correction(lx, ly) * ubl.fade_scaling_factor_for_z(lz);
564 564
       #else // no fade
565
-        lz += ubl.state.z_offset + ubl.get_z_correction(lx, ly);
565
+        lz += ubl.get_z_correction(lx, ly);
566 566
       #endif // FADE
567 567
     #endif // UBL
568 568
 
@@ -625,22 +625,22 @@ void Planner::calculate_volumetric_multipliers() {
625 625
 
626 626
         const float z_physical = RAW_Z_POSITION(logical[Z_AXIS]),
627 627
                     z_correct = ubl.get_z_correction(logical[X_AXIS], logical[Y_AXIS]),
628
-                    z_virtual = z_physical - ubl.state.z_offset - z_correct;
628
+                    z_virtual = z_physical - z_correct;
629 629
               float z_logical = LOGICAL_Z_POSITION(z_virtual);
630 630
 
631 631
         #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
632 632
 
633
-          // for P=physical_z, L=logical_z, M=mesh_z, O=z_offset, H=fade_height,
634
-          // Given P=L+O+M(1-L/H) (faded mesh correction formula for L<H)
635
-          //  then L=P-O-M(1-L/H)
636
-          //    so L=P-O-M+ML/H
637
-          //    so L-ML/H=P-O-M
638
-          //    so L(1-M/H)=P-O-M
639
-          //    so L=(P-O-M)/(1-M/H) for L<H
633
+          // for P=physical_z, L=logical_z, M=mesh_z, H=fade_height,
634
+          // Given P=L+M(1-L/H) (faded mesh correction formula for L<H)
635
+          //  then L=P-M(1-L/H)
636
+          //    so L=P-M+ML/H
637
+          //    so L-ML/H=P-M
638
+          //    so L(1-M/H)=P-M
639
+          //    so L=(P-M)/(1-M/H) for L<H
640 640
 
641 641
           if (planner.z_fade_height) {
642 642
             if (z_logical >= planner.z_fade_height)
643
-              z_logical = LOGICAL_Z_POSITION(z_physical - ubl.state.z_offset);
643
+              z_logical = LOGICAL_Z_POSITION(z_physical);
644 644
             else
645 645
               z_logical /= 1.0 - z_correct * planner.inverse_z_fade_height;
646 646
           }

Laddar…
Avbryt
Spara