|
@@ -572,10 +572,6 @@ static uint8_t target_extruder;
|
572
|
572
|
|
573
|
573
|
float delta_safe_distance_from_top();
|
574
|
574
|
|
575
|
|
-#else
|
576
|
|
-
|
577
|
|
- static bool home_all_axis = true;
|
578
|
|
-
|
579
|
575
|
#endif
|
580
|
576
|
|
581
|
577
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
|
@@ -1582,7 +1578,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
|
1582
|
1578
|
* The final current_position may not be the one that was requested
|
1583
|
1579
|
*/
|
1584
|
1580
|
void do_blocking_move_to(const float &x, const float &y, const float &z, const float &fr_mm_s /*=0.0*/) {
|
1585
|
|
- float old_feedrate_mm_s = feedrate_mm_s;
|
|
1581
|
+ const float old_feedrate_mm_s = feedrate_mm_s;
|
1586
|
1582
|
|
1587
|
1583
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
1588
|
1584
|
if (DEBUGGING(LEVELING)) print_xyz(PSTR(">>> do_blocking_move_to"), NULL, x, y, z);
|
|
@@ -2034,8 +2030,8 @@ static void clean_up_after_endstop_or_probe_move() {
|
2034
|
2030
|
if (axis_unhomed_error(true, true, true )) { stop(); return true; }
|
2035
|
2031
|
#endif
|
2036
|
2032
|
|
2037
|
|
- float oldXpos = current_position[X_AXIS],
|
2038
|
|
- oldYpos = current_position[Y_AXIS];
|
|
2033
|
+ const float oldXpos = current_position[X_AXIS],
|
|
2034
|
+ oldYpos = current_position[Y_AXIS];
|
2039
|
2035
|
|
2040
|
2036
|
#ifdef _TRIGGERED_WHEN_STOWED_TEST
|
2041
|
2037
|
|
|
@@ -2178,7 +2174,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
2178
|
2174
|
// - Raise to the BETWEEN height
|
2179
|
2175
|
// - Return the probed Z position
|
2180
|
2176
|
//
|
2181
|
|
- static float probe_pt(const float &x, const float &y, bool stow = true, int verbose_level = 1) {
|
|
2177
|
+ static float probe_pt(const float &x, const float &y, const bool stow = true, const int verbose_level = 1) {
|
2182
|
2178
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2183
|
2179
|
if (DEBUGGING(LEVELING)) {
|
2184
|
2180
|
SERIAL_ECHOPAIR(">>> probe_pt(", x);
|
|
@@ -2189,7 +2185,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
2189
|
2185
|
}
|
2190
|
2186
|
#endif
|
2191
|
2187
|
|
2192
|
|
- float old_feedrate_mm_s = feedrate_mm_s;
|
|
2188
|
+ const float old_feedrate_mm_s = feedrate_mm_s;
|
2193
|
2189
|
|
2194
|
2190
|
#if ENABLED(DELTA)
|
2195
|
2191
|
if (current_position[Z_AXIS] > delta_clip_start_height)
|
|
@@ -2206,7 +2202,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
2206
|
2202
|
|
2207
|
2203
|
if (DEPLOY_PROBE()) return NAN;
|
2208
|
2204
|
|
2209
|
|
- float measured_z = run_z_probe();
|
|
2205
|
+ const float measured_z = run_z_probe();
|
2210
|
2206
|
|
2211
|
2207
|
if (!stow)
|
2212
|
2208
|
do_probe_raise(Z_CLEARANCE_BETWEEN_PROBES);
|
|
@@ -2370,7 +2366,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
2370
|
2366
|
if (b2 == UNPROBED) b2 = 0.0; if (b1 == UNPROBED) b1 = b2;
|
2371
|
2367
|
if (c2 == UNPROBED) c2 = 0.0; if (c1 == UNPROBED) c1 = c2;
|
2372
|
2368
|
|
2373
|
|
- float a = 2 * a1 - a2, b = 2 * b1 - b2, c = 2 * c1 - c2;
|
|
2369
|
+ const float a = 2 * a1 - a2, b = 2 * b1 - b2, c = 2 * c1 - c2;
|
2374
|
2370
|
|
2375
|
2371
|
// Take the average instead of the median
|
2376
|
2372
|
bed_level_grid[x][y] = (a + b + c) / 3.0;
|
|
@@ -2416,10 +2412,10 @@ static void clean_up_after_endstop_or_probe_move() {
|
2416
|
2412
|
for (uint8_t yo = 0; yo <= ylen; yo++) {
|
2417
|
2413
|
uint8_t x2 = ctrx2 + xo, y2 = ctry2 + yo;
|
2418
|
2414
|
#ifndef HALF_IN_X
|
2419
|
|
- uint8_t x1 = ctrx1 - xo;
|
|
2415
|
+ const uint8_t x1 = ctrx1 - xo;
|
2420
|
2416
|
#endif
|
2421
|
2417
|
#ifndef HALF_IN_Y
|
2422
|
|
- uint8_t y1 = ctry1 - yo;
|
|
2418
|
+ const uint8_t y1 = ctry1 - yo;
|
2423
|
2419
|
#ifndef HALF_IN_X
|
2424
|
2420
|
extrapolate_one_point(x1, y1, +1, +1); // left-below + +
|
2425
|
2421
|
#endif
|
|
@@ -2586,7 +2582,7 @@ static void do_homing_move(const AxisEnum axis, float distance, float fr_mm_s=0.
|
2586
|
2582
|
#endif
|
2587
|
2583
|
|
2588
|
2584
|
#if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
|
2589
|
|
- bool deploy_bltouch = (axis == Z_AXIS && distance < 0);
|
|
2585
|
+ const bool deploy_bltouch = (axis == Z_AXIS && distance < 0);
|
2590
|
2586
|
if (deploy_bltouch) set_bltouch_deployed(true);
|
2591
|
2587
|
#endif
|
2592
|
2588
|
|
|
@@ -2634,7 +2630,7 @@ static void do_homing_move(const AxisEnum axis, float distance, float fr_mm_s=0.
|
2634
|
2630
|
|
2635
|
2631
|
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
|
2636
|
2632
|
|
2637
|
|
-static void homeaxis(AxisEnum axis) {
|
|
2633
|
+static void homeaxis(const AxisEnum axis) {
|
2638
|
2634
|
|
2639
|
2635
|
#if IS_SCARA
|
2640
|
2636
|
// Only Z homing (with probe) is permitted
|
|
@@ -2653,7 +2649,7 @@ static void homeaxis(AxisEnum axis) {
|
2653
|
2649
|
}
|
2654
|
2650
|
#endif
|
2655
|
2651
|
|
2656
|
|
- int axis_home_dir =
|
|
2652
|
+ const int axis_home_dir =
|
2657
|
2653
|
#if ENABLED(DUAL_X_CARRIAGE)
|
2658
|
2654
|
(axis == X_AXIS) ? x_home_dir(active_extruder) :
|
2659
|
2655
|
#endif
|
|
@@ -2769,13 +2765,13 @@ static void homeaxis(AxisEnum axis) {
|
2769
|
2765
|
|
2770
|
2766
|
#if ENABLED(FWRETRACT)
|
2771
|
2767
|
|
2772
|
|
- void retract(bool retracting, bool swapping = false) {
|
|
2768
|
+ void retract(const bool retracting, const bool swapping = false) {
|
2773
|
2769
|
|
2774
|
2770
|
static float hop_height;
|
2775
|
2771
|
|
2776
|
2772
|
if (retracting == retracted[active_extruder]) return;
|
2777
|
2773
|
|
2778
|
|
- float old_feedrate_mm_s = feedrate_mm_s;
|
|
2774
|
+ const float old_feedrate_mm_s = feedrate_mm_s;
|
2779
|
2775
|
|
2780
|
2776
|
set_destination_to_current();
|
2781
|
2777
|
|
|
@@ -2805,7 +2801,7 @@ static void homeaxis(AxisEnum axis) {
|
2805
|
2801
|
}
|
2806
|
2802
|
|
2807
|
2803
|
feedrate_mm_s = retract_recover_feedrate_mm_s;
|
2808
|
|
- float move_e = swapping ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length;
|
|
2804
|
+ const float move_e = swapping ? retract_length_swap + retract_recover_length_swap : retract_length + retract_recover_length;
|
2809
|
2805
|
current_position[E_AXIS] -= move_e / volumetric_multiplier[active_extruder];
|
2810
|
2806
|
sync_plan_position_e();
|
2811
|
2807
|
|
|
@@ -2824,11 +2820,11 @@ static void homeaxis(AxisEnum axis) {
|
2824
|
2820
|
|
2825
|
2821
|
void normalize_mix() {
|
2826
|
2822
|
float mix_total = 0.0;
|
2827
|
|
- for (int i = 0; i < MIXING_STEPPERS; i++) mix_total += RECIPROCAL(mixing_factor[i]);
|
|
2823
|
+ for (uint8_t i = 0; i < MIXING_STEPPERS; i++) mix_total += RECIPROCAL(mixing_factor[i]);
|
2828
|
2824
|
// Scale all values if they don't add up to ~1.0
|
2829
|
2825
|
if (!NEAR(mix_total, 1.0)) {
|
2830
|
2826
|
SERIAL_PROTOCOLLNPGM("Warning: Mix factors must add up to 1.0. Scaling.");
|
2831
|
|
- for (int i = 0; i < MIXING_STEPPERS; i++) mixing_factor[i] *= mix_total;
|
|
2827
|
+ for (uint8_t i = 0; i < MIXING_STEPPERS; i++) mixing_factor[i] *= mix_total;
|
2832
|
2828
|
}
|
2833
|
2829
|
}
|
2834
|
2830
|
|
|
@@ -2908,7 +2904,7 @@ void unknown_command_error() {
|
2908
|
2904
|
* while the machine is not accepting commands.
|
2909
|
2905
|
*/
|
2910
|
2906
|
void host_keepalive() {
|
2911
|
|
- millis_t ms = millis();
|
|
2907
|
+ const millis_t ms = millis();
|
2912
|
2908
|
if (host_keepalive_interval && busy_state != NOT_BUSY) {
|
2913
|
2909
|
if (PENDING(ms, next_busy_signal_ms)) return;
|
2914
|
2910
|
switch (busy_state) {
|
|
@@ -2984,7 +2980,7 @@ inline void gcode_G0_G1(
|
2984
|
2980
|
#if ENABLED(FWRETRACT)
|
2985
|
2981
|
|
2986
|
2982
|
if (autoretract_enabled && !(code_seen('X') || code_seen('Y') || code_seen('Z')) && code_seen('E')) {
|
2987
|
|
- float echange = destination[E_AXIS] - current_position[E_AXIS];
|
|
2983
|
+ const float echange = destination[E_AXIS] - current_position[E_AXIS];
|
2988
|
2984
|
// Is this move an attempt to retract or recover?
|
2989
|
2985
|
if ((echange < -MIN_RETRACT && !retracted[active_extruder]) || (echange > MIN_RETRACT && retracted[active_extruder])) {
|
2990
|
2986
|
current_position[E_AXIS] = destination[E_AXIS]; // hide the slicer-generated retract/recover from calculations
|
|
@@ -3032,7 +3028,7 @@ inline void gcode_G0_G1(
|
3032
|
3028
|
if (IsRunning()) {
|
3033
|
3029
|
|
3034
|
3030
|
#if ENABLED(SF_ARC_FIX)
|
3035
|
|
- bool relative_mode_backup = relative_mode;
|
|
3031
|
+ const bool relative_mode_backup = relative_mode;
|
3036
|
3032
|
relative_mode = true;
|
3037
|
3033
|
#endif
|
3038
|
3034
|
|
|
@@ -3113,7 +3109,7 @@ inline void gcode_G4() {
|
3113
|
3109
|
|
3114
|
3110
|
gcode_get_destination();
|
3115
|
3111
|
|
3116
|
|
- float offset[] = {
|
|
3112
|
+ const float offset[] = {
|
3117
|
3113
|
code_seen('I') ? code_value_axis_units(X_AXIS) : 0.0,
|
3118
|
3114
|
code_seen('J') ? code_value_axis_units(Y_AXIS) : 0.0,
|
3119
|
3115
|
code_seen('P') ? code_value_axis_units(X_AXIS) : 0.0,
|
|
@@ -3155,9 +3151,9 @@ inline void gcode_G4() {
|
3155
|
3151
|
// Don't allow nozzle cleaning without homing first
|
3156
|
3152
|
if (axis_unhomed_error(true, true, true)) { return; }
|
3157
|
3153
|
|
3158
|
|
- uint8_t const pattern = code_seen('P') ? code_value_ushort() : 0;
|
3159
|
|
- uint8_t const strokes = code_seen('S') ? code_value_ushort() : NOZZLE_CLEAN_STROKES;
|
3160
|
|
- uint8_t const objects = code_seen('T') ? code_value_ushort() : NOZZLE_CLEAN_TRIANGLES;
|
|
3154
|
+ const uint8_t pattern = code_seen('P') ? code_value_ushort() : 0,
|
|
3155
|
+ strokes = code_seen('S') ? code_value_ushort() : NOZZLE_CLEAN_STROKES,
|
|
3156
|
+ objects = code_seen('T') ? code_value_ushort() : NOZZLE_CLEAN_TRIANGLES;
|
3161
|
3157
|
|
3162
|
3158
|
Nozzle::clean(pattern, strokes, objects);
|
3163
|
3159
|
}
|
|
@@ -3181,9 +3177,8 @@ inline void gcode_G4() {
|
3181
|
3177
|
*/
|
3182
|
3178
|
inline void gcode_G27() {
|
3183
|
3179
|
// Don't allow nozzle parking without homing first
|
3184
|
|
- if (axis_unhomed_error(true, true, true)) { return; }
|
3185
|
|
- uint8_t const z_action = code_seen('P') ? code_value_ushort() : 0;
|
3186
|
|
- Nozzle::park(z_action);
|
|
3180
|
+ if (axis_unhomed_error(true, true, true)) return;
|
|
3181
|
+ Nozzle::park(code_seen('P') ? code_value_ushort() : 0);
|
3187
|
3182
|
}
|
3188
|
3183
|
#endif // NOZZLE_PARK_FEATURE
|
3189
|
3184
|
|
|
@@ -3195,7 +3190,7 @@ inline void gcode_G4() {
|
3195
|
3190
|
current_position[X_AXIS] = current_position[Y_AXIS] = 0.0;
|
3196
|
3191
|
sync_plan_position();
|
3197
|
3192
|
|
3198
|
|
- int x_axis_home_dir =
|
|
3193
|
+ const int x_axis_home_dir =
|
3199
|
3194
|
#if ENABLED(DUAL_X_CARRIAGE)
|
3200
|
3195
|
x_home_dir(active_extruder)
|
3201
|
3196
|
#else
|
|
@@ -3203,15 +3198,14 @@ inline void gcode_G4() {
|
3203
|
3198
|
#endif
|
3204
|
3199
|
;
|
3205
|
3200
|
|
3206
|
|
- float mlx = max_length(X_AXIS),
|
3207
|
|
- mly = max_length(Y_AXIS),
|
3208
|
|
- mlratio = mlx > mly ? mly / mlx : mlx / mly,
|
3209
|
|
- fr_mm_s = min(homing_feedrate_mm_s[X_AXIS], homing_feedrate_mm_s[Y_AXIS]) * sqrt(sq(mlratio) + 1.0);
|
|
3201
|
+ const float mlx = max_length(X_AXIS),
|
|
3202
|
+ mly = max_length(Y_AXIS),
|
|
3203
|
+ mlratio = mlx > mly ? mly / mlx : mlx / mly,
|
|
3204
|
+ fr_mm_s = min(homing_feedrate_mm_s[X_AXIS], homing_feedrate_mm_s[Y_AXIS]) * sqrt(sq(mlratio) + 1.0);
|
3210
|
3205
|
|
3211
|
3206
|
do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_s);
|
3212
|
3207
|
endstops.hit_on_purpose(); // clear endstop hit flags
|
3213
|
3208
|
current_position[X_AXIS] = current_position[Y_AXIS] = 0.0;
|
3214
|
|
-
|
3215
|
3209
|
}
|
3216
|
3210
|
|
3217
|
3211
|
#endif // QUICK_HOME
|
|
@@ -3459,7 +3453,7 @@ inline void gcode_G28() {
|
3459
|
3453
|
|
3460
|
3454
|
// Always home with tool 0 active
|
3461
|
3455
|
#if HOTENDS > 1
|
3462
|
|
- uint8_t old_tool_index = active_extruder;
|
|
3456
|
+ const uint8_t old_tool_index = active_extruder;
|
3463
|
3457
|
tool_change(0, 0, true);
|
3464
|
3458
|
#endif
|
3465
|
3459
|
|
|
@@ -3504,9 +3498,8 @@ inline void gcode_G28() {
|
3504
|
3498
|
|
3505
|
3499
|
#else // NOT DELTA
|
3506
|
3500
|
|
3507
|
|
- bool homeX = code_seen('X'), homeY = code_seen('Y'), homeZ = code_seen('Z');
|
3508
|
|
-
|
3509
|
|
- home_all_axis = (!homeX && !homeY && !homeZ) || (homeX && homeY && homeZ);
|
|
3501
|
+ const bool homeX = code_seen('X'), homeY = code_seen('Y'), homeZ = code_seen('Z'),
|
|
3502
|
+ home_all_axis = (!homeX && !homeY && !homeZ) || (homeX && homeY && homeZ);
|
3510
|
3503
|
|
3511
|
3504
|
set_destination_to_current();
|
3512
|
3505
|
|
|
@@ -3692,8 +3685,8 @@ inline void gcode_G28() {
|
3692
|
3685
|
|
3693
|
3686
|
#if ENABLED(MESH_BED_LEVELING)
|
3694
|
3687
|
|
3695
|
|
- inline void _mbl_goto_xy(float x, float y) {
|
3696
|
|
- float old_feedrate_mm_s = feedrate_mm_s;
|
|
3688
|
+ inline void _mbl_goto_xy(const float &x, const float &y) {
|
|
3689
|
+ const float old_feedrate_mm_s = feedrate_mm_s;
|
3697
|
3690
|
feedrate_mm_s = homing_feedrate_mm_s[Z_AXIS];
|
3698
|
3691
|
|
3699
|
3692
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
|
|
@@ -3760,8 +3753,8 @@ inline void gcode_G28() {
|
3760
|
3753
|
*/
|
3761
|
3754
|
inline void gcode_G29() {
|
3762
|
3755
|
|
3763
|
|
- static int probe_point = -1;
|
3764
|
|
- MeshLevelingState state = code_seen('S') ? (MeshLevelingState)code_value_byte() : MeshReport;
|
|
3756
|
+ static int probe_index = -1;
|
|
3757
|
+ const MeshLevelingState state = code_seen('S') ? (MeshLevelingState)code_value_byte() : MeshReport;
|
3765
|
3758
|
if (state < 0 || state > 5) {
|
3766
|
3759
|
SERIAL_PROTOCOLLNPGM("S out of range (0-5).");
|
3767
|
3760
|
return;
|
|
@@ -3781,17 +3774,17 @@ inline void gcode_G28() {
|
3781
|
3774
|
|
3782
|
3775
|
case MeshStart:
|
3783
|
3776
|
mbl.reset();
|
3784
|
|
- probe_point = 0;
|
|
3777
|
+ probe_index = 0;
|
3785
|
3778
|
enqueue_and_echo_commands_P(PSTR("G28\nG29 S2"));
|
3786
|
3779
|
break;
|
3787
|
3780
|
|
3788
|
3781
|
case MeshNext:
|
3789
|
|
- if (probe_point < 0) {
|
|
3782
|
+ if (probe_index < 0) {
|
3790
|
3783
|
SERIAL_PROTOCOLLNPGM("Start mesh probing with \"G29 S1\" first.");
|
3791
|
3784
|
return;
|
3792
|
3785
|
}
|
3793
|
3786
|
// For each G29 S2...
|
3794
|
|
- if (probe_point == 0) {
|
|
3787
|
+ if (probe_index == 0) {
|
3795
|
3788
|
// For the initial G29 S2 make Z a positive value (e.g., 4.0)
|
3796
|
3789
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
|
3797
|
3790
|
#if Z_HOME_DIR > 0
|
|
@@ -3802,13 +3795,13 @@ inline void gcode_G28() {
|
3802
|
3795
|
}
|
3803
|
3796
|
else {
|
3804
|
3797
|
// For G29 S2 after adjusting Z.
|
3805
|
|
- mbl.set_zigzag_z(probe_point - 1, current_position[Z_AXIS]);
|
|
3798
|
+ mbl.set_zigzag_z(probe_index - 1, current_position[Z_AXIS]);
|
3806
|
3799
|
}
|
3807
|
3800
|
// If there's another point to sample, move there with optional lift.
|
3808
|
|
- if (probe_point < (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
|
3809
|
|
- mbl.zigzag(probe_point, px, py);
|
|
3801
|
+ if (probe_index < (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
|
|
3802
|
+ mbl.zigzag(probe_index, px, py);
|
3810
|
3803
|
_mbl_goto_xy(mbl.get_probe_x(px), mbl.get_probe_y(py));
|
3811
|
|
- probe_point++;
|
|
3804
|
+ probe_index++;
|
3812
|
3805
|
}
|
3813
|
3806
|
else {
|
3814
|
3807
|
// One last "return to the bed" (as originally coded) at completion
|
|
@@ -3824,7 +3817,7 @@ inline void gcode_G28() {
|
3824
|
3817
|
|
3825
|
3818
|
// After recording the last point, activate the mbl and home
|
3826
|
3819
|
SERIAL_PROTOCOLLNPGM("Mesh probing done.");
|
3827
|
|
- probe_point = -1;
|
|
3820
|
+ probe_index = -1;
|
3828
|
3821
|
mbl.set_has_mesh(true);
|
3829
|
3822
|
enqueue_and_echo_commands_P(PSTR("G28"));
|
3830
|
3823
|
}
|
|
@@ -3936,8 +3929,8 @@ inline void gcode_G28() {
|
3936
|
3929
|
inline void gcode_G29() {
|
3937
|
3930
|
|
3938
|
3931
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
3939
|
|
- bool query = code_seen('Q');
|
3940
|
|
- uint8_t old_debug_flags = marlin_debug_flags;
|
|
3932
|
+ const bool query = code_seen('Q');
|
|
3933
|
+ const uint8_t old_debug_flags = marlin_debug_flags;
|
3941
|
3934
|
if (query) marlin_debug_flags |= DEBUG_LEVELING;
|
3942
|
3935
|
if (DEBUGGING(LEVELING)) {
|
3943
|
3936
|
DEBUG_POS(">>> gcode_G29", current_position);
|
|
@@ -3950,7 +3943,7 @@ inline void gcode_G28() {
|
3950
|
3943
|
// Don't allow auto-leveling without homing first
|
3951
|
3944
|
if (axis_unhomed_error(true, true, true)) return;
|
3952
|
3945
|
|
3953
|
|
- int verbose_level = code_seen('V') ? code_value_int() : 1;
|
|
3946
|
+ const int verbose_level = code_seen('V') ? code_value_int() : 1;
|
3954
|
3947
|
if (verbose_level < 0 || verbose_level > 4) {
|
3955
|
3948
|
SERIAL_PROTOCOLLNPGM("?(V)erbose Level is implausible (0-4).");
|
3956
|
3949
|
return;
|
|
@@ -3995,14 +3988,14 @@ inline void gcode_G28() {
|
3995
|
3988
|
front_probe_bed_position = code_seen('F') ? (int)code_value_axis_units(Y_AXIS) : LOGICAL_Y_POSITION(FRONT_PROBE_BED_POSITION),
|
3996
|
3989
|
back_probe_bed_position = code_seen('B') ? (int)code_value_axis_units(Y_AXIS) : LOGICAL_Y_POSITION(BACK_PROBE_BED_POSITION);
|
3997
|
3990
|
|
3998
|
|
- bool left_out_l = left_probe_bed_position < LOGICAL_X_POSITION(MIN_PROBE_X),
|
3999
|
|
- left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - (MIN_PROBE_EDGE),
|
4000
|
|
- right_out_r = right_probe_bed_position > LOGICAL_X_POSITION(MAX_PROBE_X),
|
4001
|
|
- right_out = right_out_r || right_probe_bed_position < left_probe_bed_position + MIN_PROBE_EDGE,
|
4002
|
|
- front_out_f = front_probe_bed_position < LOGICAL_Y_POSITION(MIN_PROBE_Y),
|
4003
|
|
- front_out = front_out_f || front_probe_bed_position > back_probe_bed_position - (MIN_PROBE_EDGE),
|
4004
|
|
- back_out_b = back_probe_bed_position > LOGICAL_Y_POSITION(MAX_PROBE_Y),
|
4005
|
|
- back_out = back_out_b || back_probe_bed_position < front_probe_bed_position + MIN_PROBE_EDGE;
|
|
3991
|
+ const bool left_out_l = left_probe_bed_position < LOGICAL_X_POSITION(MIN_PROBE_X),
|
|
3992
|
+ left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - (MIN_PROBE_EDGE),
|
|
3993
|
+ right_out_r = right_probe_bed_position > LOGICAL_X_POSITION(MAX_PROBE_X),
|
|
3994
|
+ right_out = right_out_r || right_probe_bed_position < left_probe_bed_position + MIN_PROBE_EDGE,
|
|
3995
|
+ front_out_f = front_probe_bed_position < LOGICAL_Y_POSITION(MIN_PROBE_Y),
|
|
3996
|
+ front_out = front_out_f || front_probe_bed_position > back_probe_bed_position - (MIN_PROBE_EDGE),
|
|
3997
|
+ back_out_b = back_probe_bed_position > LOGICAL_Y_POSITION(MAX_PROBE_Y),
|
|
3998
|
+ back_out = back_out_b || back_probe_bed_position < front_probe_bed_position + MIN_PROBE_EDGE;
|
4006
|
3999
|
|
4007
|
4000
|
if (left_out || right_out || front_out || back_out) {
|
4008
|
4001
|
if (left_out) {
|
|
@@ -4068,8 +4061,10 @@ inline void gcode_G28() {
|
4068
|
4061
|
|| left_probe_bed_position != bilinear_start[X_AXIS]
|
4069
|
4062
|
|| front_probe_bed_position != bilinear_start[Y_AXIS]
|
4070
|
4063
|
) {
|
4071
|
|
- // Before reset bed level, re-enable to correct the position
|
4072
|
|
- planner.abl_enabled = abl_should_enable;
|
|
4064
|
+ if (dryrun) {
|
|
4065
|
+ // Before reset bed level, re-enable to correct the position
|
|
4066
|
+ planner.abl_enabled = abl_should_enable;
|
|
4067
|
+ }
|
4073
|
4068
|
// Reset grid to 0.0 or "not probed". (Also disables ABL)
|
4074
|
4069
|
reset_bed_level();
|
4075
|
4070
|
|
|
@@ -4097,9 +4092,10 @@ inline void gcode_G28() {
|
4097
|
4092
|
* so Vx = -a Vy = -b Vz = 1 (we want the vector facing towards positive Z
|
4098
|
4093
|
*/
|
4099
|
4094
|
|
4100
|
|
- int abl2 = abl_grid_points_x * abl_grid_points_y,
|
4101
|
|
- indexIntoAB[abl_grid_points_x][abl_grid_points_y],
|
4102
|
|
- probePointCounter = -1;
|
|
4095
|
+ const int abl2 = abl_grid_points_x * abl_grid_points_y;
|
|
4096
|
+
|
|
4097
|
+ int indexIntoAB[abl_grid_points_x][abl_grid_points_y],
|
|
4098
|
+ probe_index = -1;
|
4103
|
4099
|
|
4104
|
4100
|
float eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations
|
4105
|
4101
|
eqnBVector[abl2], // "B" vector of Z points
|
|
@@ -4109,30 +4105,30 @@ inline void gcode_G28() {
|
4109
|
4105
|
|
4110
|
4106
|
#if ENABLED(PROBE_Y_FIRST)
|
4111
|
4107
|
#define PR_OUTER_VAR xCount
|
4112
|
|
- #define PR_OUTER_END abl_grid_points_x
|
|
4108
|
+ #define PR_OUTER_NUM abl_grid_points_x
|
4113
|
4109
|
#define PR_INNER_VAR yCount
|
4114
|
|
- #define PR_INNER_END abl_grid_points_y
|
|
4110
|
+ #define PR_INNER_NUM abl_grid_points_y
|
4115
|
4111
|
#else
|
4116
|
4112
|
#define PR_OUTER_VAR yCount
|
4117
|
|
- #define PR_OUTER_END abl_grid_points_y
|
|
4113
|
+ #define PR_OUTER_NUM abl_grid_points_y
|
4118
|
4114
|
#define PR_INNER_VAR xCount
|
4119
|
|
- #define PR_INNER_END abl_grid_points_x
|
|
4115
|
+ #define PR_INNER_NUM abl_grid_points_x
|
4120
|
4116
|
#endif
|
4121
|
4117
|
|
4122
|
|
- bool zig = PR_OUTER_END & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION
|
|
4118
|
+ bool zig = PR_OUTER_NUM & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION
|
4123
|
4119
|
|
4124
|
4120
|
// Outer loop is Y with PROBE_Y_FIRST disabled
|
4125
|
|
- for (uint8_t PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_END; PR_OUTER_VAR++) {
|
|
4121
|
+ for (uint8_t PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_NUM; PR_OUTER_VAR++) {
|
4126
|
4122
|
|
4127
|
4123
|
int8_t inStart, inStop, inInc;
|
4128
|
4124
|
|
4129
|
4125
|
if (zig) { // away from origin
|
4130
|
4126
|
inStart = 0;
|
4131
|
|
- inStop = PR_INNER_END;
|
|
4127
|
+ inStop = PR_INNER_NUM;
|
4132
|
4128
|
inInc = 1;
|
4133
|
4129
|
}
|
4134
|
4130
|
else { // towards origin
|
4135
|
|
- inStart = PR_INNER_END - 1;
|
|
4131
|
+ inStart = PR_INNER_NUM - 1;
|
4136
|
4132
|
inStop = -1;
|
4137
|
4133
|
inInc = -1;
|
4138
|
4134
|
}
|
|
@@ -4149,7 +4145,7 @@ inline void gcode_G28() {
|
4149
|
4145
|
yProbe = floor(yBase + (yBase < 0 ? 0 : 0.5));
|
4150
|
4146
|
|
4151
|
4147
|
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
4152
|
|
- indexIntoAB[xCount][yCount] = ++probePointCounter;
|
|
4148
|
+ indexIntoAB[xCount][yCount] = ++probe_index;
|
4153
|
4149
|
#endif
|
4154
|
4150
|
|
4155
|
4151
|
#if IS_KINEMATIC
|
|
@@ -4168,10 +4164,10 @@ inline void gcode_G28() {
|
4168
|
4164
|
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
4169
|
4165
|
|
4170
|
4166
|
mean += measured_z;
|
4171
|
|
- eqnBVector[probePointCounter] = measured_z;
|
4172
|
|
- eqnAMatrix[probePointCounter + 0 * abl2] = xProbe;
|
4173
|
|
- eqnAMatrix[probePointCounter + 1 * abl2] = yProbe;
|
4174
|
|
- eqnAMatrix[probePointCounter + 2 * abl2] = 1;
|
|
4167
|
+ eqnBVector[probe_index] = measured_z;
|
|
4168
|
+ eqnAMatrix[probe_index + 0 * abl2] = xProbe;
|
|
4169
|
+ eqnAMatrix[probe_index + 1 * abl2] = yProbe;
|
|
4170
|
+ eqnAMatrix[probe_index + 2 * abl2] = 1;
|
4175
|
4171
|
|
4176
|
4172
|
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
4177
|
4173
|
|
|
@@ -4181,8 +4177,8 @@ inline void gcode_G28() {
|
4181
|
4177
|
|
4182
|
4178
|
idle();
|
4183
|
4179
|
|
4184
|
|
- } //xProbe
|
4185
|
|
- } //yProbe
|
|
4180
|
+ } // inner
|
|
4181
|
+ } // outer
|
4186
|
4182
|
|
4187
|
4183
|
#elif ENABLED(AUTO_BED_LEVELING_3POINT)
|
4188
|
4184
|
|
|
@@ -7860,9 +7856,9 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
7860
|
7856
|
if (tmp_extruder >= EXTRUDERS)
|
7861
|
7857
|
return invalid_extruder_error(tmp_extruder);
|
7862
|
7858
|
|
7863
|
|
- float old_feedrate_mm_s = feedrate_mm_s;
|
|
7859
|
+ const float old_feedrate_mm_s = fr_mm_s > 0.0 ? fr_mm_s : feedrate_mm_s;
|
7864
|
7860
|
|
7865
|
|
- feedrate_mm_s = fr_mm_s > 0.0 ? (old_feedrate_mm_s = fr_mm_s) : XY_PROBE_FEEDRATE_MM_S;
|
|
7861
|
+ feedrate_mm_s = fr_mm_s > 0.0 ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
|
7866
|
7862
|
|
7867
|
7863
|
if (tmp_extruder != active_extruder) {
|
7868
|
7864
|
if (!no_move && axis_unhomed_error(true, true, true)) {
|