Sfoglia il codice sorgente

Remove obsolete UBL z_offset

Scott Lahteine 7 anni fa
parent
commit
1adb5a6a48

+ 1
- 3
Marlin/src/feature/bedlevel/ubl/ubl.cpp Vedi File

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

+ 3
- 4
Marlin/src/feature/bedlevel/ubl/ubl.h Vedi File

72
 
72
 
73
 typedef struct {
73
 typedef struct {
74
   bool active = false;
74
   bool active = false;
75
-  float z_offset = 0.0;
76
   int8_t storage_slot = -1;
75
   int8_t storage_slot = -1;
77
 } ubl_state;
76
 } ubl_state;
78
 
77
 
152
     static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, uint16_t[16], bool);
151
     static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, uint16_t[16], bool);
153
     static void reset();
152
     static void reset();
154
     static void invalidate();
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
     static bool sanity_check();
155
     static bool sanity_check();
157
 
156
 
158
     static void G29() _O0;                          // O0 for no optimization
157
     static void G29() _O0;                          // O0 for no optimization
316
           strcpy(lcd_status_message, "get_z_correction() indexes out of range.");
315
           strcpy(lcd_status_message, "get_z_correction() indexes out of range.");
317
           lcd_quick_feedback();
316
           lcd_quick_feedback();
318
         #endif
317
         #endif
319
-        return NAN; // this used to return state.z_offset
318
+        return NAN;
320
       }
319
       }
321
 
320
 
322
       const float z1 = calc_z0(RAW_X_POSITION(lx0),
321
       const float z1 = calc_z0(RAW_X_POSITION(lx0),
365
           }
364
           }
366
         #endif
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 Vedi File

670
     if (parser.seen('T'))
670
     if (parser.seen('T'))
671
       display_map(parser.has_value() ? parser.value_int() : 0);
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
     LEAVE:
673
     LEAVE:
733
 
674
 
734
     #if ENABLED(NEWPANEL)
675
     #if ENABLED(NEWPANEL)

+ 7
- 11
Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp Vedi File

140
         // Note: There is no Z Correction in this case. We are off the grid and don't know what
140
         // Note: There is no Z Correction in this case. We are off the grid and don't know what
141
         // a reasonable correction would be.
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
         set_current_to_destination();
144
         set_current_to_destination();
145
 
145
 
146
         if (g26_debug_flag)
146
         if (g26_debug_flag)
184
        */
184
        */
185
       if (isnan(z0)) z0 = 0.0;
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
       if (g26_debug_flag)
189
       if (g26_debug_flag)
190
         debug_current_and_destination(PSTR("FINAL_MOVE in ubl.line_to_destination()"));
190
         debug_current_and_destination(PSTR("FINAL_MOVE in ubl.line_to_destination()"));
289
             z_position = end[Z_AXIS];
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
         } //else printf("FIRST MOVE PRUNED  ");
293
         } //else printf("FIRST MOVE PRUNED  ");
294
       }
294
       }
295
 
295
 
354
             z_position = end[Z_AXIS];
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
         } //else printf("FIRST MOVE PRUNED  ");
358
         } //else printf("FIRST MOVE PRUNED  ");
359
       }
359
       }
360
 
360
 
417
           e_position = end[E_AXIS];
417
           e_position = end[E_AXIS];
418
           z_position = end[Z_AXIS];
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
         current_yi += dyi;
421
         current_yi += dyi;
422
         yi_cnt--;
422
         yi_cnt--;
423
       }
423
       }
446
           z_position = end[Z_AXIS];
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
         current_xi += dxi;
450
         current_xi += dxi;
451
         xi_cnt--;
451
         xi_cnt--;
452
       }
452
       }
592
 
592
 
593
       if (!state.active || above_fade_height) {   // no mesh leveling
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
         do {
595
         do {
598
 
596
 
599
           if (--segments) {     // not the last segment
597
           if (--segments) {     // not the last segment
608
             seg_le = ltarget[E_AXIS];
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
         } while (segments);
611
         } while (segments);
614
 
612
 
685
             z_cxcy *= fade_scaling_factor;          // apply fade factor to interpolated mesh height
683
             z_cxcy *= fade_scaling_factor;          // apply fade factor to interpolated mesh height
686
           #endif
684
           #endif
687
 
685
 
688
-          z_cxcy += state.z_offset;                 // add fixed mesh offset from G29 Z
689
-
690
           if (--segments == 0) {                    // if this is last segment, use ltarget for exact
686
           if (--segments == 0) {                    // if this is last segment, use ltarget for exact
691
             seg_rx = RAW_X_POSITION(ltarget[X_AXIS]);
687
             seg_rx = RAW_X_POSITION(ltarget[X_AXIS]);
692
             seg_ry = RAW_Y_POSITION(ltarget[Y_AXIS]);
688
             seg_ry = RAW_Y_POSITION(ltarget[Y_AXIS]);

+ 5
- 16
Marlin/src/module/configuration_store.cpp Vedi File

36
  *
36
  *
37
  */
37
  */
38
 
38
 
39
-#define EEPROM_VERSION "V41"
39
+#define EEPROM_VERSION "V42"
40
 
40
 
41
 // Change EEPROM version if these are changed:
41
 // Change EEPROM version if these are changed:
42
 #define EEPROM_OFFSET 100
42
 #define EEPROM_OFFSET 100
43
 
43
 
44
 /**
44
 /**
45
- * V41 EEPROM Layout:
45
+ * V42 EEPROM Layout:
46
  *
46
  *
47
  *  100  Version                                    (char x4)
47
  *  100  Version                                    (char x4)
48
  *  104  EEPROM CRC16                               (uint16_t)
48
  *  104  EEPROM CRC16                               (uint16_t)
87
  *  312  G29 L F   bilinear_start                   (int x2)
87
  *  312  G29 L F   bilinear_start                   (int x2)
88
  *  316            z_values[][]                     (float x9, up to float x256) +988
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
  *  324  G29 A     ubl.state.active                 (bool)
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
  * DELTA:                                           48 bytes
94
  * DELTA:                                           48 bytes
96
- *  348  M666 XYZ  delta_endstop_adj                (float x3)
95
+ *  344  M666 XYZ  delta_endstop_adj                (float x3)
97
  *  360  M665 R    delta_radius                     (float)
96
  *  360  M665 R    delta_radius                     (float)
98
  *  364  M665 L    delta_diagonal_rod               (float)
97
  *  364  M665 L    delta_diagonal_rod               (float)
99
  *  368  M665 S    delta_segments_per_second        (float)
98
  *  368  M665 S    delta_segments_per_second        (float)
408
 
407
 
409
     #if ENABLED(AUTO_BED_LEVELING_UBL)
408
     #if ENABLED(AUTO_BED_LEVELING_UBL)
410
       EEPROM_WRITE(ubl.state.active);
409
       EEPROM_WRITE(ubl.state.active);
411
-      EEPROM_WRITE(ubl.state.z_offset);
412
       EEPROM_WRITE(ubl.state.storage_slot);
410
       EEPROM_WRITE(ubl.state.storage_slot);
413
     #else
411
     #else
414
       const bool ubl_active = false;
412
       const bool ubl_active = false;
415
-      dummy = 0.0f;
416
       const int8_t storage_slot = -1;
413
       const int8_t storage_slot = -1;
417
       EEPROM_WRITE(ubl_active);
414
       EEPROM_WRITE(ubl_active);
418
-      EEPROM_WRITE(dummy);
419
       EEPROM_WRITE(storage_slot);
415
       EEPROM_WRITE(storage_slot);
420
     #endif // AUTO_BED_LEVELING_UBL
416
     #endif // AUTO_BED_LEVELING_UBL
421
 
417
 
798
 
794
 
799
       #if ENABLED(AUTO_BED_LEVELING_UBL)
795
       #if ENABLED(AUTO_BED_LEVELING_UBL)
800
         EEPROM_READ(ubl.state.active);
796
         EEPROM_READ(ubl.state.active);
801
-        EEPROM_READ(ubl.state.z_offset);
802
         EEPROM_READ(ubl.state.storage_slot);
797
         EEPROM_READ(ubl.state.storage_slot);
803
       #else
798
       #else
804
         uint8_t dummyui8;
799
         uint8_t dummyui8;
805
         EEPROM_READ(dummyb);
800
         EEPROM_READ(dummyb);
806
-        EEPROM_READ(dummy);
807
         EEPROM_READ(dummyui8);
801
         EEPROM_READ(dummyui8);
808
       #endif // AUTO_BED_LEVELING_UBL
802
       #endif // AUTO_BED_LEVELING_UBL
809
 
803
 
1573
         ubl.report_state();
1567
         ubl.report_state();
1574
 
1568
 
1575
         SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.state.storage_slot);
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
         SERIAL_ECHOPAIR("EEPROM can hold ", calc_num_meshes());
1570
         SERIAL_ECHOPAIR("EEPROM can hold ", calc_num_meshes());
1582
         SERIAL_ECHOLNPGM(" meshes.\n");
1571
         SERIAL_ECHOLNPGM(" meshes.\n");
1583
       }
1572
       }

+ 11
- 11
Marlin/src/module/planner.cpp Vedi File

560
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
560
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
561
         // if z_fade_height enabled (nonzero) and raw_z above it, no leveling required
561
         // if z_fade_height enabled (nonzero) and raw_z above it, no leveling required
562
         if (planner.z_fade_height && planner.z_fade_height <= RAW_Z_POSITION(lz)) return;
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
       #else // no fade
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
       #endif // FADE
566
       #endif // FADE
567
     #endif // UBL
567
     #endif // UBL
568
 
568
 
625
 
625
 
626
         const float z_physical = RAW_Z_POSITION(logical[Z_AXIS]),
626
         const float z_physical = RAW_Z_POSITION(logical[Z_AXIS]),
627
                     z_correct = ubl.get_z_correction(logical[X_AXIS], logical[Y_AXIS]),
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
               float z_logical = LOGICAL_Z_POSITION(z_virtual);
629
               float z_logical = LOGICAL_Z_POSITION(z_virtual);
630
 
630
 
631
         #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
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
           if (planner.z_fade_height) {
641
           if (planner.z_fade_height) {
642
             if (z_logical >= planner.z_fade_height)
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
             else
644
             else
645
               z_logical /= 1.0 - z_correct * planner.inverse_z_fade_height;
645
               z_logical /= 1.0 - z_correct * planner.inverse_z_fade_height;
646
           }
646
           }

Loading…
Annulla
Salva