Some distinct E helpers

This commit is contained in:
Scott Lahteine 2020-05-05 00:28:39 -05:00
parent 39263efef7
commit eeabe66fc4
6 changed files with 25 additions and 28 deletions

View file

@ -408,7 +408,6 @@
#if EXTRUDERS == 0 #if EXTRUDERS == 0
#undef EXTRUDERS #undef EXTRUDERS
#define EXTRUDERS 0 #define EXTRUDERS 0
#undef DISTINCT_E_FACTORS
#undef SINGLENOZZLE #undef SINGLENOZZLE
#undef SWITCHING_EXTRUDER #undef SWITCHING_EXTRUDER
#undef SWITCHING_NOZZLE #undef SWITCHING_NOZZLE
@ -513,12 +512,16 @@
* DISTINCT_E_FACTORS affects how some E factors are accessed * DISTINCT_E_FACTORS affects how some E factors are accessed
*/ */
#if ENABLED(DISTINCT_E_FACTORS) && E_STEPPERS > 1 #if ENABLED(DISTINCT_E_FACTORS) && E_STEPPERS > 1
#define DISTINCT_E E_STEPPERS
#define XYZE_N (XYZ + E_STEPPERS) #define XYZE_N (XYZ + E_STEPPERS)
#define E_INDEX_N(E) (E)
#define E_AXIS_N(E) AxisEnum(E_AXIS + E) #define E_AXIS_N(E) AxisEnum(E_AXIS + E)
#define UNUSED_E(E) NOOP #define UNUSED_E(E) NOOP
#else #else
#undef DISTINCT_E_FACTORS #undef DISTINCT_E_FACTORS
#define DISTINCT_E 1
#define XYZE_N XYZE #define XYZE_N XYZE
#define E_INDEX_N(E) 0
#define E_AXIS_N(E) E_AXIS #define E_AXIS_N(E) E_AXIS
#define UNUSED_E(E) UNUSED(E) #define UNUSED_E(E) UNUSED(E)
#endif #endif

View file

@ -38,16 +38,16 @@ void MaxAccelerationScreen::onRedraw(draw_mode_t what) {
w.color(x_axis) .adjuster( 2, GET_TEXT_F(MSG_AMAX_X), getAxisMaxAcceleration_mm_s2(X) ); w.color(x_axis) .adjuster( 2, GET_TEXT_F(MSG_AMAX_X), getAxisMaxAcceleration_mm_s2(X) );
w.color(y_axis) .adjuster( 4, GET_TEXT_F(MSG_AMAX_Y), getAxisMaxAcceleration_mm_s2(Y) ); w.color(y_axis) .adjuster( 4, GET_TEXT_F(MSG_AMAX_Y), getAxisMaxAcceleration_mm_s2(Y) );
w.color(z_axis) .adjuster( 6, GET_TEXT_F(MSG_AMAX_Z), getAxisMaxAcceleration_mm_s2(Z) ); w.color(z_axis) .adjuster( 6, GET_TEXT_F(MSG_AMAX_Z), getAxisMaxAcceleration_mm_s2(Z) );
#if EXTRUDERS == 1 || DISABLED(DISTINCT_E_FACTORS) #if DISTINCT_E == 1
w.color(e_axis).adjuster( 8, GET_TEXT_F(MSG_AMAX_E), getAxisMaxAcceleration_mm_s2(E0) ); w.color(e_axis).adjuster( 8, GET_TEXT_F(MSG_AMAX_E), getAxisMaxAcceleration_mm_s2(E0) );
#elif EXTRUDERS > 1 #elif DISTINCT_E > 1
w.heading(GET_TEXT_F(MSG_AMAX_E)); w.heading(GET_TEXT_F(MSG_AMAX_E));
w.color(e_axis).adjuster( 8, F(LCD_STR_E0), getAxisMaxAcceleration_mm_s2(E0) ); w.color(e_axis).adjuster( 8, F(LCD_STR_E0), getAxisMaxAcceleration_mm_s2(E0) );
w.color(e_axis).adjuster(10, F(LCD_STR_E1), getAxisMaxAcceleration_mm_s2(E1) ); w.color(e_axis).adjuster(10, F(LCD_STR_E1), getAxisMaxAcceleration_mm_s2(E1) );
#if EXTRUDERS > 2 #if DISTINCT_E > 2
w.color(e_axis).adjuster(12, F(LCD_STR_E2), getAxisMaxAcceleration_mm_s2(E2) ); w.color(e_axis).adjuster(12, F(LCD_STR_E2), getAxisMaxAcceleration_mm_s2(E2) );
#endif #endif
#if EXTRUDERS > 3 #if DISTINCT_E > 3
w.color(e_axis).adjuster(14, F(LCD_STR_E3), getAxisMaxAcceleration_mm_s2(E3) ); w.color(e_axis).adjuster(14, F(LCD_STR_E3), getAxisMaxAcceleration_mm_s2(E3) );
#endif #endif
#endif #endif
@ -65,15 +65,15 @@ bool MaxAccelerationScreen::onTouchHeld(uint8_t tag) {
case 7: UI_INCREMENT(AxisMaxAcceleration_mm_s2, Z ); break; case 7: UI_INCREMENT(AxisMaxAcceleration_mm_s2, Z ); break;
case 8: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E0); break; case 8: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E0); break;
case 9: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E0); break; case 9: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E0); break;
#if EXTRUDERS > 1 && ENABLED(DISTINCT_E_FACTORS) #if DISTINCT_E > 1
case 10: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E1); break; case 10: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E1); break;
case 11: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E1); break; case 11: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E1); break;
#endif #endif
#if EXTRUDERS > 2 && ENABLED(DISTINCT_E_FACTORS) #if DISTINCT_E > 2
case 12: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E2); break; case 12: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E2); break;
case 13: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E2); break; case 13: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E2); break;
#endif #endif
#if EXTRUDERS > 3 && ENABLED(DISTINCT_E_FACTORS) #if DISTINCT_E > 3
case 14: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E3); break; case 14: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E3); break;
case 15: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E3); break; case 15: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E3); break;
#endif #endif

View file

@ -64,17 +64,19 @@ bool MaxVelocityScreen::onTouchHeld(uint8_t tag) {
case 5: UI_INCREMENT(AxisMaxFeedrate_mm_s, Y); break; case 5: UI_INCREMENT(AxisMaxFeedrate_mm_s, Y); break;
case 6: UI_DECREMENT(AxisMaxFeedrate_mm_s, Z); break; case 6: UI_DECREMENT(AxisMaxFeedrate_mm_s, Z); break;
case 7: UI_INCREMENT(AxisMaxFeedrate_mm_s, Z); break; case 7: UI_INCREMENT(AxisMaxFeedrate_mm_s, Z); break;
#if DISTINCT_E > 0
case 8: UI_DECREMENT(AxisMaxFeedrate_mm_s, E0); break; case 8: UI_DECREMENT(AxisMaxFeedrate_mm_s, E0); break;
case 9: UI_INCREMENT(AxisMaxFeedrate_mm_s, E0); break; case 9: UI_INCREMENT(AxisMaxFeedrate_mm_s, E0); break;
#if EXTRUDERS > 1 && ENABLED(DISTINCT_E_FACTORS) #endif
#if DISTINCT_E > 1
case 10: UI_DECREMENT(AxisMaxFeedrate_mm_s, E1); break; case 10: UI_DECREMENT(AxisMaxFeedrate_mm_s, E1); break;
case 11: UI_INCREMENT(AxisMaxFeedrate_mm_s, E1); break; case 11: UI_INCREMENT(AxisMaxFeedrate_mm_s, E1); break;
#endif #endif
#if EXTRUDERS > 2 && ENABLED(DISTINCT_E_FACTORS) #if DISTINCT_E > 2
case 12: UI_DECREMENT(AxisMaxFeedrate_mm_s, E2); break; case 12: UI_DECREMENT(AxisMaxFeedrate_mm_s, E2); break;
case 13: UI_INCREMENT(AxisMaxFeedrate_mm_s, E2); break; case 13: UI_INCREMENT(AxisMaxFeedrate_mm_s, E2); break;
#endif #endif
#if EXTRUDERS > 3 && ENABLED(DISTINCT_E_FACTORS) #if DISTINCT_E > 3
case 14: UI_DECREMENT(AxisMaxFeedrate_mm_s, E3); break; case 14: UI_DECREMENT(AxisMaxFeedrate_mm_s, E3); break;
case 15: UI_INCREMENT(AxisMaxFeedrate_mm_s, E3); break; case 15: UI_INCREMENT(AxisMaxFeedrate_mm_s, E3); break;
#endif #endif

View file

@ -134,9 +134,8 @@ float Planner::steps_to_mm[XYZE_N]; // (mm) Millimeters per step
#if HAS_JUNCTION_DEVIATION #if HAS_JUNCTION_DEVIATION
float Planner::junction_deviation_mm; // (mm) M205 J float Planner::junction_deviation_mm; // (mm) M205 J
#if ENABLED(LIN_ADVANCE) #if HAS_LINEAR_E_JERK
float Planner::max_e_jerk // Calculated from junction_deviation_mm float Planner::max_e_jerk[DISTINCT_E]; // Calculated from junction_deviation_mm
[TERN(DISTINCT_E_FACTORS, EXTRUDERS, 1)];
#endif #endif
#endif #endif
@ -2139,7 +2138,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
#if ENABLED(LIN_ADVANCE) #if ENABLED(LIN_ADVANCE)
#define MAX_E_JERK(N) TERN(HAS_JUNCTION_DEVIATION, max_e_jerk[E_AXIS_N(N)], max_jerk.e) #define MAX_E_JERK(N) TERN(HAS_LINEAR_E_JERK, max_e_jerk[E_INDEX_N(N)], max_jerk.e)
/** /**
* *
@ -2179,24 +2178,18 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
} }
#endif #endif
#if ENABLED(DISTINCT_E_FACTORS)
#define ACCEL_IDX extruder
#else
#define ACCEL_IDX 0
#endif
// Limit acceleration per axis // Limit acceleration per axis
if (block->step_event_count <= cutoff_long) { if (block->step_event_count <= cutoff_long) {
LIMIT_ACCEL_LONG(A_AXIS, 0); LIMIT_ACCEL_LONG(A_AXIS, 0);
LIMIT_ACCEL_LONG(B_AXIS, 0); LIMIT_ACCEL_LONG(B_AXIS, 0);
LIMIT_ACCEL_LONG(C_AXIS, 0); LIMIT_ACCEL_LONG(C_AXIS, 0);
LIMIT_ACCEL_LONG(E_AXIS, ACCEL_IDX); LIMIT_ACCEL_LONG(E_AXIS, E_INDEX_N(extruder));
} }
else { else {
LIMIT_ACCEL_FLOAT(A_AXIS, 0); LIMIT_ACCEL_FLOAT(A_AXIS, 0);
LIMIT_ACCEL_FLOAT(B_AXIS, 0); LIMIT_ACCEL_FLOAT(B_AXIS, 0);
LIMIT_ACCEL_FLOAT(C_AXIS, 0); LIMIT_ACCEL_FLOAT(C_AXIS, 0);
LIMIT_ACCEL_FLOAT(E_AXIS, ACCEL_IDX); LIMIT_ACCEL_FLOAT(E_AXIS, E_INDEX_N(extruder));
} }
} }
block->acceleration_steps_per_s2 = accel; block->acceleration_steps_per_s2 = accel;

View file

@ -315,9 +315,8 @@ class Planner {
#if HAS_JUNCTION_DEVIATION #if HAS_JUNCTION_DEVIATION
static float junction_deviation_mm; // (mm) M205 J static float junction_deviation_mm; // (mm) M205 J
#if ENABLED(LIN_ADVANCE) #if HAS_LINEAR_E_JERK
static float max_e_jerk // Calculated from junction_deviation_mm static float max_e_jerk[DISTINCT_E]; // Calculated from junction_deviation_mm
[TERN(DISTINCT_E_FACTORS, EXTRUDERS, 1)];
#endif #endif
#endif #endif
@ -842,7 +841,7 @@ class Planner {
FORCE_INLINE static void recalculate_max_e_jerk() { FORCE_INLINE static void recalculate_max_e_jerk() {
const float prop = junction_deviation_mm * SQRT(0.5) / (1.0f - SQRT(0.5)); const float prop = junction_deviation_mm * SQRT(0.5) / (1.0f - SQRT(0.5));
LOOP_L_N(i, EXTRUDERS) LOOP_L_N(i, EXTRUDERS)
max_e_jerk[E_AXIS_N(i)] = SQRT(prop * settings.max_acceleration_mm_per_s2[E_AXIS_N(i)]); max_e_jerk[E_INDEX_N(i)] = SQRT(prop * settings.max_acceleration_mm_per_s2[E_INDEX_N(i)]);
} }
#endif #endif

View file

@ -58,7 +58,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#define _TMC_UART_DEFINE(SWHW, IC, ST, AI) TMC_UART_##SWHW##_DEFINE(IC, ST, TMC_##ST##_LABEL, AI) #define _TMC_UART_DEFINE(SWHW, IC, ST, AI) TMC_UART_##SWHW##_DEFINE(IC, ST, TMC_##ST##_LABEL, AI)
#define TMC_UART_DEFINE(SWHW, ST, AI) _TMC_UART_DEFINE(SWHW, ST##_DRIVER_TYPE, ST, AI##_AXIS) #define TMC_UART_DEFINE(SWHW, ST, AI) _TMC_UART_DEFINE(SWHW, ST##_DRIVER_TYPE, ST, AI##_AXIS)
#if ENABLED(DISTINCT_E_FACTORS) && E_STEPPERS > 1 #if DISTINCT_E > 1
#define TMC_SPI_DEFINE_E(AI) TMC_SPI_DEFINE(E##AI, E##AI) #define TMC_SPI_DEFINE_E(AI) TMC_SPI_DEFINE(E##AI, E##AI)
#define TMC_UART_DEFINE_E(SWHW, AI) TMC_UART_DEFINE(SWHW, E##AI, E##AI) #define TMC_UART_DEFINE_E(SWHW, AI) TMC_UART_DEFINE(SWHW, E##AI, E##AI)
#else #else