Skip to content

Commit

Permalink
Tempted by the const of a seg_length
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored and Alexander Yasnogor committed Aug 7, 2020
1 parent 4baab9d commit 574f95b
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Marlin/src/gcode/motion/G2_G3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,21 @@ void plan_arc(

const feedRate_t scaled_fr_mm_s = MMS_SCALED(feedrate_mm_s);

#ifdef ARC_SEGMENTS_PER_R
float seg_length = MM_PER_ARC_SEGMENT * radius;
LIMIT(seg_length, MM_PER_ARC_SEGMENT, ARC_SEGMENTS_PER_R);
#elif ARC_SEGMENTS_PER_SEC
float seg_length = scaled_fr_mm_s * RECIPROCAL(ARC_SEGMENTS_PER_SEC);
NOLESS(seg_length, MM_PER_ARC_SEGMENT);
#else
constexpr float seg_length = MM_PER_ARC_SEGMENT;
#endif

// Length divided by segment size gives segment count
// Start with a nominal segment length
float seg_length = (
#ifdef ARC_SEGMENTS_PER_R
constrain(MM_PER_ARC_SEGMENT * radius, MM_PER_ARC_SEGMENT, ARC_SEGMENTS_PER_R)
#elif ARC_SEGMENTS_PER_SEC
_MAX(scaled_fr_mm_s * RECIPROCAL(ARC_SEGMENTS_PER_SEC), MM_PER_ARC_SEGMENT)
#else
MM_PER_ARC_SEGMENT
#endif
);
// Divide total travel by nominal segment length
uint16_t segments = FLOOR(mm_of_travel / seg_length);
if (segments < min_segments) {
segments = min_segments; // No fewer than the minimum
seg_length = mm_of_travel / segments; // A new segment length
if (segments < min_segments) { // Too few segments?
segments = min_segments; // More segments
seg_length = mm_of_travel / segments; // but also shorter
}

/**
Expand Down

0 comments on commit 574f95b

Please sign in to comment.