Quellcode durchsuchen

Save 28b PROGMEM in ultralcd.cpp (line_to_current)

Scott Lahteine vor 8 Jahren
Ursprung
Commit
2a41f0ff84
1 geänderte Dateien mit 16 neuen und 19 gelöschten Zeilen
  1. 16
    19
      Marlin/ultralcd.cpp

+ 16
- 19
Marlin/ultralcd.cpp Datei anzeigen

686
     else lcd_buzz(20, 440);
686
     else lcd_buzz(20, 440);
687
   }
687
   }
688
 
688
 
689
-  inline void line_to_current(AxisEnum axis) {
690
-    planner.buffer_line_kinematic(current_position, MMM_TO_MMS(manual_feedrate_mm_m[axis]), active_extruder);
689
+  inline void line_to_current_z() {
690
+    planner.buffer_line_kinematic(current_position, MMM_TO_MMS(manual_feedrate_mm_m[Z_AXIS]), active_extruder);
691
+  }
692
+
693
+  inline void line_to_z(const float &z) {
694
+    current_position[Z_AXIS] = z;
695
+    line_to_current_z();
691
   }
696
   }
692
 
697
 
693
   #if ENABLED(SDSUPPORT)
698
   #if ENABLED(SDSUPPORT)
1521
     //
1526
     //
1522
     void _lcd_after_probing() {
1527
     void _lcd_after_probing() {
1523
       #if MANUAL_PROBE_HEIGHT > 0
1528
       #if MANUAL_PROBE_HEIGHT > 0
1524
-        current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT;
1525
-        line_to_current(Z_AXIS);
1529
+        line_to_z(LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT);
1526
       #endif
1530
       #endif
1527
       // Display "Done" screen and wait for moves to complete
1531
       // Display "Done" screen and wait for moves to complete
1528
       #if MANUAL_PROBE_HEIGHT > 0 || ENABLED(MESH_BED_LEVELING)
1532
       #if MANUAL_PROBE_HEIGHT > 0 || ENABLED(MESH_BED_LEVELING)
1539
       // Utility to go to the next mesh point
1543
       // Utility to go to the next mesh point
1540
       inline void _manual_probe_goto_xy(float x, float y) {
1544
       inline void _manual_probe_goto_xy(float x, float y) {
1541
         #if MANUAL_PROBE_HEIGHT > 0
1545
         #if MANUAL_PROBE_HEIGHT > 0
1542
-          current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT;
1543
-          line_to_current(Z_AXIS);
1546
+          line_to_z(LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT);
1544
         #endif
1547
         #endif
1545
         current_position[X_AXIS] = LOGICAL_X_POSITION(x);
1548
         current_position[X_AXIS] = LOGICAL_X_POSITION(x);
1546
         current_position[Y_AXIS] = LOGICAL_Y_POSITION(y);
1549
         current_position[Y_AXIS] = LOGICAL_Y_POSITION(y);
1547
         planner.buffer_line_kinematic(current_position, MMM_TO_MMS(XY_PROBE_SPEED), active_extruder);
1550
         planner.buffer_line_kinematic(current_position, MMM_TO_MMS(XY_PROBE_SPEED), active_extruder);
1548
         #if MANUAL_PROBE_HEIGHT > 0
1551
         #if MANUAL_PROBE_HEIGHT > 0
1549
-          current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS);
1550
-          line_to_current(Z_AXIS);
1552
+          line_to_z(LOGICAL_Z_POSITION(Z_MIN_POS));
1551
         #endif
1553
         #endif
1552
         lcd_synchronize();
1554
         lcd_synchronize();
1553
       }
1555
       }
1629
       //
1631
       //
1630
       if (encoderPosition) {
1632
       if (encoderPosition) {
1631
         refresh_cmd_timeout();
1633
         refresh_cmd_timeout();
1632
-        current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
1633
-        NOLESS(current_position[Z_AXIS], -(LCD_PROBE_Z_RANGE) * 0.5);
1634
-        NOMORE(current_position[Z_AXIS],  (LCD_PROBE_Z_RANGE) * 0.5);
1635
-        line_to_current(Z_AXIS);
1634
+        const float z = current_position[Z_AXIS] + float((int32_t)encoderPosition) * (MBL_Z_STEP);
1635
+        line_to_z(constrain(z, -(LCD_PROBE_Z_RANGE) * 0.5, (LCD_PROBE_Z_RANGE) * 0.5));
1636
         lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
1636
         lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
1637
         encoderPosition = 0;
1637
         encoderPosition = 0;
1638
       }
1638
       }
2299
         reset_bed_level(); // After calibration bed-level data is no longer valid
2299
         reset_bed_level(); // After calibration bed-level data is no longer valid
2300
       #endif
2300
       #endif
2301
 
2301
 
2302
-      current_position[Z_AXIS] = max(Z_HOMING_HEIGHT, Z_CLEARANCE_BETWEEN_PROBES) + (DELTA_PRINTABLE_RADIUS) / 5;
2303
-      line_to_current(Z_AXIS);
2302
+      line_to_z(max(Z_HOMING_HEIGHT, Z_CLEARANCE_BETWEEN_PROBES) + (DELTA_PRINTABLE_RADIUS) / 5);
2304
 
2303
 
2305
       current_position[X_AXIS] = a < 0 ? LOGICAL_X_POSITION(X_HOME_POS) : cos(RADIANS(a)) * delta_calibration_radius;
2304
       current_position[X_AXIS] = a < 0 ? LOGICAL_X_POSITION(X_HOME_POS) : cos(RADIANS(a)) * delta_calibration_radius;
2306
       current_position[Y_AXIS] = a < 0 ? LOGICAL_Y_POSITION(Y_HOME_POS) : sin(RADIANS(a)) * delta_calibration_radius;
2305
       current_position[Y_AXIS] = a < 0 ? LOGICAL_Y_POSITION(Y_HOME_POS) : sin(RADIANS(a)) * delta_calibration_radius;
2307
-      line_to_current(Z_AXIS);
2306
+      line_to_current_z();
2308
 
2307
 
2309
-      current_position[Z_AXIS] = 4.0;
2310
-      line_to_current(Z_AXIS);
2308
+      line_to_z(4.0);
2311
 
2309
 
2312
       lcd_synchronize();
2310
       lcd_synchronize();
2313
 
2311
 
2536
     #if ENABLED(DELTA)
2534
     #if ENABLED(DELTA)
2537
       #define _MOVE_XY_ALLOWED (current_position[Z_AXIS] <= delta_clip_start_height)
2535
       #define _MOVE_XY_ALLOWED (current_position[Z_AXIS] <= delta_clip_start_height)
2538
       void lcd_lower_z_to_clip_height() {
2536
       void lcd_lower_z_to_clip_height() {
2539
-        current_position[Z_AXIS] = delta_clip_start_height;
2540
-        line_to_current(Z_AXIS);
2537
+        line_to_z(delta_clip_start_height);
2541
         lcd_synchronize();
2538
         lcd_synchronize();
2542
       }
2539
       }
2543
     #else
2540
     #else

Laden…
Abbrechen
Speichern