Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jun 24, 2022
1 parent 9d1d54d commit 2cd00fa
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 46 deletions.
18 changes: 16 additions & 2 deletions Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,18 @@
#include "../../../MarlinCore.h"
#include <math.h>

//#define DEBUG_UBL_MOTION
#define DEBUG_OUT ENABLED(DEBUG_UBL_MOTION)
#include "../../../core/debug_out.h"

#if !UBL_SEGMENTED

// TODO: The first and last parts of a move might result in very short segment(s)
// after getting split on the cell boundary, so moves like that should not
// get split. This will be most common for moves that start/end near the
// corners of cells. To fix the issue, simply check if the start/end of the line
// is very close to a cell boundary in advance and don't split the line there.

void unified_bed_leveling::line_to_destination_cartesian(const_feedRate_t scaled_fr_mm_s, const uint8_t extruder) {
/**
* Much of the nozzle movement will be within the same cell. So we will do as little computation
Expand Down Expand Up @@ -176,7 +186,9 @@
dest.z += z0;
planner.buffer_segment(dest, scaled_fr_mm_s, extruder);

} //else printf("FIRST MOVE PRUNED ");
}
else
DEBUG_ECHOLNPGM("[ubl] skip Y segment");
}

// At the final destination? Usually not, but when on a Y Mesh Line it's completed.
Expand Down Expand Up @@ -225,7 +237,9 @@
dest.z += z0;
if (!planner.buffer_segment(dest, scaled_fr_mm_s, extruder)) break;

} //else printf("FIRST MOVE PRUNED ");
}
else
DEBUG_ECHOLNPGM("[ubl] skip Y segment");
}

if (xy_pos_t(current_position) != xy_pos_t(end))
Expand Down
6 changes: 4 additions & 2 deletions Marlin/src/gcode/motion/G2_G3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,10 @@ void plan_arc(
#endif

if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0
OPTARG(SCARA_FEEDRATE_SCALING, inv_duration), i > 1 ? radius : 0.0))
break;
OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
, i > 1 ? radius : 0
)
) break;
}
}

Expand Down
56 changes: 14 additions & 42 deletions Marlin/src/module/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,7 @@ void Planner::synchronize() { while (busy()) idle(); }
bool Planner::_buffer_steps(const xyze_long_t &target
OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float)
OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm)
, feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters
, feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/
OPTARG(ARC_SUPPORT, const_float_t arc_radius/*=0.0*/)
) {

Expand All @@ -1797,11 +1797,12 @@ bool Planner::_buffer_steps(const xyze_long_t &target

// Fill the block with the specified movement
if (!_populate_block(block, false, target
OPTARG(HAS_POSITION_FLOAT, target_float)
OPTARG(HAS_DIST_MM_ARG, cart_dist_mm)
, fr_mm_s, extruder, millimeters
OPTARG(ARC_SUPPORT, arc_radius)
)) {
OPTARG(HAS_POSITION_FLOAT, target_float)
OPTARG(HAS_DIST_MM_ARG, cart_dist_mm)
, fr_mm_s, extruder, millimeters
OPTARG(ARC_SUPPORT, arc_radius)
)
) {
// Movement was not queued, probably because it was too short.
// Simply accept that as movement queued and done
return true;
Expand Down Expand Up @@ -1859,36 +1860,8 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
);

/* <-- add a slash to enable
SERIAL_ECHOLNPGM(
" _populate_block FR:", fr_mm_s,
" A:", target.a, " (", da, " steps)"
#if HAS_Y_AXIS
" B:", target.b, " (", db, " steps)"
#endif
#if HAS_Z_AXIS
" C:", target.c, " (", dc, " steps)"
#endif
#if HAS_I_AXIS
" " STR_I ":", target.i, " (", di, " steps)"
#endif
#if HAS_J_AXIS
" " STR_J ":", target.j, " (", dj, " steps)"
#endif
#if HAS_K_AXIS
" " STR_K ":", target.k, " (", dk, " steps)"
#endif
#if HAS_U_AXIS
" " STR_U ":", target.u, " (", du, " steps)"
#endif
#if HAS_V_AXIS
" " STR_V ":", target.v, " (", dv, " steps)"
#endif
#if HAS_W_AXIS
" " STR_W ":", target.w, " (", dw, " steps)"
#if HAS_EXTRUDERS
" E:", target.e, " (", de, " steps)"
#endif
);
#define _ALINE(A) " A:", target[_AXIS(A)], " (", int32_t(target[_AXIS(A)] - position[_AXIS(A)]), " steps)"
SERIAL_ECHOLNPGM(" _populate_block FR:", fr_mm_s, LOGICAL_AXIS_MAP(_ALINE));
//*/

#if EITHER(PREVENT_COLD_EXTRUSION, PREVENT_LENGTHY_EXTRUDE)
Expand Down Expand Up @@ -2653,14 +2626,13 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
// Convert delta vector to unit vector
xyze_float_t junction_unit_vec = unit_vec - prev_unit_vec;
normalize_junction_vector(junction_unit_vec);

const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec);

#if ENABLED(ARC_SUPPORT)
if (arc_radius > 0.0)
vmax_junction_sqr = junction_acceleration * arc_radius;
else
#endif
{
if (TERN0(ARC_SUPPORT, arc_radius)) {
TERN_(ARC_SUPPORT, vmax_junction_sqr = junction_acceleration * arc_radius);
}
else {
NOLESS(junction_cos_theta, -0.999999f); // Check for numerical round-off to avoid divide by zero.

const float sin_theta_d2 = SQRT(0.5f * (1.0f - junction_cos_theta)); // Trig half angle identity. Always positive.
Expand Down

0 comments on commit 2cd00fa

Please sign in to comment.