|
@@ -105,11 +105,10 @@ float Planner::max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second
|
105
|
105
|
|
106
|
106
|
int16_t Planner::flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100); // Extrusion factor for each extruder
|
107
|
107
|
|
108
|
|
-// Initialized by settings.load()
|
109
|
|
-float Planner::e_factor[EXTRUDERS], // The flow percentage and volumetric multiplier combine to scale E movement
|
110
|
|
- Planner::filament_size[EXTRUDERS], // As a baseline for the multiplier, filament diameter
|
|
108
|
+float Planner::e_factor[EXTRUDERS], // The flow percentage and volumetric multiplier combine to scale E movement
|
|
109
|
+ Planner::filament_size[EXTRUDERS], // diameter of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder
|
111
|
110
|
Planner::volumetric_area_nominal = CIRCLE_AREA((DEFAULT_NOMINAL_FILAMENT_DIA) * 0.5), // Nominal cross-sectional area
|
112
|
|
- Planner::volumetric_multiplier[EXTRUDERS]; // May be auto-adjusted by a filament width sensor
|
|
111
|
+ Planner::volumetric_multiplier[EXTRUDERS]; // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner
|
113
|
112
|
|
114
|
113
|
uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N],
|
115
|
114
|
Planner::max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
|
|
@@ -129,12 +128,11 @@ float Planner::min_feedrate_mm_s,
|
129
|
128
|
#if ABL_PLANAR
|
130
|
129
|
matrix_3x3 Planner::bed_level_matrix; // Transform to compensate for bed level
|
131
|
130
|
#endif
|
132
|
|
-#endif
|
133
|
|
-
|
134
|
|
-#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
135
|
|
- float Planner::z_fade_height, // Initialized by settings.load()
|
136
|
|
- Planner::inverse_z_fade_height,
|
137
|
|
- Planner::last_fade_z;
|
|
131
|
+ #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
|
132
|
+ float Planner::z_fade_height, // Initialized by settings.load()
|
|
133
|
+ Planner::inverse_z_fade_height,
|
|
134
|
+ Planner::last_fade_z;
|
|
135
|
+ #endif
|
138
|
136
|
#endif
|
139
|
137
|
|
140
|
138
|
#if ENABLED(AUTOTEMP)
|
|
@@ -571,7 +569,7 @@ void Planner::calculate_volumetric_multipliers() {
|
571
|
569
|
*/
|
572
|
570
|
void Planner::apply_leveling(float &rx, float &ry, float &rz) {
|
573
|
571
|
|
574
|
|
- if (!planner.leveling_active) return;
|
|
572
|
+ if (!leveling_active) return;
|
575
|
573
|
|
576
|
574
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
577
|
575
|
const float fade_scaling_factor = fade_scaling_factor_for_z(rz);
|
|
@@ -614,20 +612,22 @@ void Planner::calculate_volumetric_multipliers() {
|
614
|
612
|
|
615
|
613
|
void Planner::unapply_leveling(float raw[XYZ]) {
|
616
|
614
|
|
617
|
|
- if (!planner.leveling_active) return;
|
|
615
|
+ if (!leveling_active) return;
|
618
|
616
|
|
619
|
617
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
620
|
|
- if (z_fade_height && raw[Z_AXIS] >= z_fade_height) return;
|
|
618
|
+ if (!leveling_active_at_z(raw[Z_AXIS])) return;
|
621
|
619
|
#endif
|
622
|
620
|
|
623
|
621
|
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
624
|
622
|
|
625
|
|
- const float z_correct = ubl.get_z_correction(raw[X_AXIS], raw[Y_AXIS]);
|
626
|
|
- float z_raw = raw[Z_AXIS] - z_correct;
|
|
623
|
+ const float z_physical = raw[Z_AXIS],
|
|
624
|
+ z_correct = ubl.get_z_correction(raw[X_AXIS], raw[Y_AXIS]),
|
|
625
|
+ z_virtual = z_physical - z_correct;
|
|
626
|
+ float z_raw = z_virtual;
|
627
|
627
|
|
628
|
628
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
629
|
629
|
|
630
|
|
- // for P=physical_z, L=raw_z, M=mesh_z, H=fade_height,
|
|
630
|
+ // for P=physical_z, L=logical_z, M=mesh_z, H=fade_height,
|
631
|
631
|
// Given P=L+M(1-L/H) (faded mesh correction formula for L<H)
|
632
|
632
|
// then L=P-M(1-L/H)
|
633
|
633
|
// so L=P-M+ML/H
|
|
@@ -637,7 +637,7 @@ void Planner::calculate_volumetric_multipliers() {
|
637
|
637
|
|
638
|
638
|
if (planner.z_fade_height) {
|
639
|
639
|
if (z_raw >= planner.z_fade_height)
|
640
|
|
- z_raw = raw[Z_AXIS];
|
|
640
|
+ z_raw = z_physical;
|
641
|
641
|
else
|
642
|
642
|
z_raw /= 1.0 - z_correct * planner.inverse_z_fade_height;
|
643
|
643
|
}
|
|
@@ -646,28 +646,32 @@ void Planner::calculate_volumetric_multipliers() {
|
646
|
646
|
|
647
|
647
|
raw[Z_AXIS] = z_raw;
|
648
|
648
|
|
649
|
|
- #elif ENABLED(MESH_BED_LEVELING)
|
|
649
|
+ return; // don't fall thru to other ENABLE_LEVELING_FADE_HEIGHT logic
|
650
|
650
|
|
651
|
|
- #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
652
|
|
- const float c = mbl.get_z(raw[X_AXIS], raw[Y_AXIS], 1.0);
|
653
|
|
- raw[Z_AXIS] = (z_fade_height * (raw[Z_AXIS] - c)) / (z_fade_height - c);
|
654
|
|
- #else
|
655
|
|
- raw[Z_AXIS] -= mbl.get_z(raw[X_AXIS], raw[Y_AXIS]);
|
656
|
|
- #endif
|
|
651
|
+ #endif
|
|
652
|
+
|
|
653
|
+ #if ENABLED(MESH_BED_LEVELING)
|
|
654
|
+
|
|
655
|
+ if (leveling_active) {
|
|
656
|
+ #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
|
657
|
+ const float c = mbl.get_z(raw[X_AXIS], raw[Y_AXIS], 1.0);
|
|
658
|
+ raw[Z_AXIS] = (z_fade_height * (raw[Z_AXIS]) - c) / (z_fade_height - c);
|
|
659
|
+ #else
|
|
660
|
+ raw[Z_AXIS] -= mbl.get_z(raw[X_AXIS], raw[Y_AXIS]);
|
|
661
|
+ #endif
|
|
662
|
+ }
|
657
|
663
|
|
658
|
664
|
#elif ABL_PLANAR
|
659
|
665
|
|
660
|
666
|
matrix_3x3 inverse = matrix_3x3::transpose(bed_level_matrix);
|
661
|
667
|
|
662
|
668
|
float dx = raw[X_AXIS] - (X_TILT_FULCRUM),
|
663
|
|
- dy = raw[Y_AXIS] - (Y_TILT_FULCRUM),
|
664
|
|
- dz = raw[Z_AXIS];
|
|
669
|
+ dy = raw[Y_AXIS] - (Y_TILT_FULCRUM);
|
665
|
670
|
|
666
|
|
- apply_rotation_xyz(inverse, dx, dy, dz);
|
|
671
|
+ apply_rotation_xyz(inverse, dx, dy, raw[Z_AXIS]);
|
667
|
672
|
|
668
|
673
|
raw[X_AXIS] = dx + X_TILT_FULCRUM;
|
669
|
674
|
raw[Y_AXIS] = dy + Y_TILT_FULCRUM;
|
670
|
|
- raw[Z_AXIS] = dz;
|
671
|
675
|
|
672
|
676
|
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
673
|
677
|
|