Add HAS_JUNCTION_DEVIATION
This commit is contained in:
		@@ -800,7 +800,7 @@
 | 
			
		||||
 *   https://reprap.org/forum/read.php?1,739819
 | 
			
		||||
 *   http://blog.kyneticcnc.com/2018/10/computing-junction-deviation-for-marlin.html
 | 
			
		||||
 */
 | 
			
		||||
#if DISABLED(CLASSIC_JERK)
 | 
			
		||||
#if HAS_JUNCTION_DEVIATION
 | 
			
		||||
  #define JUNCTION_DEVIATION_MM 0.013 // (mm) Distance from real junction edge
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -121,7 +121,7 @@ void GcodeSuite::M204() {
 | 
			
		||||
 *    J = Junction Deviation (mm) (If not using CLASSIC_JERK)
 | 
			
		||||
 */
 | 
			
		||||
void GcodeSuite::M205() {
 | 
			
		||||
  #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
  #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
    #define J_PARAM  "J"
 | 
			
		||||
  #else
 | 
			
		||||
    #define J_PARAM
 | 
			
		||||
@@ -137,7 +137,7 @@ void GcodeSuite::M205() {
 | 
			
		||||
  if (parser.seen('B')) planner.settings.min_segment_time_us = parser.value_ulong();
 | 
			
		||||
  if (parser.seen('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units();
 | 
			
		||||
  if (parser.seen('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units();
 | 
			
		||||
  #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
  #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
    if (parser.seen('J')) {
 | 
			
		||||
      const float junc_dev = parser.value_linear_units();
 | 
			
		||||
      if (WITHIN(junc_dev, 0.01f, 0.3f)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -680,6 +680,10 @@
 | 
			
		||||
  #define HAS_CLASSIC_JERK 1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if DISABLED(CLASSIC_JERK)
 | 
			
		||||
  #define HAS_JUNCTION_DEVIATION 1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// E jerk exists with JD disabled (of course) but also when Linear Advance is disabled on Delta/SCARA
 | 
			
		||||
#if ENABLED(CLASSIC_JERK) || (IS_KINEMATIC && DISABLED(LIN_ADVANCE))
 | 
			
		||||
  #define HAS_CLASSIC_E_JERK 1
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// Linear advance uses Jerk since E is an isolated axis
 | 
			
		||||
#if DISABLED(CLASSIC_JERK) && ENABLED(LIN_ADVANCE)
 | 
			
		||||
#if HAS_JUNCTION_DEVIATION && ENABLED(LIN_ADVANCE)
 | 
			
		||||
  #define HAS_LINEAR_E_JERK 1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -355,7 +355,7 @@
 | 
			
		||||
  #error "LEVEL_BED_CORNERS requires LEVEL_CORNERS_INSET_LFRB values. Please update your Configuration.h."
 | 
			
		||||
#elif defined(BEZIER_JERK_CONTROL)
 | 
			
		||||
  #error "BEZIER_JERK_CONTROL is now S_CURVE_ACCELERATION. Please update your configuration."
 | 
			
		||||
#elif DISABLED(CLASSIC_JERK) && defined(JUNCTION_DEVIATION_FACTOR)
 | 
			
		||||
#elif HAS_JUNCTION_DEVIATION && defined(JUNCTION_DEVIATION_FACTOR)
 | 
			
		||||
  #error "JUNCTION_DEVIATION_FACTOR is now JUNCTION_DEVIATION_MM. Please update your configuration."
 | 
			
		||||
#elif defined(JUNCTION_ACCELERATION_FACTOR)
 | 
			
		||||
  #error "JUNCTION_ACCELERATION_FACTOR is obsolete. Delete it from Configuration_adv.h."
 | 
			
		||||
@@ -1137,7 +1137,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
 | 
			
		||||
/**
 | 
			
		||||
 * Junction deviation is incompatible with kinematic systems.
 | 
			
		||||
 */
 | 
			
		||||
#if DISABLED(CLASSIC_JERK) && IS_KINEMATIC
 | 
			
		||||
#if HAS_JUNCTION_DEVIATION && IS_KINEMATIC
 | 
			
		||||
  #error "CLASSIC_JERK is required for DELTA and SCARA."
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -133,7 +133,7 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
 | 
			
		||||
      .tag(5) .button( VELOCITY_POS,           GET_TEXT_F(MSG_VELOCITY))
 | 
			
		||||
      .tag(6) .button( ACCELERATION_POS,       GET_TEXT_F(MSG_ACCELERATION))
 | 
			
		||||
      .tag(7) .button( JERK_POS,               GET_TEXT_F(
 | 
			
		||||
        #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
        #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
          MSG_JUNCTION_DEVIATION
 | 
			
		||||
        #else
 | 
			
		||||
          MSG_JERK
 | 
			
		||||
@@ -163,7 +163,7 @@ bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) {
 | 
			
		||||
    case 5:  GOTO_SCREEN(MaxVelocityScreen);          break;
 | 
			
		||||
    case 6:  GOTO_SCREEN(DefaultAccelerationScreen);  break;
 | 
			
		||||
    case 7:
 | 
			
		||||
      #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
      #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
        GOTO_SCREEN(JunctionDeviationScreen);
 | 
			
		||||
      #else
 | 
			
		||||
        GOTO_SCREEN(JerkScreen);
 | 
			
		||||
 
 | 
			
		||||
@@ -68,7 +68,7 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
 | 
			
		||||
      .tag(7) .button( BTN_POS(2,1), BTN_SIZE(1,1), GET_TEXT_F(MSG_STEPS_PER_MM))
 | 
			
		||||
      .tag(8) .button( BTN_POS(2,2), BTN_SIZE(1,1), GET_TEXT_F(MSG_VELOCITY))
 | 
			
		||||
      .tag(9) .button( BTN_POS(2,3), BTN_SIZE(1,1), GET_TEXT_F(MSG_ACCELERATION))
 | 
			
		||||
      #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
      #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
        .tag(10) .button( BTN_POS(2,4), BTN_SIZE(1,1), GET_TEXT_F(MSG_JUNCTION_DEVIATION))
 | 
			
		||||
      #else
 | 
			
		||||
        .tag(10) .button( BTN_POS(2,4), BTN_SIZE(1,1), GET_TEXT_F(MSG_JERK))
 | 
			
		||||
@@ -113,7 +113,7 @@ bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) {
 | 
			
		||||
    case 8: GOTO_SCREEN(MaxVelocityScreen);                break;
 | 
			
		||||
    case 9: GOTO_SCREEN(DefaultAccelerationScreen);        break;
 | 
			
		||||
    case 10:
 | 
			
		||||
      #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
      #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
        GOTO_SCREEN(JunctionDeviationScreen);
 | 
			
		||||
      #else
 | 
			
		||||
        GOTO_SCREEN(JerkScreen);
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,7 @@
 | 
			
		||||
 | 
			
		||||
#include "../config.h"
 | 
			
		||||
 | 
			
		||||
#if ENABLED(TOUCH_UI_FTDI_EVE) && DISABLED(CLASSIC_JERK)
 | 
			
		||||
#if ENABLED(TOUCH_UI_FTDI_EVE) && HAS_JUNCTION_DEVIATION
 | 
			
		||||
 | 
			
		||||
#include "screens.h"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -78,7 +78,7 @@ SCREEN_TABLE {
 | 
			
		||||
  DECL_SCREEN(MaxVelocityScreen),
 | 
			
		||||
  DECL_SCREEN(MaxAccelerationScreen),
 | 
			
		||||
  DECL_SCREEN(DefaultAccelerationScreen),
 | 
			
		||||
#if DISABLED(CLASSIC_JERK)
 | 
			
		||||
#if HAS_JUNCTION_DEVIATION
 | 
			
		||||
  DECL_SCREEN(JunctionDeviationScreen),
 | 
			
		||||
#else
 | 
			
		||||
  DECL_SCREEN(JerkScreen),
 | 
			
		||||
 
 | 
			
		||||
@@ -58,7 +58,7 @@ enum {
 | 
			
		||||
#if HAS_MESH
 | 
			
		||||
  BED_MESH_SCREEN_CACHE,
 | 
			
		||||
#endif
 | 
			
		||||
#if DISABLED(CLASSIC_JERK)
 | 
			
		||||
#if HAS_JUNCTION_DEVIATION
 | 
			
		||||
  JUNC_DEV_SCREEN_CACHE,
 | 
			
		||||
#else
 | 
			
		||||
  JERK_SCREEN_CACHE,
 | 
			
		||||
@@ -566,7 +566,7 @@ class DefaultAccelerationScreen : public BaseNumericAdjustmentScreen, public Cac
 | 
			
		||||
    static bool onTouchHeld(uint8_t tag);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#if DISABLED(CLASSIC_JERK)
 | 
			
		||||
#if HAS_JUNCTION_DEVIATION
 | 
			
		||||
  class JunctionDeviationScreen : public BaseNumericAdjustmentScreen, public CachedScreen<JUNC_DEV_SCREEN_CACHE> {
 | 
			
		||||
    public:
 | 
			
		||||
      static void onRedraw(draw_mode_t);
 | 
			
		||||
 
 | 
			
		||||
@@ -631,7 +631,7 @@ namespace ExtUI {
 | 
			
		||||
    }
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
  #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
 | 
			
		||||
    float getJunctionDeviation_mm() {
 | 
			
		||||
      return planner.junction_deviation_mm;
 | 
			
		||||
 
 | 
			
		||||
@@ -186,7 +186,7 @@ namespace ExtUI {
 | 
			
		||||
    void setLinearAdvance_mm_mm_s(const float, const extruder_t);
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
  #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
    float getJunctionDeviation_mm();
 | 
			
		||||
    void setJunctionDeviation_mm(const float);
 | 
			
		||||
  #else
 | 
			
		||||
 
 | 
			
		||||
@@ -423,7 +423,7 @@ void menu_cancelobject();
 | 
			
		||||
    START_MENU();
 | 
			
		||||
    BACK_ITEM(MSG_ADVANCED_SETTINGS);
 | 
			
		||||
 | 
			
		||||
    #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
    #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
      #if ENABLED(LIN_ADVANCE)
 | 
			
		||||
        EDIT_ITEM(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.001f, 0.3f, planner.recalculate_max_e_jerk);
 | 
			
		||||
      #else
 | 
			
		||||
 
 | 
			
		||||
@@ -2393,7 +2393,7 @@ void MarlinSettings::reset() {
 | 
			
		||||
    TERN_(HAS_CLASSIC_E_JERK, planner.max_jerk.e = DEFAULT_EJERK;);
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
  #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
    planner.junction_deviation_mm = float(JUNCTION_DEVIATION_MM);
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
@@ -2862,7 +2862,7 @@ void MarlinSettings::reset() {
 | 
			
		||||
 | 
			
		||||
    CONFIG_ECHO_HEADING(
 | 
			
		||||
      "Advanced: B<min_segment_time_us> S<min_feedrate> T<min_travel_feedrate>"
 | 
			
		||||
      #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
      #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
        " J<junc_dev>"
 | 
			
		||||
      #endif
 | 
			
		||||
      #if HAS_CLASSIC_JERK
 | 
			
		||||
@@ -2875,7 +2875,7 @@ void MarlinSettings::reset() {
 | 
			
		||||
        PSTR("  M205 B"), LINEAR_UNIT(planner.settings.min_segment_time_us)
 | 
			
		||||
      , PSTR(" S"), LINEAR_UNIT(planner.settings.min_feedrate_mm_s)
 | 
			
		||||
      , SP_T_STR, LINEAR_UNIT(planner.settings.min_travel_feedrate_mm_s)
 | 
			
		||||
      #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
      #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
        , PSTR(" J"), LINEAR_UNIT(planner.junction_deviation_mm)
 | 
			
		||||
      #endif
 | 
			
		||||
      #if HAS_CLASSIC_JERK
 | 
			
		||||
 
 | 
			
		||||
@@ -132,7 +132,7 @@ uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N]; // (steps/s^2) Derived
 | 
			
		||||
 | 
			
		||||
float Planner::steps_to_mm[XYZE_N];           // (mm) Millimeters per step
 | 
			
		||||
 | 
			
		||||
#if DISABLED(CLASSIC_JERK)
 | 
			
		||||
#if HAS_JUNCTION_DEVIATION
 | 
			
		||||
  float Planner::junction_deviation_mm;       // (mm) M205 J
 | 
			
		||||
  #if ENABLED(LIN_ADVANCE)
 | 
			
		||||
    #if ENABLED(DISTINCT_E_FACTORS)
 | 
			
		||||
@@ -2151,7 +2151,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
 | 
			
		||||
 | 
			
		||||
    #if ENABLED(LIN_ADVANCE)
 | 
			
		||||
 | 
			
		||||
      #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
      #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
        #if ENABLED(DISTINCT_E_FACTORS)
 | 
			
		||||
          #define MAX_E_JERK max_e_jerk[extruder]
 | 
			
		||||
        #else
 | 
			
		||||
@@ -2238,7 +2238,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
 | 
			
		||||
 | 
			
		||||
  float vmax_junction_sqr; // Initial limit on the segment entry velocity (mm/s)^2
 | 
			
		||||
 | 
			
		||||
  #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
  #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
    /**
 | 
			
		||||
     * Compute maximum allowable entry speed at junction by centripetal acceleration approximation.
 | 
			
		||||
     * Let a circle be tangent to both previous and current path line segments, where the junction
 | 
			
		||||
@@ -2285,7 +2285,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
 | 
			
		||||
    ;
 | 
			
		||||
    unit_vec *= inverse_millimeters;
 | 
			
		||||
 | 
			
		||||
    #if IS_CORE && DISABLED(CLASSIC_JERK)
 | 
			
		||||
    #if IS_CORE && HAS_JUNCTION_DEVIATION
 | 
			
		||||
      /**
 | 
			
		||||
       * On CoreXY the length of the vector [A,B] is SQRT(2) times the length of the head movement vector [X,Y].
 | 
			
		||||
       * So taking Z and E into account, we cannot scale to a unit vector with "inverse_millimeters".
 | 
			
		||||
@@ -2460,7 +2460,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
 | 
			
		||||
 | 
			
		||||
    previous_safe_speed = safe_speed;
 | 
			
		||||
 | 
			
		||||
    #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
    #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
      vmax_junction_sqr = _MIN(vmax_junction_sqr, sq(vmax_junction));
 | 
			
		||||
    #else
 | 
			
		||||
      vmax_junction_sqr = sq(vmax_junction);
 | 
			
		||||
@@ -2649,7 +2649,7 @@ bool Planner::buffer_line(const float &rx, const float &ry, const float &rz, con
 | 
			
		||||
 | 
			
		||||
  #if IS_KINEMATIC
 | 
			
		||||
 | 
			
		||||
    #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
    #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
      const xyze_pos_t cart_dist_mm = {
 | 
			
		||||
        rx - position_cart.x, ry - position_cart.y,
 | 
			
		||||
        rz - position_cart.z, e  - position_cart.e
 | 
			
		||||
@@ -2675,7 +2675,7 @@ bool Planner::buffer_line(const float &rx, const float &ry, const float &rz, con
 | 
			
		||||
      const feedRate_t feedrate = fr_mm_s;
 | 
			
		||||
    #endif
 | 
			
		||||
    if (buffer_segment(delta.a, delta.b, delta.c, machine.e
 | 
			
		||||
      #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
      #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
        , cart_dist_mm
 | 
			
		||||
      #endif
 | 
			
		||||
      , feedrate, extruder, mm
 | 
			
		||||
 
 | 
			
		||||
@@ -61,7 +61,7 @@
 | 
			
		||||
                            manual_feedrate_mm_s { _mf.x / 60.0f, _mf.y / 60.0f, _mf.z / 60.0f, _mf.e / 60.0f };
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if IS_KINEMATIC && DISABLED(CLASSIC_JERK)
 | 
			
		||||
#if IS_KINEMATIC && HAS_JUNCTION_DEVIATION
 | 
			
		||||
  #define HAS_DIST_MM_ARG 1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -304,7 +304,7 @@ class Planner {
 | 
			
		||||
    static uint32_t max_acceleration_steps_per_s2[XYZE_N]; // (steps/s^2) Derived from mm_per_s2
 | 
			
		||||
    static float steps_to_mm[XYZE_N];           // Millimeters per step
 | 
			
		||||
 | 
			
		||||
    #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
    #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
      static float junction_deviation_mm;       // (mm) M205 J
 | 
			
		||||
      #if ENABLED(LIN_ADVANCE)
 | 
			
		||||
        static float max_e_jerk                 // Calculated from junction_deviation_mm
 | 
			
		||||
@@ -900,7 +900,7 @@ class Planner {
 | 
			
		||||
 | 
			
		||||
    static void recalculate();
 | 
			
		||||
 | 
			
		||||
    #if DISABLED(CLASSIC_JERK)
 | 
			
		||||
    #if HAS_JUNCTION_DEVIATION
 | 
			
		||||
 | 
			
		||||
      FORCE_INLINE static void normalize_junction_vector(xyze_float_t &vector) {
 | 
			
		||||
        float magnitude_sq = 0;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user