Define max_e_jerk as array always

This commit is contained in:
Scott Lahteine 2020-05-04 23:07:54 -05:00
parent 97e47b4494
commit 90e1035e9b
2 changed files with 10 additions and 22 deletions

View file

@ -130,13 +130,13 @@ planner_settings_t Planner::settings; // Initialized by settings.load(
uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N]; // (steps/s^2) Derived from mm_per_s2
float Planner::steps_to_mm[XYZE_N]; // (mm) Millimeters per step
float Planner::steps_to_mm[XYZE_N]; // (mm) Millimeters per step
#if HAS_JUNCTION_DEVIATION
float Planner::junction_deviation_mm; // (mm) M205 J
float Planner::junction_deviation_mm; // (mm) M205 J
#if ENABLED(LIN_ADVANCE)
float Planner::max_e_jerk // Calculated from junction_deviation_mm
TERN_(DISTINCT_E_FACTORS, [EXTRUDERS]);
float Planner::max_e_jerk // Calculated from junction_deviation_mm
[TERN(DISTINCT_E_FACTORS, EXTRUDERS, 1)];
#endif
#endif
@ -2139,15 +2139,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
#if ENABLED(LIN_ADVANCE)
#if HAS_JUNCTION_DEVIATION
#if ENABLED(DISTINCT_E_FACTORS)
#define MAX_E_JERK max_e_jerk[extruder]
#else
#define MAX_E_JERK max_e_jerk
#endif
#else
#define MAX_E_JERK max_jerk.e
#endif
#define MAX_E_JERK(N) TERN(HAS_JUNCTION_DEVIATION, max_e_jerk[E_AXIS_N(N)], max_jerk.e)
/**
*
@ -2179,7 +2171,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
if (block->e_D_ratio > 3.0f)
block->use_advance_lead = false;
else {
const uint32_t max_accel_steps_per_s2 = MAX_E_JERK / (extruder_advance_K[active_extruder] * block->e_D_ratio) * steps_per_mm;
const uint32_t max_accel_steps_per_s2 = MAX_E_JERK(extruder) / (extruder_advance_K[active_extruder] * block->e_D_ratio) * steps_per_mm;
if (TERN0(LA_DEBUG, accel > max_accel_steps_per_s2))
SERIAL_ECHOLNPGM("Acceleration limited.");
NOMORE(accel, max_accel_steps_per_s2);

View file

@ -317,7 +317,7 @@ class Planner {
static float junction_deviation_mm; // (mm) M205 J
#if ENABLED(LIN_ADVANCE)
static float max_e_jerk // Calculated from junction_deviation_mm
TERN_(DISTINCT_E_FACTORS, [EXTRUDERS]);
[TERN(DISTINCT_E_FACTORS, EXTRUDERS, 1)];
#endif
#endif
@ -840,13 +840,9 @@ class Planner {
#if HAS_LINEAR_E_JERK
FORCE_INLINE static void recalculate_max_e_jerk() {
#define GET_MAX_E_JERK(N) SQRT(junction_deviation_mm * (N) * SQRT(0.5) / (1.0f - SQRT(0.5)))
#if ENABLED(DISTINCT_E_FACTORS)
LOOP_L_N(i, EXTRUDERS)
max_e_jerk[i] = GET_MAX_E_JERK(settings.max_acceleration_mm_per_s2[E_AXIS_N(i)]);
#else
max_e_jerk = GET_MAX_E_JERK(settings.max_acceleration_mm_per_s2[E_AXIS]);
#endif
const float prop = junction_deviation_mm * SQRT(0.5) / (1.0f - SQRT(0.5));
LOOP_L_N(i, EXTRUDERS)
max_e_jerk[E_AXIS_N(i)] = SQRT(prop * settings.max_acceleration_mm_per_s2[E_AXIS_N(i)]);
}
#endif