Bläddra i källkod

Remove obsolete UBL z_offset

Scott Lahteine 7 år sedan
förälder
incheckning
3d5b10735f
6 ändrade filer med 25 tillägg och 103 borttagningar
  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 Visa fil

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)
89
  *
89
  *
90
  * AUTO_BED_LEVELING_UBL:                           6 bytes
90
  * AUTO_BED_LEVELING_UBL:                           6 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  endstop_adj                      (float x3)
95
  *  348  M666 XYZ  endstop_adj                      (float x3)
437
 
436
 
438
     #if ENABLED(AUTO_BED_LEVELING_UBL)
437
     #if ENABLED(AUTO_BED_LEVELING_UBL)
439
       EEPROM_WRITE(ubl.state.active);
438
       EEPROM_WRITE(ubl.state.active);
440
-      EEPROM_WRITE(ubl.state.z_offset);
441
       EEPROM_WRITE(ubl.state.storage_slot);
439
       EEPROM_WRITE(ubl.state.storage_slot);
442
     #else
440
     #else
443
       const bool ubl_active = false;
441
       const bool ubl_active = false;
444
-      dummy = 0.0f;
445
       const int8_t storage_slot = -1;
442
       const int8_t storage_slot = -1;
446
       EEPROM_WRITE(ubl_active);
443
       EEPROM_WRITE(ubl_active);
447
-      EEPROM_WRITE(dummy);
448
       EEPROM_WRITE(storage_slot);
444
       EEPROM_WRITE(storage_slot);
449
     #endif // AUTO_BED_LEVELING_UBL
445
     #endif // AUTO_BED_LEVELING_UBL
450
 
446
 
829
 
825
 
830
       #if ENABLED(AUTO_BED_LEVELING_UBL)
826
       #if ENABLED(AUTO_BED_LEVELING_UBL)
831
         EEPROM_READ(ubl.state.active);
827
         EEPROM_READ(ubl.state.active);
832
-        EEPROM_READ(ubl.state.z_offset);
833
         EEPROM_READ(ubl.state.storage_slot);
828
         EEPROM_READ(ubl.state.storage_slot);
834
       #else
829
       #else
835
         uint8_t dummyui8;
830
         uint8_t dummyui8;
836
         EEPROM_READ(dummyb);
831
         EEPROM_READ(dummyb);
837
-        EEPROM_READ(dummy);
838
         EEPROM_READ(dummyui8);
832
         EEPROM_READ(dummyui8);
839
       #endif // AUTO_BED_LEVELING_UBL
833
       #endif // AUTO_BED_LEVELING_UBL
840
 
834
 
1609
       if (!forReplay) {
1603
       if (!forReplay) {
1610
         SERIAL_EOL();
1604
         SERIAL_EOL();
1611
         ubl.report_state();
1605
         ubl.report_state();
1612
-
1613
         SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.state.storage_slot);
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
         SERIAL_ECHOPAIR("EEPROM can hold ", calc_num_meshes());
1607
         SERIAL_ECHOPAIR("EEPROM can hold ", calc_num_meshes());
1620
         SERIAL_ECHOLNPGM(" meshes.\n");
1608
         SERIAL_ECHOLNPGM(" meshes.\n");
1621
       }
1609
       }

+ 11
- 11
Marlin/planner.cpp Visa fil

533
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
533
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
534
         // if z_fade_height enabled (nonzero) and raw_z above it, no leveling required
534
         // if z_fade_height enabled (nonzero) and raw_z above it, no leveling required
535
         if (planner.z_fade_height && planner.z_fade_height <= RAW_Z_POSITION(lz)) return;
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
       #else // no fade
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
       #endif // FADE
539
       #endif // FADE
540
     #endif // UBL
540
     #endif // UBL
541
 
541
 
598
 
598
 
599
         const float z_physical = RAW_Z_POSITION(logical[Z_AXIS]),
599
         const float z_physical = RAW_Z_POSITION(logical[Z_AXIS]),
600
                     z_correct = ubl.get_z_correction(logical[X_AXIS], logical[Y_AXIS]),
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
               float z_logical = LOGICAL_Z_POSITION(z_virtual);
602
               float z_logical = LOGICAL_Z_POSITION(z_virtual);
603
 
603
 
604
         #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
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
           if (planner.z_fade_height) {
614
           if (planner.z_fade_height) {
615
             if (z_logical >= planner.z_fade_height)
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
             else
617
             else
618
               z_logical /= 1.0 - z_correct * planner.inverse_z_fade_height;
618
               z_logical /= 1.0 - z_correct * planner.inverse_z_fade_height;
619
           }
619
           }

+ 1
- 3
Marlin/ubl.cpp Visa fil

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

+ 3
- 4
Marlin/ubl.h Visa fil

78
 
78
 
79
   typedef struct {
79
   typedef struct {
80
     bool active = false;
80
     bool active = false;
81
-    float z_offset = 0.0;
82
     int8_t storage_slot = -1;
81
     int8_t storage_slot = -1;
83
   } ubl_state;
82
   } ubl_state;
84
 
83
 
158
       static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, uint16_t[16], bool);
157
       static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, uint16_t[16], bool);
159
       static void reset();
158
       static void reset();
160
       static void invalidate();
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
       static bool sanity_check();
161
       static bool sanity_check();
163
 
162
 
164
       static void G29() _O0;                          // O0 for no optimization
163
       static void G29() _O0;                          // O0 for no optimization
310
             strcpy(lcd_status_message, "get_z_correction() indexes out of range.");
309
             strcpy(lcd_status_message, "get_z_correction() indexes out of range.");
311
             lcd_quick_feedback();
310
             lcd_quick_feedback();
312
           #endif
311
           #endif
313
-          return NAN; // this used to return state.z_offset
312
+          return NAN;
314
         }
313
         }
315
 
314
 
316
         const float z1 = calc_z0(RAW_X_POSITION(lx0),
315
         const float z1 = calc_z0(RAW_X_POSITION(lx0),
359
             }
358
             }
360
           #endif
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 Visa fil

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

+ 7
- 11
Marlin/ubl_motion.cpp Visa fil

153
         // Note: There is no Z Correction in this case. We are off the grid and don't know what
153
         // Note: There is no Z Correction in this case. We are off the grid and don't know what
154
         // a reasonable correction would be.
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
         set_current_to_destination();
157
         set_current_to_destination();
158
 
158
 
159
         if (g26_debug_flag)
159
         if (g26_debug_flag)
197
        */
197
        */
198
       if (isnan(z0)) z0 = 0.0;
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
       if (g26_debug_flag)
202
       if (g26_debug_flag)
203
         debug_current_and_destination(PSTR("FINAL_MOVE in ubl.line_to_destination()"));
203
         debug_current_and_destination(PSTR("FINAL_MOVE in ubl.line_to_destination()"));
302
             z_position = end[Z_AXIS];
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
         } //else printf("FIRST MOVE PRUNED  ");
306
         } //else printf("FIRST MOVE PRUNED  ");
307
       }
307
       }
308
 
308
 
367
             z_position = end[Z_AXIS];
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
         } //else printf("FIRST MOVE PRUNED  ");
371
         } //else printf("FIRST MOVE PRUNED  ");
372
       }
372
       }
373
 
373
 
430
           e_position = end[E_AXIS];
430
           e_position = end[E_AXIS];
431
           z_position = end[Z_AXIS];
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
         current_yi += dyi;
434
         current_yi += dyi;
435
         yi_cnt--;
435
         yi_cnt--;
436
       }
436
       }
459
           z_position = end[Z_AXIS];
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
         current_xi += dxi;
463
         current_xi += dxi;
464
         xi_cnt--;
464
         xi_cnt--;
465
       }
465
       }
605
 
605
 
606
       if (!state.active || above_fade_height) {   // no mesh leveling
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
         do {
608
         do {
611
 
609
 
612
           if (--segments) {     // not the last segment
610
           if (--segments) {     // not the last segment
621
             seg_le = ltarget[E_AXIS];
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
         } while (segments);
624
         } while (segments);
627
 
625
 
698
             z_cxcy *= fade_scaling_factor;          // apply fade factor to interpolated mesh height
696
             z_cxcy *= fade_scaling_factor;          // apply fade factor to interpolated mesh height
699
           #endif
697
           #endif
700
 
698
 
701
-          z_cxcy += state.z_offset;                 // add fixed mesh offset from G29 Z
702
-
703
           if (--segments == 0) {                    // if this is last segment, use ltarget for exact
699
           if (--segments == 0) {                    // if this is last segment, use ltarget for exact
704
             seg_rx = RAW_X_POSITION(ltarget[X_AXIS]);
700
             seg_rx = RAW_X_POSITION(ltarget[X_AXIS]);
705
             seg_ry = RAW_Y_POSITION(ltarget[Y_AXIS]);
701
             seg_ry = RAW_Y_POSITION(ltarget[Y_AXIS]);

Laddar…
Avbryt
Spara